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#ifndef QTVARIANTPROPERTY_H
5#define QTVARIANTPROPERTY_H
6
7#include "qtpropertybrowser.h"
8#include <QtCore/QVariant>
9#include <QtGui/QIcon>
10
11QT_BEGIN_NAMESPACE
12
13class QRegularExpression;
14
15class QtVariantPropertyManager;
16
17class QtVariantProperty : public QtProperty
18{
19public:
20 ~QtVariantProperty();
21 QVariant value() const;
22 QVariant attributeValue(const QString &attribute) const;
23 int valueType() const;
24 int propertyType() const;
25
26 void setValue(const QVariant &value);
27 void setAttribute(const QString &attribute, const QVariant &value);
28protected:
29 QtVariantProperty(QtVariantPropertyManager *manager);
30private:
31 friend class QtVariantPropertyManager;
32 QScopedPointer<class QtVariantPropertyPrivate> d_ptr;
33};
34
35class QtVariantPropertyManager : public QtAbstractPropertyManager
36{
37 Q_OBJECT
38public:
39 QtVariantPropertyManager(QObject *parent = 0);
40 ~QtVariantPropertyManager();
41
42 virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString());
43
44 int propertyType(const QtProperty *property) const;
45 int valueType(const QtProperty *property) const;
46 QtVariantProperty *variantProperty(const QtProperty *property) const;
47
48 virtual bool isPropertyTypeSupported(int propertyType) const;
49 virtual int valueType(int propertyType) const;
50 virtual QStringList attributes(int propertyType) const;
51 virtual int attributeType(int propertyType, const QString &attribute) const;
52
53 virtual QVariant value(const QtProperty *property) const;
54 virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const;
55
56 static int enumTypeId();
57 static int flagTypeId();
58 static int groupTypeId();
59 static int iconMapTypeId();
60public Q_SLOTS:
61 virtual void setValue(QtProperty *property, const QVariant &val);
62 virtual void setAttribute(QtProperty *property,
63 const QString &attribute, const QVariant &value);
64Q_SIGNALS:
65 void valueChanged(QtProperty *property, const QVariant &val);
66 void attributeChanged(QtProperty *property,
67 const QString &attribute, const QVariant &val);
68protected:
69 bool hasValue(const QtProperty *property) const override;
70 QString valueText(const QtProperty *property) const override;
71 QIcon valueIcon(const QtProperty *property) const override;
72 void initializeProperty(QtProperty *property) override;
73 void uninitializeProperty(QtProperty *property) override;
74 QtProperty *createProperty() override;
75private:
76 QScopedPointer<class QtVariantPropertyManagerPrivate> d_ptr;
77 Q_DECLARE_PRIVATE(QtVariantPropertyManager)
78 Q_DISABLE_COPY_MOVE(QtVariantPropertyManager)
79};
80
81class QtVariantEditorFactory : public QtAbstractEditorFactory<QtVariantPropertyManager>
82{
83 Q_OBJECT
84public:
85 QtVariantEditorFactory(QObject *parent = 0);
86 ~QtVariantEditorFactory();
87protected:
88 void connectPropertyManager(QtVariantPropertyManager *manager) override;
89 QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property,
90 QWidget *parent) override;
91 void disconnectPropertyManager(QtVariantPropertyManager *manager) override;
92private:
93 QScopedPointer<class QtVariantEditorFactoryPrivate> d_ptr;
94 Q_DECLARE_PRIVATE(QtVariantEditorFactory)
95 Q_DISABLE_COPY_MOVE(QtVariantEditorFactory)
96};
97
98QT_END_NAMESPACE
99
100#endif
101

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