OSDN Git Service

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