iwizardfactory.h 4.77 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
**
hjk's avatar
hjk committed
24
25
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

Tobias Hunger's avatar
Tobias Hunger committed
30
31
#ifndef IWIZARDFACTORY_H
#define IWIZARDFACTORY_H
con's avatar
con committed
32
33

#include <coreplugin/core_global.h>
hjk's avatar
hjk committed
34
35
#include <coreplugin/id.h>
#include <coreplugin/featureprovider.h>
36

hjk's avatar
hjk committed
37
#include <QIcon>
38
#include <QObject>
39
#include <QVariantMap>
con's avatar
con committed
40
41
42

namespace Core {

Tobias Hunger's avatar
Tobias Hunger committed
43
class CORE_EXPORT IWizardFactory
con's avatar
con committed
44
45
46
47
    : public QObject
{
    Q_OBJECT
public:
48
49
50
51
    enum WizardKind {
        FileWizard = 0x01,
        ClassWizard = 0x02,
        ProjectWizard = 0x04
con's avatar
con committed
52
    };
53
    Q_DECLARE_FLAGS(WizardKinds, WizardKind)
54
    enum WizardFlag {
55
56
        PlatformIndependent = 0x01,
        ForceCapitalLetterForFileName = 0x02
57
58
    };
    Q_DECLARE_FLAGS(WizardFlags, WizardFlag)
con's avatar
con committed
59

hjk's avatar
hjk committed
60
61
62
    class CORE_EXPORT Data
    {
    public:
Tobias Hunger's avatar
Tobias Hunger committed
63
        Data() : kind(IWizardFactory::FileWizard) {}
hjk's avatar
hjk committed
64

Tobias Hunger's avatar
Tobias Hunger committed
65
        IWizardFactory::WizardKind kind;
hjk's avatar
hjk committed
66
67
68
69
70
71
72
        QIcon icon;
        QString description;
        QString displayName;
        QString id;
        QString category;
        QString displayCategory;
        FeatureSet requiredFeatures;
Tobias Hunger's avatar
Tobias Hunger committed
73
        IWizardFactory::WizardFlags flags;
hjk's avatar
hjk committed
74
75
        QString descriptionImage;
    };
76

Tobias Hunger's avatar
Tobias Hunger committed
77
    IWizardFactory() { }
hjk's avatar
hjk committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

    QString id() const { return m_data.id; }
    WizardKind kind() const { return m_data.kind; }
    QIcon icon() const { return m_data.icon; }
    QString description() const { return m_data.description; }
    QString displayName() const { return m_data.displayName; }
    QString category() const { return m_data.category; }
    QString displayCategory() const { return m_data.displayCategory; }
    QString descriptionImage() const { return m_data.descriptionImage; }
    FeatureSet requiredFeatures() const { return m_data.requiredFeatures; }
    WizardFlags flags() const { return m_data.flags; }

    void setData(const Data &data) { m_data = data; }
    void setId(const QString &id) { m_data.id = id; }
    void setWizardKind(WizardKind kind) { m_data.kind = kind; }
    void setIcon(const QIcon &icon) { m_data.icon = icon; }
    void setDescription(const QString &description) { m_data.description = description; }
    void setDisplayName(const QString &displayName) { m_data.displayName = displayName; }
    void setCategory(const QString &category) { m_data.category = category; }
    void setDisplayCategory(const QString &displayCategory) { m_data.displayCategory = displayCategory; }
    void setDescriptionImage(const QString &descriptionImage) { m_data.descriptionImage = descriptionImage; }
    void setRequiredFeatures(const FeatureSet &featureSet) { m_data.requiredFeatures = featureSet; }
    void addRequiredFeature(const Feature &feature) { m_data.requiredFeatures |= feature; }
    void setFlags(WizardFlags flags) { m_data.flags = flags; }
102

103
    virtual void runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &variables) = 0;
104

105
106
    bool isAvailable(const QString &platformName) const;
    QStringList supportedPlatforms() const;
107

108
    // Utility to find all registered wizards
Tobias Hunger's avatar
Tobias Hunger committed
109
    static QList<IWizardFactory*> allWizardFactories();
110
    // Utility to find all registered wizards of a certain kind
Tobias Hunger's avatar
Tobias Hunger committed
111
    static QList<IWizardFactory*> wizardFactoriesOfKind(WizardKind kind);
112
113
    static QStringList allAvailablePlatforms();
    static QString displayNameForPlatform(const QString &string);
hjk's avatar
hjk committed
114
115
116

private:
    Data m_data;
con's avatar
con committed
117
};
hjk's avatar
hjk committed
118

con's avatar
con committed
119
120
} // namespace Core

Tobias Hunger's avatar
Tobias Hunger committed
121
122
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizardFactory::WizardKinds)
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizardFactory::WizardFlags)
123

Tobias Hunger's avatar
Tobias Hunger committed
124
#endif // IWIZARDFACTORY_H