OSDN Git Service

Merge remote branch 'origin/2.2'
[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) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
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 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef BUILDSTEP_H
35 #define BUILDSTEP_H
36
37 #include "projectconfiguration.h"
38 #include "projectexplorer_export.h"
39 #include "task.h"
40
41 #include <QtCore/QFutureInterface>
42 #include <QtGui/QWidget>
43
44 namespace ProjectExplorer {
45
46 class BuildConfiguration;
47 class BuildStepList;
48 class DeployConfiguration;
49 class Target;
50
51 /*
52 // BuildSteps are the primary way plugin developers can customize
53 // how their projects (or projects from other plugins) are build.
54 //
55 // Building a project, is done by taking the list of buildsteps
56 // from the project and calling first init() than run() on them.
57 //
58 // That means to change the way your project is build, reimplemnt
59 // this class and add your Step to the buildStep list of the project.
60 //
61 // Note: The projects own the buildstep, do not delete them yourself.
62 //
63 // init() is called in the GUI thread and can be used to query the
64 // project for any information you need.
65 //
66 // run() is run via QtConccurrent in a own thread, if you need an
67 // eventloop you need to create it yourself!
68 //
69 */
70
71 class BuildStepConfigWidget;
72
73 class PROJECTEXPLORER_EXPORT BuildStep : public ProjectConfiguration
74 {
75     Q_OBJECT
76
77 protected:
78     BuildStep(BuildStepList *bsl, const QString &id);
79     BuildStep(BuildStepList *bsl, BuildStep *bs);
80
81 public:
82     virtual ~BuildStep();
83
84     // This function is run in the gui thread,
85     // use it to retrieve any information that you need in run()
86     virtual bool init() = 0;
87
88     // Reimplement this. This function is called when the target is build.
89     // This function is NOT run in the gui thread. It runs in its own thread
90     // If you need an event loop, you need to create one.
91     // The absolute minimal implementation is:
92     // fi.reportResult(true);
93     virtual void run(QFutureInterface<bool> &fi) = 0;
94
95     // the Widget shown in the target settings dialog for this buildStep
96     // ownership is transferred to the caller
97     virtual BuildStepConfigWidget *createConfigWidget() = 0;
98
99     // if this function returns true, the user can't delete this BuildStep for this target
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     BuildConfiguration *buildConfiguration() const;
105     DeployConfiguration *deployConfiguration() const;
106     Target *target() const;
107
108     enum OutputFormat { NormalOutput, ErrorOutput, MessageOutput, ErrorMessageOutput };
109     enum OutputNewlineSetting { DoAppendNewline, DontAppendNewline };
110
111 signals:
112     // Add a task.
113     void addTask(const ProjectExplorer::Task &task);
114
115     // The string is added to the generated output, usually in the output
116     // window.
117     // It should be in plain text, with the format in the parameter
118     void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format,
119         ProjectExplorer::BuildStep::OutputNewlineSetting newlineSetting = DoAppendNewline);
120 };
121
122 class PROJECTEXPLORER_EXPORT IBuildStepFactory :
123     public QObject
124 {
125     Q_OBJECT
126
127 public:
128     explicit IBuildStepFactory(QObject *parent = 0);
129     virtual ~IBuildStepFactory();
130
131     // used to show the list of possible additons to a target, returns a list of types
132     virtual QStringList availableCreationIds(BuildStepList *parent) const = 0;
133     // used to translate the types to names to display to the user
134     virtual QString displayNameForId(const QString &id) const = 0;
135
136     virtual bool canCreate(BuildStepList *parent, const QString &id) const = 0;
137     virtual BuildStep *create(BuildStepList *parent, const QString &id) = 0;
138     // used to recreate the runConfigurations when restoring settings
139     virtual bool canRestore(BuildStepList *parent, const QVariantMap &map) const = 0;
140     virtual BuildStep *restore(BuildStepList *parent, const QVariantMap &map) = 0;
141     virtual bool canClone(BuildStepList *parent, BuildStep *product) const = 0;
142     virtual BuildStep *clone(BuildStepList *parent, BuildStep *product) = 0;
143 };
144
145 class PROJECTEXPLORER_EXPORT BuildConfigWidget
146     : public QWidget
147 {
148     Q_OBJECT
149 public:
150     BuildConfigWidget()
151         :QWidget(0)
152         {}
153
154     virtual QString displayName() const = 0;
155
156     // This is called to set up the config widget before showing it
157     virtual void init(BuildConfiguration *bc) = 0;
158
159 signals:
160     void displayNameChanged(const QString &);
161 };
162
163 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
164     : public QWidget
165 {
166     Q_OBJECT
167 public:
168     BuildStepConfigWidget()
169         : QWidget()
170         {}
171     virtual void init() = 0;
172     virtual QString summaryText() const = 0;
173     virtual QString displayName() const = 0;
174 signals:
175     void updateSummary();
176 };
177
178 } // namespace ProjectExplorer
179
180 Q_DECLARE_METATYPE(ProjectExplorer::BuildStep::OutputFormat)
181 Q_DECLARE_METATYPE(ProjectExplorer::BuildStep::OutputNewlineSetting)
182
183 #endif // BUILDSTEP_H