1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
28 **************************************************************************/
33 #include "projectexplorer_export.h"
34 #include "taskwindow.h"
36 #include <QtCore/QFutureInterface>
37 #include <QtGui/QWidget>
39 namespace ProjectExplorer {
40 class BuildConfiguration;
43 // BuildSteps are the primary way plugin developers can customize
44 // how their projects (or projects from other plugins) are build.
46 // Building a project, is done by taking the list of buildsteps
47 // from the project and calling first init() than run() on them.
49 // That means to change the way your project is build, reimplemnt
50 // this class and add your Step to the buildStep list of the project.
52 // Note: The projects own the buildstep, do not delete them yourself.
54 // init() is called in the GUI thread and can be used to query the
55 // project for any information you need.
57 // run() is run via QtConccurrent in a own thread, if you need an
58 // eventloop you need to create it yourself!
60 // You can use setValue() to store settings which a specific
61 // to your buildstep. (You can set settings to apply only
62 // to one buildconfiguration.
63 // And later retrieve the same information with value()
67 class BuildStepConfigWidget;
69 class PROJECTEXPLORER_EXPORT BuildStep : public QObject
73 BuildStep(BuildConfiguration *bc);
74 BuildStep(BuildStep *bs, BuildConfiguration *bc);
79 // This function is run in the gui thread,
80 // use it to retrieve any information that you need in run()
81 virtual bool init() = 0;
83 // Reimplement this. This function is called when the project is build.
84 // This function is NOT run in the gui thread. It runs in its own thread
85 // If you need an event loop, you need to create one.
86 // The absolute minimal implementation is:
87 // fi.reportResult(true);
88 virtual void run(QFutureInterface<bool> &fi) = 0;
91 virtual QString name() = 0;
92 // The name shown to the user
93 virtual QString displayName() = 0;
95 // the Widget shown in the project settings dialog for this buildStep
96 // ownership is transfered to the caller
97 virtual BuildStepConfigWidget *createConfigWidget() = 0;
99 // if this function returns true, the user can't delete this BuildStep for this project
100 // and the user is prevented from changing the order immutable steps are run
101 // the default implementation returns false
102 virtual bool immutable() const;
104 // TODO remove after 2.0
105 virtual void restoreFromGlobalMap(const QMap<QString, QVariant> &map);
107 virtual void restoreFromLocalMap(const QMap<QString, QVariant> &map);
108 virtual void storeIntoLocalMap(QMap<QString, QVariant> &map);
110 BuildConfiguration *buildConfiguration() const;
114 void addTask(const ProjectExplorer::TaskWindow::Task &task);
115 // The string is added to the generated output, usually in the output
117 // It should be in html format, that is properly escaped
118 void addOutput(const QString &string);
121 BuildConfiguration *m_buildConfiguration;
124 class PROJECTEXPLORER_EXPORT IBuildStepFactory
131 virtual ~IBuildStepFactory();
132 /// Called to check wheter this factory can restore the named BuildStep
133 virtual bool canCreate(const QString &name) const = 0;
134 /// Called to restore a buildstep
135 virtual BuildStep *create(BuildConfiguration *bc, const QString &name) const = 0;
136 /// Called by the add BuildStep action to check which BuildSteps could be added
137 /// to the project by this factory, should return a list of names
138 virtual QStringList canCreateForBuildConfiguration(BuildConfiguration *bc) const = 0;
139 /// Called to convert an internal name to a displayName
141 /// Called to clone a BuildStep
142 virtual BuildStep *clone(BuildStep *bs, BuildConfiguration *bc) const = 0;
143 virtual QString displayNameForName(const QString &name) const = 0;
146 class PROJECTEXPLORER_EXPORT BuildConfigWidget
155 virtual QString displayName() const = 0;
157 // This is called to set up the config widget before showing it
158 virtual void init(BuildConfiguration *bc) = 0;
161 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
166 BuildStepConfigWidget()
169 virtual void init() = 0;
170 virtual QString summaryText() const = 0;
171 virtual QString displayName() const = 0;
173 void updateSummary();
176 } // namespace ProjectExplorer
178 #endif // BUILDSTEP_H