OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmlprojectmanager / qmlprojectrunconfiguration.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 QMLPROJECTRUNCONFIGURATION_H
35 #define QMLPROJECTRUNCONFIGURATION_H
36
37 #include "qmlprojectmanager_global.h"
38 #include <projectexplorer/runconfiguration.h>
39 #include <QWeakPointer>
40 #include <QComboBox>
41 #include <QLabel>
42
43 QT_FORWARD_DECLARE_CLASS(QStringListModel)
44
45 namespace Core {
46     class IEditor;
47 }
48
49 namespace Utils {
50     class Environment;
51     class EnvironmentItem;
52 }
53
54 namespace Qt4ProjectManager {
55     class QtVersion;
56 }
57
58 namespace QmlProjectManager {
59
60 namespace Internal {
61     class QmlProjectTarget;
62     class QmlProjectRunConfigurationFactory;
63     class QmlProjectRunConfigurationWidget;
64 }
65
66 class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplorer::RunConfiguration
67 {
68     Q_OBJECT
69     friend class Internal::QmlProjectRunConfigurationFactory;
70     friend class Internal::QmlProjectRunConfigurationWidget;
71
72     // used in qmldumptool.cpp
73     Q_PROPERTY(int qtVersionId READ qtVersionId)
74
75 public:
76     QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent);
77     virtual ~QmlProjectRunConfiguration();
78
79     Internal::QmlProjectTarget *qmlTarget() const;
80
81     QString viewerPath() const;
82     QString observerPath() const;
83     QString viewerArguments() const;
84     QString workingDirectory() const;
85     int qtVersionId() const;
86     Qt4ProjectManager::QtVersion *qtVersion() const;
87
88     enum MainScriptSource {
89         FileInEditor,
90         FileInProjectFile,
91         FileInSettings
92     };
93     MainScriptSource mainScriptSource() const;
94     void setScriptSource(MainScriptSource source, const QString &settingsPath = QString());
95
96     QString mainScript() const;
97
98     Utils::Environment environment() const;
99
100     // RunConfiguration
101     bool isEnabled(ProjectExplorer::BuildConfiguration *bc) const;
102     virtual QWidget *createConfigurationWidget();
103     ProjectExplorer::OutputFormatter *createOutputFormatter() const;
104     QVariantMap toMap() const;
105
106 public slots:
107     void changeCurrentFile(Core::IEditor*);
108
109 private slots:
110     void updateEnabled();
111     void updateQtVersions();
112
113 protected:
114     QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent,
115                                QmlProjectRunConfiguration *source);
116     virtual bool fromMap(const QVariantMap &map);
117     void setEnabled(bool value);
118
119 private:
120     void ctor();
121     static bool isValidVersion(Qt4ProjectManager::QtVersion *version);
122     void setQtVersionId(int id);
123     
124     static QString canonicalCapsPath(const QString &filePath);
125
126     Utils::Environment baseEnvironment() const;
127     void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
128     QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
129
130     // absolute path to current file (if being used)
131     QString m_currentFileFilename;
132     // absolute path to selected main script (if being used)
133     QString m_mainScriptFilename;
134
135     int m_qtVersionId;
136     QString m_scriptFile;
137     QString m_qmlViewerArgs;
138
139     Internal::QmlProjectTarget *m_projectTarget;
140     QWeakPointer<Internal::QmlProjectRunConfigurationWidget> m_configurationWidget;
141
142     bool m_usingCurrentFile;
143     bool m_isEnabled;
144
145     QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
146 };
147
148 } // namespace QmlProjectManager
149
150 #endif // QMLPROJECTRUNCONFIGURATION_H