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