OSDN Git Service

9823e2e3e53108a4a843d2339486a98f15e86f63
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / project.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 PROJECT_H
35 #define PROJECT_H
36
37 #include "projectexplorer_export.h"
38
39 #include <QtCore/QObject>
40 #include <QtCore/QSet>
41 #include <QtGui/QFileSystemModel>
42
43 namespace Core {
44 class IFile;
45 }
46
47 namespace ProjectExplorer {
48
49 class BuildConfigWidget;
50 class IProjectManager;
51 class EditorConfiguration;
52 class ProjectNode;
53 class Target;
54 class ITargetFactory;
55 class ProjectPrivate;
56
57 class PROJECTEXPLORER_EXPORT Project
58     : public QObject
59 {
60     Q_OBJECT
61
62 public:
63     // Roles to be implemented by all models that are exported via model()
64     enum ModelRoles {
65         // Absolute file path
66         FilePathRole = QFileSystemModel::FilePathRole
67     };
68
69     Project();
70     virtual ~Project();
71
72     virtual QString displayName() const = 0;
73     virtual QString id() const = 0;
74     virtual Core::IFile *file() const = 0;
75     virtual IProjectManager *projectManager() const = 0;
76
77     virtual QList<Project *> dependsOn() = 0; //NBS TODO implement dependsOn
78
79     bool hasActiveBuildSettings() const;
80
81     // EditorConfiguration:
82     EditorConfiguration *editorConfiguration() const;
83
84     // Target:
85     void addTarget(Target *target);
86     void removeTarget(Target *target);
87
88     QList<Target *> targets() const;
89     // Note: activeTarget can be 0 (if no targets are defined).
90     Target *activeTarget() const;
91     void setActiveTarget(Target *target);
92     Target *target(const QString &id) const;
93
94     void saveSettings();
95     bool restoreSettings();
96
97     virtual QList<BuildConfigWidget*> subConfigWidgets();
98
99     virtual ProjectNode *rootProjectNode() const = 0;
100
101     enum FilesMode { AllFiles, ExcludeGeneratedFiles };
102     virtual QStringList files(FilesMode fileMode) const = 0;
103     // TODO: generalize to find source(s) of generated files?
104     virtual QString generatedUiHeader(const QString &formFile) const;
105
106     static QString makeUnique(const QString &preferedName, const QStringList &usedNames);
107
108     // Serialize all data into a QVariantMap. This map is then saved
109     // in the .user file of the project.
110     //
111     // Just put all your data into the map.
112     //
113     // Note: Do not forget to call your base class' toMap method.
114     // Note: Do not forget to call setActiveBuildConfiguration when
115     //       creating new BuilConfigurations.
116     virtual QVariantMap toMap() const;
117
118     // The directory that holds the project file. This includes the absolute path.
119     QString projectDirectory() const;
120     static QString projectDirectory(const QString &proFile);
121
122 signals:
123     void fileListChanged();
124
125     // Note: activeTarget can be 0 (if no targets are defined).
126     void activeTargetChanged(ProjectExplorer::Target *target);
127
128     void aboutToRemoveTarget(ProjectExplorer::Target *target);
129     void removedTarget(ProjectExplorer::Target *target);
130     void addedTarget(ProjectExplorer::Target *target);
131
132     /// convenience signal emitted if the activeBuildConfiguration emits environmentChanged
133     /// or if the activeBuildConfiguration changes
134     /// (including due to the active target changing).
135     void environmentChanged();
136
137     /// convenience signal emitted if the activeBuildConfiguration emits isEnabledChanged()
138     /// or if the activeBuildConfiguration changes
139     /// (including due to the active target changing).
140     void buildConfigurationEnabledChanged();
141
142 protected:
143     // restore all data from the map.
144     //
145     // Note: Do not forget to call your base class' fromMap method!
146     virtual bool fromMap(const QVariantMap &map);
147
148 private slots:
149     void changeEnvironment();
150     void changeBuildConfigurationEnabled();
151
152 private:
153     QScopedPointer<ProjectPrivate> d;
154 };
155
156 } // namespace ProjectExplorer
157
158 Q_DECLARE_METATYPE(ProjectExplorer::Project *)
159
160 #endif // PROJECT_H