project.h 5.62 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 13 14
** 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
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
**
hjk's avatar
hjk committed
24 25
** 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
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

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

#include "projectexplorer_export.h"

35 36
#include <coreplugin/id.h>

37 38
#include <utils/fileutils.h>

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

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

namespace ProjectExplorer {

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

60
// Documentation inside.
con's avatar
con committed
61 62 63 64 65 66
class PROJECTEXPLORER_EXPORT Project
    : public QObject
{
    Q_OBJECT

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

    Project();
    virtual ~Project();

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

82
    Utils::FileName projectFilePath() const;
83

Tobias Hunger's avatar
Tobias Hunger committed
84
    bool hasActiveBuildSettings() const;
con's avatar
con committed
85

Tobias Hunger's avatar
Tobias Hunger committed
86 87
    // EditorConfiguration:
    EditorConfiguration *editorConfiguration() const;
dt's avatar
dt committed
88

Tobias Hunger's avatar
Tobias Hunger committed
89 90
    // Target:
    void addTarget(Target *target);
Daniel Teske's avatar
Daniel Teske committed
91
    bool removeTarget(Target *target);
con's avatar
con committed
92

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

Tobias Hunger's avatar
Tobias Hunger committed
101
    Target *createTarget(Kit *k);
Tobias Hunger's avatar
Tobias Hunger committed
102
    Target *restoreTarget(const QVariantMap &data);
con's avatar
con committed
103 104

    void saveSettings();
dt's avatar
dt committed
105
    bool restoreSettings();
con's avatar
con committed
106 107 108 109 110

    virtual ProjectNode *rootProjectNode() const = 0;

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

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

116 117
    virtual QVariantMap toMap() const;

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

122 123
    Core::Context projectContext() const;
    Core::Context projectLanguages() const;
124

125
    QVariant namedSettings(const QString &name) const;
126
    void setNamedSettings(const QString &name, const QVariant &value);
127

128
    virtual bool needsConfiguration() const;
129
    virtual void configureAsExampleProject(const QStringList &platforms);
130

131
    virtual bool supportsNoTargetPanel() const;
132 133 134
    virtual ProjectImporter *createProjectImporter() const;
    virtual KitMatcher *createRequiredKitMatcher() const { return 0; }
    virtual KitMatcher *createPreferredKitMatcher() const { return 0; }
135

136 137
    virtual bool needsSpecialDeployment() const;

138 139
    void setup(QList<const BuildInfo *> infoList);

con's avatar
con committed
140
signals:
141
    void displayNameChanged();
con's avatar
con committed
142
    void fileListChanged();
dt's avatar
dt committed
143

Tobias Hunger's avatar
Tobias Hunger committed
144 145 146 147 148 149
    // 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
150

Tobias Hunger's avatar
Tobias Hunger committed
151
    void environmentChanged();
152
    void buildConfigurationEnabledChanged();
153

Tobias Hunger's avatar
Tobias Hunger committed
154
    void buildDirectoryChanged();
155

156 157 158
    void settingsLoaded();
    void aboutToSaveSettings();

159 160 161
    void projectContextUpdated();
    void projectLanguagesUpdated();

con's avatar
con committed
162
protected:
163
    virtual bool fromMap(const QVariantMap &map);
164
    virtual bool setupTarget(Target *t);
con's avatar
con committed
165

166
    void setId(Core::Id id);
167 168 169 170 171
    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);
172

Tobias Hunger's avatar
Tobias Hunger committed
173 174
private slots:
    void changeEnvironment();
175
    void changeBuildConfigurationEnabled();
Tobias Hunger's avatar
Tobias Hunger committed
176
    void onBuildDirectoryChanged();
Tobias Hunger's avatar
Tobias Hunger committed
177

con's avatar
con committed
178
private:
hjk's avatar
hjk committed
179
    ProjectPrivate *d;
con's avatar
con committed
180 181
};

hjk's avatar
hjk committed
182
} // namespace ProjectExplorer
con's avatar
con committed
183

184 185
Q_DECLARE_METATYPE(ProjectExplorer::Project *)

186
#endif // PROJECT_H