project.h 5.83 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
Eike Ziller's avatar
Eike Ziller committed
13
14
** conditions see http://www.qt.io/licensing.  For further information
** use the contact form at http://www.qt.io/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18
19
20
21
22
23
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
hjk's avatar
hjk committed
25
26
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
27
28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
hjk's avatar
hjk committed
30

con's avatar
con committed
31
32
33
34
35
#ifndef PROJECT_H
#define PROJECT_H

#include "projectexplorer_export.h"

36
37
#include <coreplugin/id.h>

38
39
#include <utils/fileutils.h>

40
41
#include <QObject>
#include <QFileSystemModel>
42

con's avatar
con committed
43
namespace Core {
44
class IDocument;
45
class Context;
con's avatar
con committed
46
47
}

48
49
namespace Utils { class MacroExpander; }

con's avatar
con committed
50
51
namespace ProjectExplorer {

52
class BuildInfo;
con's avatar
con committed
53
54
class IProjectManager;
class EditorConfiguration;
55
class ProjectImporter;
56
class ProjectNode;
Tobias Hunger's avatar
Tobias Hunger committed
57
class Kit;
58
class KitMatcher;
59
class NamedWidget;
Tobias Hunger's avatar
Tobias Hunger committed
60
class Target;
61
class ProjectPrivate;
con's avatar
con committed
62

63
// Documentation inside.
con's avatar
con committed
64
65
66
67
68
69
class PROJECTEXPLORER_EXPORT Project
    : public QObject
{
    Q_OBJECT

public:
70
    // Roles to be implemented by all models that are exported via model()
con's avatar
con committed
71
72
    enum ModelRoles {
        // Absolute file path
73
74
        FilePathRole = QFileSystemModel::FilePathRole,
        EnabledRole
con's avatar
con committed
75
76
77
78
79
    };

    Project();
    virtual ~Project();

80
    virtual QString displayName() const = 0;
81
    Core::Id id() const;
82
    virtual Core::IDocument *document() const = 0;
con's avatar
con committed
83
84
    virtual IProjectManager *projectManager() const = 0;

85
    Utils::FileName projectFilePath() const;
86

Tobias Hunger's avatar
Tobias Hunger committed
87
    bool hasActiveBuildSettings() const;
con's avatar
con committed
88

Tobias Hunger's avatar
Tobias Hunger committed
89
90
    // EditorConfiguration:
    EditorConfiguration *editorConfiguration() const;
dt's avatar
dt committed
91

Tobias Hunger's avatar
Tobias Hunger committed
92
93
    // Target:
    void addTarget(Target *target);
Daniel Teske's avatar
Daniel Teske committed
94
    bool removeTarget(Target *target);
con's avatar
con committed
95

Tobias Hunger's avatar
Tobias Hunger committed
96
97
98
99
    QList<Target *> targets() const;
    // Note: activeTarget can be 0 (if no targets are defined).
    Target *activeTarget() const;
    void setActiveTarget(Target *target);
100
    Target *target(Core::Id id) const;
Tobias Hunger's avatar
Tobias Hunger committed
101
    Target *target(Kit *k) const;
102
    virtual bool supportsKit(Kit *k, QString *errorMessage = 0) const;
Tobias Hunger's avatar
Tobias Hunger committed
103

Tobias Hunger's avatar
Tobias Hunger committed
104
    Target *createTarget(Kit *k);
Tobias Hunger's avatar
Tobias Hunger committed
105
    Target *restoreTarget(const QVariantMap &data);
con's avatar
con committed
106
107

    void saveSettings();
dt's avatar
dt committed
108
    bool restoreSettings();
con's avatar
con committed
109
110
111
112
113

    virtual ProjectNode *rootProjectNode() const = 0;

    enum FilesMode { AllFiles, ExcludeGeneratedFiles };
    virtual QStringList files(FilesMode fileMode) const = 0;
114
115
    // TODO: generalize to find source(s) of generated files?
    virtual QString generatedUiHeader(const QString &formFile) const;
con's avatar
con committed
116

117
    static QString makeUnique(const QString &preferredName, const QStringList &usedNames);
Tobias Hunger's avatar
Tobias Hunger committed
118

119
120
    virtual QVariantMap toMap() const;

Tobias Hunger's avatar
Tobias Hunger committed
121
    // The directory that holds the project. This includes the absolute path.
122
123
    Utils::FileName projectDirectory() const;
    static Utils::FileName projectDirectory(const Utils::FileName &top);
124

125
126
    Core::Context projectContext() const;
    Core::Context projectLanguages() const;
127

128
    QVariant namedSettings(const QString &name) const;
129
    void setNamedSettings(const QString &name, const QVariant &value);
130

131
    virtual bool needsConfiguration() const;
132
    virtual void configureAsExampleProject(const QStringList &platforms);
133

134
    virtual bool requiresTargetPanel() const;
135
    virtual ProjectImporter *createProjectImporter() const;
136
137
138
139
140
141

    KitMatcher requiredKitMatcher() const;
    void setRequiredKitMatcher(const KitMatcher &matcher);

    KitMatcher preferredKitMatcher() const;
    void setPreferredKitMatcher(const KitMatcher &matcher);
142

143
144
    virtual bool needsSpecialDeployment() const;

145
    void setup(QList<const BuildInfo *> infoList);
146
    Utils::MacroExpander *macroExpander() const;
147

con's avatar
con committed
148
signals:
149
    void displayNameChanged();
con's avatar
con committed
150
    void fileListChanged();
dt's avatar
dt committed
151

Tobias Hunger's avatar
Tobias Hunger committed
152
153
154
155
156
157
    // Note: activeTarget can be 0 (if no targets are defined).
    void activeTargetChanged(ProjectExplorer::Target *target);

    void aboutToRemoveTarget(ProjectExplorer::Target *target);
    void removedTarget(ProjectExplorer::Target *target);
    void addedTarget(ProjectExplorer::Target *target);
dt's avatar
dt committed
158

Tobias Hunger's avatar
Tobias Hunger committed
159
    void environmentChanged();
160
    void buildConfigurationEnabledChanged();
161

Tobias Hunger's avatar
Tobias Hunger committed
162
    void buildDirectoryChanged();
163

164
165
166
    void settingsLoaded();
    void aboutToSaveSettings();

167
168
169
    void projectContextUpdated();
    void projectLanguagesUpdated();

con's avatar
con committed
170
protected:
171
    virtual bool fromMap(const QVariantMap &map);
172
    virtual bool setupTarget(Target *t);
con's avatar
con committed
173

174
    void setId(Core::Id id);
175
176
177
178
179
    void setProjectContext(Core::Context context);
    void setProjectLanguages(Core::Context language);
    void addProjectLanguage(Core::Id id);
    void removeProjectLanguage(Core::Id id);
    void setProjectLanguage(Core::Id id, bool enabled);
180

Tobias Hunger's avatar
Tobias Hunger committed
181
182
private slots:
    void changeEnvironment();
183
    void changeBuildConfigurationEnabled();
Tobias Hunger's avatar
Tobias Hunger committed
184
    void onBuildDirectoryChanged();
Tobias Hunger's avatar
Tobias Hunger committed
185

con's avatar
con committed
186
private:
hjk's avatar
hjk committed
187
    ProjectPrivate *d;
con's avatar
con committed
188
189
};

hjk's avatar
hjk committed
190
} // namespace ProjectExplorer
con's avatar
con committed
191

192
193
Q_DECLARE_METATYPE(ProjectExplorer::Project *)

194
#endif // PROJECT_H