OSDN Git Service

af6e575a365162fc134c1d0f992e622a054606dd
[qt-creator-jp/qt-creator-jp.git] / src / plugins / cmakeprojectmanager / cmakeopenprojectwizard.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 CMAKEOPENPROJECTWIZARD_H
35 #define CMAKEOPENPROJECTWIZARD_H
36
37 #include <utils/environment.h>
38 #include <utils/wizard.h>
39 #include <utils/qtcprocess.h>
40
41 #include <QtGui/QPushButton>
42 #include <QtGui/QComboBox>
43 #include <QtGui/QLineEdit>
44 #include <QtGui/QLabel>
45 #include <QtGui/QPlainTextEdit>
46
47 namespace Utils {
48     class PathChooser;
49 }
50
51 namespace ProjectExplorer {
52 class ToolChain;
53 }
54
55 namespace CMakeProjectManager {
56 namespace Internal {
57
58 class CMakeManager;
59
60 class CMakeOpenProjectWizard : public Utils::Wizard
61 {
62     Q_OBJECT
63 public:
64     enum PageId {
65         InSourcePageId,
66         ShadowBuildPageId,
67         CMakeRunPageId
68     };
69
70     enum Mode {
71         Nothing,
72         NeedToCreate,
73         NeedToUpdate,
74         WantToUpdate
75     };
76
77     // used at importing a project without a .user file
78     CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const Utils::Environment &env);
79     /// used to update if we have already a .user file
80     /// recreates or updates the cbp file
81     CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &buildDirectory, Mode mode, const Utils::Environment &env);
82     /// used to change the build directory of one buildconfiguration
83     /// shows a page for selecting a directory
84     /// then the run cmake page
85     CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &oldBuildDirectory, const Utils::Environment &env);
86
87     virtual int nextId() const;
88     QString buildDirectory() const;
89     QString sourceDirectory() const;
90     void setBuildDirectory(const QString &directory);
91     CMakeManager *cmakeManager() const;
92     QString arguments() const;
93     void setArguments(const QString &args);
94     ProjectExplorer::ToolChain *toolChain() const;
95     void setToolChain(ProjectExplorer::ToolChain *);
96     Utils::Environment environment() const;
97     bool existsUpToDateXmlFile() const;
98
99 private:
100     void init();
101     bool hasInSourceBuild() const;
102     CMakeManager *m_cmakeManager;
103     QString m_buildDirectory;
104     QString m_sourceDirectory;
105     QString m_arguments;
106     bool m_creatingCbpFiles;
107     Utils::Environment m_environment;
108     ProjectExplorer::ToolChain *m_toolChain;
109 };
110
111 class InSourceBuildPage : public QWizardPage
112 {
113     Q_OBJECT
114 public:
115     InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard);
116 private:
117     CMakeOpenProjectWizard *m_cmakeWizard;
118 };
119
120 class ShadowBuildPage : public QWizardPage
121 {
122     Q_OBJECT
123 public:
124     explicit ShadowBuildPage(CMakeOpenProjectWizard *cmakeWizard, bool change = false);
125 private slots:
126     void buildDirectoryChanged();
127 private:
128     CMakeOpenProjectWizard *m_cmakeWizard;
129     Utils::PathChooser *m_pc;
130 };
131
132 class CMakeRunPage : public QWizardPage
133 {
134     Q_OBJECT
135 public:
136     enum Mode { Initial, NeedToUpdate, Recreate, ChangeDirectory, WantToUpdate };
137     explicit CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode = Initial, const QString &buildDirectory = QString());
138
139     virtual void initializePage();
140     virtual void cleanupPage();
141     virtual bool isComplete() const;
142 private slots:
143     void runCMake();
144     void cmakeFinished();
145     void cmakeReadyReadStandardOutput();
146     void cmakeReadyReadStandardError();
147 private:
148     void initWidgets();
149     CMakeOpenProjectWizard *m_cmakeWizard;
150     QPlainTextEdit *m_output;
151     QPushButton *m_runCMake;
152     Utils::QtcProcess *m_cmakeProcess;
153     QLineEdit *m_argumentsLineEdit;
154     Utils::PathChooser *m_cmakeExecutable;
155     QComboBox *m_generatorComboBox;
156     QLabel *m_descriptionLabel;
157     QLabel *m_exitCodeLabel;
158     bool m_complete;
159     Mode m_mode;
160     QString m_buildDirectory;
161 };
162
163 }
164 }
165
166 #endif // CMAKEOPENPROJECTWIZARD_H