OSDN Git Service

Merge remote-tracking branch 'origin/2.3'
[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 info@qt.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 class BuildStepConfigWidget;
51
52 // Documentation inside.
53 class PROJECTEXPLORER_EXPORT BuildStep : public ProjectConfiguration
54 {
55     Q_OBJECT
56
57 protected:
58     BuildStep(BuildStepList *bsl, const QString &id);
59     BuildStep(BuildStepList *bsl, BuildStep *bs);
60
61 public:
62     virtual ~BuildStep();
63
64     virtual bool init() = 0;
65
66     virtual void run(QFutureInterface<bool> &fi) = 0;
67
68     virtual BuildStepConfigWidget *createConfigWidget() = 0;
69
70     virtual bool immutable() const;
71     virtual bool runInGuiThread() const;
72     virtual void cancel();
73
74     BuildConfiguration *buildConfiguration() const;
75     DeployConfiguration *deployConfiguration() const;
76     Target *target() const;
77
78     enum OutputFormat { NormalOutput, ErrorOutput, MessageOutput, ErrorMessageOutput };
79     enum OutputNewlineSetting { DoAppendNewline, DontAppendNewline };
80
81 signals:
82     void addTask(const ProjectExplorer::Task &task);
83
84     void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format,
85         ProjectExplorer::BuildStep::OutputNewlineSetting newlineSetting = DoAppendNewline) const;
86
87     void finished();
88 };
89
90 class PROJECTEXPLORER_EXPORT IBuildStepFactory :
91     public QObject
92 {
93     Q_OBJECT
94
95 public:
96     explicit IBuildStepFactory(QObject *parent = 0);
97     virtual ~IBuildStepFactory();
98
99     // used to show the list of possible additons to a target, returns a list of types
100     virtual QStringList availableCreationIds(BuildStepList *parent) const = 0;
101     // used to translate the types to names to display to the user
102     virtual QString displayNameForId(const QString &id) const = 0;
103
104     virtual bool canCreate(BuildStepList *parent, const QString &id) const = 0;
105     virtual BuildStep *create(BuildStepList *parent, const QString &id) = 0;
106     // used to recreate the runConfigurations when restoring settings
107     virtual bool canRestore(BuildStepList *parent, const QVariantMap &map) const = 0;
108     virtual BuildStep *restore(BuildStepList *parent, const QVariantMap &map) = 0;
109     virtual bool canClone(BuildStepList *parent, BuildStep *product) const = 0;
110     virtual BuildStep *clone(BuildStepList *parent, BuildStep *product) = 0;
111 };
112
113 class PROJECTEXPLORER_EXPORT BuildConfigWidget
114     : public QWidget
115 {
116     Q_OBJECT
117 public:
118     BuildConfigWidget()
119         :QWidget(0)
120         {}
121
122     virtual QString displayName() const = 0;
123
124     // This is called to set up the config widget before showing it
125     virtual void init(BuildConfiguration *bc) = 0;
126
127 signals:
128     void displayNameChanged(const QString &);
129 };
130
131 class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
132     : public QWidget
133 {
134     Q_OBJECT
135 public:
136     BuildStepConfigWidget()
137         : QWidget()
138         {}
139     virtual QString summaryText() const = 0;
140     virtual QString displayName() const = 0;
141 signals:
142     void updateSummary();
143 };
144
145 } // namespace ProjectExplorer
146
147 Q_DECLARE_METATYPE(ProjectExplorer::BuildStep::OutputFormat)
148 Q_DECLARE_METATYPE(ProjectExplorer::BuildStep::OutputNewlineSetting)
149
150 #endif // BUILDSTEP_H