project.h 5.68 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** 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.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** 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.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

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

#include "projectexplorer_export.h"

#include <QtCore/QObject>
#include <QtGui/QFileSystemModel>
37
38
39
40

QT_BEGIN_NAMESPACE
class QMenu;
QT_END_NAMESPACE
con's avatar
con committed
41
42

namespace Core {
43
class IFile;
con's avatar
con committed
44
45
46
47
48
49
}

namespace ProjectExplorer {

class BuildManager;
class BuildStep;
dt's avatar
dt committed
50
class BuildConfigWidget;
con's avatar
con committed
51
52
53
class IProjectManager;
class RunConfiguration;
class EditorConfiguration;
54
55
56
57
58
class Environment;
class ProjectNode;
class PersistentSettingsWriter;
class PersistentSettingsReader;
class BuildConfiguration;
59
class IBuildConfigurationFactory;
con's avatar
con committed
60
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    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;

84
85
    virtual bool hasBuildSettings() const;

86
    // Build configuration
87
88
    void addBuildConfiguration(BuildConfiguration *configuration);
    void removeBuildConfiguration(BuildConfiguration *configuration);
dt's avatar
dt committed
89

90
91
92
    QList<BuildConfiguration *> buildConfigurations() const;
    BuildConfiguration *activeBuildConfiguration() const;
    void setActiveBuildConfiguration(BuildConfiguration *configuration);
con's avatar
con committed
93

94
    virtual IBuildConfigurationFactory *buildConfigurationFactory() const = 0;
con's avatar
con committed
95
96

    // Running
97
98
99
    QList<RunConfiguration *> runConfigurations() const;
    void addRunConfiguration(RunConfiguration* runConfiguration);
    void removeRunConfiguration(RunConfiguration* runConfiguration);
con's avatar
con committed
100

101
102
    RunConfiguration* activeRunConfiguration() const;
    void setActiveRunConfiguration(RunConfiguration* runConfiguration);
con's avatar
con committed
103
104
105
106

    EditorConfiguration *editorConfiguration() const;

    void saveSettings();
dt's avatar
dt committed
107
    bool restoreSettings();
con's avatar
con committed
108

dt's avatar
dt committed
109
110
    virtual BuildConfigWidget *createConfigWidget() = 0;
    virtual QList<BuildConfigWidget*> subConfigWidgets();
con's avatar
con committed
111
112
113
114
115
116

    virtual ProjectNode *rootProjectNode() const = 0;

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

117
118
119
120
121
122
    // 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;

123
    static QString makeUnique(const QString &preferedName, const QStringList &usedNames);
con's avatar
con committed
124
125
signals:
    void fileListChanged();
dt's avatar
dt committed
126
127
128
129
130
131

// TODO clean up signal names
// might be better to also have
// a aboutToRemoveRunConfiguration
// and a removedBuildConfiguration
// a runconfiguration display name changed is missing
con's avatar
con committed
132
133
    void activeBuildConfigurationChanged();
    void activeRunConfigurationChanged();
134
    void runConfigurationsEnabledStateChanged();
dt's avatar
dt committed
135
136
137
138

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

dt's avatar
dt committed
139
140
    void removedBuildConfiguration(ProjectExplorer::Project *p, ProjectExplorer::BuildConfiguration *bc);
    void addedBuildConfiguration(ProjectExplorer::Project *p, ProjectExplorer::BuildConfiguration *bc);
dt's avatar
dt committed
141

con's avatar
con committed
142
protected:
143
144
145
146
147
148
149
    /* 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.
     */
con's avatar
con committed
150
151
    virtual void saveSettingsImpl(PersistentSettingsWriter &writer);

152
153
154
155
156
157
158
    /* 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.
     */
dt's avatar
dt committed
159
    virtual bool restoreSettingsImpl(PersistentSettingsReader &reader);
con's avatar
con committed
160
161

private:
con's avatar
con committed
162
    QList<BuildConfiguration *> m_buildConfigurationValues;
dt's avatar
dt committed
163
    BuildConfiguration *m_activeBuildConfiguration;
164
165
    QList<RunConfiguration *> m_runConfigurations;
    RunConfiguration* m_activeRunConfiguration;
con's avatar
con committed
166
167
168
    EditorConfiguration *m_editorConfiguration;
};

hjk's avatar
hjk committed
169
} // namespace ProjectExplorer
con's avatar
con committed
170

171
#endif // PROJECT_H