OSDN Git Service

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