1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include "core_global.h"
#include "generatedfile.h"
#include <coreplugin/iwizardfactory.h>
#include <utils/filepath.h>
#include <QList>
#include <QVariantMap>
QT_BEGIN_NAMESPACE
class QWizard;
class QWizardPage;
QT_END_NAMESPACE
namespace Utils { class Wizard; }
namespace Core {
class BaseFileWizard;
class CORE_EXPORT WizardDialogParameters
{
public:
using WizardPageList = QList<QWizardPage *>;
enum DialogParameterEnum {
ForceCapitalLetterForFileName = 0x01
};
Q_DECLARE_FLAGS(DialogParameterFlags, DialogParameterEnum)
explicit WizardDialogParameters(const Utils::FilePath &defaultPath, Utils::Id platform,
const QSet<Utils::Id> &requiredFeatures, DialogParameterFlags flags,
const QVariantMap &extraValues)
: m_defaultPath(defaultPath),
m_selectedPlatform(platform),
m_requiredFeatures(requiredFeatures),
m_parameterFlags(flags),
m_extraValues(extraValues)
{}
Utils::FilePath defaultPath() const { return m_defaultPath; }
Utils::Id selectedPlatform() const { return m_selectedPlatform; }
QSet<Utils::Id> requiredFeatures() const { return m_requiredFeatures; }
DialogParameterFlags flags() const { return m_parameterFlags; }
QVariantMap extraValues() const { return m_extraValues; }
private:
Utils::FilePath m_defaultPath;
Utils::Id m_selectedPlatform;
QSet<Utils::Id> m_requiredFeatures;
DialogParameterFlags m_parameterFlags;
QVariantMap m_extraValues;
};
class CORE_EXPORT BaseFileWizardFactory : public IWizardFactory
{
Q_OBJECT
friend class BaseFileWizard;
public:
static Utils::FilePath buildFileName(const Utils::FilePath &path, const QString &baseName, const QString &extension);
protected:
virtual BaseFileWizard *create(QWidget *parent, const WizardDialogParameters ¶meters) const = 0;
virtual GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const = 0;
virtual bool writeFiles(const GeneratedFiles &files, QString *errorMessage) const;
virtual bool postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage) const;
static QString preferredSuffix(const QString &mimeType);
enum OverwriteResult { OverwriteOk, OverwriteError, OverwriteCanceled };
static OverwriteResult promptOverwrite(GeneratedFiles *files,
QString *errorMessage);
static bool postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = nullptr);
private:
Utils::Wizard *runWizardImpl(const Utils::FilePath &path, QWidget *parent, Utils::Id platform,
const QVariantMap &extraValues, bool showWizard = true) final;
};
} // namespace Core
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::GeneratedFile::Attributes)
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::WizardDialogParameters::DialogParameterFlags)
|