qt4runconfiguration.h 7.93 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** 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.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** 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.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
31
32
#ifndef QT4RUNCONFIGURATION_H
#define QT4RUNCONFIGURATION_H

33
#include <utils/pathchooser.h>
dt's avatar
dt committed
34
#include <utils/detailswidget.h>
con's avatar
con committed
35
#include <projectexplorer/applicationrunconfiguration.h>
36
37
#include <projectexplorer/environment.h>
#include <projectexplorer/environmenteditmodel.h>
con's avatar
con committed
38
#include <QtCore/QStringList>
39
#include <QtGui/QWidget>
dt's avatar
dt committed
40
#include <QtGui/QToolButton>
41

hjk's avatar
hjk committed
42
QT_BEGIN_NAMESPACE
43
class QWidget;
44
class QCheckBox;
45
46
class QLabel;
class QLineEdit;
47
class QRadioButton;
48
class QComboBox;
hjk's avatar
hjk committed
49
QT_END_NAMESPACE
con's avatar
con committed
50
51
52
53
54
55

namespace Qt4ProjectManager {

class Qt4Project;

namespace Internal {
56
class Qt4PriFileNode;
57
class Qt4ProFileNode;
58
class Qt4RunConfigurationFactory;
59

60
class Qt4RunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
con's avatar
con committed
61
62
{
    Q_OBJECT
63
    // to change the display name and arguments and set the userenvironmentchanges
64
    friend class Qt4RunConfigurationWidget;
65
66
    friend class Qt4RunConfigurationFactory;

con's avatar
con committed
67
public:
68
    Qt4RunConfiguration(Qt4Project *parent, const QString &proFilePath);
con's avatar
con committed
69
70
    virtual ~Qt4RunConfiguration();

dt's avatar
dt committed
71
72
    Qt4Project *qt4Project() const;

73
    virtual bool isEnabled(ProjectExplorer::BuildConfiguration *configuration) const;
con's avatar
con committed
74
75
76
77
78
79
80
    virtual QWidget *configurationWidget();

    virtual QString executable() const;
    virtual RunMode runMode() const;
    virtual QString workingDirectory() const;
    virtual QStringList commandLineArguments() const;
    virtual ProjectExplorer::Environment environment() const;
81
    virtual QString dumperLibrary() const;
82
    virtual QStringList dumperLibraryLocations() const;
83
    virtual ProjectExplorer::ToolChain::ToolChainType toolChainType() const;
con's avatar
con committed
84

85
86
    bool isUsingDyldImageSuffix() const;
    void setUsingDyldImageSuffix(bool state);
con's avatar
con committed
87
88
    QString proFilePath() const;

89
    // TODO detectQtShadowBuild() ? how did this work ?
90
    QVariantMap toMap() const;
91
92
93
94
95
96
97
98

public slots:
    // This function is called if:
    // X the pro file changes
    // X the active buildconfiguration changes
    // X  the qmake parameters change
    // X  the build directory changes
    void invalidateCachedTargetInformation();
con's avatar
con committed
99

100
signals:
101
    void displayNameChanged(const QString&);
102
    void commandLineArgumentsChanged(const QString&);
103
    void workingDirectoryChanged(const QString&);
104
    void runModeChanged(ProjectExplorer::LocalApplicationRunConfiguration::RunMode runMode);
105
    void usingDyldImageSuffixChanged(bool);
106
    void baseEnvironmentChanged();
107
    void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff);
108

Tobias Hunger's avatar
Tobias Hunger committed
109
    // Note: These signals might not get emitted for every change!
110
    void effectiveTargetInformationChanged();
111

con's avatar
con committed
112
private slots:
113
114
    void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
    void setArguments(const QString &argumentsString);
115
    void setWorkingDirectory(const QString &workingDirectory);
116
    void setUserName(const QString&);
117
    void setRunMode(RunMode runMode);
con's avatar
con committed
118

119
120
121
122
protected:
    Qt4RunConfiguration(Qt4Project *parent, Qt4RunConfiguration *source);
    virtual bool fromMap(const QVariantMap &map);

con's avatar
con committed
123
private:
124
125
126
    enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
                               SystemEnvironmentBase = 1,
                               BuildEnvironmentBase  = 2 };
127
    void setDefaultDisplayName();
128
129
130
    void setBaseEnvironmentBase(BaseEnvironmentBase env);
    BaseEnvironmentBase baseEnvironmentBase() const;

131
132
    void ctor();

133
    ProjectExplorer::Environment baseEnvironment() const;
134
    QString baseEnvironmentText() const;
135
136
137
    void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
    QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;

138
    void updateTarget();
con's avatar
con committed
139
140
141
142
143
144
    QStringList m_commandLineArguments;
    QString m_proFilePath; // Full path to the Application Pro File

    // Cached startup sub project information
    QString m_executable;
    QString m_workingDir;
145
    ProjectExplorer::LocalApplicationRunConfiguration::RunMode m_runMode;
con's avatar
con committed
146
    bool m_userSetName;
147
    bool m_cachedTargetInformationValid;
148
    bool m_isUsingDyldImageSuffix;
149
150
    bool m_userSetWokingDirectory;
    QString m_userWorkingDirectory;
151
    QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
152
    BaseEnvironmentBase m_baseEnvironmentBase;
153
154
155
156
157
};

class Qt4RunConfigurationWidget : public QWidget
{
    Q_OBJECT
158

159
160
public:
    Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4runconfigration, QWidget *parent);
161
162
163
protected:
    void showEvent(QShowEvent *event);
    void hideEvent(QHideEvent *event);
164
private slots:
165
166
167
    void workDirectoryEdited();
    void workingDirectoryReseted();
    void argumentsEdited(const QString &arguments);
168
    void displayNameEdited(const QString &name);
169
    void userChangesEdited();
170
171

    void workingDirectoryChanged(const QString &workingDirectory);
172
    void commandLineArgumentsChanged(const QString &args);
173
    void displayNameChanged(const QString &name);
174
    void runModeChanged(ProjectExplorer::LocalApplicationRunConfiguration::RunMode runMode);
175
    void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges);
176
    void baseEnvironmentChanged();
177

178
    void effectiveTargetInformationChanged();
179
    void termToggled(bool);
180
181
    void usingDyldImageSuffixToggled(bool);
    void usingDyldImageSuffixChanged(bool);
182
    void baseEnvironmentSelected(int index);
dt's avatar
dt committed
183

184
185
186
187
private:
    Qt4RunConfiguration *m_qt4RunConfiguration;
    bool m_ignoreChange;
    QLabel *m_executableLabel;
188
    Utils::PathChooser *m_workingDirectoryEdit;
189
190
    QLineEdit *m_nameLineEdit;
    QLineEdit *m_argumentsLineEdit;
191
    QCheckBox *m_useTerminalCheck;
192
    QCheckBox *m_usingDyldImageSuffix;
193

194
    QComboBox *m_baseEnvironmentComboBox;
dt's avatar
dt committed
195
    Utils::DetailsWidget *m_detailsContainer;
196

197
    ProjectExplorer::EnvironmentWidget *m_environmentWidget;
198
    bool m_isShown;
con's avatar
con committed
199
200
201
202
203
};

class Qt4RunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
{
    Q_OBJECT
204

con's avatar
con committed
205
public:
206
    explicit Qt4RunConfigurationFactory(QObject *parent = 0);
con's avatar
con committed
207
    virtual ~Qt4RunConfigurationFactory();
208
209

    virtual bool canCreate(ProjectExplorer::Project *project, const QString &id) const;
210
    virtual ProjectExplorer::RunConfiguration *create(ProjectExplorer::Project *project, const QString &id);
211
212
213
214
215
216
    virtual bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const;
    virtual ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Project *parent, const QVariantMap &map);
    virtual bool canClone(ProjectExplorer::Project *parent, ProjectExplorer::RunConfiguration *source) const;
    virtual ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Project *parent, ProjectExplorer::RunConfiguration *source);

    QStringList availableCreationIds(ProjectExplorer::Project *parent) const;
217
    QString displayNameForId(const QString &id) const;
con's avatar
con committed
218
219
220
221
222
223
};

} // namespace Internal
} // namespace Qt4ProjectManager

#endif // QT4RUNCONFIGURATION_H