BaseFileWizardFactory Class
class Core::BaseFileWizardFactoryThe BaseFileWizardFactory class implements a generic wizard for creating files. More...
Header: | #include <coreplugin/basefilewizardfactory.h> |
Inherits: | Core::IWizardFactory |
Protected Functions
virtual BaseFileWizard * | create(QWidget *parent, const WizardDialogParameters ¶meters) const = 0 |
virtual GeneratedFiles | generateFiles(const QWizard *w, QString *errorMessage) const = 0 |
virtual bool | postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage) const |
virtual bool | writeFiles(const GeneratedFiles &files, QString *errorMessage) const |
Static Protected Members
bool | postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = nullptr) |
QString | preferredSuffix(const QString &mimeType) |
OverwriteResult | promptOverwrite(GeneratedFiles *files, QString *errorMessage) |
Detailed Description
The following abstract functions must be implemented:
- create(): Called to create the QWizard dialog to be shown.
- generateFiles(): Generates file content.
The behavior can be further customized by overwriting the virtual function postGenerateFiles(), which is called after generating the files.
Note: Instead of using this class, we recommend that you create JSON-based wizards, as instructed in Adding New Custom Wizards.
See also Core::GeneratedFile, Core::WizardDialogParameters, and Core::BaseFileWizard.
Member Function Documentation
[pure virtual protected]
BaseFileWizard *BaseFileWizardFactory::create(QWidget *parent, const WizardDialogParameters ¶meters) const
Creates the wizard on the parent with the parameters.
[pure virtual protected]
GeneratedFiles BaseFileWizardFactory::generateFiles(const QWizard *w, QString *errorMessage) const
Overwrite to query the parameters from the wizard w and generate the files.
Possible errors are held in errorMessage.
Note: This does not generate physical files, but merely the list of Core::GeneratedFile.
[virtual protected]
bool BaseFileWizardFactory::postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage) const
Overwrite to perform steps to be done by the wizard w after the files specified by l are actually created.
The default implementation opens editors with the newly generated files that have GeneratedFile::OpenEditorAttribute set.
Returns errorMessage if errors occur.
[static protected]
bool BaseFileWizardFactory::postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = nullptr)
Opens the editors for the files l if their GeneratedFile::OpenEditorAttribute attribute is set accordingly.
If the editorrs cannot be opened, returns false
and dand sets errorMessage to the message that is displayed to users.
[static protected]
QString BaseFileWizardFactory::preferredSuffix(const QString &mimeType)
Returns the preferred suffix for mimeType.
[static protected]
OverwriteResult BaseFileWizardFactory::promptOverwrite(GeneratedFiles *files, QString *errorMessage)
Performs an overwrite check on a set of files. Checks if the file exists and can be overwritten at all, and then prompts the user with a summary.
Returns errorMessage if the file cannot be overwritten.
[virtual protected]
bool BaseFileWizardFactory::writeFiles(const GeneratedFiles &files, QString *errorMessage) const
Physically writes files.
If the files cannot be written, returns false
and sets errorMessage to the message that is displayed to users.
Re-implement (calling the base implementation) to create files with GeneratedFile::CustomGeneratorAttribute set.