projectexplorer.h 9.52 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
#ifndef PROJECTEXPLORER_H
#define PROJECTEXPLORER_H

#include "projectexplorer_export.h"
34
#include "projectexplorerconstants.h"
con's avatar
con committed
35
36

#include <extensionsystem/iplugin.h>
37

38
#include <QPair>
con's avatar
con committed
39

40
41
QT_BEGIN_NAMESPACE
class QPoint;
42
class QMenu;
43
class QAction;
44
QT_END_NAMESPACE
con's avatar
con committed
45
46
47

namespace Core {
class IMode;
48
class Id;
49
50
}

51
namespace ProjectExplorer {
con's avatar
con committed
52
53
54
class BuildManager;
class RunControl;
class SessionManager;
55
56
57
58
class RunConfiguration;
class IRunControlFactory;
class Project;
class Node;
59
class BuildConfiguration;
60
class ProjectNode;
61
class TaskHub;
con's avatar
con committed
62

63
namespace Internal { class ProjectExplorerSettings; }
con's avatar
con committed
64

65
66
struct ProjectExplorerPluginPrivate;

con's avatar
con committed
67
68
69
70
class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin
    : public ExtensionSystem::IPlugin
{
    Q_OBJECT
71
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ProjectExplorer.json")
con's avatar
con committed
72
73
74
75
76
77
78

public:
    ProjectExplorerPlugin();
    ~ProjectExplorerPlugin();

    static ProjectExplorerPlugin *instance();

79
    Project *openProject(const QString &fileName, QString *error);
80
81
    QList<Project *> openProjects(const QStringList &fileNames, QString *error);
    Q_SLOT void openProjectWelcomePage(const QString &fileName);
82
    void unloadProject(Project *project);
con's avatar
con committed
83
84
85

    SessionManager *session() const;

86
    static Project *currentProject();
con's avatar
con committed
87
88
89
90
91
92
93
94
    Node *currentNode() const;

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

    Project *startupProject() const;

    BuildManager *buildManager() const;
hjk's avatar
hjk committed
95
    static TaskHub *taskHub();
con's avatar
con committed
96

97
    bool saveModifiedFiles();
con's avatar
con committed
98

99
    void showContextMenu(QWidget *view, const QPoint &globalPos, Node *node);
con's avatar
con committed
100
101

    //PluginInterface
hjk's avatar
hjk committed
102
    bool initialize(const QStringList &arguments, QString *errorMessage);
con's avatar
con committed
103
    void extensionsInitialized();
104
    ShutdownFlag aboutToShutdown();
con's avatar
con committed
105

106
107
108
    void setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes);
    Internal::ProjectExplorerSettings projectExplorerSettings() const;

109
    void startRunControl(RunControl *runControl, RunMode runMode);
110
    static void showRunErrorMessage(const QString &errorMessage);
111

dt's avatar
dt committed
112
113
    // internal public for FlatModel
    void renameFile(Node *node, const QString &to);
114
    static QStringList projectFilePatterns();
115
    bool coreAboutToClose();
116
    QList<QPair<QString, QString> > recentProjects();
dt's avatar
dt committed
117

118
119
120
121
    bool canRun(Project *pro, RunMode runMode);
    QString cannotRunReason(Project *project, RunMode runMode);
    void runProject(Project *pro, RunMode, const bool forceSkipDeploy = false);
    void runRunConfiguration(ProjectExplorer::RunConfiguration *rc, RunMode runMode,
122
                             const bool forceSkipDeploy = false);
123

124
    void addExistingFiles(ProjectExplorer::ProjectNode *projectNode, const QStringList &filePaths);
125
126
    void addExistingFiles(const QStringList &filePaths);

127
    void buildProject(ProjectExplorer::Project *p);
128
129
130
    /// Normally there's no need to call this function.
    /// This function needs to be called, only if the pages that support a project changed.
    void requestProjectModeUpdate(ProjectExplorer::Project *p);
131

132
133
    QList<RunControl *> runControls() const;

134
    static QString displayNameForStepId(Core::Id stepId);
135

con's avatar
con committed
136
signals:
137
138
    void runControlStarted(ProjectExplorer::RunControl *rc);
    void runControlFinished(ProjectExplorer::RunControl *rc);
con's avatar
con committed
139
140
141
142
143
144
145
146
147
    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);
148
    void aboutToExecuteProject(ProjectExplorer::Project *project, RunMode runMode);
149
    void recentProjectsChanged();
con's avatar
con committed
150

151
152
    void settingsChanged();

153
154
    void updateRunActions();

155
public slots:
156
    void openOpenProjectDialog();
157

con's avatar
con committed
158
159
160
private slots:
    void buildStateChanged(ProjectExplorer::Project * pro);
    void buildQueueFinished(bool success);
161
    void buildProjectOnly();
con's avatar
con committed
162
    void buildProject();
163
    void buildProjectContextMenu();
con's avatar
con committed
164
    void buildSession();
165
    void rebuildProjectOnly();
con's avatar
con committed
166
    void rebuildProject();
167
    void rebuildProjectContextMenu();
con's avatar
con committed
168
    void rebuildSession();
Tobias Hunger's avatar
Tobias Hunger committed
169
170
171
172
    void deployProjectOnly();
    void deployProject();
    void deployProjectContextMenu();
    void deploySession();
173
    void cleanProjectOnly();
con's avatar
con committed
174
    void cleanProject();
