qtvariantproperty.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the Qt Solutions component.
7**
8** $QT_BEGIN_LICENSE:BSD$
9** You may use this file under the terms of the BSD license as follows:
10**
11** "Redistribution and use in source and binary forms, with or without
12** modification, are permitted provided that the following conditions are
13** met:
14** * Redistributions of source code must retain the above copyright
15** notice, this list of conditions and the following disclaimer.
16** * Redistributions in binary form must reproduce the above copyright
17** notice, this list of conditions and the following disclaimer in
18** the documentation and/or other materials provided with the
19** distribution.
20** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21** of its contributors may be used to endorse or promote products derived
22** from this software without specific prior written permission.
23**
24**
25** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41
42#pragma once
43
44#include <QIcon>
45#include <QVariant>
46
47#include "qtpropertybrowser.h"
48
49QT_BEGIN_NAMESPACE
50
51using QtIconMap = QMap<int, QIcon>;
52
55
57{
58public:
59 ~QtVariantProperty() override;
60 QVariant value() const;
61 QVariant attributeValue(const QString& attribute) const;
62 int valueType() const;
63 int propertyType() const;
64
65 void setValue(const QVariant& value);
66 void setAttribute(const QString& attribute, const QVariant& value);
67
68protected:
70
71private:
74};
75
77
79{
80 Q_OBJECT
81public:
82 QtVariantPropertyManager(QObject* parent = 0);
84
85 virtual QtVariantProperty* addProperty(int propertyType, const QString& name = QString());
86
87 int propertyType(const QtProperty* property) const;
88 int valueType(const QtProperty* property) const;
89 QtVariantProperty* variantProperty(const QtProperty* property) const;
90
91 virtual bool isPropertyTypeSupported(int propertyType) const;
92 virtual int valueType(int propertyType) const;
93 virtual QStringList attributes(int propertyType) const;
94 virtual int attributeType(int propertyType, const QString& attribute) const;
95
96 virtual QVariant value(const QtProperty* property) const;
97 virtual QVariant attributeValue(const QtProperty* property, const QString& attribute) const;
98
99 static int enumTypeId();
100 static int flagTypeId();
101 static int groupTypeId();
102 static int iconMapTypeId();
103public Q_SLOTS:
104 virtual void setValue(QtProperty* property, const QVariant& val);
105 virtual void
106 setAttribute(QtProperty* property, const QString& attribute, const QVariant& value);
107Q_SIGNALS:
108 void valueChanged(QtProperty* property, const QVariant& val);
109 void attributeChanged(QtProperty* property, const QString& attribute, const QVariant& val);
110
111protected:
112 bool hasValue(const QtProperty* property) const override;
113 QString valueText(const QtProperty* property) const override;
114 QIcon valueIcon(const QtProperty* property) const override;
115 void initializeProperty(QtProperty* property) override;
116 void uninitializeProperty(QtProperty* property) override;
117 QtProperty* createProperty() override;
118
119private:
121 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, int))
122 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, int, int))
123 Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty*, int))
124 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, double))
125 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, double, double))
126 Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty*, double))
127 Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty*, int))
128 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, bool))
129 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QString&))
130 Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty*, const QRegExp&))
131 Q_PRIVATE_SLOT(d_func(), void slotEchoModeChanged(QtProperty*, int))
132 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QDate&))
133 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, const QDate&, const QDate&))
134 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QTime&))
135 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QDateTime&))
136 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QKeySequence&))
137 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QChar&))
138 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QLocale&))
139 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QPoint&))
140 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QPointF&))
141 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QSize&))
142 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, const QSize&, const QSize&))
143 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QSizeF&))
144 Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, const QSizeF&, const QSizeF&))
145 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QRect&))
146 Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty*, const QRect&))
147 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QRectF&))
148 Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty*, const QRectF&))
149 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QColor&))
150 Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty*, const QStringList&))
151 Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty*, const QMap<int, QIcon>&))
152 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QSizePolicy&))
153 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QFont&))
154 Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QCursor&))
155 Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty*, const QStringList&))
156 Q_PRIVATE_SLOT(d_func(), void slotReadOnlyChanged(QtProperty*, bool))
157 Q_PRIVATE_SLOT(d_func(), void slotTextVisibleChanged(QtProperty*, bool))
158 Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))
159 Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty*, QtProperty*))
160 Q_DECLARE_PRIVATE(QtVariantPropertyManager)
161 Q_DISABLE_COPY(QtVariantPropertyManager)
162};
163
165
167 public QtAbstractEditorFactory<QtVariantPropertyManager>
168{
169 Q_OBJECT
170public:
171 QtVariantEditorFactory(QObject* parent = 0);
172 ~QtVariantEditorFactory() override;
173
174protected:
175 void connectPropertyManager(QtVariantPropertyManager* manager) override;
176 QWidget*
177 createEditor(QtVariantPropertyManager* manager, QtProperty* property, QWidget* parent) override;
179
180private:
182 Q_DECLARE_PRIVATE(QtVariantEditorFactory)
183 Q_DISABLE_COPY(QtVariantEditorFactory)
184};
185
186QT_END_NAMESPACE
187
188Q_DECLARE_METATYPE(QIcon)
189Q_DECLARE_METATYPE(QtIconMap)
QtAbstractPropertyManager(QObject *parent=0)
The QtProperty class encapsulates an instance of a property.
QIcon valueIcon() const
QString valueText() const
QtProperty(QtAbstractPropertyManager *manager)
bool hasValue() const
void connectPropertyManager(QtVariantPropertyManager *manager) override
void disconnectPropertyManager(QtVariantPropertyManager *manager) override
QWidget * createEditor(QtVariantPropertyManager *manager, QtProperty *property, QWidget *parent) override
QtVariantEditorFactory(QObject *parent=0)
The QtVariantPropertyManager class provides and manages QVariant based properties.
void initializeProperty(QtProperty *property) override
virtual QtVariantProperty * addProperty(int propertyType, const QString &name=QString())
QtVariantProperty * variantProperty(const QtProperty *property) const
virtual QVariant value(const QtProperty *property) const
QtVariantPropertyManager(QObject *parent=0)
QtProperty * createProperty() override
virtual int attributeType(int propertyType, const QString &attribute) const
virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const
virtual void setValue(QtProperty *property, const QVariant &val)
void valueChanged(QtProperty *property, const QVariant &val)
void uninitializeProperty(QtProperty *property) override
virtual void setAttribute(QtProperty *property, const QString &attribute, const QVariant &value)
virtual bool isPropertyTypeSupported(int propertyType) const
virtual QStringList attributes(int propertyType) const
int propertyType(const QtProperty *property) const
int valueType(const QtProperty *property) const
void attributeChanged(QtProperty *property, const QString &attribute, const QVariant &val)
The QtVariantProperty class is a convenience class handling QVariant based properties.
QVariant value() const
QtVariantProperty(QtVariantPropertyManager *manager)
void setAttribute(const QString &attribute, const QVariant &value)
friend class QtVariantPropertyManager
QVariant attributeValue(const QString &attribute) const
void setValue(const QVariant &value)
#define QT_QTPROPERTYBROWSER_EXPORT
QMap< int, QIcon > QtIconMap