iwizardfactory.h 4.67 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 {

43
44
namespace Internal { class CorePlugin; }

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

62
    IWizardFactory() : m_kind(FileWizard) { }
hjk's avatar
hjk committed
63

Tobias Hunger's avatar
Tobias Hunger committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    QString id() const { return m_id; }
    WizardKind kind() const { return m_kind; }
    QIcon icon() const { return m_icon; }
    QString description() const { return m_description; }
    QString displayName() const { return m_displayName; }
    QString category() const { return m_category; }
    QString displayCategory() const { return m_displayCategory; }
    QString descriptionImage() const { return m_descriptionImage; }
    FeatureSet requiredFeatures() const { return m_requiredFeatures; }
    WizardFlags flags() const { return m_flags; }

    void setId(const QString &id) { m_id = id; }
    void setWizardKind(WizardKind kind) { m_kind = kind; }
    void setIcon(const QIcon &icon) { m_icon = icon; }
    void setDescription(const QString &description) { m_description = description; }
    void setDisplayName(const QString &displayName) { m_displayName = displayName; }
    void setCategory(const QString &category) { m_category = category; }
    void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
    void setDescriptionImage(const QString &descriptionImage) { m_descriptionImage = descriptionImage; }
    void setRequiredFeatures(const FeatureSet &featureSet) { m_requiredFeatures = featureSet; }
    void addRequiredFeature(const Feature &feature) { m_requiredFeatures |= feature; }
    void setFlags(WizardFlags flags) { m_flags = flags; }
86

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

89
90
    bool isAvailable(const QString &platformName) const;
    QStringList supportedPlatforms() const;
91

92
    // Utility to find all registered wizards
Tobias Hunger's avatar
Tobias Hunger committed
93
    static QList<IWizardFactory*> allWizardFactories();
94
    // Utility to find all registered wizards of a certain kind
Tobias Hunger's avatar
Tobias Hunger committed
95
    static QList<IWizardFactory*> wizardFactoriesOfKind(WizardKind kind);
96
97
    static QStringList allAvailablePlatforms();
    static QString displayNameForPlatform(const QString &string);
hjk's avatar
hjk committed
98

99
100
    static void registerFeatureProvider(IFeatureProvider *provider);

hjk's avatar
hjk committed
101
private:
102
103
    static void destroyFeatureProvider();

Tobias Hunger's avatar
Tobias Hunger committed
104
105
106
107
108
109
110
111
112
113
    IWizardFactory::WizardKind m_kind;
    QIcon m_icon;
    QString m_description;
    QString m_displayName;
    QString m_id;
    QString m_category;
    QString m_displayCategory;
    FeatureSet m_requiredFeatures;
    WizardFlags m_flags;
    QString m_descriptionImage;
114
115

    friend class Internal::CorePlugin;
con's avatar
con committed
116
};
hjk's avatar
hjk committed
117

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

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

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