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
22QT_BEGIN_NAMESPACE
23
24class QRegularExpression;
25
26class QtVariantPropertyManager;
27
28class QtVariantProperty : public QtProperty
29{
30public:
31 ~QtVariantProperty() override;
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);
39protected:
40 QtVariantProperty(QtVariantPropertyManager *manager);
41private:
42 friend class QtVariantPropertyManager;
43 QScopedPointer<class QtVariantPropertyPrivate> d_ptr;
44};
45
46class QtVariantPropertyManager : public QtAbstractPropertyManager
47{
48 Q_OBJECT
49public:
50 QtVariantPropertyManager(QObject *parent = nullptr);
51 ~QtVariantPropertyManager() override;
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();
71public Q_SLOTS:
72 virtual void setValue(QtProperty *property, const QVariant &val);
73 virtual void setAttribute(QtProperty *property,
74 const QString &attribute, const QVariant &value);
75Q_SIGNALS:
76 void valueChanged(QtProperty *property, const QVariant &val);
77 void attributeChanged(QtProperty *property,
78 const QString &attribute, const QVariant &val);
79protected:
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;
86private:
87 QScopedPointer<class QtVariantPropertyManagerPrivate> d_ptr;
88 Q_DECLARE_PRIVATE(QtVariantPropertyManager)
89 Q_DISABLE_COPY_MOVE(QtVariantPropertyManager)
90};
91
92class QtVariantEditorFactory : public QtAbstractEditorFactory<QtVariantPropertyManager>
93{
94 Q_OBJECT
95public:
96 QtVariantEditorFactory(QObject *parent = nullptr);
97 ~QtVariantEditorFactory() override;
98
99protected:
100 void connectPropertyManager(QtVariantPropertyManager *manager) override;
101 QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property,
102 QWidget *parent) override;
103 void disconnectPropertyManager(QtVariantPropertyManager *manager) override;
104private:
105 QScopedPointer<class QtVariantEditorFactoryPrivate> d_ptr;
106 Q_DECLARE_PRIVATE(QtVariantEditorFactory)
107 Q_DISABLE_COPY_MOVE(QtVariantEditorFactory)
108};
109
110QT_END_NAMESPACE
111
112#endif
113

source code of qttools/src/shared/qtpropertybrowser/qtvariantproperty_p.h