diff options
author | Tobias Hunger <tobias.hunger@nokia.com> | 2010-03-29 17:57:18 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@nokia.com> | 2010-03-29 19:42:11 +0200 |
commit | e9e84fc1be8acea8b9ae09c5c15e38a6057221c8 (patch) | |
tree | 22c357bd5ca6b775ecfe4bf8232fceca6fcab7bc /src/plugins | |
parent | 2319f57caaaf1668f1d32fec95b104d4ec70b698 (diff) | |
download | qt-creator-e9e84fc1be8acea8b9ae09c5c15e38a6057221c8.tar.gz |
Update wizards to use targetsetuppage
Diffstat (limited to 'src/plugins')
10 files changed, 62 insertions, 330 deletions
diff --git a/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizarddialog.cpp b/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizarddialog.cpp index d478bc5075..1870531b7b 100644 --- a/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizarddialog.cpp +++ b/src/plugins/qt4projectmanager/customwidgetwizard/customwidgetwizarddialog.cpp @@ -52,7 +52,7 @@ CustomWidgetWizardDialog::CustomWidgetWizardDialog(const QString &templateName, setIntroDescription(tr("This wizard generates a Qt4 Designer Custom Widget " "or a Qt4 Designer Custom Widget Collection project.")); - addTargetsPage(BaseQt4ProjectWizardDialog::desktopTarget()); + addTargetSetupPage(BaseQt4ProjectWizardDialog::desktopTarget()); m_widgetPageId = addPage(m_widgetsPage); m_pluginPageId = addPage(m_pluginPage); diff --git a/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp index d34793489e..fc59468d94 100644 --- a/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp +++ b/src/plugins/qt4projectmanager/wizards/consoleappwizarddialog.cpp @@ -52,7 +52,7 @@ ConsoleAppWizardDialog::ConsoleAppWizardDialog(const QString &templateName, "provide a GUI.")); addModulesPage(); - addTargetsPage(); + addTargetSetupPage(); foreach (QWizardPage *p, extensionPages) addPage(p); diff --git a/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp index a10dd60487..e572120cf3 100644 --- a/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp +++ b/src/plugins/qt4projectmanager/wizards/emptyprojectwizarddialog.cpp @@ -45,7 +45,7 @@ EmptyProjectWizardDialog::EmptyProjectWizardDialog(const QString &templateName, setIntroDescription(tr("This wizard generates an empty Qt4 project. " "Add files to it later on by using the other wizards.")); - addTargetsPage(); + addTargetSetupPage(); foreach (QWizardPage *p, extensionPages) addPage(p); diff --git a/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp index 0f3959b188..2155af9da4 100644 --- a/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp +++ b/src/plugins/qt4projectmanager/wizards/guiappwizarddialog.cpp @@ -62,7 +62,7 @@ GuiAppWizardDialog::GuiAppWizardDialog(const QString &templateName, "and includes an empty widget.")); addModulesPage(); - addTargetsPage(); + addTargetSetupPage(); m_filesPage->setFormInputCheckable(true); m_filesPage->setClassTypeComboVisible(false); @@ -110,12 +110,11 @@ GuiAppParameters GuiAppWizardDialog::parameters() const rc.formFileName = m_filesPage->formFileName(); rc.designerForm = m_filesPage->formInputChecked(); rc.isMobileApplication = true; - QSet<QString> targets = selectedTargets(); - if (targets.contains(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))) { + if (isTargetSelected(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))) { rc.widgetWidth = 800; rc.widgetHeight = 480; - } else if (targets.contains(QLatin1String(Constants::S60_DEVICE_TARGET_ID)) || - targets.contains(QLatin1String(Constants::S60_EMULATOR_TARGET_ID))) { + } else if (isTargetSelected(QLatin1String(Constants::S60_DEVICE_TARGET_ID)) || + isTargetSelected(QLatin1String(Constants::S60_EMULATOR_TARGET_ID))) { rc.widgetWidth = 360; rc.widgetHeight = 640; } else { diff --git a/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp index 2f396f4c0a..dad6cff56a 100644 --- a/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp +++ b/src/plugins/qt4projectmanager/wizards/librarywizarddialog.cpp @@ -146,7 +146,7 @@ LibraryWizardDialog::LibraryWizardDialog(const QString &templateName, // Use the intro page instead, set up initially setIntroDescription(tr("This wizard generates a C++ library project.")); - m_targetPageId = addTargetsPage(); + m_targetPageId = addTargetSetupPage(); m_modulesPageId = addModulesPage(); m_filesPage->setNamespacesEnabled(true); diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp index 66f046304c..3e84b864c9 100644 --- a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp @@ -30,10 +30,11 @@ #include "qtwizard.h" #include "qt4project.h" +#include "qt4projectmanager.h" #include "qt4projectmanagerconstants.h" #include "qt4target.h" #include "modulespage.h" -#include "targetspage.h" +#include "targetsetuppage.h" #include <coreplugin/icore.h> #include <cpptools/cpptoolsconstants.h> @@ -164,7 +165,7 @@ QWizard *CustomQt4ProjectWizard::createWizardDialog(QWidget *parent, initProjectWizardDialog(wizard, defaultPath, extensionPages); if (wizard->pageIds().contains(targetPageId)) qWarning("CustomQt4ProjectWizard: Unable to insert target page at %d", int(targetPageId)); - wizard->addTargetsPage(QSet<QString>(), targetPageId); + wizard->addTargetSetupPage(QSet<QString>(), targetPageId); return wizard; } @@ -182,7 +183,7 @@ void CustomQt4ProjectWizard::registerSelf() BaseQt4ProjectWizardDialog::BaseQt4ProjectWizardDialog(bool showModulesPage, QWidget *parent) : ProjectExplorer::BaseProjectWizardDialog(parent), m_modulesPage(0), - m_targetsPage(0) + m_targetSetupPage(0) { init(showModulesPage); } @@ -192,15 +193,15 @@ BaseQt4ProjectWizardDialog::BaseQt4ProjectWizardDialog(bool showModulesPage, int introId, QWidget *parent) : ProjectExplorer::BaseProjectWizardDialog(introPage, introId, parent), m_modulesPage(0), - m_targetsPage(0) + m_targetSetupPage(0) { init(showModulesPage); } BaseQt4ProjectWizardDialog::~BaseQt4ProjectWizardDialog() { - if (m_targetsPage && !m_targetsPage->parent()) - delete m_targetsPage; + if (m_targetSetupPage && !m_targetSetupPage->parent()) + delete m_targetSetupPage; if (m_modulesPage && !m_modulesPage->parent()) delete m_modulesPage; } @@ -209,7 +210,6 @@ void BaseQt4ProjectWizardDialog::init(bool showModulesPage) { if (showModulesPage) m_modulesPage = new ModulesPage; - m_targetsPage = new TargetsPage; } int BaseQt4ProjectWizardDialog::addModulesPage(int id) @@ -223,18 +223,26 @@ int BaseQt4ProjectWizardDialog::addModulesPage(int id) return addPage(m_modulesPage); } -int BaseQt4ProjectWizardDialog::addTargetsPage(QSet<QString> targets, int id) +int BaseQt4ProjectWizardDialog::addTargetSetupPage(QSet<QString> targets, int id) { - m_targetsPage->setValidTargets(targets); - - if (!m_targetsPage->needToDisplayPage()) + m_targetSetupPage = new TargetSetupPage; + QList<TargetSetupPage::ImportInfo> infos = TargetSetupPage::importInfosForKnownQtVersions(0); + if (!targets.isEmpty()) + infos = TargetSetupPage::filterImportInfos(targets, infos); + m_targetSetupPage->setImportDirectoryBrowsingEnabled(false); + m_targetSetupPage->setShowLocationInformation(false); + + if (infos.count() <= 1) return -1; - if (id >= 0) { - setPage(id, m_targetsPage); - return id; - } - return addPage(m_targetsPage); + m_targetSetupPage->setImportInfos(infos); + + if (id >= 0) + setPage(id, m_targetSetupPage); + else + id = addPage(m_targetSetupPage); + + return id; } QString BaseQt4ProjectWizardDialog::selectedModules() const @@ -269,18 +277,30 @@ void BaseQt4ProjectWizardDialog::setDeselectedModules(const QString &modules) } } -void BaseQt4ProjectWizardDialog::writeUserFile(const QString &proFileName) const +bool BaseQt4ProjectWizardDialog::writeUserFile(const QString &proFileName) const +{ + if (!m_targetSetupPage) + return false; + + Qt4Manager *manager = ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>(); + Q_ASSERT(manager); + + Qt4Project *pro = new Qt4Project(manager, proFileName); + bool success = m_targetSetupPage->setupProject(pro); + if (success) + pro->saveSettings(); + delete pro; + return success; +} + +bool BaseQt4ProjectWizardDialog::setupProject(Qt4Project *project) const { - if (m_targetsPage) - m_targetsPage->writeUserFile(proFileName); + return m_targetSetupPage->setupProject(project); } -QSet<QString> BaseQt4ProjectWizardDialog::selectedTargets() const +bool BaseQt4ProjectWizardDialog::isTargetSelected(const QString &targetid) const { - QSet<QString> targets; - if (m_targetsPage) - targets = m_targetsPage->selectedTargets(); - return targets; + return m_targetSetupPage->isTargetSelected(targetid); } QSet<QString> BaseQt4ProjectWizardDialog::desktopTarget() diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.h b/src/plugins/qt4projectmanager/wizards/qtwizard.h index 760a72095d..c5e0d9a72c 100644 --- a/src/plugins/qt4projectmanager/wizards/qtwizard.h +++ b/src/plugins/qt4projectmanager/wizards/qtwizard.h @@ -39,10 +39,13 @@ #include <QtCore/QSet> namespace Qt4ProjectManager { + +class Qt4Project; + namespace Internal { class ModulesPage; -class TargetsPage; +class TargetSetupPage; /* Base class for wizard creating Qt projects using QtProjectParameters. * To implement a project wizard, overwrite: @@ -125,7 +128,7 @@ public: virtual ~BaseQt4ProjectWizardDialog(); int addModulesPage(int id = -1); - int addTargetsPage(QSet<QString> targets = QSet<QString>(), int id = -1); + int addTargetSetupPage(QSet<QString> targets = QSet<QString>(), int id = -1); static QSet<QString> desktopTarget(); @@ -135,14 +138,15 @@ public: QString deselectedModules() const; void setDeselectedModules(const QString &); - void writeUserFile(const QString &proFileName) const; - QSet<QString> selectedTargets() const; + bool writeUserFile(const QString &proFileName) const; + bool setupProject(Qt4Project *project) const; + bool isTargetSelected(const QString &targetid) const; private: inline void init(bool showModulesPage); ModulesPage *m_modulesPage; - TargetsPage *m_targetsPage; + TargetSetupPage *m_targetSetupPage; QString m_selectedModules; QString m_deselectedModules; }; diff --git a/src/plugins/qt4projectmanager/wizards/targetspage.cpp b/src/plugins/qt4projectmanager/wizards/targetspage.cpp deleted file mode 100644 index c4bf2c186e..0000000000 --- a/src/plugins/qt4projectmanager/wizards/targetspage.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "targetspage.h" - -#include "qt4projectmanager/qt4project.h" -#include "qt4projectmanager/qt4projectmanager.h" -#include "qt4projectmanager/qt4target.h" -#include "qt4projectmanager/qtversionmanager.h" -#include "qt4projectmanager/qt4projectmanagerconstants.h" - -#include <extensionsystem/pluginmanager.h> - -#include <QtCore/QSet> -#include <QtCore/QString> - -#include <QtGui/QTreeWidget> -#include <QtGui/QLabel> -#include <QtGui/QLayout> - -using namespace Qt4ProjectManager::Internal; - -TargetsPage::TargetsPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Choose Qt versions")); - - QVBoxLayout *vbox = new QVBoxLayout(this); - - setTitle(tr("Select required Qt versions")); - QLabel *label = new QLabel(tr("Select the Qt versions to use in your project."), this); - label->setWordWrap(true); - vbox->addWidget(label); - - m_treeWidget = new QTreeWidget(this); - m_treeWidget->setHeaderHidden(true); - vbox->addWidget(m_treeWidget); - - QtVersionManager *vm = QtVersionManager::instance(); - QStringList targets = vm->supportedTargetIds().toList(); - qSort(targets.begin(), targets.end()); - - Qt4TargetFactory factory; - - foreach (const QString &t, targets) { - QTreeWidgetItem *targetItem = new QTreeWidgetItem(m_treeWidget); - targetItem->setText(0, factory.displayNameForId(t)); - targetItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - targetItem->setData(0, Qt::UserRole, t); - targetItem->setExpanded(true); - - foreach (QtVersion *v, vm->versionsForTargetId(t)) { - QTreeWidgetItem *versionItem = new QTreeWidgetItem(targetItem); - versionItem->setText(0, v->displayName()); - versionItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - versionItem->setData(0, Qt::UserRole, v->uniqueId()); - versionItem->setCheckState(0, Qt::Unchecked); - } - } - - connect(m_treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)), - this, SLOT(itemWasChanged())); - - emit completeChanged(); -} - -void TargetsPage::setValidTargets(const QSet<QString> &targets) -{ - if (targets.isEmpty()) - return; - - for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem *currentTargetItem = m_treeWidget->topLevelItem(i); - QString currentTarget = currentTargetItem->data(0, Qt::UserRole).toString(); - if (targets.contains(currentTarget)) - currentTargetItem->setHidden(false); - else - currentTargetItem->setHidden(true); - } - - // Make sure we have something checked! - if (selectedTargets().isEmpty()) { - for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem *currentTargetItem = m_treeWidget->topLevelItem(i); - QString currentTarget = currentTargetItem->data(0, Qt::UserRole).toString(); - if (targets.contains(currentTarget) && currentTargetItem->childCount() >= 1) { - currentTargetItem->child(0)->setCheckState(0, Qt::Checked); - break; - } - } - } - emit completeChanged(); -} - -QSet<QString> TargetsPage::selectedTargets() const -{ - QSet<QString> result; - for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem * targetItem = m_treeWidget->topLevelItem(i); - QString target = targetItem->data(0, Qt::UserRole).toString(); - - QList<int> versions = selectedQtVersionIdsForTarget(target); - if (!versions.isEmpty()) - result.insert(target); - } - return result; -} - -QList<int> TargetsPage::selectedQtVersionIdsForTarget(const QString &t) const -{ - QList<int> result; - for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem * current = m_treeWidget->topLevelItem(i); - QString target = current->data(0, Qt::UserRole).toString(); - if (t != target || current->isHidden()) - continue; - - for (int j = 0; j < current->childCount(); ++j) { - QTreeWidgetItem * child = current->child(j); - if (child->checkState(0) != Qt::Checked) - continue; - result.append(child->data(0, Qt::UserRole).toInt()); - } - } - return result; -} - -void TargetsPage::itemWasChanged() -{ - emit completeChanged(); -} - -bool TargetsPage::isComplete() const -{ - return !selectedTargets().isEmpty(); -} - -bool TargetsPage::needToDisplayPage() const -{ - int targetCount = 0; - for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem * current = m_treeWidget->topLevelItem(i); - if (current->isHidden()) - continue; - ++targetCount; - if (targetCount > 1) - return true; - - if (current->childCount() > 1) - return true; - } - return false; -} - -void TargetsPage::writeUserFile(const QString &proFileName) const -{ - Qt4Manager *manager = ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>(); - Q_ASSERT(manager); - - Qt4Project *pro = new Qt4Project(manager, proFileName); - if (setupProject(pro)) - pro->saveSettings(); - delete pro; -} - -bool TargetsPage::setupProject(Qt4ProjectManager::Qt4Project *project) const -{ - if (!project) - return false; - - // Generate user settings: - QSet<QString> targets = selectedTargets(); - if (targets.isEmpty()) - return false; - - QtVersionManager *vm = QtVersionManager::instance(); - - foreach (const QString &targetId, targets) { - QList<int> versionIds = selectedQtVersionIdsForTarget(targetId); - QList<QtVersion *> versions; - foreach (int id, versionIds) - versions.append(vm->version(id)); - Qt4Target * target = project->targetFactory()->create(project, targetId, versions); - project->addTarget(target); - } - return true; -} diff --git a/src/plugins/qt4projectmanager/wizards/targetspage.h b/src/plugins/qt4projectmanager/wizards/targetspage.h deleted file mode 100644 index 15629d42e4..0000000000 --- a/src/plugins/qt4projectmanager/wizards/targetspage.h +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef TARGETSPAGE_H -#define TARGETSPAGE_H - -#include <QtCore/QList> -#include <QtCore/QSet> -#include <QtCore/QString> - -#include <QtGui/QWizard> - -QT_BEGIN_NAMESPACE -class QTreeWidget; -QT_END_NAMESPACE - -namespace Qt4ProjectManager { -class Qt4Project; - -namespace Internal { - -class TargetsPage : public QWizardPage -{ - Q_OBJECT - -public: - explicit TargetsPage(QWidget* parent = 0); - - void setValidTargets(const QSet<QString> &targets); - - QSet<QString> selectedTargets() const; - QList<int> selectedQtVersionIdsForTarget(const QString &) const; - - bool isComplete() const; - - bool needToDisplayPage() const; - - void writeUserFile(const QString &proFileName) const; - bool setupProject(Qt4Project *project) const; - -private slots: - void itemWasChanged(); - -private: - QSet<QString> m_validTargets; - QTreeWidget * m_treeWidget; -}; - -} // namespace Internal -} // namespace Qt4ProjectManager - -#endif // TARGETSPAGE_H diff --git a/src/plugins/qt4projectmanager/wizards/testwizarddialog.cpp b/src/plugins/qt4projectmanager/wizards/testwizarddialog.cpp index 24b774060a..2f4969a176 100644 --- a/src/plugins/qt4projectmanager/wizards/testwizarddialog.cpp +++ b/src/plugins/qt4projectmanager/wizards/testwizarddialog.cpp @@ -60,7 +60,7 @@ TestWizardDialog::TestWizardDialog(const QString &templateName, setWindowIcon(icon); setWindowTitle(templateName); setSelectedModules(QLatin1String("core testlib"), true); - addTargetsPage(); + addTargetSetupPage(); m_testPageId = addPage(m_testPage); m_modulesPageId = addModulesPage(); foreach (QWizardPage *p, extensionPages) |