forked from qt-creator/qt-creator
CustomWizard: Use object pool to find factories
Rename class type of CustomQmakeProjectWizard from "qt4project" to "qmakeproject" and document that change in the manual and changes-3.1.0. Also update all the in-tree xml files to that new class name. Change-Id: I7a9ef914a429d68e7f37a2115c03fa81d7433398 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
1
dist/changes-3.1.0
vendored
1
dist/changes-3.1.0
vendored
@@ -96,6 +96,7 @@ Platform Specific
|
|||||||
Linux
|
Linux
|
||||||
|
|
||||||
Qt Support
|
Qt Support
|
||||||
|
* Custom wizards now use class "qmakeproject" instead of "qt4project"
|
||||||
|
|
||||||
QNX
|
QNX
|
||||||
* Added support for Python based pretty printers when debugging on devices
|
* Added support for Python based pretty printers when debugging on devices
|
||||||
|
|||||||
@@ -113,7 +113,7 @@
|
|||||||
\code
|
\code
|
||||||
|
|
||||||
<wizard version="1" kind="project"
|
<wizard version="1" kind="project"
|
||||||
class="qt4project" firstpage="10"
|
class="qmakeproject" firstpage="10"
|
||||||
id="A.HelloWorld" category="B.CustomProjects">
|
id="A.HelloWorld" category="B.CustomProjects">
|
||||||
|
|
||||||
\endcode
|
\endcode
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
\c class.
|
\c class.
|
||||||
|
|
||||||
\li \c class specifies the type of the project. This attribute is
|
\li \c class specifies the type of the project. This attribute is
|
||||||
optional. Use the value \c qt4project to add Qt 4 specific pages.
|
optional. Use the value \c qmakeproject to add Qt specific pages.
|
||||||
|
|
||||||
\li \c firstpage specifies the place of the new page in the standard
|
\li \c firstpage specifies the place of the new page in the standard
|
||||||
project wizard. The value 10 ensures that the custom page
|
project wizard. The value 10 ensures that the custom page
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
-->
|
-->
|
||||||
<wizard version="1" kind="project"
|
<wizard version="1" kind="project"
|
||||||
class="qt4project" firstpage="10"
|
class="qmakeproject" firstpage="10"
|
||||||
id="Q.QnxBlackBerryCascadesApp" category="F.QtApplications"
|
id="Q.QnxBlackBerryCascadesApp" category="F.QtApplications"
|
||||||
featuresRequired="QtSupport.Wizards.FeatureBlackBerry">
|
featuresRequired="QtSupport.Wizards.FeatureBlackBerry">
|
||||||
<icon>icon.png</icon>
|
<icon>icon.png</icon>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
|
|||||||
leave room for the Qt 4 target page.
|
leave room for the Qt 4 target page.
|
||||||
-->
|
-->
|
||||||
<wizard version="1" kind="project"
|
<wizard version="1" kind="project"
|
||||||
class="qt4project" firstpage="10"
|
class="qmakeproject" firstpage="10"
|
||||||
id="Z.Snippet" category="H.QtProjects">
|
id="Z.Snippet" category="H.QtProjects">
|
||||||
<description>Creates a qmake-based test project for which a code snippet can be entered.</description>
|
<description>Creates a qmake-based test project for which a code snippet can be entered.</description>
|
||||||
<displayname>Code Snippet</displayname>;
|
<displayname>Code Snippet</displayname>;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
|
|||||||
leave room for the Qt 4 target page.
|
leave room for the Qt 4 target page.
|
||||||
-->
|
-->
|
||||||
<wizard version="1" kind="project"
|
<wizard version="1" kind="project"
|
||||||
class="qt4project" firstpage="10"
|
class="qmakeproject" firstpage="10"
|
||||||
id="A.HelloWorld" category="B.CustomProjects">
|
id="A.HelloWorld" category="B.CustomProjects">
|
||||||
<icon>console.png</icon>
|
<icon>console.png</icon>
|
||||||
<description>Creates a hello-world-project with custom message.</description>
|
<description>Creates a hello-world-project with custom message.</description>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
|
|||||||
leave room for the Qt 4 target page.
|
leave room for the Qt 4 target page.
|
||||||
-->
|
-->
|
||||||
<wizard version="1" kind="project"
|
<wizard version="1" kind="project"
|
||||||
class="qt4project" firstpage="10"
|
class="qmakeproject" firstpage="10"
|
||||||
id="R.Plain C" category="I.Projects"
|
id="R.Plain C" category="I.Projects"
|
||||||
featuresRequired="QtSupport.Wizards.FeatureQt">
|
featuresRequired="QtSupport.Wizards.FeatureQt">
|
||||||
<icon>../common/console.png</icon>
|
<icon>../common/console.png</icon>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
|
|||||||
leave room for the Qt 4 target page.
|
leave room for the Qt 4 target page.
|
||||||
-->
|
-->
|
||||||
<wizard version="1" kind="project"
|
<wizard version="1" kind="project"
|
||||||
class="qt4project" firstpage="10"
|
class="qmakeproject" firstpage="10"
|
||||||
id="R.Plain C++" category="I.Projects"
|
id="R.Plain C++" category="I.Projects"
|
||||||
featuresRequired="QtSupport.Wizards.FeatureQt">
|
featuresRequired="QtSupport.Wizards.FeatureQt">
|
||||||
<icon>../common/console.png</icon>
|
<icon>../common/console.png</icon>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
|
|||||||
leave room for the Qt 4 target page.
|
leave room for the Qt 4 target page.
|
||||||
-->
|
-->
|
||||||
<wizard version="1" kind="project"
|
<wizard version="1" kind="project"
|
||||||
class="qt4project" firstpage="10"
|
class="qmakeproject" firstpage="10"
|
||||||
id="R.QtCreatorPlugin" category="G.Libraries"
|
id="R.QtCreatorPlugin" category="G.Libraries"
|
||||||
featuresRequired="QtSupport.Wizards.FeatureQt,QtSupport.Wizards.FeatureDesktop">
|
featuresRequired="QtSupport.Wizards.FeatureQt,QtSupport.Wizards.FeatureDesktop">
|
||||||
<icon>qtcreator_logo_24.png</icon>
|
<icon>qtcreator_logo_24.png</icon>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
|
|||||||
leave room for the Qt 4 target page.
|
leave room for the Qt 4 target page.
|
||||||
-->
|
-->
|
||||||
<wizard version="1" kind="project"
|
<wizard version="1" kind="project"
|
||||||
class="qt4project" firstpage="10"
|
class="qmakeproject" firstpage="10"
|
||||||
id="QtQuick1ExtensionPlugin" category="G.Libraries"
|
id="QtQuick1ExtensionPlugin" category="G.Libraries"
|
||||||
featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.1">
|
featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.1">
|
||||||
<icon>lib.png</icon>
|
<icon>lib.png</icon>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
|
|||||||
leave room for the Qt 4 target page.
|
leave room for the Qt 4 target page.
|
||||||
-->
|
-->
|
||||||
<wizard version="1" kind="project"
|
<wizard version="1" kind="project"
|
||||||
class="qt4project" firstpage="10"
|
class="qmakeproject" firstpage="10"
|
||||||
id="QtQuick2ExtensionPlugin" category="G.Libraries"
|
id="QtQuick2ExtensionPlugin" category="G.Libraries"
|
||||||
featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.2">
|
featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.2">
|
||||||
<icon>lib.png</icon>
|
<icon>lib.png</icon>
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -330,39 +332,23 @@ CustomWizard::CustomWizardContextPtr CustomWizard::context() const
|
|||||||
return d->m_context;
|
return d->m_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static factory map
|
CustomWizard *CustomWizard::createWizard(const CustomProjectWizard::CustomWizardParametersPtr &p,
|
||||||
typedef QMap<QString, QSharedPointer<ICustomWizardFactory> > CustomWizardFactoryMap;
|
const Core::IWizard::Data &b)
|
||||||
Q_GLOBAL_STATIC(CustomWizardFactoryMap, customWizardFactoryMap)
|
|
||||||
|
|
||||||
void CustomWizard::registerFactory(const QString &name, const ICustomWizardFactoryPtr &f)
|
|
||||||
{
|
|
||||||
customWizardFactoryMap()->insert(name, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomWizard *CustomWizard::createWizard(const CustomProjectWizard::CustomWizardParametersPtr &p, const Core::IWizard::Data &b)
|
|
||||||
{
|
{
|
||||||
CustomWizard *rc = 0;
|
CustomWizard *rc = 0;
|
||||||
if (p->klass.isEmpty()) {
|
QList<ICustomWizardFactory *> factories = ExtensionSystem::PluginManager::getObjects<ICustomWizardFactory>();
|
||||||
// Use defaults for empty class names
|
foreach (ICustomWizardFactory *tmp, factories) {
|
||||||
switch (b.kind) {
|
if ((p->klass.isEmpty() && b.kind == tmp->kind())
|
||||||
case Core::IWizard::ProjectWizard:
|
|| (!p->klass.isEmpty() && p->klass == tmp->klass())) {
|
||||||
rc = new CustomProjectWizard;
|
rc = tmp->create();
|
||||||
break;
|
|
||||||
case Core::IWizard::FileWizard:
|
|
||||||
case Core::IWizard::ClassWizard:
|
|
||||||
rc = new CustomWizard;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Look up class name in map
|
|
||||||
const CustomWizardFactoryMap::const_iterator it = customWizardFactoryMap()->constFind(p->klass);
|
|
||||||
if (it != customWizardFactoryMap()->constEnd())
|
|
||||||
rc = it.value()->create();
|
|
||||||
}
|
}
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
qWarning("Unable to create custom wizard for class %s.", qPrintable(p->klass));
|
qWarning("Unable to create custom wizard for class %s.", qPrintable(p->klass));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc->setData(b);
|
rc->setData(b);
|
||||||
rc->setParameters(p);
|
rc->setParameters(p);
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@@ -55,17 +55,31 @@ namespace Internal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Documentation inside.
|
// Documentation inside.
|
||||||
class ICustomWizardFactory
|
class ICustomWizardFactory : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual CustomWizard *create(QObject *parent = 0) const = 0;
|
ICustomWizardFactory(const QString &klass, Core::IWizard::WizardKind kind) :
|
||||||
virtual ~ICustomWizardFactory() {}
|
m_klass(klass), m_kind(kind)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual CustomWizard *create() const = 0;
|
||||||
|
QString klass() const { return m_klass; }
|
||||||
|
int kind() const { return m_kind; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_klass;
|
||||||
|
Core::IWizard::WizardKind m_kind;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convenience template to create wizard factory classes.
|
// Convenience template to create wizard factory classes.
|
||||||
template <class Wizard> class CustomWizardFactory : public ICustomWizardFactory
|
template <class Wizard> class CustomWizardFactory : public ICustomWizardFactory
|
||||||
{
|
{
|
||||||
CustomWizard *create(QObject * = 0) const { return new Wizard; }
|
public:
|
||||||
|
CustomWizardFactory(const QString &klass, Core::IWizard::WizardKind kind) : ICustomWizardFactory(klass, kind) { }
|
||||||
|
CustomWizardFactory(Core::IWizard::WizardKind kind) : ICustomWizardFactory(QString(), kind) { }
|
||||||
|
CustomWizard *create() const { return new Wizard; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Documentation inside.
|
// Documentation inside.
|
||||||
@@ -87,11 +101,6 @@ public:
|
|||||||
|
|
||||||
Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const;
|
Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const;
|
||||||
|
|
||||||
// Register a factory for a derived custom widget
|
|
||||||
static void registerFactory(const QString &name, const ICustomWizardFactoryPtr &f);
|
|
||||||
template <class Wizard> static void registerFactory(const QString &name)
|
|
||||||
{ registerFactory(name, ICustomWizardFactoryPtr(new CustomWizardFactory<Wizard>)); }
|
|
||||||
|
|
||||||
// Create all wizards. As other plugins might register factories for derived
|
// Create all wizards. As other plugins might register factories for derived
|
||||||
// classes, call it in extensionsInitialized().
|
// classes, call it in extensionsInitialized().
|
||||||
static QList<CustomWizard*> createWizards();
|
static QList<CustomWizard*> createWizards();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "projectexplorer.h"
|
#include "projectexplorer.h"
|
||||||
|
|
||||||
#include "buildsteplist.h"
|
#include "buildsteplist.h"
|
||||||
|
#include "customwizard/customwizard.h"
|
||||||
#include "deployablefile.h"
|
#include "deployablefile.h"
|
||||||
#include "deployconfiguration.h"
|
#include "deployconfiguration.h"
|
||||||
#include "gcctoolchainfactories.h"
|
#include "gcctoolchainfactories.h"
|
||||||
@@ -394,6 +395,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
connect(sessionManager, SIGNAL(sessionLoaded(QString)),
|
connect(sessionManager, SIGNAL(sessionLoaded(QString)),
|
||||||
this, SLOT(updateWelcomePage()));
|
this, SLOT(updateWelcomePage()));
|
||||||
|
|
||||||
|
addAutoReleasedObject(new CustomWizardFactory<CustomProjectWizard>(Core::IWizard::ProjectWizard));
|
||||||
|
addAutoReleasedObject(new CustomWizardFactory<CustomWizard>(Core::IWizard::FileWizard));
|
||||||
|
addAutoReleasedObject(new CustomWizardFactory<CustomWizard>(Core::IWizard::ClassWizard));
|
||||||
|
|
||||||
d->m_proWindow = new ProjectWindow;
|
d->m_proWindow = new ProjectWindow;
|
||||||
addAutoReleasedObject(d->m_proWindow);
|
addAutoReleasedObject(d->m_proWindow);
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
|
|||||||
addAutoReleasedObject(new TestWizard);
|
addAutoReleasedObject(new TestWizard);
|
||||||
addAutoReleasedObject(new CustomWidgetWizard);
|
addAutoReleasedObject(new CustomWidgetWizard);
|
||||||
|
|
||||||
CustomQmakeProjectWizard::registerSelf();
|
addAutoReleasedObject(new CustomWizardFactory<CustomQmakeProjectWizard>
|
||||||
|
(QLatin1String("qmakeproject"), Core::IWizard::ProjectWizard));
|
||||||
|
|
||||||
addAutoReleasedObject(new QMakeStepFactory);
|
addAutoReleasedObject(new QMakeStepFactory);
|
||||||
addAutoReleasedObject(new MakeStepFactory);
|
addAutoReleasedObject(new MakeStepFactory);
|
||||||
|
|||||||
@@ -151,11 +151,6 @@ bool CustomQmakeProjectWizard::postGenerateFiles(const QWizard *w, const Core::G
|
|||||||
return QtWizard::qt4ProjectPostGenerateFiles(w, l, errorMessage);
|
return QtWizard::qt4ProjectPostGenerateFiles(w, l, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomQmakeProjectWizard::registerSelf()
|
|
||||||
{
|
|
||||||
ProjectExplorer::CustomWizard::registerFactory<CustomQmakeProjectWizard>(QLatin1String("qt4project"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------- BaseQmakeProjectWizardDialog
|
// ----------------- BaseQmakeProjectWizardDialog
|
||||||
BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(bool showModulesPage, QWidget *parent,
|
BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(bool showModulesPage, QWidget *parent,
|
||||||
const Core::WizardDialogParameters ¶meters) :
|
const Core::WizardDialogParameters ¶meters) :
|
||||||
|
|||||||
@@ -91,8 +91,6 @@ class CustomQmakeProjectWizard : public ProjectExplorer::CustomProjectWizard
|
|||||||
public:
|
public:
|
||||||
CustomQmakeProjectWizard();
|
CustomQmakeProjectWizard();
|
||||||
|
|
||||||
static void registerSelf();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWizard *createWizardDialog(QWidget *parent,
|
QWizard *createWizardDialog(QWidget *parent,
|
||||||
const Core::WizardDialogParameters &wizardDialogParameters) const;
|
const Core::WizardDialogParameters &wizardDialogParameters) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user