1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the Qt API. It exists for the convenience |
9 | // of Qt Designer. This header file may change from version to version |
10 | // without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | // |
14 | |
15 | #ifndef QTVARIANTPROPERTY_H |
16 | #define QTVARIANTPROPERTY_H |
17 | |
18 | #include "qtpropertybrowser_p.h" |
19 | #include <QtCore/QVariant> |
20 | #include <QtGui/QIcon> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class QRegularExpression; |
25 | |
26 | class QtVariantPropertyManager; |
27 | |
28 | class QtVariantProperty : public QtProperty |
29 | { |
30 | public: |
31 | ~QtVariantProperty(); |
32 | QVariant value() const; |
33 | QVariant attributeValue(const QString &attribute) const; |
34 | int valueType() const; |
35 | int propertyType() const; |
36 | |
37 | void setValue(const QVariant &value); |
38 | void setAttribute(const QString &attribute, const QVariant &value); |
39 | protected: |
40 | QtVariantProperty(QtVariantPropertyManager *manager); |
41 | private: |
42 | friend class QtVariantPropertyManager; |
43 | QScopedPointer<class QtVariantPropertyPrivate> d_ptr; |
44 | }; |
45 | |
46 | class QtVariantPropertyManager : public QtAbstractPropertyManager |
47 | { |
48 | Q_OBJECT |
49 | public: |
50 | QtVariantPropertyManager(QObject *parent = 0); |
51 | ~QtVariantPropertyManager(); |
52 | |
53 | virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString()); |
54 | |
55 | int propertyType(const QtProperty *property) const; |
56 | int valueType(const QtProperty *property) const; |
57 | QtVariantProperty *variantProperty(const QtProperty *property) const; |
58 | |
59 | virtual bool isPropertyTypeSupported(int propertyType) const; |
60 | virtual int valueType(int propertyType) const; |
61 | virtual QStringList attributes(int propertyType) const; |
62 | virtual int attributeType(int propertyType, const QString &attribute) const; |
63 | |
64 | virtual QVariant value(const QtProperty *property) const; |
65 | virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const; |
66 | |
67 | static int enumTypeId(); |
68 | static int flagTypeId(); |
69 | static int groupTypeId(); |
70 | static int iconMapTypeId(); |
71 | public Q_SLOTS: |
72 | virtual void setValue(QtProperty *property, const QVariant &val); |
73 | virtual void setAttribute(QtProperty *property, |
74 | const QString &attribute, const QVariant &value); |
75 | Q_SIGNALS: |
76 | void valueChanged(QtProperty *property, const QVariant &val); |
77 | void attributeChanged(QtProperty *property, |
78 | const QString &attribute, const QVariant &val); |
79 | protected: |
80 | bool hasValue(const QtProperty *property) const override; |
81 | QString valueText(const QtProperty *property) const override; |
82 | QIcon valueIcon(const QtProperty *property) const override; |
83 | void initializeProperty(QtProperty *property) override; |
84 | void uninitializeProperty(QtProperty *property) override; |
85 | QtProperty *createProperty() override; |
86 | private: |
87 | QScopedPointer<class QtVariantPropertyManagerPrivate> d_ptr; |
88 | Q_DECLARE_PRIVATE(QtVariantPropertyManager) |
89 | Q_DISABLE_COPY_MOVE(QtVariantPropertyManager) |
90 | }; |
91 | |
92 | class QtVariantEditorFactory : public QtAbstractEditorFactory<QtVariantPropertyManager> |
93 | { |
94 | Q_OBJECT |
95 | public: |
96 | QtVariantEditorFactory(QObject *parent = 0); |
97 | ~QtVariantEditorFactory(); |
98 | protected: |
99 | void connectPropertyManager(QtVariantPropertyManager *manager) override; |
100 | QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property, |
101 | QWidget *parent) override; |
102 | void disconnectPropertyManager(QtVariantPropertyManager *manager) override; |
103 | private: |
104 | QScopedPointer<class QtVariantEditorFactoryPrivate> d_ptr; |
105 | Q_DECLARE_PRIVATE(QtVariantEditorFactory) |
106 | Q_DISABLE_COPY_MOVE(QtVariantEditorFactory) |
107 | }; |
108 | |
109 | QT_END_NAMESPACE |
110 | |
111 | #endif |
112 | |