OSDN Git Service

7231eddfa5ee2bd9082cc67c9d99a7132f251e48
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / wizards / qtwizard.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef QTWIZARD_H
35 #define QTWIZARD_H
36
37 #include "qtprojectparameters.h"
38 #include <projectexplorer/baseprojectwizarddialog.h>
39 #include <projectexplorer/customwizard/customwizard.h>
40
41 #include <coreplugin/basefilewizard.h>
42
43 #include <QtCore/QSet>
44
45 namespace Qt4ProjectManager {
46
47 class Qt4Project;
48 class TargetSetupPage;
49
50 namespace Internal {
51
52 class ModulesPage;
53
54 /* Base class for wizard creating Qt projects using QtProjectParameters.
55  * To implement a project wizard, overwrite:
56  * - createWizardDialog() to create up the dialog
57  * - generateFiles() to set their contents
58  * The base implementation provides the wizard parameters and opens
59  * the finished project in postGenerateFiles().
60  * The pro-file must be the last one of the generated files. */
61
62 class QtWizard : public Core::BaseFileWizard
63 {
64     Q_OBJECT
65     Q_DISABLE_COPY(QtWizard)
66
67 protected:
68     QtWizard(const QString &id,
69              const QString &category,
70              const QString &categoryTranslationScope,
71              const QString &displayCategory,
72              const QString &name,
73              const QString &description,
74              const QIcon &icon);
75
76 public:
77
78     static QString templateDir();
79
80     static QString sourceSuffix();
81     static QString headerSuffix();
82     static QString formSuffix();
83     static QString profileSuffix();
84
85     // Query CppTools settings for the class wizard settings
86     static bool lowerCaseFiles();
87
88     static bool qt4ProjectPostGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
89
90 protected:
91     static bool showModulesPageForApplications();
92     static bool showModulesPageForLibraries();
93
94 private:
95     bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
96 };
97
98 // A custom wizard with an additional Qt 4 target page
99 class CustomQt4ProjectWizard : public ProjectExplorer::CustomProjectWizard {
100     Q_OBJECT
101 public:
102     explicit CustomQt4ProjectWizard(const Core::BaseFileWizardParameters& baseFileParameters,
103                                     QObject *parent = 0);
104
105     virtual QWizard *createWizardDialog(QWidget *parent,
106                                         const QString &defaultPath,
107                                         const WizardPageList &extensionPages) const;
108     static void registerSelf();
109
110 protected:
111     virtual bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage);
112
113 private:
114     enum { targetPageId = 2 };
115 };
116
117 /* BaseQt4ProjectWizardDialog: Additionally offers modules page
118  * and getter/setter for blank-delimited modules list, transparently
119  * handling the visibility of the modules page list as well as a page
120  * to select targets and Qt versions.
121  */
122
123 class BaseQt4ProjectWizardDialog : public ProjectExplorer::BaseProjectWizardDialog {
124     Q_OBJECT
125 protected:
126     explicit BaseQt4ProjectWizardDialog(bool showModulesPage,
127                                         Utils::ProjectIntroPage *introPage,
128                                         int introId = -1,
129                                         QWidget *parent = 0);
130 public:
131     explicit BaseQt4ProjectWizardDialog(bool showModulesPage, QWidget *parent = 0);
132     virtual ~BaseQt4ProjectWizardDialog();
133
134     int addModulesPage(int id = -1);
135     int addTargetSetupPage(QSet<QString> targets = QSet<QString>(), bool mobile = false, int id = -1);
136
137     static QSet<QString> desktopTarget();
138
139     QString selectedModules() const;
140     void setSelectedModules(const QString &, bool lock = false);
141
142     QString deselectedModules() const;
143     void setDeselectedModules(const QString &);
144
145     bool writeUserFile(const QString &proFileName) const;
146     bool setupProject(Qt4Project *project) const;
147     bool isTargetSelected(const QString &targetid) const;
148
149 private slots:
150     void generateProfileName(const QString &name, const QString &path);
151
152 private:
153     inline void init(bool showModulesPage);
154
155     ModulesPage *m_modulesPage;
156     TargetSetupPage *m_targetSetupPage;
157     QString m_selectedModules;
158     QString m_deselectedModules;
159     QSet<QString> m_targets;
160 };
161
162 } // namespace Internal
163 } // namespace Qt4ProjectManager
164
165 #endif // QTWIZARD_H