aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/project.h
blob: 0df80346bbf1096623b923a4612896adf366b278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/

#ifndef PROJECT_H
#define PROJECT_H

#include "projectexplorer_export.h"

#include <QtCore/QSharedPointer>
#include <QtCore/QObject>
#include <QtGui/QFileSystemModel>

QT_BEGIN_NAMESPACE
class QMenu;
QT_END_NAMESPACE

namespace Core {
class IFile;
}

namespace ProjectExplorer {

class BuildManager;
class BuildStep;
class BuildConfigWidget;
class IProjectManager;
class RunConfiguration;
class EditorConfiguration;
class Environment;
class ProjectNode;
class PersistentSettingsWriter;
class PersistentSettingsReader;
class BuildConfiguration;
class IBuildConfigurationFactory;

class PROJECTEXPLORER_EXPORT Project
    : public QObject
{
    Q_OBJECT

public:
    // Roles to be implemented by all models that are exported via model()
    enum ModelRoles {
        // Absolute file path
        FilePathRole = QFileSystemModel::FilePathRole
    };

    Project();
    virtual ~Project();

    virtual QString name() const = 0;
    virtual Core::IFile *file() const = 0;
    virtual IProjectManager *projectManager() const = 0;

    virtual QList<Project *> dependsOn() = 0; //NBS TODO implement dependsOn

    virtual bool isApplication() const = 0;

    virtual bool hasBuildSettings() const;

    // Build/Clean Step functions
    QList<BuildStep *> buildSteps() const;
    void insertBuildStep(int position, BuildStep *step);
    void removeBuildStep(int position);
    void moveBuildStepUp(int position);

    QList<BuildStep *> cleanSteps() const;
    void insertCleanStep(int position, BuildStep *step);
    void removeCleanStep(int position);
    void moveCleanStepUp(int position);

    // Build configuration
    void addBuildConfiguration(BuildConfiguration *configuration);
    void removeBuildConfiguration(BuildConfiguration *configuration);
    void copyBuildConfiguration(const QString &source, const QString &dest);
    BuildConfiguration *buildConfiguration(const QString & name) const;
    QList<BuildConfiguration *> buildConfigurations() const;
    // remove and add "QString uniqueConfigurationDisplayName(const QString &proposedName) const" instead
    void setDisplayNameFor(BuildConfiguration *configuration, const QString &displayName);
    BuildConfiguration *activeBuildConfiguration() const;
    void setActiveBuildConfiguration(BuildConfiguration *configuration);

    virtual IBuildConfigurationFactory *buildConfigurationFactory() const = 0;

    void setValue(const QString &name, const QVariant &value);
    QVariant value(const QString &name) const;

    // Running
    QList<QSharedPointer<RunConfiguration> > runConfigurations() const;
    void addRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration);
    void removeRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration);

    QSharedPointer<RunConfiguration> activeRunConfiguration() const;
    void setActiveRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration);

    EditorConfiguration *editorConfiguration() const;

    virtual Environment environment(BuildConfiguration *configuration) const = 0;
    virtual QString buildDirectory(BuildConfiguration *configuration) const = 0;

    void saveSettings();
    bool restoreSettings();

    virtual BuildConfigWidget *createConfigWidget() = 0;
    virtual QList<BuildConfigWidget*> subConfigWidgets();

    virtual ProjectNode *rootProjectNode() const = 0;

    enum FilesMode { AllFiles, ExcludeGeneratedFiles };
    virtual QStringList files(FilesMode fileMode) const = 0;

    // C++ specific
    // TODO do a C++ project as a base ?
    virtual QByteArray predefinedMacros(const QString &fileName) const;
    virtual QStringList includePaths(const QString &fileName) const;
    virtual QStringList frameworkPaths(const QString &fileName) const;

signals:
    void fileListChanged();

// TODO clean up signal names
// might be better to also have
// a aboutToRemoveRunConfiguration
// and a removedBuildConfiguration
// a runconfiguration display name changed is missing
    void activeBuildConfigurationChanged();
    void activeRunConfigurationChanged();
    void runConfigurationsEnabledStateChanged();

    void removedRunConfiguration(ProjectExplorer::Project *p, const QString &name);
    void addedRunConfiguration(ProjectExplorer::Project *p, const QString &name);

    void removedBuildConfiguration(ProjectExplorer::Project *p, const QString &name);
    void addedBuildConfiguration(ProjectExplorer::Project *p, const QString &name);

    // This signal is jut there for updating the tree list in the buildsettings wizard
    void buildConfigurationDisplayNameChanged(const QString &buildConfiguration);
    void environmentChanged(const QString &buildConfiguration);

protected:
    /* This method is called when the project .user file is saved. Simply call
     * writer.saveValue() for each value you want to save. Make sure to always
     * call your base class implementation.
     *
     * Note: All the values from the project/buildsteps and buildconfigurations
     * are automatically stored.
     */
    virtual void saveSettingsImpl(PersistentSettingsWriter &writer);

    /* This method is called when the project is opened. You can retrieve all
     * the values you saved in saveSettingsImpl() in this method.
     *
     * Note: This function is also called if there is no .user file. You should
     * probably add some default build and run settings to the project so that
     * it can be build and run.
     */
    virtual bool restoreSettingsImpl(PersistentSettingsReader &reader);

private:
    static QString makeUnique(const QString &preferedName, const QStringList &usedNames);
    QList<BuildStep *> m_buildSteps;
    QList<BuildStep *> m_cleanSteps;
    QMap<QString, QVariant> m_values;
    QList<BuildConfiguration *> m_buildConfigurationValues;
    QString m_activeBuildConfiguration;
    QList<QSharedPointer<RunConfiguration> > m_runConfigurations;
    QSharedPointer<RunConfiguration> m_activeRunConfiguration;
    EditorConfiguration *m_editorConfiguration;
};

} // namespace ProjectExplorer

#endif // PROJECT_H