OSDN Git Service

Merge remote branch 'origin/2.0'
[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) 2010 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 "projectconfiguration.h"
34 #include "projectexplorer_export.h"
35 #include "task.h"
36
37 #include <QtCore/QFutureInterface>
38 #include <QtGui/QWidget>
39
40 namespace ProjectExplorer {
41
42 enum StepType { Build = 0,
43                 Clean = 1,
44                 LastStepType = 2};
45
46 class BuildConfiguration;
47
48 /*
49 // BuildSteps are the primary way plugin developers can customize
50 // how their projects (or projects from other plugins) are build.
51 //
52 // Building a project, is done by taking the list of buildsteps
53 // from the project and calling first init() than run() on them.
54 //
55 // That means to change the way your project is build, reimplemnt
56 // this class and add your Step to the buildStep list of the project.
57 //
58 // Note: The projects own the buildstep, do not delete them yourself.
59 //
60 // init() is called in the GUI thread and can be used to query the
61 // project for any information you need.
62 //
63 // run() is run via QtConccurrent in a own thread, if you need an
64 // eventloop you need to create it yourself!
65 //
66 */
67
68 class BuildStepConfigWidget;
69
70 class PROJECTEXPLORER_EXPORT BuildStep : public ProjectConfiguration
71 {
72     Q_OBJECT
73
74 protected:
75     BuildStep(BuildConfiguration *bc, const QString &id);
76     BuildStep(BuildConfiguration *bc, BuildStep *bs);
77
78 public:
79     virtual ~BuildStep();
80
81     // This function is run in the gui thread,
82     // use it to retrieve any information that you need in run()
83     virtual bool init() = 0;
84
85     // Reimplement this. This function is called when the target is build.
86     // This function is NOT run in the gui thread. It runs in its own thread
87     // If you need an event loop, you need to create one.
88     // The absolute minimal implementation is:
89     // fi.reportResult(true);
90     virtual void run(QFutureInterface<bool> &fi) = 0;
91
92     // the Widget shown in the target settings dialog for this buildStep
93     // ownership is transferred to the caller
94     virtual BuildStepConfigWidget *createConfigWidget() = 0;
95
96     // if this function returns true, the user can't delete this BuildStep for this target
97     // and the user is prevented from changing the order immutable steps are run
98     // the default implementation returns false
99     virtual bool immutable() const;
100
101     BuildConfiguration *buildConfiguration() const;
102
103 signals:
104     // Add a task.
105     void addTask(const ProjectExplorer::Task &task);
106     // The string is added to the generated output, usually in the output
107     // window.
108     // It should be in plain text, with the format in the parameter
109     void addOutput(const QString &string, const QTextCharFormat &textCharFormat);
110
111 private:
112     BuildConfiguration *m_buildConfiguration;
113 };
114
115 class PROJECTEXPLORER_EXPORT IBuildStepFactory :
116     public QObject
117 {
118     Q_OBJECT
119
120 public:
121     explicit IBuildStepFactory(QObject *parent = 0);
122     virtual ~IBuildStepFactory();
123
124     // used to show the list of possible additons to a target, returns a list of types
125     virtual QStringList availableCreationIds(BuildConfiguration *parent, StepType type) const = 0;
126     // used to translate the types to names to display to the user
127     virtual QString displayNameForId(const QString &id) const = 0;
128
129     virtual bool canCreate(BuildConfiguration *parent, StepType type, const QString &id) const = 0;
130     virtual BuildStep *create(BuildConfiguration *parent, StepType type, const QString &id) = 0;
131     // used to recreate the runConfigurations when restoring settings
132     virtual bool canRestore(BuildConfiguration *parent, StepType type, const QVariantMap &map) const = 0;
133     virtual BuildStep *restore(BuildConfiguration *parent, StepType type, const QVariantMap &map) = 0;
134     virtual bool canClone(BuildConfiguration *parent, StepType type, BuildStep *product) const = 0;
135     virtual BuildStep *clone(BuildConfiguration *parent, StepType type, BuildStep *product) = 0;
136 };
137
138 class PROJECTEXPLORER_EXPORT BuildConfigWidget
139     : public QWidget
140 {
141     Q_OBJECT
142 public:
143     BuildConfigWidget()
144         :QWidget(0)
145         {}
146
147     virtual QString displayName() const = 0;
148
149     // This is called to set up the config widget before showing it
150     virtual void init(BuildConfiguration *bc) = 0;
151 };
152
153 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
154     : public QWidget
155 {
156     Q_OBJECT
157 public:
158     BuildStepConfigWidget()
159         : QWidget()
160         {}
161     virtual void init() = 0;
162     virtual QString summaryText() const = 0;
163     virtual QString displayName() const = 0;
164 signals:
165     void updateSummary();
166 };
167
168 } // namespace ProjectExplorer
169
170 #endif // BUILDSTEP_H