OSDN Git Service

Merge branch '1.3'
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / buildstep.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** Commercial Usage
10 **
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.
15 **
16 ** GNU Lesser General Public License Usage
17 **
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.
24 **
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
27 **
28 **************************************************************************/
29
30 #ifndef BUILDSTEP_H
31 #define BUILDSTEP_H
32
33 #include "projectexplorer_export.h"
34 #include "taskwindow.h"
35
36 #include <QtCore/QFutureInterface>
37 #include <QtGui/QWidget>
38
39 namespace ProjectExplorer {
40 class BuildConfiguration;
41
42 /*
43 // BuildSteps are the primary way plugin developers can customize
44 // how their projects (or projects from other plugins) are build.
45 //
46 // Building a project, is done by taking the list of buildsteps
47 // from the project and calling first init() than run() on them.
48 //
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.
51 //
52 // Note: The projects own the buildstep, do not delete them yourself.
53 //
54 // init() is called in the GUI thread and can be used to query the
55 // project for any information you need.
56 //
57 // run() is run via QtConccurrent in a own thread, if you need an
58 // eventloop you need to create it yourself!
59 //
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()
64
65 */
66
67 class BuildStepConfigWidget;
68
69 class PROJECTEXPLORER_EXPORT BuildStep : public QObject
70 {
71     Q_OBJECT
72 protected:
73     BuildStep(BuildConfiguration *bc);
74     BuildStep(BuildStep *bs, BuildConfiguration *bc);
75
76 public:
77     virtual ~BuildStep();
78
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;
82
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;
89
90     // The internal name
91     virtual QString name() = 0;
92     // The name shown to the user
93     virtual QString displayName() = 0;
94
95     // the Widget shown in the project settings dialog for this buildStep
96     // ownership is transfered to the caller
97     virtual BuildStepConfigWidget *createConfigWidget() = 0;
98
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;
103
104     // TODO remove after 2.0
105     virtual void restoreFromGlobalMap(const QMap<QString, QVariant> &map);
106
107     virtual void restoreFromLocalMap(const QMap<QString, QVariant> &map);
108     virtual void storeIntoLocalMap(QMap<QString, QVariant> &map);
109
110     BuildConfiguration *buildConfiguration() const;
111
112 signals:
113     // Add a task.
114     void addTask(const ProjectExplorer::TaskWindow::Task &task);
115     // The string is added to the generated output, usually in the output
116     // window.
117     // It should be in html format, that is properly escaped
118     void addOutput(const QString &string);
119
120 private:
121     BuildConfiguration *m_buildConfiguration;
122 };
123
124 class PROJECTEXPLORER_EXPORT IBuildStepFactory
125     : public QObject
126 {
127     Q_OBJECT
128
129 public:
130     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
140
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;
144 };
145
146 class PROJECTEXPLORER_EXPORT BuildConfigWidget
147     : public QWidget
148 {
149     Q_OBJECT
150 public:
151     BuildConfigWidget()
152         :QWidget(0)
153         {}
154
155     virtual QString displayName() const = 0;
156
157     // This is called to set up the config widget before showing it
158     virtual void init(BuildConfiguration *bc) = 0;
159 };
160
161 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
162     : public QWidget
163 {
164     Q_OBJECT
165 public:
166     BuildStepConfigWidget()
167         : QWidget()
168         {}
169     virtual void init() = 0;
170     virtual QString summaryText() const = 0;
171     virtual QString displayName() const = 0;
172 signals:
173     void updateSummary();
174 };
175
176 } // namespace ProjectExplorer
177
178 #endif // BUILDSTEP_H