Commit dc54e3f4 authored by Friedemann Kleint's avatar Friedemann Kleint

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: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent cba54bf4
......@@ -35,16 +35,16 @@
namespace Qt4ProjectManager {
namespace Internal {
enum { IntroPageId, WidgetsPageId, PluginPageId };
enum { IntroPageId = 0};
CustomWidgetWizardDialog::CustomWidgetWizardDialog(const QString &templateName,
const QIcon &icon,
const QList<QWizardPage*> &extensionPages,
QWidget *parent) :
ProjectExplorer::BaseProjectWizardDialog(parent),
BaseQt4ProjectWizardDialog(false, parent),
m_widgetsPage(new CustomWidgetWidgetsWizardPage),
m_pluginPage(new CustomWidgetPluginWizardPage)
m_pluginPage(new CustomWidgetPluginWizardPage),
m_widgetPageId(-1), m_pluginPageId(-1)
{
setWindowIcon(icon);
setWindowTitle(templateName);
......@@ -52,8 +52,9 @@ CustomWidgetWizardDialog::CustomWidgetWizardDialog(const QString &templateName,
setIntroDescription(tr("This wizard generates a Qt4 Designer Custom Widget "
"or a Qt4 Designer Custom Widget Collection project."));
setPage(WidgetsPageId, m_widgetsPage);
setPage(PluginPageId, m_pluginPage);
addTargetsPage(BaseQt4ProjectWizardDialog::desktopTarget());
m_widgetPageId = addPage(m_widgetsPage);
m_pluginPageId = addPage(m_pluginPage);
foreach (QWizardPage *p, extensionPages)
addPage(p);
......@@ -73,14 +74,8 @@ void CustomWidgetWizardDialog::setFileNamingParameters(const FileNamingParameter
void CustomWidgetWizardDialog::slotCurrentIdChanged(int id)
{
switch (id) {
case IntroPageId:
case WidgetsPageId:
break;
case PluginPageId:
if (id == m_pluginPageId)
m_pluginPage->init(m_widgetsPage);
break;
}
}
QSharedPointer<PluginOptions> CustomWidgetWizardDialog::pluginOptions() const
......
......@@ -30,7 +30,7 @@
#ifndef CUSTOMWIDGETWIZARDDIALOG_H
#define CUSTOMWIDGETWIZARDDIALOG_H
#include <projectexplorer/baseprojectwizarddialog.h>
#include "../wizards/qtwizard.h"
#include <QtCore/QSharedPointer>
......@@ -42,7 +42,7 @@ class CustomWidgetPluginWizardPage;
struct PluginOptions;
struct FileNamingParameters;
class CustomWidgetWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
class CustomWidgetWizardDialog : public BaseQt4ProjectWizardDialog
{
Q_OBJECT
public:
......@@ -63,6 +63,8 @@ private slots:
private:
CustomWidgetWidgetsWizardPage *m_widgetsPage;
CustomWidgetPluginWizardPage *m_pluginPage;
int m_widgetPageId;
int m_pluginPageId;
};
} // namespace Internal
......
......@@ -40,7 +40,6 @@
#include <QtGui/QLabel>
enum { debugLibWizard = 0 };
enum { IntroPageId, ModulesPageId, FilePageId };
namespace Qt4ProjectManager {
namespace Internal {
......@@ -105,8 +104,6 @@ public:
QtProjectParameters::Type type() const;
virtual int nextId() const;
private:
QComboBox *m_typeCombo;
};
......@@ -125,31 +122,21 @@ LibraryIntroPage::LibraryIntroPage(QWidget *parent) :
insertControl(0, new QLabel(LibraryWizardDialog::tr("Type")), m_typeCombo);
}
QtProjectParameters::Type LibraryIntroPage::type() const
{
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(const QString &templateName,
const QIcon &icon,
const QList<QWizardPage*> &extensionPages,
bool showModulesPage,
QWidget *parent) :
BaseQt4ProjectWizardDialog(showModulesPage, new LibraryIntroPage, IntroPageId, parent),
BaseQt4ProjectWizardDialog(showModulesPage, new LibraryIntroPage, -1, parent),
m_filesPage(new FilesPage),
m_pluginBaseClassesInitialized(false)
m_pluginBaseClassesInitialized(false),
m_filesPageId(-1), m_modulesPageId(-1), m_targetPageId(-1)
{
setWindowIcon(icon);
setWindowTitle(templateName);
......@@ -159,13 +146,14 @@ LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
// Use the intro page instead, set up initially
setIntroDescription(tr("This wizard generates a C++ library project."));
addModulesPage(ModulesPageId);
addTargetsPage();
m_targetPageId = addTargetsPage();
m_modulesPageId = addModulesPage();
m_filesPage->setNamespacesEnabled(true);
m_filesPage->setFormFileInputVisible(false);
m_filesPage->setClassTypeComboVisible(false);
setPage(FilePageId, m_filesPage);
m_filesPageId = addPage(m_filesPage);
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();
}
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 rc;
......@@ -216,7 +216,7 @@ void LibraryWizardDialog::slotCurrentIdChanged(int id)
if (debugLibWizard)
qDebug() << Q_FUNC_INFO << id;
// Switching to files page: Set up base class accordingly (plugin)
if (id != FilePageId)
if (id != m_filesPageId)
return;
switch (type()) {
case QtProjectParameters::Qt4Plugin:
......
......@@ -58,6 +58,8 @@ public:
QtProjectParameters parameters() const;
LibraryParameters libraryParameters() const;
virtual int nextId() const;
private slots:
void slotCurrentIdChanged(int);
......@@ -66,6 +68,9 @@ private:
FilesPage *m_filesPage;
bool m_pluginBaseClassesInitialized;
int m_filesPageId;
int m_modulesPageId;
int m_targetPageId;
};
} // namespace Internal
......
......@@ -32,6 +32,7 @@
#include "qt4project.h"
#include "qt4projectmanager.h"
#include "qt4projectmanagerconstants.h"
#include "qt4target.h"
#include "modulespage.h"
#include "targetspage.h"
......@@ -192,34 +193,34 @@ void BaseQt4ProjectWizardDialog::init(bool showModulesPage)
m_targetsPage = new TargetsPage;
}
void BaseQt4ProjectWizardDialog::addModulesPage(int id)
int BaseQt4ProjectWizardDialog::addModulesPage(int id)
{
if (m_modulesPage) {
if (id >= 0) {
setPage(id, m_modulesPage);
} else {
addPage(m_modulesPage);
}
if (!m_modulesPage)
return -1;
if (id >= 0) {
setPage(id, 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)
return;
return -1;
m_targetsPage->setValidTargets(targets);
if (!m_targetsPage->needToDisplayPage())
return;
return -1;
if (id >= 0)
if (id >= 0) {
setPage(id, m_targetsPage);
else
addPage(m_targetsPage);
return id;
}
return addPage(m_targetsPage);
}
QString BaseQt4ProjectWizardDialog::selectedModules() const
{
return m_modulesPage ? m_modulesPage->selectedModules() : m_selectedModules;
......@@ -265,3 +266,10 @@ QList<int> BaseQt4ProjectWizardDialog::selectedQtVersionIdsForTarget(const QStri
return QList<int>();
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,
QWidget *parent = 0);
void addModulesPage(int id = -1);
void addTargetsPage(QSet<QString> targets = QSet<QString>(), int id = -1);
int addModulesPage(int id = -1);
int addTargetsPage(QSet<QString> targets = QSet<QString>(), int id = -1);
static QSet<QString> desktopTarget();
public:
QString selectedModules() const;
......
......@@ -32,7 +32,7 @@
#include <QtCore/QFileInfo>
enum PageIds { StartPageId, TestPageId, ModulesPageId };
enum PageIds { StartPageId = 0 };
namespace Qt4ProjectManager {
namespace Internal {
......@@ -52,15 +52,17 @@ TestWizardDialog::TestWizardDialog(const QString &templateName,
const QList<QWizardPage*> &extensionPages,
QWidget *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 "
"consisting of a single source file with a test class."));
setWindowIcon(icon);
setWindowTitle(templateName);
setSelectedModules(QLatin1String("core testlib"), true);
setPage(TestPageId, m_testPage);
addModulesPage(ModulesPageId);
addTargetsPage();
m_testPageId = addPage(m_testPage);
m_modulesPageId = addModulesPage();
foreach (QWizardPage *p, extensionPages)
addPage(p);
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentIdChanged(int)));
......@@ -68,7 +70,7 @@ TestWizardDialog::TestWizardDialog(const QString &templateName,
void TestWizardDialog::slotCurrentIdChanged(int id)
{
if (id == TestPageId)
if (id == m_testPageId)
m_testPage->setProjectName(projectName());
}
......
......@@ -75,6 +75,8 @@ private slots:
private:
TestWizardPage *m_testPage;
int m_testPageId;
int m_modulesPageId;
};
} // namespace Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment