cmakerunconfiguration.h 6.25 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
dt's avatar
dt committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
dt's avatar
dt committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
dt's avatar
dt committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
dt's avatar
dt committed
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22
** 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.
dt's avatar
dt committed
23
**
hjk's avatar
hjk committed
24 25
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
dt's avatar
dt committed
29 30 31 32

#ifndef CMAKERUNCONFIGURATION_H
#define CMAKERUNCONFIGURATION_H

33
#include <projectexplorer/localapplicationrunconfiguration.h>
34
#include <utils/environment.h>
dt's avatar
dt committed
35

36
QT_BEGIN_NAMESPACE
37
class QComboBox;
kh's avatar
kh committed
38
QT_END_NAMESPACE
39

40
namespace Utils {
41 42 43 44 45 46
class PathChooser;
class DetailsWidget;
}

namespace ProjectExplorer {
class EnvironmentWidget;
47 48
}

dt's avatar
dt committed
49 50 51
namespace CMakeProjectManager {
namespace Internal {

Tobias Hunger's avatar
Tobias Hunger committed
52
class CMakeTarget;
dt's avatar
dt committed
53

54
class CMakeRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
dt's avatar
dt committed
55
{
56
    Q_OBJECT
57 58 59
    friend class CMakeRunConfigurationWidget;
    friend class CMakeRunConfigurationFactory;

dt's avatar
dt committed
60
public:
Tobias Hunger's avatar
Tobias Hunger committed
61
    CMakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &target,
62 63 64 65 66
                          const QString &workingDirectory, const QString &title);
    ~CMakeRunConfiguration();

    QString executable() const;
    RunMode runMode() const;
67
    void setRunMode(RunMode runMode);
68
    QString workingDirectory() const;
69
    QString commandLineArguments() const;
70
    Utils::Environment environment() const;
71
    QWidget *createConfigurationWidget();
dt's avatar
dt committed
72

dt's avatar
dt committed
73
    void setExecutable(const QString &executable);
74
    void setBaseWorkingDirectory(const QString &workingDirectory);
75

dt's avatar
dt committed
76 77
    QString title() const;

78 79 80 81
    QString dumperLibrary() const;
    QStringList dumperLibraryLocations() const;

    QVariantMap toMap() const;
82

83 84
    void setEnabled(bool b);

85
    bool isEnabled() const;
dt_'s avatar
dt_ committed
86
    QString disabledReason() const;
87

88 89
signals:
    void baseEnvironmentChanged();
90
    void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &diff);
91
    void baseWorkingDirectoryChanged(const QString&);
92

93
private slots:
94
    void setCommandLineArguments(const QString &newText);
95 96

protected:
Tobias Hunger's avatar
Tobias Hunger committed
97
    CMakeRunConfiguration(ProjectExplorer::Target *parent, CMakeRunConfiguration *source);
98
    virtual bool fromMap(const QVariantMap &map);
99
    QString defaultDisplayName() const;
100

dt's avatar
dt committed
101
private:
102
    void setUserWorkingDirectory(const QString &workingDirectory);
103
    QString baseWorkingDirectory() const;
104 105
    void ctor();

106 107 108
    enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
                               SystemEnvironmentBase = 1,
                               BuildEnvironmentBase = 2};
109 110
    void setBaseEnvironmentBase(BaseEnvironmentBase env);
    BaseEnvironmentBase baseEnvironmentBase() const;
111
    Utils::Environment baseEnvironment() const;
112 113
    QString baseEnvironmentText() const;

114 115
    void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
    QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
116

117
    RunMode m_runMode;
118
    QString m_buildTarget;
dt's avatar
dt committed
119
    QString m_workingDirectory;
120
    QString m_userWorkingDirectory;
dt's avatar
dt committed
121
    QString m_title;
122
    QString m_arguments;
123
    QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
124
    BaseEnvironmentBase m_baseEnvironmentBase;
125
    bool m_enabled;
126 127 128 129 130 131
};

class CMakeRunConfigurationWidget : public QWidget
{
    Q_OBJECT
public:
132
    explicit CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent = 0);
133

134 135 136 137
private slots:
    void setArguments(const QString &args);
    void baseEnvironmentChanged();
    void userEnvironmentChangesChanged();
138
    void userChangesChanged();
139 140
    void setWorkingDirectory();
    void resetWorkingDirectory();
141
    void runInTerminalToggled(bool toggled);
142

143
    void baseEnvironmentComboBoxChanged(int index);
144
    void workingDirectoryChanged(const QString &workingDirectory);
145

146
private:
147
    void ctor();
148
    bool m_ignoreChange;
149
    CMakeRunConfiguration *m_cmakeRunConfiguration;
150
    Utils::PathChooser *m_workingDirectoryEdit;
151
    QComboBox *m_baseEnvironmentComboBox;
152
    ProjectExplorer::EnvironmentWidget *m_environmentWidget;
153
    Utils::DetailsWidget *m_detailsContainer;
dt's avatar
dt committed
154 155
};

156
class CMakeRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
dt's avatar
dt committed
157
{
Adriaan de Groot's avatar
Adriaan de Groot committed
158
    Q_OBJECT
159

dt's avatar
dt committed
160
public:
161 162
    explicit CMakeRunConfigurationFactory(QObject *parent = 0);
    ~CMakeRunConfigurationFactory();
Tobias Hunger's avatar
Tobias Hunger committed
163

164
    bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
Tobias Hunger's avatar
Tobias Hunger committed
165 166 167 168
    bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
    bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const;
    ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product);

169 170
    QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
    QString displayNameForId(const Core::Id id) const;
Tobias Hunger's avatar
Tobias Hunger committed
171

172 173 174
    static Core::Id idFromBuildTarget(const QString &target);
    static QString buildTargetFromId(Core::Id id);

Daniel Teske's avatar
Daniel Teske committed
175
private:
Tobias Hunger's avatar
Tobias Hunger committed
176
    bool canHandle(ProjectExplorer::Target *parent) const;
177 178

    ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
179 180
    ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
                                                 const QVariantMap &map);
dt's avatar
dt committed
181 182 183 184 185 186
};

}
}

#endif // CMAKERUNCONFIGURATION_H