1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Designer of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef QWIZARD_CONTAINER_H
30#define QWIZARD_CONTAINER_H
31
32#include <QtDesigner/container.h>
33
34#include <qdesigner_propertysheet_p.h>
35#include <extensionfactory_p.h>
36
37#include <QtWidgets/qwizard.h>
38
39QT_BEGIN_NAMESPACE
40
41class QWizardPage;
42
43namespace qdesigner_internal {
44
45// Container for QWizard. Care must be taken to position
46// the QWizard at some valid page after removal/insertion
47// as it is not used to having its pages ripped out.
48class QWizardContainer: public QObject, public QDesignerContainerExtension
49{
50 Q_OBJECT
51 Q_INTERFACES(QDesignerContainerExtension)
52public:
53 explicit QWizardContainer(QWizard *widget, QObject *parent = nullptr);
54
55 int count() const override;
56 QWidget *widget(int index) const override;
57 int currentIndex() const override;
58 void setCurrentIndex(int index) override;
59 void addWidget(QWidget *widget) override;
60 void insertWidget(int index, QWidget *widget) override;
61 void remove(int index) override;
62
63private:
64 QWizard *m_wizard;
65};
66
67// QWizardPagePropertySheet: Introduces a attribute string fake property
68// "pageId" that allows for specifying enumeration values (uic only).
69// This breaks the pattern of having a "currentSth" property for the
70// container, but was deemed to make sense here since the Page has
71// its own "title" properties.
72class QWizardPagePropertySheet: public QDesignerPropertySheet
73{
74 Q_OBJECT
75public:
76 explicit QWizardPagePropertySheet(QWizardPage *object, QObject *parent = nullptr);
77
78 bool reset(int index) override;
79
80 static const char *pageIdProperty;
81
82private:
83 const int m_pageIdIndex;
84};
85
86// QWizardPropertySheet: Hides the "startId" property. It cannot be used
87// as QWizard cannot handle setting it as a property before the actual
88// page is added.
89
90class QWizardPropertySheet: public QDesignerPropertySheet
91{
92 Q_OBJECT
93public:
94 explicit QWizardPropertySheet(QWizard *object, QObject *parent = nullptr);
95 bool isVisible(int index) const override;
96
97private:
98 const QString m_startId;
99};
100
101// Factories
102using QWizardPropertySheetFactory = QDesignerPropertySheetFactory<QWizard, QWizardPropertySheet>;
103using QWizardPagePropertySheetFactory = QDesignerPropertySheetFactory<QWizardPage, QWizardPagePropertySheet>;
104using QWizardContainerFactory = ExtensionFactory<QDesignerContainerExtension, QWizard, QWizardContainer>;
105} // namespace qdesigner_internal
106
107QT_END_NAMESPACE
108
109#endif // QWIZARD_CONTAINER_H
110

source code of qttools/src/designer/src/components/formeditor/qwizard_container.h