1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QTVARIANTPROPERTY_H
|
---|
43 | #define QTVARIANTPROPERTY_H
|
---|
44 |
|
---|
45 | #include "qtpropertybrowser.h"
|
---|
46 | #include <QtCore/QVariant>
|
---|
47 | #include <QtGui/QIcon>
|
---|
48 |
|
---|
49 | QT_BEGIN_NAMESPACE
|
---|
50 |
|
---|
51 | typedef QMap<int, QIcon> QtIconMap;
|
---|
52 |
|
---|
53 | class QtVariantPropertyManager;
|
---|
54 |
|
---|
55 | class QtVariantProperty : public QtProperty
|
---|
56 | {
|
---|
57 | public:
|
---|
58 | ~QtVariantProperty();
|
---|
59 | QVariant value() const;
|
---|
60 | QVariant attributeValue(const QString &attribute) const;
|
---|
61 | int valueType() const;
|
---|
62 | int propertyType() const;
|
---|
63 |
|
---|
64 | void setValue(const QVariant &value);
|
---|
65 | void setAttribute(const QString &attribute, const QVariant &value);
|
---|
66 | protected:
|
---|
67 | QtVariantProperty(QtVariantPropertyManager *manager);
|
---|
68 | private:
|
---|
69 | friend class QtVariantPropertyManager;
|
---|
70 | QScopedPointer<class QtVariantPropertyPrivate> d_ptr;
|
---|
71 | };
|
---|
72 |
|
---|
73 | class QtVariantPropertyManager : public QtAbstractPropertyManager
|
---|
74 | {
|
---|
75 | Q_OBJECT
|
---|
76 | public:
|
---|
77 | QtVariantPropertyManager(QObject *parent = 0);
|
---|
78 | ~QtVariantPropertyManager();
|
---|
79 |
|
---|
80 | virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString());
|
---|
81 |
|
---|
82 | int propertyType(const QtProperty *property) const;
|
---|
83 | int valueType(const QtProperty *property) const;
|
---|
84 | QtVariantProperty *variantProperty(const QtProperty *property) const;
|
---|
85 |
|
---|
86 | virtual bool isPropertyTypeSupported(int propertyType) const;
|
---|
87 | virtual int valueType(int propertyType) const;
|
---|
88 | virtual QStringList attributes(int propertyType) const;
|
---|
89 | virtual int attributeType(int propertyType, const QString &attribute) const;
|
---|
90 |
|
---|
91 | virtual QVariant value(const QtProperty *property) const;
|
---|
92 | virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const;
|
---|
93 |
|
---|
94 | static int enumTypeId();
|
---|
95 | static int flagTypeId();
|
---|
96 | static int groupTypeId();
|
---|
97 | static int iconMapTypeId();
|
---|
98 | public Q_SLOTS:
|
---|
99 | virtual void setValue(QtProperty *property, const QVariant &val);
|
---|
100 | virtual void setAttribute(QtProperty *property,
|
---|
101 | const QString &attribute, const QVariant &value);
|
---|
102 | Q_SIGNALS:
|
---|
103 | void valueChanged(QtProperty *property, const QVariant &val);
|
---|
104 | void attributeChanged(QtProperty *property,
|
---|
105 | const QString &attribute, const QVariant &val);
|
---|
106 | protected:
|
---|
107 | virtual bool hasValue(const QtProperty *property) const;
|
---|
108 | QString valueText(const QtProperty *property) const;
|
---|
109 | QIcon valueIcon(const QtProperty *property) const;
|
---|
110 | virtual void initializeProperty(QtProperty *property);
|
---|
111 | virtual void uninitializeProperty(QtProperty *property);
|
---|
112 | virtual QtProperty *createProperty();
|
---|
113 | private:
|
---|
114 | QScopedPointer<class QtVariantPropertyManagerPrivate> d_ptr;
|
---|
115 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int))
|
---|
116 | Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
|
---|
117 | Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
|
---|
118 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double))
|
---|
119 | Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double))
|
---|
120 | Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double))
|
---|
121 | Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int))
|
---|
122 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool))
|
---|
123 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &))
|
---|
124 | Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &))
|
---|
125 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDate &))
|
---|
126 | Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QDate &, const QDate &))
|
---|
127 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QTime &))
|
---|
128 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDateTime &))
|
---|
129 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QKeySequence &))
|
---|
130 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &))
|
---|
131 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &))
|
---|
132 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &))
|
---|
133 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &))
|
---|
134 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &))
|
---|
135 | Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, const QSize &))
|
---|
136 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &))
|
---|
137 | Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &))
|
---|
138 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &))
|
---|
139 | Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRect &))
|
---|
140 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &))
|
---|
141 | Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRectF &))
|
---|
142 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &))
|
---|
143 | Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, const QStringList &))
|
---|
144 | Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &))
|
---|
145 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizePolicy &))
|
---|
146 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &))
|
---|
147 | Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &))
|
---|
148 | Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &))
|
---|
149 |
|
---|
150 | Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))
|
---|
151 | Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *))
|
---|
152 | Q_DECLARE_PRIVATE(QtVariantPropertyManager)
|
---|
153 | Q_DISABLE_COPY(QtVariantPropertyManager)
|
---|
154 | };
|
---|
155 |
|
---|
156 | class QtVariantEditorFactory : public QtAbstractEditorFactory<QtVariantPropertyManager>
|
---|
157 | {
|
---|
158 | Q_OBJECT
|
---|
159 | public:
|
---|
160 | QtVariantEditorFactory(QObject *parent = 0);
|
---|
161 | ~QtVariantEditorFactory();
|
---|
162 | protected:
|
---|
163 | void connectPropertyManager(QtVariantPropertyManager *manager);
|
---|
164 | QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property,
|
---|
165 | QWidget *parent);
|
---|
166 | void disconnectPropertyManager(QtVariantPropertyManager *manager);
|
---|
167 | private:
|
---|
168 | QScopedPointer<class QtVariantEditorFactoryPrivate> d_ptr;
|
---|
169 | Q_DECLARE_PRIVATE(QtVariantEditorFactory)
|
---|
170 | Q_DISABLE_COPY(QtVariantEditorFactory)
|
---|
171 | };
|
---|
172 |
|
---|
173 | QT_END_NAMESPACE
|
---|
174 |
|
---|
175 | Q_DECLARE_METATYPE(QIcon)
|
---|
176 | Q_DECLARE_METATYPE(QtIconMap)
|
---|
177 | #endif
|
---|