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 tools applications of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
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 Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QTVARIANTPROPERTY_H
41#define QTVARIANTPROPERTY_H
42
43#include "qtpropertybrowser.h"
44#include <QtCore/QVariant>
45#include <QtGui/QIcon>
46
47QT_BEGIN_NAMESPACE
48
49typedef QMap<int, QIcon> QtIconMap;
50
51class QtVariantPropertyManager;
52
53class QtVariantProperty : public QtProperty
54{
55public:
56 ~QtVariantProperty();
57 QVariant value() const;
58 QVariant attributeValue(const QString &attribute) const;
59 int valueType() const;
60 int propertyType() const;
61
62 void setValue(const QVariant &value);
63 void setAttribute(const QString &attribute, const QVariant &value);
64protected:
65 QtVariantProperty(QtVariantPropertyManager *manager);
66private:
67 friend class QtVariantPropertyManager;
68 QScopedPointer<class QtVariantPropertyPrivate> d_ptr;
69};
70
71class QtVariantPropertyManager : public QtAbstractPropertyManager
72{
73 Q_OBJECT
74public:
75 QtVariantPropertyManager(QObject *parent = 0);
76 ~QtVariantPropertyManager();
77
78 virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString());
79
80 int propertyType(const QtProperty *property) const;
81 int valueType(const QtProperty *property) const;
82 QtVariantProperty *variantProperty(const QtProperty *property) const;
83
84 virtual bool isPropertyTypeSupported(int propertyType) const;
85 virtual int valueType(int propertyType) const;
86 virtual QStringList attributes(int propertyType) const;
87 virtual int attributeType(int propertyType, const QString &attribute) const;
88
89 virtual QVariant value(const QtProperty *property) const;
90 virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const;
91
92 static int enumTypeId();
93 static int flagTypeId();
94 static int groupTypeId();
95 static int iconMapTypeId();
96public Q_SLOTS:
97 virtual void setValue(QtProperty *property, const QVariant &val);
98 virtual void setAttribute(QtProperty *property,
99 const QString &attribute, const QVariant &value);
100Q_SIGNALS:
101 void valueChanged(QtProperty *property, const QVariant &val);
102 void attributeChanged(QtProperty *property,
103 const QString &attribute, const QVariant &val);
104protected:
105 virtual bool hasValue(const QtProperty *property) const;
106 QString valueText(const QtProperty *property) const;
107 QIcon valueIcon(const QtProperty *property) const;
108 virtual void initializeProperty(QtProperty *property);
109 virtual void uninitializeProperty(QtProperty *property);
110 virtual QtProperty *createProperty();
111private:
112 QScopedPointer<class QtVariantPropertyManagerPrivate> d_ptr;
113 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int))
114 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
115 Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
116 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double))
117 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double))
118 Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double))
119 Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int))
120 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool))
121 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &))
122 Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &))
123 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDate &))
124 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QDate &, const QDate &))
125 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QTime &))
126 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDateTime &))
127 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QKeySequence &))
128 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &))
129 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &))
130 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &))
131 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &))
132 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &))
133 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, const QSize &))
134 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &))
135 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &))
136 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &))
137 Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRect &))
138 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &))
139 Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRectF &))
140 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &))
141 Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, const QStringList &))
142 Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &))
143 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizePolicy &))
144 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &))
145 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &))
146 Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &))
147
148 Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))
149 Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *))
150 Q_DECLARE_PRIVATE(QtVariantPropertyManager)
151 Q_DISABLE_COPY_MOVE(QtVariantPropertyManager)
152};
153
154class QtVariantEditorFactory : public QtAbstractEditorFactory<QtVariantPropertyManager>
155{
156 Q_OBJECT
157public:
158 QtVariantEditorFactory(QObject *parent = 0);
159 ~QtVariantEditorFactory();
160protected:
161 void connectPropertyManager(QtVariantPropertyManager *manager);
162 QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property,
163 QWidget *parent);
164 void disconnectPropertyManager(QtVariantPropertyManager *manager);
165private:
166 QScopedPointer<class QtVariantEditorFactoryPrivate> d_ptr;
167 Q_DECLARE_PRIVATE(QtVariantEditorFactory)
168 Q_DISABLE_COPY_MOVE(QtVariantEditorFactory)
169};
170
171QT_END_NAMESPACE
172
173Q_DECLARE_METATYPE(QIcon)
174Q_DECLARE_METATYPE(QtIconMap)
175#endif
176

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