forked from qt-creator/qt-creator
IWizardFactory: Remove class wizard kind
Map existing class wizards to file wizards. The separation has never been clean anyway. Now "file" wizards create one or more files, "project" wizards create a complete project (something that can be opened as a project in Qt Creator). Change-Id: I0562f26019b54a59d46814a13a0b2fa8995c3e0f Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -130,7 +130,7 @@
|
||||
\row
|
||||
\li Core::IWizard::WizardKind
|
||||
\li kind
|
||||
\li Enumeration value that indicates the type of the wizard (project, class, file).
|
||||
\li Enumeration value that indicates the type of the wizard (project or file).
|
||||
|
||||
\row
|
||||
\li QIcon
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
|
||||
\code
|
||||
"version": 1,
|
||||
"kind": "class",
|
||||
"kind": "file",
|
||||
"id": "A.Class",
|
||||
"category": "O.C++",
|
||||
\endcode
|
||||
@@ -123,8 +123,8 @@
|
||||
\li \c version is the version of the file contents. Do not
|
||||
modify this value.
|
||||
|
||||
\li \c kind specifies the type of the wizard: \c class,
|
||||
\c file, or \c project.
|
||||
\li \c kind specifies the type of the wizard: \c file or
|
||||
\c project.
|
||||
|
||||
\li \c id is the unique identifier for your wizard. You can
|
||||
use a leading letter to specify the position of the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 1,
|
||||
"kind": "class",
|
||||
"kind": "file",
|
||||
"id": "A.Class",
|
||||
"category": "O.C++",
|
||||
"trDescription": "Creates a C++ header and a source file for a new class that you can add to a C++ project.",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 1,
|
||||
"kind": "class",
|
||||
"kind": "file",
|
||||
"id": "P.PyClass",
|
||||
"category": "U.Python",
|
||||
"trDescription": "Creates new Python class file.",
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
Custom class wizard example configuration file. -->
|
||||
<wizard version="1" kind="class" id="A.ListModel" category="B.CustomClasses">
|
||||
<wizard version="1" kind="file" id="A.ListModel" category="B.CustomClasses">
|
||||
<description>Creates a QAbstractListModel implementation.</description>
|
||||
<description xml:lang="de">Erzeugt eine Implementierung von QAbstractListModel.</description>
|
||||
<displayname>QAbstractListModel implementation</displayname>;
|
||||
|
||||
@@ -226,7 +226,6 @@ const char WIZARD_CATEGORY_QT[] = "R.Qt";
|
||||
const char WIZARD_TR_CATEGORY_QT[] = QT_TRANSLATE_NOOP("Core", "Qt");
|
||||
const char WIZARD_KIND_UNKNOWN[] = "unknown";
|
||||
const char WIZARD_KIND_PROJECT[] = "project";
|
||||
const char WIZARD_KIND_CLASS[] = "class";
|
||||
const char WIZARD_KIND_FILE[] = "file";
|
||||
|
||||
const char SETTINGS_CATEGORY_CORE[] = "A.Core";
|
||||
|
||||
@@ -261,12 +261,12 @@ void NewDialog::setWizardFactories(QList<IWizardFactory *> factories,
|
||||
QStandardItem *projectKindItem = new QStandardItem(tr("Projects"));
|
||||
projectKindItem->setData(IWizardFactory::ProjectWizard, Qt::UserRole);
|
||||
projectKindItem->setFlags(0); // disable item to prevent focus
|
||||
QStandardItem *filesClassesKindItem = new QStandardItem(tr("Files and Classes"));
|
||||
filesClassesKindItem->setData(IWizardFactory::FileWizard, Qt::UserRole);
|
||||
filesClassesKindItem->setFlags(0); // disable item to prevent focus
|
||||
QStandardItem *filesKindItem = new QStandardItem(tr("Files and Classes"));
|
||||
filesKindItem->setData(IWizardFactory::FileWizard, Qt::UserRole);
|
||||
filesKindItem->setFlags(0); // disable item to prevent focus
|
||||
|
||||
parentItem->appendRow(projectKindItem);
|
||||
parentItem->appendRow(filesClassesKindItem);
|
||||
parentItem->appendRow(filesKindItem);
|
||||
|
||||
if (m_dummyIcon.isNull())
|
||||
m_dummyIcon = QIcon(QLatin1String(Core::Constants::ICON_NEWFILE));
|
||||
@@ -290,10 +290,9 @@ void NewDialog::setWizardFactories(QList<IWizardFactory *> factories,
|
||||
case IWizardFactory::ProjectWizard:
|
||||
kindItem = projectKindItem;
|
||||
break;
|
||||
case IWizardFactory::ClassWizard:
|
||||
case IWizardFactory::FileWizard:
|
||||
default:
|
||||
kindItem = filesClassesKindItem;
|
||||
kindItem = filesKindItem;
|
||||
break;
|
||||
}
|
||||
addItem(kindItem, factory);
|
||||
|
||||
@@ -49,10 +49,8 @@ class CORE_EXPORT IWizardFactory
|
||||
public:
|
||||
enum WizardKind {
|
||||
FileWizard = 0x01,
|
||||
ClassWizard = 0x02,
|
||||
ProjectWizard = 0x04
|
||||
ProjectWizard = 0x02
|
||||
};
|
||||
Q_DECLARE_FLAGS(WizardKinds, WizardKind)
|
||||
enum WizardFlag {
|
||||
PlatformIndependent = 0x01,
|
||||
ForceCapitalLetterForFileName = 0x02
|
||||
@@ -120,7 +118,6 @@ private:
|
||||
|
||||
} // namespace Core
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizardFactory::WizardKinds)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizardFactory::WizardFlags)
|
||||
|
||||
#endif // IWIZARDFACTORY_H
|
||||
|
||||
@@ -134,7 +134,7 @@ void FormEditorPlugin::initializeTemplates()
|
||||
{
|
||||
#ifdef CPP_ENABLED
|
||||
IWizardFactory *wizard = new FormClassWizard;
|
||||
wizard->setWizardKind(IWizardFactory::ClassWizard);
|
||||
wizard->setWizardKind(IWizardFactory::FileWizard);
|
||||
wizard->setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT));
|
||||
wizard->setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::WIZARD_TR_CATEGORY_QT));
|
||||
wizard->setDisplayName(tr("Qt Designer Form Class"));
|
||||
|
||||
@@ -451,12 +451,8 @@ static ParseState nextClosingState(ParseState in, const QStringRef &name)
|
||||
static inline IWizardFactory::WizardKind kindAttribute(const QXmlStreamReader &r)
|
||||
{
|
||||
const QStringRef value = r.attributes().value(QLatin1String(kindAttributeC));
|
||||
if (!value.isEmpty()) {
|
||||
if (value == QLatin1String("file"))
|
||||
return IWizardFactory::FileWizard;
|
||||
if (value == QLatin1String("class"))
|
||||
return IWizardFactory::ClassWizard;
|
||||
}
|
||||
if (value == QLatin1String("file") || value == QLatin1String("class"))
|
||||
return IWizardFactory::FileWizard;
|
||||
return IWizardFactory::ProjectWizard;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +67,6 @@ static IWizardFactory::WizardKind wizardKind(JsonWizard *wiz)
|
||||
const QString kindStr = wiz->stringValue(QLatin1String("kind"));
|
||||
if (kindStr == QLatin1String(Core::Constants::WIZARD_KIND_PROJECT))
|
||||
kind = IWizardFactory::ProjectWizard;
|
||||
else if (kindStr == QLatin1String(Core::Constants::WIZARD_KIND_CLASS))
|
||||
kind = IWizardFactory::ClassWizard;
|
||||
else if (kindStr == QLatin1String(Core::Constants::WIZARD_KIND_FILE))
|
||||
kind = IWizardFactory::FileWizard;
|
||||
else
|
||||
|
||||
@@ -387,8 +387,6 @@ void JsonWizardFactory::runWizard(const QString &path, QWidget *parent, const QS
|
||||
QString kindStr = QLatin1String(Core::Constants::WIZARD_KIND_UNKNOWN);
|
||||
if (kind() == IWizardFactory::FileWizard)
|
||||
kindStr = QLatin1String(Core::Constants::WIZARD_KIND_FILE);
|
||||
else if (kind() == IWizardFactory::ClassWizard)
|
||||
kindStr = QLatin1String(Core::Constants::WIZARD_KIND_CLASS);
|
||||
else if (kind() == IWizardFactory::ProjectWizard)
|
||||
kindStr = QLatin1String(Core::Constants::WIZARD_KIND_PROJECT);
|
||||
wizard.setValue(QStringLiteral("kind"), kindStr);
|
||||
@@ -503,9 +501,7 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir,
|
||||
return false;
|
||||
}
|
||||
IWizardFactory::WizardKind kind = IWizardFactory::ProjectWizard;
|
||||
if (strVal == QLatin1String("class"))
|
||||
kind = IWizardFactory::ClassWizard;
|
||||
if (strVal == QLatin1String("file"))
|
||||
if (strVal == QLatin1String("file") || strVal == QLatin1String("class"))
|
||||
kind = IWizardFactory::FileWizard;
|
||||
setWizardKind(kind);
|
||||
|
||||
|
||||
@@ -528,7 +528,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
|
||||
addAutoReleasedObject(new CustomWizardMetaFactory<CustomProjectWizard>(IWizardFactory::ProjectWizard));
|
||||
addAutoReleasedObject(new CustomWizardMetaFactory<CustomWizard>(IWizardFactory::FileWizard));
|
||||
addAutoReleasedObject(new CustomWizardMetaFactory<CustomWizard>(IWizardFactory::ClassWizard));
|
||||
|
||||
// For JsonWizard:
|
||||
JsonWizardFactory::registerPageFactory(new FieldPageFactory);
|
||||
@@ -2995,8 +2994,7 @@ void ProjectExplorerPluginPrivate::addNewFile()
|
||||
map.insert(QLatin1String(Constants::PROJECT_KIT_IDS), QVariant::fromValue(profileIds));
|
||||
}
|
||||
ICore::showNewItemDialog(tr("New File", "Title of dialog"),
|
||||
IWizardFactory::wizardFactoriesOfKind(IWizardFactory::FileWizard)
|
||||
+ IWizardFactory::wizardFactoriesOfKind(IWizardFactory::ClassWizard),
|
||||
IWizardFactory::wizardFactoriesOfKind(IWizardFactory::FileWizard),
|
||||
location, map);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user