project.h 5.15 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2013 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 <QObject>
#include <QFileSystemModel>
39

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

namespace ProjectExplorer {

class IProjectManager;
class EditorConfiguration;
49
class ProjectNode;
Tobias Hunger's avatar
Tobias Hunger committed
50
class Kit;
51
class NamedWidget;
Tobias Hunger's avatar
Tobias Hunger committed
52
class Target;
53
class ProjectPrivate;
con's avatar
con committed
54

55
// Documentation inside.
con's avatar
con committed
56 57 58 59 60 61
class PROJECTEXPLORER_EXPORT Project
    : public QObject
{
    Q_OBJECT

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

    Project();
    virtual ~Project();

72
    virtual QString displayName() const = 0;
73
    virtual Core::Id id() const = 0;
74
    virtual Core::IDocument *document() const = 0;
con's avatar
con committed
75 76
    virtual IProjectManager *projectManager() const = 0;

Tobias Hunger's avatar
Tobias Hunger committed
77
    bool hasActiveBuildSettings() const;
con's avatar
con committed
78

Tobias Hunger's avatar
Tobias Hunger committed
79 80
    // EditorConfiguration:
    EditorConfiguration *editorConfiguration() const;
dt's avatar
dt committed
81

Tobias Hunger's avatar
Tobias Hunger committed
82 83
    // Target:
    void addTarget(Target *target);
Daniel Teske's avatar
Daniel Teske committed
84
    bool removeTarget(Target *target);
con's avatar
con committed
85

Tobias Hunger's avatar
Tobias Hunger committed
86 87 88 89
    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
90
    Target *target(const Core::Id id) const;
Tobias Hunger's avatar
Tobias Hunger committed
91
    Target *target(Kit *k) const;
92
    virtual bool supportsKit(Kit *k, QString *errorMessage = 0) const;
Tobias Hunger's avatar
Tobias Hunger committed
93

Tobias Hunger's avatar
Tobias Hunger committed
94
    Target *createTarget(Kit *k);
Tobias Hunger's avatar
Tobias Hunger committed
95
    Target *restoreTarget(const QVariantMap &data);
con's avatar
con committed
96 97

    void saveSettings();
dt's avatar
dt committed
98
    bool restoreSettings();
con's avatar
con committed
99 100 101 102 103

    virtual ProjectNode *rootProjectNode() const = 0;

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

Tobias Hunger's avatar
Tobias Hunger committed
107 108
    static QString makeUnique(const QString &preferedName, const QStringList &usedNames);

109 110
    virtual QVariantMap toMap() const;

Tobias Hunger's avatar
Tobias Hunger committed
111
    // The directory that holds the project. This includes the absolute path.
112
    QString projectDirectory() const;
Tobias Hunger's avatar
Tobias Hunger committed
113
    static QString projectDirectory(const QString &top);
114

115 116
    Core::Context projectContext() const;
    Core::Context projectLanguages() const;
117

118
    QVariant namedSettings(const QString &name) const;
119
    void setNamedSettings(const QString &name, const QVariant &value);
120

121
    virtual bool needsConfiguration() const;
122
    virtual void configureAsExampleProject(const QStringList &platforms);
123

124 125
    virtual bool supportsNoTargetPanel() const;

con's avatar
con committed
126
signals:
127
    void displayNameChanged();
con's avatar
con committed
128
    void fileListChanged();
dt's avatar
dt committed
129

Tobias Hunger's avatar
Tobias Hunger committed
130 131 132 133 134 135
    // 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
136

Tobias Hunger's avatar
Tobias Hunger committed
137
    void environmentChanged();
138
    void buildConfigurationEnabledChanged();
139

Tobias Hunger's avatar
Tobias Hunger committed
140
    void buildDirectoryChanged();
141

142 143 144
    void settingsLoaded();
    void aboutToSaveSettings();

145 146 147
    void projectContextUpdated();
    void projectLanguagesUpdated();

con's avatar
con committed
148
protected:
149
    virtual bool fromMap(const QVariantMap &map);
150
    virtual bool setupTarget(Target *t);
con's avatar
con committed
151

152 153 154 155 156
    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);
157

Tobias Hunger's avatar
Tobias Hunger committed
158 159
private slots:
    void changeEnvironment();
160
    void changeBuildConfigurationEnabled();
Tobias Hunger's avatar
Tobias Hunger committed
161
    void onBuildDirectoryChanged();
Tobias Hunger's avatar
Tobias Hunger committed
162

con's avatar
con committed
163
private:
hjk's avatar
hjk committed
164
    ProjectPrivate *d;
con's avatar
con committed
165 166
};

hjk's avatar
hjk committed
167
} // namespace ProjectExplorer
con's avatar
con committed
168

169 170
Q_DECLARE_METATYPE(ProjectExplorer::Project *)

171
#endif // PROJECT_H