OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / customexecutablerunconfiguration.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 CUSTOMEXECUTABLERUNCONFIGURATION_H
34 #define CUSTOMEXECUTABLERUNCONFIGURATION_H
35
36 #include "applicationrunconfiguration.h"
37
38 #include <utils/environment.h>
39
40 #include <QtCore/QVariantMap>
41
42 namespace ProjectExplorer {
43 class Target;
44
45 namespace Internal {
46 class CustomExecutableConfigurationWidget;
47 }
48
49 class CustomExecutableRunConfigurationFactory;
50
51 class PROJECTEXPLORER_EXPORT CustomExecutableRunConfiguration : public LocalApplicationRunConfiguration
52 {
53     Q_OBJECT
54     // the configuration widget needs to setExecutable setWorkingDirectory and setCommandLineArguments
55     friend class Internal::CustomExecutableConfigurationWidget;
56     friend class CustomExecutableRunConfigurationFactory;
57
58 public:
59     explicit CustomExecutableRunConfiguration(Target *parent);
60     ~CustomExecutableRunConfiguration();
61
62     /**
63      * Returns the executable, looks in the environment for it and might even
64      * ask the user if none is specified
65      */
66     QString executable() const;
67
68     /** Returns whether this runconfiguration ever was configured with a executable
69      */
70     bool isConfigured() const;
71
72     LocalApplicationRunConfiguration::RunMode runMode() const;
73     QString workingDirectory() const;
74     QString commandLineArguments() const;
75     Utils::Environment environment() const;
76
77     QWidget *createConfigurationWidget();
78     QString dumperLibrary() const;
79     QStringList dumperLibraryLocations() const;
80
81     ProjectExplorer::Abi abi() const;
82
83     QVariantMap toMap() const;
84
85 signals:
86     void changed();
87
88     void baseEnvironmentChanged();
89     void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &diff);
90
91 private slots:
92     void activeBuildConfigurationChanged();
93
94 protected:
95     CustomExecutableRunConfiguration(Target *parent, CustomExecutableRunConfiguration *source);
96     virtual bool fromMap(const QVariantMap &map);
97     QString defaultDisplayName() const;
98
99 private:
100     void ctor();
101
102     enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
103                                SystemEnvironmentBase = 1,
104                                BuildEnvironmentBase = 2};
105     void setBaseEnvironmentBase(BaseEnvironmentBase env);
106     BaseEnvironmentBase baseEnvironmentBase() const;
107     Utils::Environment baseEnvironment() const;
108     QString baseEnvironmentText() const;
109     void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
110     QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
111
112     void setExecutable(const QString &executable);
113     QString rawExecutable() const;
114     void setCommandLineArguments(const QString &commandLineArguments);
115     QString rawCommandLineArguments() const;
116     void setBaseWorkingDirectory(const QString &workingDirectory);
117     QString baseWorkingDirectory() const;
118     void setUserName(const QString &name);
119     void setRunMode(RunMode runMode);
120
121     QString m_executable;
122     QString m_workingDirectory;
123     QString m_cmdArguments;
124     RunMode m_runMode;
125     bool m_userSetName;
126     QString m_userName;
127     QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
128     BaseEnvironmentBase m_baseEnvironmentBase;
129     ProjectExplorer::BuildConfiguration *m_lastActiveBuildConfiguration;
130 };
131
132 class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory
133 {
134     Q_OBJECT
135
136 public:
137     explicit CustomExecutableRunConfigurationFactory(QObject *parent = 0);
138     ~CustomExecutableRunConfigurationFactory();
139
140     QStringList availableCreationIds(Target *parent) const;
141     QString displayNameForId(const QString &id) const;
142
143     bool canCreate(Target *parent, const QString &id) const;
144     RunConfiguration *create(Target *parent, const QString &id);
145     bool canRestore(Target *parent, const QVariantMap &map) const;
146     RunConfiguration *restore(Target *parent, const QVariantMap &map);
147     bool canClone(Target *parent, RunConfiguration *product) const;
148     RunConfiguration *clone(Target *parent, RunConfiguration *source);
149 };
150
151 } // namespace ProjectExplorer
152
153 #endif // CUSTOMEXECUTABLERUNCONFIGURATION_H