OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / qt-desktop / qt4runconfiguration.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 (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef QT4RUNCONFIGURATION_H
34 #define QT4RUNCONFIGURATION_H
35
36 #include <projectexplorer/applicationrunconfiguration.h>
37
38 #include <utils/environment.h>
39
40 #include <QtCore/QStringList>
41 #include <QtGui/QWidget>
42 #include <QtCore/QMetaType>
43
44 QT_BEGIN_NAMESPACE
45 class QCheckBox;
46 class QLineEdit;
47 class QRadioButton;
48 class QComboBox;
49 QT_END_NAMESPACE
50
51 namespace Utils {
52 class PathChooser;
53 class DebuggerLanguageChooser;
54 class DetailsWidget;
55 }
56
57 namespace ProjectExplorer {
58     class EnvironmentWidget;
59 }
60
61 namespace Qt4ProjectManager {
62
63 class Qt4Project;
64 class Qt4BaseTarget;
65
66 namespace Internal {
67 class Qt4DesktopTarget;
68 class Qt4PriFileNode;
69 class Qt4ProFileNode;
70 class Qt4RunConfigurationFactory;
71
72 class Qt4RunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
73 {
74     Q_OBJECT
75     // to change the display name and arguments and set the userenvironmentchanges
76     friend class Qt4RunConfigurationWidget;
77     friend class Qt4RunConfigurationFactory;
78
79 public:
80     Qt4RunConfiguration(Qt4BaseTarget *parent, const QString &proFilePath);
81     virtual ~Qt4RunConfiguration();
82
83     Qt4DesktopTarget *qt4Target() const;
84
85     virtual bool isEnabled(ProjectExplorer::BuildConfiguration *configuration) const;
86     using ProjectExplorer::LocalApplicationRunConfiguration::isEnabled;
87     virtual QWidget *createConfigurationWidget();
88
89     virtual QString executable() const;
90     virtual RunMode runMode() const;
91     virtual QString workingDirectory() const;
92     virtual QString commandLineArguments() const;
93     virtual Utils::Environment environment() const;
94     virtual QString dumperLibrary() const;
95     virtual QStringList dumperLibraryLocations() const;
96
97     bool isUsingDyldImageSuffix() const;
98     void setUsingDyldImageSuffix(bool state);
99
100     QString proFilePath() const;
101
102     // TODO detectQtShadowBuild() ? how did this work ?
103     QVariantMap toMap() const;
104
105     ProjectExplorer::OutputFormatter *createOutputFormatter() const;
106
107 signals:
108     void commandLineArgumentsChanged(const QString&);
109     void baseWorkingDirectoryChanged(const QString&);
110     void runModeChanged(ProjectExplorer::LocalApplicationRunConfiguration::RunMode runMode);
111     void usingDyldImageSuffixChanged(bool);
112     void baseEnvironmentChanged();
113     void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &diff);
114
115     // Note: These signals might not get emitted for every change!
116     void effectiveTargetInformationChanged();
117
118 private slots:
119     void proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *pro, bool success);
120     void proFileInvalidated(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
121
122 protected:
123     Qt4RunConfiguration(Qt4BaseTarget *parent, Qt4RunConfiguration *source);
124     virtual bool fromMap(const QVariantMap &map);
125
126 private:
127     void handleParseState(bool success);
128     void setRunMode(RunMode runMode);
129     void setBaseWorkingDirectory(const QString &workingDirectory);
130     QString baseWorkingDirectory() const;
131     void setCommandLineArguments(const QString &argumentsString);
132     QString rawCommandLineArguments() const;
133     enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
134                                SystemEnvironmentBase = 1,
135                                BuildEnvironmentBase  = 2 };
136     QString defaultDisplayName();
137     void setBaseEnvironmentBase(BaseEnvironmentBase env);
138     BaseEnvironmentBase baseEnvironmentBase() const;
139
140     void ctor();
141
142     Utils::Environment baseEnvironment() const;
143     QString baseEnvironmentText() const;
144     void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
145     QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
146
147     void updateTarget();
148     QString m_commandLineArguments;
149     QString m_proFilePath; // Full path to the Application Pro File
150
151     // Cached startup sub project information
152     ProjectExplorer::LocalApplicationRunConfiguration::RunMode m_runMode;
153     bool m_userSetName;
154     bool m_isUsingDyldImageSuffix;
155     QString m_userWorkingDirectory;
156     QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
157     BaseEnvironmentBase m_baseEnvironmentBase;
158     bool m_parseSuccess;
159 };
160
161 class Qt4RunConfigurationWidget : public QWidget
162 {
163     Q_OBJECT
164
165 public:
166     Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4runconfigration, QWidget *parent);
167     ~Qt4RunConfigurationWidget();
168
169 protected:
170     void showEvent(QShowEvent *event);
171     void hideEvent(QHideEvent *event);
172
173 private slots:
174     void runConfigurationEnabledChange(bool);
175     void workDirectoryEdited();
176     void workingDirectoryReseted();
177     void argumentsEdited(const QString &arguments);
178     void userChangesEdited();
179
180     void workingDirectoryChanged(const QString &workingDirectory);
181     void commandLineArgumentsChanged(const QString &args);
182     void runModeChanged(ProjectExplorer::LocalApplicationRunConfiguration::RunMode runMode);
183     void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &userChanges);
184     void baseEnvironmentChanged();
185
186     void effectiveTargetInformationChanged();
187     void termToggled(bool);
188     void usingDyldImageSuffixToggled(bool);
189     void usingDyldImageSuffixChanged(bool);
190     void baseEnvironmentSelected(int index);
191     void useCppDebuggerToggled(bool toggled);
192     void useQmlDebuggerToggled(bool toggled);
193     void qmlDebugServerPortChanged(uint port);
194
195 private:
196     Qt4RunConfiguration *m_qt4RunConfiguration;
197     bool m_ignoreChange;
198     QLineEdit *m_executableLineEdit;
199     Utils::PathChooser *m_workingDirectoryEdit;
200     QLineEdit *m_argumentsLineEdit;
201     QCheckBox *m_useTerminalCheck;
202     QCheckBox *m_usingDyldImageSuffix;
203     QLineEdit *m_qmlDebugPort;
204
205     QComboBox *m_baseEnvironmentComboBox;
206     Utils::DetailsWidget *m_detailsContainer;
207     Utils::DebuggerLanguageChooser *m_debuggerLanguageChooser;
208     ProjectExplorer::EnvironmentWidget *m_environmentWidget;
209     bool m_isShown;
210 };
211
212 class Qt4RunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
213 {
214     Q_OBJECT
215
216 public:
217     explicit Qt4RunConfigurationFactory(QObject *parent = 0);
218     virtual ~Qt4RunConfigurationFactory();
219
220     virtual bool canCreate(ProjectExplorer::Target *parent, const QString &id) const;
221     virtual ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const QString &id);
222     virtual bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
223     virtual ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
224     virtual bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
225     virtual ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
226
227     QStringList availableCreationIds(ProjectExplorer::Target *parent) const;
228     QString displayNameForId(const QString &id) const;
229 };
230
231 } // namespace Internal
232 } // namespace Qt4ProjectManager
233
234 #endif // QT4RUNCONFIGURATION_H