forked from qt-creator/qt-creator
Library/Unit Test/Custom Widget Wizard: Add Target page.
Handle target page correctly. Remove static enumerations of page ids by member variables to handle differing page setups. Fix page switching logic in library wizard. Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -35,16 +35,16 @@
|
|||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
enum { IntroPageId, WidgetsPageId, PluginPageId };
|
enum { IntroPageId = 0};
|
||||||
|
|
||||||
CustomWidgetWizardDialog::CustomWidgetWizardDialog(const QString &templateName,
|
CustomWidgetWizardDialog::CustomWidgetWizardDialog(const QString &templateName,
|
||||||
const QIcon &icon,
|
const QIcon &icon,
|
||||||
const QList<QWizardPage*> &extensionPages,
|
const QList<QWizardPage*> &extensionPages,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
ProjectExplorer::BaseProjectWizardDialog(parent),
|
BaseQt4ProjectWizardDialog(false, parent),
|
||||||
m_widgetsPage(new CustomWidgetWidgetsWizardPage),
|
m_widgetsPage(new CustomWidgetWidgetsWizardPage),
|
||||||
m_pluginPage(new CustomWidgetPluginWizardPage)
|
m_pluginPage(new CustomWidgetPluginWizardPage),
|
||||||
|
m_widgetPageId(-1), m_pluginPageId(-1)
|
||||||
{
|
{
|
||||||
setWindowIcon(icon);
|
setWindowIcon(icon);
|
||||||
setWindowTitle(templateName);
|
setWindowTitle(templateName);
|
||||||
@@ -52,8 +52,9 @@ CustomWidgetWizardDialog::CustomWidgetWizardDialog(const QString &templateName,
|
|||||||
setIntroDescription(tr("This wizard generates a Qt4 Designer Custom Widget "
|
setIntroDescription(tr("This wizard generates a Qt4 Designer Custom Widget "
|
||||||
"or a Qt4 Designer Custom Widget Collection project."));
|
"or a Qt4 Designer Custom Widget Collection project."));
|
||||||
|
|
||||||
setPage(WidgetsPageId, m_widgetsPage);
|
addTargetsPage(BaseQt4ProjectWizardDialog::desktopTarget());
|
||||||
setPage(PluginPageId, m_pluginPage);
|
m_widgetPageId = addPage(m_widgetsPage);
|
||||||
|
m_pluginPageId = addPage(m_pluginPage);
|
||||||
|
|
||||||
foreach (QWizardPage *p, extensionPages)
|
foreach (QWizardPage *p, extensionPages)
|
||||||
addPage(p);
|
addPage(p);
|
||||||
@@ -73,14 +74,8 @@ void CustomWidgetWizardDialog::setFileNamingParameters(const FileNamingParameter
|
|||||||
|
|
||||||
void CustomWidgetWizardDialog::slotCurrentIdChanged(int id)
|
void CustomWidgetWizardDialog::slotCurrentIdChanged(int id)
|
||||||
{
|
{
|
||||||
switch (id) {
|
if (id == m_pluginPageId)
|
||||||
case IntroPageId:
|
|
||||||
case WidgetsPageId:
|
|
||||||
break;
|
|
||||||
case PluginPageId:
|
|
||||||
m_pluginPage->init(m_widgetsPage);
|
m_pluginPage->init(m_widgetsPage);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<PluginOptions> CustomWidgetWizardDialog::pluginOptions() const
|
QSharedPointer<PluginOptions> CustomWidgetWizardDialog::pluginOptions() const
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#ifndef CUSTOMWIDGETWIZARDDIALOG_H
|
#ifndef CUSTOMWIDGETWIZARDDIALOG_H
|
||||||
#define CUSTOMWIDGETWIZARDDIALOG_H
|
#define CUSTOMWIDGETWIZARDDIALOG_H
|
||||||
|
|
||||||
#include <projectexplorer/baseprojectwizarddialog.h>
|
#include "../wizards/qtwizard.h"
|
||||||
|
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ class CustomWidgetPluginWizardPage;
|
|||||||
struct PluginOptions;
|
struct PluginOptions;
|
||||||
struct FileNamingParameters;
|
struct FileNamingParameters;
|
||||||
|
|
||||||
class CustomWidgetWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
|
class CustomWidgetWizardDialog : public BaseQt4ProjectWizardDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -63,6 +63,8 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
CustomWidgetWidgetsWizardPage *m_widgetsPage;
|
CustomWidgetWidgetsWizardPage *m_widgetsPage;
|
||||||
CustomWidgetPluginWizardPage *m_pluginPage;
|
CustomWidgetPluginWizardPage *m_pluginPage;
|
||||||
|
int m_widgetPageId;
|
||||||
|
int m_pluginPageId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
|
|
||||||
enum { debugLibWizard = 0 };
|
enum { debugLibWizard = 0 };
|
||||||
enum { IntroPageId, ModulesPageId, FilePageId };
|
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -105,8 +104,6 @@ public:
|
|||||||
|
|
||||||
QtProjectParameters::Type type() const;
|
QtProjectParameters::Type type() const;
|
||||||
|
|
||||||
virtual int nextId() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QComboBox *m_typeCombo;
|
QComboBox *m_typeCombo;
|
||||||
};
|
};
|
||||||
@@ -125,31 +122,21 @@ LibraryIntroPage::LibraryIntroPage(QWidget *parent) :
|
|||||||
insertControl(0, new QLabel(LibraryWizardDialog::tr("Type")), m_typeCombo);
|
insertControl(0, new QLabel(LibraryWizardDialog::tr("Type")), m_typeCombo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QtProjectParameters::Type LibraryIntroPage::type() const
|
QtProjectParameters::Type LibraryIntroPage::type() const
|
||||||
{
|
{
|
||||||
return static_cast<QtProjectParameters::Type>(m_typeCombo->itemData(m_typeCombo->currentIndex()).toInt());
|
return static_cast<QtProjectParameters::Type>(m_typeCombo->itemData(m_typeCombo->currentIndex()).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
int LibraryIntroPage::nextId() const
|
|
||||||
{
|
|
||||||
// The modules page is skipped in the case of a plugin since it knows its
|
|
||||||
// dependencies by itself
|
|
||||||
const int rc = type() == QtProjectParameters::Qt4Plugin ? FilePageId : ModulesPageId;
|
|
||||||
if (debugLibWizard)
|
|
||||||
qDebug() << Q_FUNC_INFO << "returns" << rc;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------- LibraryWizardDialog
|
// ------------------- LibraryWizardDialog
|
||||||
LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
|
LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
|
||||||
const QIcon &icon,
|
const QIcon &icon,
|
||||||
const QList<QWizardPage*> &extensionPages,
|
const QList<QWizardPage*> &extensionPages,
|
||||||
bool showModulesPage,
|
bool showModulesPage,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
BaseQt4ProjectWizardDialog(showModulesPage, new LibraryIntroPage, IntroPageId, parent),
|
BaseQt4ProjectWizardDialog(showModulesPage, new LibraryIntroPage, -1, parent),
|
||||||
m_filesPage(new FilesPage),
|
m_filesPage(new FilesPage),
|
||||||
m_pluginBaseClassesInitialized(false)
|
m_pluginBaseClassesInitialized(false),
|
||||||
|
m_filesPageId(-1), m_modulesPageId(-1), m_targetPageId(-1)
|
||||||
{
|
{
|
||||||
setWindowIcon(icon);
|
setWindowIcon(icon);
|
||||||
setWindowTitle(templateName);
|
setWindowTitle(templateName);
|
||||||
@@ -159,13 +146,14 @@ LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
|
|||||||
// Use the intro page instead, set up initially
|
// Use the intro page instead, set up initially
|
||||||
setIntroDescription(tr("This wizard generates a C++ library project."));
|
setIntroDescription(tr("This wizard generates a C++ library project."));
|
||||||
|
|
||||||
addModulesPage(ModulesPageId);
|
m_targetPageId = addTargetsPage();
|
||||||
addTargetsPage();
|
m_modulesPageId = addModulesPage();
|
||||||
|
|
||||||
m_filesPage->setNamespacesEnabled(true);
|
m_filesPage->setNamespacesEnabled(true);
|
||||||
m_filesPage->setFormFileInputVisible(false);
|
m_filesPage->setFormFileInputVisible(false);
|
||||||
m_filesPage->setClassTypeComboVisible(false);
|
m_filesPage->setClassTypeComboVisible(false);
|
||||||
setPage(FilePageId, m_filesPage);
|
|
||||||
|
m_filesPageId = addPage(m_filesPage);
|
||||||
|
|
||||||
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentIdChanged(int)));
|
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentIdChanged(int)));
|
||||||
|
|
||||||
@@ -188,6 +176,18 @@ QtProjectParameters::Type LibraryWizardDialog::type() const
|
|||||||
return static_cast<const LibraryIntroPage*>(introPage())->type();
|
return static_cast<const LibraryIntroPage*>(introPage())->type();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LibraryWizardDialog::nextId() const
|
||||||
|
{
|
||||||
|
// When leaving the intro or target page, the modules page is skipped
|
||||||
|
// in the case of a plugin since it knows its dependencies by itself.
|
||||||
|
const int m_beforeModulesPageId = m_targetPageId != -1 ? m_targetPageId : 0;
|
||||||
|
if (currentId() != m_beforeModulesPageId)
|
||||||
|
return BaseQt4ProjectWizardDialog::nextId();
|
||||||
|
if (type() != QtProjectParameters::Qt4Plugin && m_modulesPageId != -1)
|
||||||
|
return m_modulesPageId;
|
||||||
|
return m_filesPageId;
|
||||||
|
}
|
||||||
|
|
||||||
QtProjectParameters LibraryWizardDialog::parameters() const
|
QtProjectParameters LibraryWizardDialog::parameters() const
|
||||||
{
|
{
|
||||||
QtProjectParameters rc;
|
QtProjectParameters rc;
|
||||||
@@ -216,7 +216,7 @@ void LibraryWizardDialog::slotCurrentIdChanged(int id)
|
|||||||
if (debugLibWizard)
|
if (debugLibWizard)
|
||||||
qDebug() << Q_FUNC_INFO << id;
|
qDebug() << Q_FUNC_INFO << id;
|
||||||
// Switching to files page: Set up base class accordingly (plugin)
|
// Switching to files page: Set up base class accordingly (plugin)
|
||||||
if (id != FilePageId)
|
if (id != m_filesPageId)
|
||||||
return;
|
return;
|
||||||
switch (type()) {
|
switch (type()) {
|
||||||
case QtProjectParameters::Qt4Plugin:
|
case QtProjectParameters::Qt4Plugin:
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public:
|
|||||||
QtProjectParameters parameters() const;
|
QtProjectParameters parameters() const;
|
||||||
LibraryParameters libraryParameters() const;
|
LibraryParameters libraryParameters() const;
|
||||||
|
|
||||||
|
virtual int nextId() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotCurrentIdChanged(int);
|
void slotCurrentIdChanged(int);
|
||||||
|
|
||||||
@@ -66,6 +68,9 @@ private:
|
|||||||
|
|
||||||
FilesPage *m_filesPage;
|
FilesPage *m_filesPage;
|
||||||
bool m_pluginBaseClassesInitialized;
|
bool m_pluginBaseClassesInitialized;
|
||||||
|
int m_filesPageId;
|
||||||
|
int m_modulesPageId;
|
||||||
|
int m_targetPageId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "qt4project.h"
|
#include "qt4project.h"
|
||||||
#include "qt4projectmanager.h"
|
#include "qt4projectmanager.h"
|
||||||
#include "qt4projectmanagerconstants.h"
|
#include "qt4projectmanagerconstants.h"
|
||||||
|
#include "qt4target.h"
|
||||||
#include "modulespage.h"
|
#include "modulespage.h"
|
||||||
#include "targetspage.h"
|
#include "targetspage.h"
|
||||||
|
|
||||||
@@ -192,34 +193,34 @@ void BaseQt4ProjectWizardDialog::init(bool showModulesPage)
|
|||||||
m_targetsPage = new TargetsPage;
|
m_targetsPage = new TargetsPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseQt4ProjectWizardDialog::addModulesPage(int id)
|
int BaseQt4ProjectWizardDialog::addModulesPage(int id)
|
||||||
{
|
{
|
||||||
if (m_modulesPage) {
|
if (!m_modulesPage)
|
||||||
if (id >= 0) {
|
return -1;
|
||||||
setPage(id, m_modulesPage);
|
if (id >= 0) {
|
||||||
} else {
|
setPage(id, m_modulesPage);
|
||||||
addPage(m_modulesPage);
|
return id;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return addPage(m_modulesPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseQt4ProjectWizardDialog::addTargetsPage(QSet<QString> targets, int id)
|
int BaseQt4ProjectWizardDialog::addTargetsPage(QSet<QString> targets, int id)
|
||||||
{
|
{
|
||||||
if (!m_targetsPage)
|
if (!m_targetsPage)
|
||||||
return;
|
return -1;
|
||||||
|
|
||||||
m_targetsPage->setValidTargets(targets);
|
m_targetsPage->setValidTargets(targets);
|
||||||
|
|
||||||
if (!m_targetsPage->needToDisplayPage())
|
if (!m_targetsPage->needToDisplayPage())
|
||||||
return;
|
return -1;
|
||||||
|
|
||||||
if (id >= 0)
|
if (id >= 0) {
|
||||||
setPage(id, m_targetsPage);
|
setPage(id, m_targetsPage);
|
||||||
else
|
return id;
|
||||||
addPage(m_targetsPage);
|
}
|
||||||
|
return addPage(m_targetsPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString BaseQt4ProjectWizardDialog::selectedModules() const
|
QString BaseQt4ProjectWizardDialog::selectedModules() const
|
||||||
{
|
{
|
||||||
return m_modulesPage ? m_modulesPage->selectedModules() : m_selectedModules;
|
return m_modulesPage ? m_modulesPage->selectedModules() : m_selectedModules;
|
||||||
@@ -265,3 +266,10 @@ QList<int> BaseQt4ProjectWizardDialog::selectedQtVersionIdsForTarget(const QStri
|
|||||||
return QList<int>();
|
return QList<int>();
|
||||||
return m_targetsPage->selectedVersionIdsForTarget(target);
|
return m_targetsPage->selectedVersionIdsForTarget(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSet<QString> BaseQt4ProjectWizardDialog::desktopTarget()
|
||||||
|
{
|
||||||
|
QSet<QString> rc;
|
||||||
|
rc.insert(QLatin1String(DESKTOP_TARGET_ID));
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|||||||
@@ -101,8 +101,10 @@ protected:
|
|||||||
int introId = -1,
|
int introId = -1,
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
|
|
||||||
void addModulesPage(int id = -1);
|
int addModulesPage(int id = -1);
|
||||||
void addTargetsPage(QSet<QString> targets = QSet<QString>(), int id = -1);
|
int addTargetsPage(QSet<QString> targets = QSet<QString>(), int id = -1);
|
||||||
|
|
||||||
|
static QSet<QString> desktopTarget();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString selectedModules() const;
|
QString selectedModules() const;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
|
|
||||||
enum PageIds { StartPageId, TestPageId, ModulesPageId };
|
enum PageIds { StartPageId = 0 };
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -52,15 +52,17 @@ TestWizardDialog::TestWizardDialog(const QString &templateName,
|
|||||||
const QList<QWizardPage*> &extensionPages,
|
const QList<QWizardPage*> &extensionPages,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
BaseQt4ProjectWizardDialog(true, parent),
|
BaseQt4ProjectWizardDialog(true, parent),
|
||||||
m_testPage(new TestWizardPage)
|
m_testPage(new TestWizardPage),
|
||||||
|
m_testPageId(-1), m_modulesPageId(-1)
|
||||||
{
|
{
|
||||||
setIntroDescription(tr("This wizard generates a Qt unit test "
|
setIntroDescription(tr("This wizard generates a Qt unit test "
|
||||||
"consisting of a single source file with a test class."));
|
"consisting of a single source file with a test class."));
|
||||||
setWindowIcon(icon);
|
setWindowIcon(icon);
|
||||||
setWindowTitle(templateName);
|
setWindowTitle(templateName);
|
||||||
setSelectedModules(QLatin1String("core testlib"), true);
|
setSelectedModules(QLatin1String("core testlib"), true);
|
||||||
setPage(TestPageId, m_testPage);
|
addTargetsPage();
|
||||||
addModulesPage(ModulesPageId);
|
m_testPageId = addPage(m_testPage);
|
||||||
|
m_modulesPageId = addModulesPage();
|
||||||
foreach (QWizardPage *p, extensionPages)
|
foreach (QWizardPage *p, extensionPages)
|
||||||
addPage(p);
|
addPage(p);
|
||||||
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentIdChanged(int)));
|
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentIdChanged(int)));
|
||||||
@@ -68,7 +70,7 @@ TestWizardDialog::TestWizardDialog(const QString &templateName,
|
|||||||
|
|
||||||
void TestWizardDialog::slotCurrentIdChanged(int id)
|
void TestWizardDialog::slotCurrentIdChanged(int id)
|
||||||
{
|
{
|
||||||
if (id == TestPageId)
|
if (id == m_testPageId)
|
||||||
m_testPage->setProjectName(projectName());
|
m_testPage->setProjectName(projectName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TestWizardPage *m_testPage;
|
TestWizardPage *m_testPage;
|
||||||
|
int m_testPageId;
|
||||||
|
int m_modulesPageId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user