175
    void cleanProjectContextMenu();
con's avatar
con committed
176
177
178
179
    void cleanSession();
    void cancelBuild();
    void loadAction();
    void unloadProject();
Daniel Teske's avatar
Compile  
Daniel Teske committed
180
    void closeAllProjects();
con's avatar
con committed
181
    void newProject();
182
    void showSessionManager();
con's avatar
con committed
183
184
    void populateOpenWithMenu();
    void updateSessionMenu();
185
    void setSession(QAction *action);
con's avatar
con committed
186

187
    void determineSessionToRestoreAtStartup();
con's avatar
con committed
188
    void restoreSession();
189
    void restoreSession2();
con's avatar
con committed
190
191
    void loadSession(const QString &session);
    void runProject();
192
    void runProjectWithoutDeploy();
193
    void runProjectContextMenu();
con's avatar
con committed
194
195
196
197
    void savePersistentSettings();

    void addNewFile();
    void addExistingFiles();
198
    void addNewSubproject();
199
    void removeProject();
con's avatar
con committed
200
    void openFile();
201
    void searchOnFileSystem();
202
    void showInGraphicalShell();
con's avatar
con committed
203
    void removeFile();
204
    void deleteFile();
con's avatar
con committed
205
    void renameFile();
206
    void setStartupProject();
207
    void setStartupProject(ProjectExplorer::Project *project);
con's avatar
con committed
208
209

    void updateRecentProjectMenu();
210
    void clearRecentProjects();
con's avatar
con committed
211
    void openRecentProject();
212
    void openTerminalHere();
con's avatar
con committed
213
214
215
216
217
218
219

    void invalidateProject(ProjectExplorer::Project *project);

    void setCurrentFile(const QString &filePath);

    void runControlFinished();

220
221
    void projectAdded(ProjectExplorer::Project *pro);
    void projectRemoved(ProjectExplorer::Project *pro);
222
    void projectDisplayNameChanged(ProjectExplorer::Project *pro);
con's avatar
con committed
223
    void startupProjectChanged(); // Calls updateRunAction
224
225
226
    void activeTargetChanged();
    void activeRunConfigurationChanged();

Tobias Hunger's avatar
Tobias Hunger committed
227
    void updateDeployActions();
228
    void slotUpdateRunActions();
con's avatar
con committed
229

230
    void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode);
Tobias Hunger's avatar
Tobias Hunger committed
231
    void updateActions();
232
    void loadCustomWizards();
hjk's avatar
hjk committed
233
    void updateVariable(const QByteArray &variable);
234
    void updateRunWithoutDeployMenu();
con's avatar
con committed
235

236
    void publishProject();
237
    void updateWelcomePage();
238
    void updateExternalFileWarning();
239

240
241
    void updateContext();

242
#ifdef WITH_TESTS
243
244
245
    void testAnsiFilterOutputParser_data();
    void testAnsiFilterOutputParser();

246
247
    void testGccOutputParsers_data();
    void testGccOutputParsers();
248

249
250
251
    void testClangOutputParser_data();
    void testClangOutputParser();

dt's avatar
dt committed
252
253
254
    void testLinuxIccOutputParsers_data();
    void testLinuxIccOutputParsers();

255
256
257
258
    void testGnuMakeParserParsing_data();
    void testGnuMakeParserParsing();
    void testGnuMakeParserTaskMangling_data();
    void testGnuMakeParserTaskMangling();
Tobias Hunger's avatar
Tobias Hunger committed
259
260
261

    void testMsvcOutputParsers_data();
    void testMsvcOutputParsers();
262
263
264

    void testGccAbiGuessing_data();
    void testGccAbiGuessing();
265
266
267

    void testAbiOfBinary_data();
    void testAbiOfBinary();
268
    void testFlavorForOs();
269
270

    void testDeviceManager();
271
272
273

    void testCustomWizardPreprocessor_data();
    void testCustomWizardPreprocessor();
274
275
#endif

con's avatar
con committed
276
private:
277
    QString directoryFor(Node *node);
278
    QString pathFor(Node *node);
Tobias Hunger's avatar
Tobias Hunger committed
279
    void deploy(QList<Project *>);
280
    int queue(QList<Project *>, QList<Core::Id> stepIds);
dt's avatar
dt committed
281
    void updateContextMenuActions();
282
    bool parseArguments(const QStringList &arguments, QString *error);
283
    void executeRunConfiguration(RunConfiguration *, RunMode mode);
284
    bool hasBuildSettings(Project *pro);
285
286
    QPair<bool, QString> buildSettingsEnabledForSession();
    QPair<bool, QString> buildSettingsEnabled(Project *pro);
Tobias Hunger's avatar
Tobias Hunger committed
287
288
    bool hasDeploySettings(Project *pro);

con's avatar
con committed
289
290
291
    void setCurrent(Project *project, QString filePath, Node *node);

    QStringList allFilesWithDependencies(Project *pro);
292
    IRunControlFactory *findRunControlFactory(RunConfiguration *config, RunMode mode);
con's avatar
con committed
293

294
    void addToRecentProjects(const QString &fileName, const QString &displayName);
con's avatar
con committed
295
296

    static ProjectExplorerPlugin *m_instance;
297
    ProjectExplorerPluginPrivate *d;
con's avatar
con committed
298
299
300
301
302
};

} // namespace ProjectExplorer

#endif // PROJECTEXPLORER_H