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 class BuildConfiguration;
43 class BuildStepList;
44 class Target;
45
46 /*
47 // BuildSteps are the primary way plugin developers can customize
48 // how their projects (or projects from other plugins) are build.
49 //
50 // Building a project, is done by taking the list of buildsteps
51 // from the project and calling first init() than run() on them.
52 //
53 // That means to change the way your project is build, reimplemnt
54 // this class and add your Step to the buildStep list of the project.
55 //
56 // Note: The projects own the buildstep, do not delete them yourself.
57 //
58 // init() is called in the GUI thread and can be used to query the
59 // project for any information you need.
60 //
61 // run() is run via QtConccurrent in a own thread, if you need an
62 // eventloop you need to create it yourself!
63 //
64 */
65
66 class BuildStepConfigWidget;
67
68 class PROJECTEXPLORER_EXPORT BuildStep : public ProjectConfiguration
69 {
70     Q_OBJECT
71
72 protected:
73     BuildStep(BuildStepList *bsl, const QString &id);
74     BuildStep(BuildStepList *bsl, BuildStep *bs);
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 target 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 Widget shown in the target settings dialog for this buildStep
91     // ownership is transferred to the caller
92     virtual BuildStepConfigWidget *createConfigWidget() = 0;
93
94     // if this function returns true, the user can't delete this BuildStep for this target
95     // and the user is prevented from changing the order immutable steps are run
96     // the default implementation returns false
97     virtual bool immutable() const;
98
99     BuildConfiguration *buildConfiguration() const;
100     Target *target() const;
101
102     enum OutputFormat { NormalOutput, ErrorOutput, MessageOutput, ErrorMessageOutput };
103
104 signals:
105     // Add a task.
106     void addTask(const ProjectExplorer::Task &task);
107     // The string is added to the generated output, usually in the output
108     // window.
109     // It should be in plain text, with the format in the parameter
110     void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
111 };
112
113 class PROJECTEXPLORER_EXPORT IBuildStepFactory :
114     public QObject
115 {
116     Q_OBJECT
117
118 public:
119     explicit IBuildStepFactory(QObject *parent = 0);
120     virtual ~IBuildStepFactory();
121
122     // used to show the list of possible additons to a target, returns a list of types
123     virtual QStringList availableCreationIds(BuildStepList *parent) const = 0;
124     // used to translate the types to names to display to the user
125     virtual QString displayNameForId(const QString &id) const = 0;
126
127     virtual bool canCreate(BuildStepList *parent, const QString &id) const = 0;
128     virtual BuildStep *create(BuildStepList *parent, const QString &id) = 0;
129     // used to recreate the runConfigurations when restoring settings
130     virtual bool canRestore(BuildStepList *parent, const QVariantMap &map) const = 0;
131     virtual BuildStep *restore(BuildStepList *parent, const QVariantMap &map) = 0;
132     virtual bool canClone(BuildStepList *parent, BuildStep *product) const = 0;
133     virtual BuildStep *clone(BuildStepList *parent, BuildStep *product) = 0;
134 };
135
136 class PROJECTEXPLORER_EXPORT BuildConfigWidget
137     : public QWidget
138 {
139     Q_OBJECT
140 public:
141     BuildConfigWidget()
142         :QWidget(0)
143         {}
144
145     virtual QString displayName() const = 0;
146
147     // This is called to set up the config widget before showing it
148     virtual void init(BuildConfiguration *bc) = 0;
149
150 signals:
151     void displayNameChanged(const QString &);
152 };
153
154 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
155     : public QWidget
156 {
157     Q_OBJECT
158 public:
159     BuildStepConfigWidget()
160         : QWidget()
161         {}
162     virtual void init() = 0;
163     virtual QString summaryText() const = 0;
164     virtual QString displayName() const = 0;
165 signals:
166     void updateSummary();
167 };
168
169 } // namespace ProjectExplorer
170
171 Q_DECLARE_METATYPE(ProjectExplorer::BuildStep::OutputFormat)
172
173 #endif // BUILDSTEP_H