OSDN Git Service

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