1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
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
16 ** GNU Lesser General Public License Usage
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.
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.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef CUSTOMEXECUTABLERUNCONFIGURATION_H
35 #define CUSTOMEXECUTABLERUNCONFIGURATION_H
37 #include "applicationrunconfiguration.h"
39 #include <utils/environment.h>
41 #include <QtCore/QVariantMap>
43 namespace ProjectExplorer {
47 class CustomExecutableConfigurationWidget;
50 class CustomExecutableRunConfigurationFactory;
52 class PROJECTEXPLORER_EXPORT CustomExecutableRunConfiguration : public LocalApplicationRunConfiguration
55 // the configuration widget needs to setExecutable setWorkingDirectory and setCommandLineArguments
56 friend class Internal::CustomExecutableConfigurationWidget;
57 friend class CustomExecutableRunConfigurationFactory;
60 explicit CustomExecutableRunConfiguration(Target *parent);
61 ~CustomExecutableRunConfiguration();
64 * Returns the executable, looks in the environment for it and might even
65 * ask the user if none is specified
67 QString executable() const;
69 /** Returns whether this runconfiguration ever was configured with a executable
71 bool isConfigured() const;
73 LocalApplicationRunConfiguration::RunMode runMode() const;
74 QString workingDirectory() const;
75 QString commandLineArguments() const;
76 Utils::Environment environment() const;
78 QWidget *createConfigurationWidget();
79 QString dumperLibrary() const;
80 QStringList dumperLibraryLocations() const;
82 ProjectExplorer::ToolChainType toolChainType() const;
84 QVariantMap toMap() const;
89 void baseEnvironmentChanged();
90 void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &diff);
93 void activeBuildConfigurationChanged();
96 CustomExecutableRunConfiguration(Target *parent, CustomExecutableRunConfiguration *source);
97 virtual bool fromMap(const QVariantMap &map);
98 QString defaultDisplayName() const;
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;
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);
122 QString m_executable;
123 QString m_workingDirectory;
124 QString m_cmdArguments;
128 QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
129 BaseEnvironmentBase m_baseEnvironmentBase;
130 ProjectExplorer::BuildConfiguration *m_lastActiveBuildConfiguration;
133 class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory
138 explicit CustomExecutableRunConfigurationFactory(QObject *parent = 0);
139 ~CustomExecutableRunConfigurationFactory();
141 QStringList availableCreationIds(Target *parent) const;
142 QString displayNameForId(const QString &id) const;
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);
152 } // namespace ProjectExplorer
154 #endif // CUSTOMEXECUTABLERUNCONFIGURATION_H