aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projectexplorer.h
blob: d21adb8abda09a5404ccbd6866f32986737542c0 (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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact:  Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file.  Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/

#ifndef PROJECTEXPLORER_H
#define PROJECTEXPLORER_H

#include "project.h"
#include "session.h"
#include "projectexplorer_export.h"

#include <extensionsystem/iplugin.h>
#include <coreplugin/icorelistener.h>

#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QtCore/QSharedPointer>
#include <QtCore/QList>
#include <QtCore/QQueue>
#include <QtCore/QModelIndex>
#include <QtGui/QMenu>
#include <QtGui/QTreeWidget>
#include <QtGui/QTreeWidgetItem>


namespace Core {
class IContext;
class IMode;
class IFileFactory;
namespace Internal {
    class WelcomeMode;
}
}

namespace ProjectExplorer {

class BuildManager;
class PersistentSettings;
class RunConfiguration;
class RunControl;
class SessionManager;
class IRunConfigurationRunner;

namespace Internal {
class ApplicationOutput;
class OutputPane;
class ProjectWindow;
class ProjectFileFactory;

} // namespace Internal

class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin
    : public ExtensionSystem::IPlugin
{
    Q_OBJECT

public:
    ProjectExplorerPlugin();
    ~ProjectExplorerPlugin();

    static ProjectExplorerPlugin *instance();

    bool openProject(const QString &fileName);
    bool openProjects(const QStringList &fileNames);

    SessionManager *session() const;

    Project *currentProject() const;
    Node *currentNode() const;

    void setCurrentFile(Project *project, const QString &file);
    void setCurrentNode(Node *node);

    Project *startupProject() const;
    void setStartupProject(ProjectExplorer::Project *project = 0);

    BuildManager *buildManager() const;

    bool saveModifiedFiles(const QList<Project *> & projects);

    void showContextMenu(const QPoint &globalPos, Node *node);

    //PluginInterface
    bool initialize(const QStringList &arguments, QString *error_message);
    void extensionsInitialized();
    void shutdown();

signals:
    void aboutToShowContextMenu(ProjectExplorer::Project *project,
                                ProjectExplorer::Node *node);

    // Is emitted when a project has been added/removed,
    // or the file list of a specific project has changed.
    void fileListChanged();

    void currentProjectChanged(ProjectExplorer::Project *project);
    void currentNodeChanged(ProjectExplorer::Node *node, ProjectExplorer::Project *project);
    void aboutToExecuteProject(ProjectExplorer::Project *project);

private slots:
    void buildStateChanged(ProjectExplorer::Project * pro);
    void buildQueueFinished(bool success);
    void buildProject();
    void buildSession();
    void rebuildProject();
    void rebuildSession();
    void cleanProject();
    void cleanSession();
    void cancelBuild();
    void debugProject();
    void loadAction();
    void unloadProject();
    void clearSession();
    void newProject();
    void showSessionManager();
    void populateBuildConfigurationMenu();
    void buildConfigurationMenuTriggered(QAction *);
    void populateRunConfigurationMenu();
    void runConfigurationMenuTriggered(QAction *);
    void populateOpenWithMenu();
    void openWithMenuTriggered(QAction *action);
    void updateSessionMenu();
    void setSession(QAction *action);

    void restoreSession();
    void loadSession(const QString &session);
    void runProject();
    void runProjectContextMenu();
    void savePersistentSettings();
    void goToTaskWindow();

    void updateContextMenuActions();
    void addNewFile();
    void addExistingFiles();
    void openFile();
    void removeFile();
    void renameFile();

    void updateRecentProjectMenu();
    void openRecentProject();

    void invalidateProject(ProjectExplorer::Project *project);

    void setCurrentFile(const QString &filePath);

    // RunControl
    void runControlFinished();

    void startupProjectChanged(); // Calls updateRunAction
    void updateRunAction();

    void addToApplicationOutputWindow(RunControl *, const QString &line);
    void addToApplicationOutputWindowInline(RunControl *, const QString &line);
    void addErrorToApplicationOutputWindow(RunControl *, const QString &error);
    void updateTaskActions();

    void loadProject(const QString &project) { openProject(project); }
    void currentModeChanged(Core::IMode *mode);

private:
    void runProjectImpl(Project *pro);
    void setCurrent(Project *project, QString filePath, Node *node);

    QStringList allFilesWithDependencies(Project *pro);
    IRunConfigurationRunner *findRunner(QSharedPointer<RunConfiguration> config, const QString &mode);

    void updateActions();
    void addToRecentProjects(const QString &fileName);
    void updateWelcomePage(Core::Internal::WelcomeMode *welcomeMode);
    Internal::ProjectFileFactory *findProjectFileFactory(const QString &filename) const;

    static ProjectExplorerPlugin *m_instance;

    QMenu *m_sessionContextMenu;
    QMenu *m_sessionMenu;
    QMenu *m_projectMenu;
    QMenu *m_subProjectMenu;
    QMenu *m_folderMenu;
    QMenu *m_fileMenu;
    QMenu *m_openWithMenu;

    QMultiMap<int, QObject*> m_actionMap;
    QAction *m_sessionManagerAction;
    QAction *m_newAction;
#if 0
    QAction *m_loadAction;
#endif
    QAction *m_unloadAction;
    QAction *m_clearSession;
    QAction *m_buildAction;
    QAction *m_buildSessionAction;
    QAction *m_rebuildAction;
    QAction *m_rebuildSessionAction;
    QAction *m_cleanAction;
    QAction *m_cleanSessionAction;
    QAction *m_runAction;
    QAction *m_runActionContextMenu;
    QAction *m_cancelBuildAction;
    QAction *m_debugAction;
    QAction *m_taskAction;
    QAction *m_addNewFileAction;
    QAction *m_addExistingFilesAction;
    QAction *m_openFileAction;
    QAction *m_removeFileAction;
    QAction *m_renameFileAction;

    QMenu *m_buildConfigurationMenu;
    QActionGroup *m_buildConfigurationActionGroup;
    QMenu *m_runConfigurationMenu;
    QActionGroup *m_runConfigurationActionGroup;

    Internal::ProjectWindow *m_proWindow;
    SessionManager *m_session;

    Project *m_currentProject;
    Node *m_currentNode;

    BuildManager *m_buildManager;

    QList<Internal::ProjectFileFactory*> m_fileFactories;
    QStringList m_profileMimeTypes;
    Internal::OutputPane *m_outputPane;

    QStringList m_recentProjects;
    static const int m_maxRecentProjects = 7;
    QMap<QAction*, QString> m_recentProjectsActions;

    QString m_lastOpenDirectory;
    QSharedPointer<RunConfiguration> m_delayedRunConfiguration;
    RunControl *m_debuggingRunControl;
    QString m_runMode;
    QString m_projectFilterString;
};

namespace Internal {

class CoreListenerCheckingForRunningBuild : public Core::ICoreListener
{
    Q_OBJECT
public:
    CoreListenerCheckingForRunningBuild(BuildManager *manager);

    bool coreAboutToClose();

private:
    BuildManager *m_manager;
};

} // namespace Internal

} // namespace ProjectExplorer

#endif // PROJECTEXPLORER_H