OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / cmakeprojectmanager / cmakerunconfiguration.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 CMAKERUNCONFIGURATION_H
35 #define CMAKERUNCONFIGURATION_H
36
37 #include <projectexplorer/applicationrunconfiguration.h>
38 #include <projectexplorer/persistentsettings.h>
39 #include <projectexplorer/environmenteditmodel.h>
40 #include <utils/environment.h>
41 #include <utils/pathchooser.h>
42 #include <utils/detailswidget.h>
43
44 QT_BEGIN_NAMESPACE
45 class QComboBox;
46 QT_END_NAMESPACE
47
48 namespace Utils {
49 class DebuggerLanguageChooser;
50 }
51
52 namespace CMakeProjectManager {
53 namespace Internal {
54
55 class CMakeBuildConfiguration;
56 class CMakeTarget;
57
58 class CMakeRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
59 {
60     Q_OBJECT
61     friend class CMakeRunConfigurationWidget;
62     friend class CMakeRunConfigurationFactory;
63
64 public:
65     CMakeRunConfiguration(CMakeTarget *parent, const QString &target,
66                           const QString &workingDirectory, const QString &title);
67     ~CMakeRunConfiguration();
68
69     CMakeTarget *cmakeTarget() const;
70     CMakeBuildConfiguration *activeBuildConfiguration() const;
71
72     QString executable() const;
73     RunMode runMode() const;
74     QString workingDirectory() const;
75     QString commandLineArguments() const;
76     Utils::Environment environment() const;
77     QWidget *createConfigurationWidget();
78
79     void setExecutable(const QString &executable);
80     void setBaseWorkingDirectory(const QString &workingDirectory);
81
82     QString title() const;
83
84     QString dumperLibrary() const;
85     QStringList dumperLibraryLocations() const;
86     ProjectExplorer::ToolChainType toolChainType() const;
87
88     QVariantMap toMap() const;
89
90     void setEnabled(bool b);
91
92     bool isEnabled(ProjectExplorer::BuildConfiguration *bc) const;
93     using LocalApplicationRunConfiguration::isEnabled;
94
95 signals:
96     void baseEnvironmentChanged();
97     void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &diff);
98     void baseWorkingDirectoryChanged(const QString&);
99
100 private slots:
101     void setCommandLineArguments(const QString &newText);
102
103 protected:
104     CMakeRunConfiguration(CMakeTarget *parent, CMakeRunConfiguration *source);
105     virtual bool fromMap(const QVariantMap &map);
106     QString defaultDisplayName() const;
107
108 private:
109     void setUserWorkingDirectory(const QString &workingDirectory);
110     QString baseWorkingDirectory() const;
111     void ctor();
112
113     enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
114                                SystemEnvironmentBase = 1,
115                                BuildEnvironmentBase = 2};
116     void setBaseEnvironmentBase(BaseEnvironmentBase env);
117     BaseEnvironmentBase baseEnvironmentBase() const;
118     Utils::Environment baseEnvironment() const;
119     QString baseEnvironmentText() const;
120
121     void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
122     QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
123
124     RunMode m_runMode;
125     QString m_buildTarget;
126     QString m_workingDirectory;
127     QString m_userWorkingDirectory;
128     QString m_title;
129     QString m_arguments;
130     QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
131     BaseEnvironmentBase m_baseEnvironmentBase;
132     bool m_enabled;
133 };
134
135 class CMakeRunConfigurationWidget : public QWidget
136 {
137     Q_OBJECT
138 public:
139     explicit CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent = 0);
140
141 private slots:
142     void setArguments(const QString &args);
143     void baseEnvironmentChanged();
144     void userEnvironmentChangesChanged();
145     void userChangesChanged();
146     void setWorkingDirectory();
147     void resetWorkingDirectory();
148     void useCppDebuggerToggled(bool toggled);
149     void useQmlDebuggerToggled(bool toggled);
150     void qmlDebugServerPortChanged(uint port);
151
152 private slots:
153     void baseEnvironmentComboBoxChanged(int index);
154     void workingDirectoryChanged(const QString &workingDirectory);
155
156 private:
157     void ctor();
158     bool m_ignoreChange;
159     CMakeRunConfiguration *m_cmakeRunConfiguration;
160     Utils::PathChooser *m_workingDirectoryEdit;
161     QComboBox *m_baseEnvironmentComboBox;
162     Utils::DebuggerLanguageChooser *m_debuggerLanguageChooser;
163     ProjectExplorer::EnvironmentWidget *m_environmentWidget;
164     Utils::DetailsWidget *m_detailsContainer;
165 };
166
167 class CMakeRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
168 {
169     Q_OBJECT
170
171 public:
172     explicit CMakeRunConfigurationFactory(QObject *parent = 0);
173     ~CMakeRunConfigurationFactory();
174
175     bool canCreate(ProjectExplorer::Target *parent, const QString &id) const;
176     ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const QString &id);
177     bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
178     ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
179     bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const;
180     ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product);
181
182     QStringList availableCreationIds(ProjectExplorer::Target *parent) const;
183     QString displayNameForId(const QString &id) const;
184 };
185
186 }
187 }
188
189 #endif // CMAKERUNCONFIGURATION_H