0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the tools applications of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#include "qtvariantproperty.h"
|
|
43 |
#include "qtpropertymanager.h"
|
|
44 |
#include "qteditorfactory.h"
|
|
45 |
#include <QtCore/QVariant>
|
|
46 |
#include <QtGui/QIcon>
|
|
47 |
#include <QtCore/QDate>
|
|
48 |
#include <QtCore/QLocale>
|
|
49 |
|
|
50 |
#if defined(Q_CC_MSVC)
|
|
51 |
# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */
|
|
52 |
#endif
|
|
53 |
|
|
54 |
QT_BEGIN_NAMESPACE
|
|
55 |
|
|
56 |
class QtEnumPropertyType
|
|
57 |
{
|
|
58 |
};
|
|
59 |
|
|
60 |
|
|
61 |
class QtFlagPropertyType
|
|
62 |
{
|
|
63 |
};
|
|
64 |
|
|
65 |
|
|
66 |
class QtGroupPropertyType
|
|
67 |
{
|
|
68 |
};
|
|
69 |
|
|
70 |
QT_END_NAMESPACE
|
|
71 |
|
|
72 |
Q_DECLARE_METATYPE(QtEnumPropertyType)
|
|
73 |
Q_DECLARE_METATYPE(QtFlagPropertyType)
|
|
74 |
Q_DECLARE_METATYPE(QtGroupPropertyType)
|
|
75 |
|
|
76 |
QT_BEGIN_NAMESPACE
|
|
77 |
|
|
78 |
/*!
|
|
79 |
Returns the type id for an enum property.
|
|
80 |
|
|
81 |
Note that the property's value type can be retrieved using the
|
|
82 |
valueType() function (which is QVariant::Int for the enum property
|
|
83 |
type).
|
|
84 |
|
|
85 |
\sa propertyType(), valueType()
|
|
86 |
*/
|
|
87 |
int QtVariantPropertyManager::enumTypeId()
|
|
88 |
{
|
|
89 |
return qMetaTypeId<QtEnumPropertyType>();
|
|
90 |
}
|
|
91 |
|
|
92 |
/*!
|
|
93 |
Returns the type id for a flag property.
|
|
94 |
|
|
95 |
Note that the property's value type can be retrieved using the
|
|
96 |
valueType() function (which is QVariant::Int for the flag property
|
|
97 |
type).
|
|
98 |
|
|
99 |
\sa propertyType(), valueType()
|
|
100 |
*/
|
|
101 |
int QtVariantPropertyManager::flagTypeId()
|
|
102 |
{
|
|
103 |
return qMetaTypeId<QtFlagPropertyType>();
|
|
104 |
}
|
|
105 |
|
|
106 |
/*!
|
|
107 |
Returns the type id for a group property.
|
|
108 |
|
|
109 |
Note that the property's value type can be retrieved using the
|
|
110 |
valueType() function (which is QVariant::Invalid for the group
|
|
111 |
property type, since it doesn't provide any value).
|
|
112 |
|
|
113 |
\sa propertyType(), valueType()
|
|
114 |
*/
|
|
115 |
int QtVariantPropertyManager::groupTypeId()
|
|
116 |
{
|
|
117 |
return qMetaTypeId<QtGroupPropertyType>();
|
|
118 |
}
|
|
119 |
|
|
120 |
/*!
|
|
121 |
Returns the type id for a icon map attribute.
|
|
122 |
|
|
123 |
Note that the property's attribute type can be retrieved using the
|
|
124 |
attributeType() function.
|
|
125 |
|
|
126 |
\sa attributeType(), QtEnumPropertyManager::enumIcons()
|
|
127 |
*/
|
|
128 |
int QtVariantPropertyManager::iconMapTypeId()
|
|
129 |
{
|
|
130 |
return qMetaTypeId<QtIconMap>();
|
|
131 |
}
|
|
132 |
|
|
133 |
typedef QMap<const QtProperty *, QtProperty *> PropertyMap;
|
|
134 |
Q_GLOBAL_STATIC(PropertyMap, propertyToWrappedProperty)
|
|
135 |
|
|
136 |
static QtProperty *wrappedProperty(QtProperty *property)
|
|
137 |
{
|
|
138 |
return propertyToWrappedProperty()->value(property, 0);
|
|
139 |
}
|
|
140 |
|
|
141 |
class QtVariantPropertyPrivate
|
|
142 |
{
|
|
143 |
QtVariantProperty *q_ptr;
|
|
144 |
public:
|
|
145 |
QtVariantPropertyPrivate(QtVariantPropertyManager *m) : manager(m) {}
|
|
146 |
|
|
147 |
QtVariantPropertyManager *manager;
|
|
148 |
};
|
|
149 |
|
|
150 |
/*!
|
|
151 |
\class QtVariantProperty
|
|
152 |
\internal
|
|
153 |
\inmodule QtDesigner
|
|
154 |
\since 4.4
|
|
155 |
|
|
156 |
\brief The QtVariantProperty class is a convenience class handling
|
|
157 |
QVariant based properties.
|
|
158 |
|
|
159 |
QtVariantProperty provides additional API: A property's type,
|
|
160 |
value type, attribute values and current value can easily be
|
|
161 |
retrieved using the propertyType(), valueType(), attributeValue()
|
|
162 |
and value() functions respectively. In addition, the attribute
|
|
163 |
values and the current value can be set using the corresponding
|
|
164 |
setValue() and setAttribute() functions.
|
|
165 |
|
|
166 |
For example, instead of writing:
|
|
167 |
|
|
168 |
\snippet doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp 0
|
|
169 |
|
|
170 |
you can write:
|
|
171 |
|
|
172 |
\snippet doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp 1
|
|
173 |
|
|
174 |
QtVariantProperty instances can only be created by the
|
|
175 |
QtVariantPropertyManager class.
|
|
176 |
|
|
177 |
\sa QtProperty, QtVariantPropertyManager, QtVariantEditorFactory
|
|
178 |
*/
|
|
179 |
|
|
180 |
/*!
|
|
181 |
Creates a variant property using the given \a manager.
|
|
182 |
|
|
183 |
Do not use this constructor to create variant property instances;
|
|
184 |
use the QtVariantPropertyManager::addProperty() function
|
|
185 |
instead. This constructor is used internally by the
|
|
186 |
QtVariantPropertyManager::createProperty() function.
|
|
187 |
|
|
188 |
\sa QtVariantPropertyManager
|
|
189 |
*/
|
|
190 |
QtVariantProperty::QtVariantProperty(QtVariantPropertyManager *manager)
|
|
191 |
: QtProperty(manager), d_ptr(new QtVariantPropertyPrivate(manager))
|
|
192 |
{
|
|
193 |
}
|
|
194 |
|
|
195 |
/*!
|
|
196 |
Destroys this property.
|
|
197 |
|
|
198 |
\sa QtProperty::~QtProperty()
|
|
199 |
*/
|
|
200 |
QtVariantProperty::~QtVariantProperty()
|
|
201 |
{
|
|
202 |
}
|
|
203 |
|
|
204 |
/*!
|
|
205 |
Returns the property's current value.
|
|
206 |
|
|
207 |
\sa valueType(), setValue()
|
|
208 |
*/
|
|
209 |
QVariant QtVariantProperty::value() const
|
|
210 |
{
|
|
211 |
return d_ptr->manager->value(this);
|
|
212 |
}
|
|
213 |
|
|
214 |
/*!
|
|
215 |
Returns this property's value for the specified \a attribute.
|
|
216 |
|
|
217 |
QtVariantPropertyManager provides a couple of related functions:
|
|
218 |
\l{QtVariantPropertyManager::attributes()}{attributes()} and
|
|
219 |
\l{QtVariantPropertyManager::attributeType()}{attributeType()}.
|
|
220 |
|
|
221 |
\sa setAttribute()
|
|
222 |
*/
|
|
223 |
QVariant QtVariantProperty::attributeValue(const QString &attribute) const
|
|
224 |
{
|
|
225 |
return d_ptr->manager->attributeValue(this, attribute);
|
|
226 |
}
|
|
227 |
|
|
228 |
/*!
|
|
229 |
Returns the type of this property's value.
|
|
230 |
|
|
231 |
\sa propertyType()
|
|
232 |
*/
|
|
233 |
int QtVariantProperty::valueType() const
|
|
234 |
{
|
|
235 |
return d_ptr->manager->valueType(this);
|
|
236 |
}
|
|
237 |
|
|
238 |
/*!
|
|
239 |
Returns this property's type.
|
|
240 |
|
|
241 |
QtVariantPropertyManager provides several related functions:
|
|
242 |
\l{QtVariantPropertyManager::enumTypeId()}{enumTypeId()},
|
|
243 |
\l{QtVariantPropertyManager::flagTypeId()}{flagTypeId()} and
|
|
244 |
\l{QtVariantPropertyManager::groupTypeId()}{groupTypeId()}.
|
|
245 |
|
|
246 |
\sa valueType()
|
|
247 |
*/
|
|
248 |
int QtVariantProperty::propertyType() const
|
|
249 |
{
|
|
250 |
return d_ptr->manager->propertyType(this);
|
|
251 |
}
|
|
252 |
|
|
253 |
/*!
|
|
254 |
Sets the value of this property to \a value.
|
|
255 |
|
|
256 |
The specified \a value must be of the type returned by
|
|
257 |
valueType(), or of a type that can be converted to valueType()
|
|
258 |
using the QVariant::canConvert() function; otherwise this function
|
|
259 |
does nothing.
|
|
260 |
|
|
261 |
\sa value()
|
|
262 |
*/
|
|
263 |
void QtVariantProperty::setValue(const QVariant &value)
|
|
264 |
{
|
|
265 |
d_ptr->manager->setValue(this, value);
|
|
266 |
}
|
|
267 |
|
|
268 |
/*!
|
|
269 |
Sets the \a attribute of property to \a value.
|
|
270 |
|
|
271 |
QtVariantPropertyManager provides the related
|
|
272 |
\l{QtVariantPropertyManager::setAttribute()}{setAttribute()}
|
|
273 |
function.
|
|
274 |
|
|
275 |
\sa attributeValue()
|
|
276 |
*/
|
|
277 |
void QtVariantProperty::setAttribute(const QString &attribute, const QVariant &value)
|
|
278 |
{
|
|
279 |
d_ptr->manager->setAttribute(this, attribute, value);
|
|
280 |
}
|
|
281 |
|
|
282 |
class QtVariantPropertyManagerPrivate
|
|
283 |
{
|
|
284 |
QtVariantPropertyManager *q_ptr;
|
|
285 |
Q_DECLARE_PUBLIC(QtVariantPropertyManager)
|
|
286 |
public:
|
|
287 |
QtVariantPropertyManagerPrivate();
|
|
288 |
|
|
289 |
bool m_creatingProperty;
|
|
290 |
bool m_creatingSubProperties;
|
|
291 |
bool m_destroyingSubProperties;
|
|
292 |
int m_propertyType;
|
|
293 |
|
|
294 |
void slotValueChanged(QtProperty *property, int val);
|
|
295 |
void slotRangeChanged(QtProperty *property, int min, int max);
|
|
296 |
void slotSingleStepChanged(QtProperty *property, int step);
|
|
297 |
void slotValueChanged(QtProperty *property, double val);
|
|
298 |
void slotRangeChanged(QtProperty *property, double min, double max);
|
|
299 |
void slotSingleStepChanged(QtProperty *property, double step);
|
|
300 |
void slotDecimalsChanged(QtProperty *property, int prec);
|
|
301 |
void slotValueChanged(QtProperty *property, bool val);
|
|
302 |
void slotValueChanged(QtProperty *property, const QString &val);
|
|
303 |
void slotRegExpChanged(QtProperty *property, const QRegExp ®Exp);
|
|
304 |
void slotValueChanged(QtProperty *property, const QDate &val);
|
|
305 |
void slotRangeChanged(QtProperty *property, const QDate &min, const QDate &max);
|
|
306 |
void slotValueChanged(QtProperty *property, const QTime &val);
|
|
307 |
void slotValueChanged(QtProperty *property, const QDateTime &val);
|
|
308 |
void slotValueChanged(QtProperty *property, const QKeySequence &val);
|
|
309 |
void slotValueChanged(QtProperty *property, const QChar &val);
|
|
310 |
void slotValueChanged(QtProperty *property, const QLocale &val);
|
|
311 |
void slotValueChanged(QtProperty *property, const QPoint &val);
|
|
312 |
void slotValueChanged(QtProperty *property, const QPointF &val);
|
|
313 |
void slotValueChanged(QtProperty *property, const QSize &val);
|
|
314 |
void slotRangeChanged(QtProperty *property, const QSize &min, const QSize &max);
|
|
315 |
void slotValueChanged(QtProperty *property, const QSizeF &val);
|
|
316 |
void slotRangeChanged(QtProperty *property, const QSizeF &min, const QSizeF &max);
|
|
317 |
void slotValueChanged(QtProperty *property, const QRect &val);
|
|
318 |
void slotConstraintChanged(QtProperty *property, const QRect &val);
|
|
319 |
void slotValueChanged(QtProperty *property, const QRectF &val);
|
|
320 |
void slotConstraintChanged(QtProperty *property, const QRectF &val);
|
|
321 |
void slotValueChanged(QtProperty *property, const QColor &val);
|
|
322 |
void slotEnumChanged(QtProperty *property, int val);
|
|
323 |
void slotEnumNamesChanged(QtProperty *property, const QStringList &enumNames);
|
|
324 |
void slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &enumIcons);
|
|
325 |
void slotValueChanged(QtProperty *property, const QSizePolicy &val);
|
|
326 |
void slotValueChanged(QtProperty *property, const QFont &val);
|
|
327 |
void slotValueChanged(QtProperty *property, const QCursor &val);
|
|
328 |
void slotFlagChanged(QtProperty *property, int val);
|
|
329 |
void slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames);
|
|
330 |
void slotPropertyInserted(QtProperty *property, QtProperty *parent, QtProperty *after);
|
|
331 |
void slotPropertyRemoved(QtProperty *property, QtProperty *parent);
|
|
332 |
|
|
333 |
void valueChanged(QtProperty *property, const QVariant &val);
|
|
334 |
|
|
335 |
int internalPropertyToType(QtProperty *property) const;
|
|
336 |
QtVariantProperty *createSubProperty(QtVariantProperty *parent, QtVariantProperty *after,
|
|
337 |
QtProperty *internal);
|
|
338 |
void removeSubProperty(QtVariantProperty *property);
|
|
339 |
|
|
340 |
QMap<int, QtAbstractPropertyManager *> m_typeToPropertyManager;
|
|
341 |
QMap<int, QMap<QString, int> > m_typeToAttributeToAttributeType;
|
|
342 |
|
|
343 |
QMap<const QtProperty *, QPair<QtVariantProperty *, int> > m_propertyToType;
|
|
344 |
|
|
345 |
QMap<int, int> m_typeToValueType;
|
|
346 |
|
|
347 |
|
|
348 |
QMap<QtProperty *, QtVariantProperty *> m_internalToProperty;
|
|
349 |
|
|
350 |
const QString m_constraintAttribute;
|
|
351 |
const QString m_singleStepAttribute;
|
|
352 |
const QString m_decimalsAttribute;
|
|
353 |
const QString m_enumIconsAttribute;
|
|
354 |
const QString m_enumNamesAttribute;
|
|
355 |
const QString m_flagNamesAttribute;
|
|
356 |
const QString m_maximumAttribute;
|
|
357 |
const QString m_minimumAttribute;
|
|
358 |
const QString m_regExpAttribute;
|
|
359 |
};
|
|
360 |
|
|
361 |
QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() :
|
|
362 |
m_constraintAttribute(QLatin1String("constraint")),
|
|
363 |
m_singleStepAttribute(QLatin1String("singleStep")),
|
|
364 |
m_decimalsAttribute(QLatin1String("decimals")),
|
|
365 |
m_enumIconsAttribute(QLatin1String("enumIcons")),
|
|
366 |
m_enumNamesAttribute(QLatin1String("enumNames")),
|
|
367 |
m_flagNamesAttribute(QLatin1String("flagNames")),
|
|
368 |
m_maximumAttribute(QLatin1String("maximum")),
|
|
369 |
m_minimumAttribute(QLatin1String("minimum")),
|
|
370 |
m_regExpAttribute(QLatin1String("regExp"))
|
|
371 |
{
|
|
372 |
}
|
|
373 |
|
|
374 |
int QtVariantPropertyManagerPrivate::internalPropertyToType(QtProperty *property) const
|
|
375 |
{
|
|
376 |
int type = 0;
|
|
377 |
QtAbstractPropertyManager *internPropertyManager = property->propertyManager();
|
|
378 |
if (qobject_cast<QtIntPropertyManager *>(internPropertyManager))
|
|
379 |
type = QVariant::Int;
|
|
380 |
else if (qobject_cast<QtEnumPropertyManager *>(internPropertyManager))
|
|
381 |
type = QtVariantPropertyManager::enumTypeId();
|
|
382 |
else if (qobject_cast<QtBoolPropertyManager *>(internPropertyManager))
|
|
383 |
type = QVariant::Bool;
|
|
384 |
else if (qobject_cast<QtDoublePropertyManager *>(internPropertyManager))
|
|
385 |
type = QVariant::Double;
|
|
386 |
return type;
|
|
387 |
}
|
|
388 |
|
|
389 |
QtVariantProperty *QtVariantPropertyManagerPrivate::createSubProperty(QtVariantProperty *parent,
|
|
390 |
QtVariantProperty *after, QtProperty *internal)
|
|
391 |
{
|
|
392 |
int type = internalPropertyToType(internal);
|
|
393 |
if (!type)
|
|
394 |
return 0;
|
|
395 |
|
|
396 |
bool wasCreatingSubProperties = m_creatingSubProperties;
|
|
397 |
m_creatingSubProperties = true;
|
|
398 |
|
|
399 |
QtVariantProperty *varChild = q_ptr->addProperty(type, internal->propertyName());
|
|
400 |
|
|
401 |
m_creatingSubProperties = wasCreatingSubProperties;
|
|
402 |
|
|
403 |
varChild->setPropertyName(internal->propertyName());
|
|
404 |
varChild->setToolTip(internal->toolTip());
|
|
405 |
varChild->setStatusTip(internal->statusTip());
|
|
406 |
varChild->setWhatsThis(internal->whatsThis());
|
|
407 |
|
|
408 |
parent->insertSubProperty(varChild, after);
|
|
409 |
|
|
410 |
m_internalToProperty[internal] = varChild;
|
|
411 |
propertyToWrappedProperty()->insert(varChild, internal);
|
|
412 |
return varChild;
|
|
413 |
}
|
|
414 |
|
|
415 |
void QtVariantPropertyManagerPrivate::removeSubProperty(QtVariantProperty *property)
|
|
416 |
{
|
|
417 |
QtProperty *internChild = wrappedProperty(property);
|
|
418 |
bool wasDestroyingSubProperties = m_destroyingSubProperties;
|
|
419 |
m_destroyingSubProperties = true;
|
|
420 |
delete property;
|
|
421 |
m_destroyingSubProperties = wasDestroyingSubProperties;
|
|
422 |
m_internalToProperty.remove(internChild);
|
|
423 |
propertyToWrappedProperty()->remove(property);
|
|
424 |
}
|
|
425 |
|
|
426 |
void QtVariantPropertyManagerPrivate::slotPropertyInserted(QtProperty *property,
|
|
427 |
QtProperty *parent, QtProperty *after)
|
|
428 |
{
|
|
429 |
if (m_creatingProperty)
|
|
430 |
return;
|
|
431 |
|
|
432 |
QtVariantProperty *varParent = m_internalToProperty.value(parent, 0);
|
|
433 |
if (!varParent)
|
|
434 |
return;
|
|
435 |
|
|
436 |
QtVariantProperty *varAfter = 0;
|
|
437 |
if (after) {
|
|
438 |
varAfter = m_internalToProperty.value(after, 0);
|
|
439 |
if (!varAfter)
|
|
440 |
return;
|
|
441 |
}
|
|
442 |
|
|
443 |
createSubProperty(varParent, varAfter, property);
|
|
444 |
}
|
|
445 |
|
|
446 |
void QtVariantPropertyManagerPrivate::slotPropertyRemoved(QtProperty *property, QtProperty *parent)
|
|
447 |
{
|
|
448 |
Q_UNUSED(parent)
|
|
449 |
|
|
450 |
QtVariantProperty *varProperty = m_internalToProperty.value(property, 0);
|
|
451 |
if (!varProperty)
|
|
452 |
return;
|
|
453 |
|
|
454 |
removeSubProperty(varProperty);
|
|
455 |
}
|
|
456 |
|
|
457 |
void QtVariantPropertyManagerPrivate::valueChanged(QtProperty *property, const QVariant &val)
|
|
458 |
{
|
|
459 |
QtVariantProperty *varProp = m_internalToProperty.value(property, 0);
|
|
460 |
if (!varProp)
|
|
461 |
return;
|
|
462 |
emit q_ptr->valueChanged(varProp, val);
|
|
463 |
emit q_ptr->propertyChanged(varProp);
|
|
464 |
}
|
|
465 |
|
|
466 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, int val)
|
|
467 |
{
|
|
468 |
valueChanged(property, QVariant(val));
|
|
469 |
}
|
|
470 |
|
|
471 |
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, int min, int max)
|
|
472 |
{
|
|
473 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
|
|
474 |
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
|
|
475 |
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
|
|
476 |
}
|
|
477 |
}
|
|
478 |
|
|
479 |
void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, int step)
|
|
480 |
{
|
|
481 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
|
|
482 |
emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step));
|
|
483 |
}
|
|
484 |
|
|
485 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, double val)
|
|
486 |
{
|
|
487 |
valueChanged(property, QVariant(val));
|
|
488 |
}
|
|
489 |
|
|
490 |
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, double min, double max)
|
|
491 |
{
|
|
492 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
|
|
493 |
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
|
|
494 |
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
|
|
495 |
}
|
|
496 |
}
|
|
497 |
|
|
498 |
void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, double step)
|
|
499 |
{
|
|
500 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
|
|
501 |
emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step));
|
|
502 |
}
|
|
503 |
|
|
504 |
void QtVariantPropertyManagerPrivate::slotDecimalsChanged(QtProperty *property, int prec)
|
|
505 |
{
|
|
506 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
|
|
507 |
emit q_ptr->attributeChanged(varProp, m_decimalsAttribute, QVariant(prec));
|
|
508 |
}
|
|
509 |
|
|
510 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, bool val)
|
|
511 |
{
|
|
512 |
valueChanged(property, QVariant(val));
|
|
513 |
}
|
|
514 |
|
|
515 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QString &val)
|
|
516 |
{
|
|
517 |
valueChanged(property, QVariant(val));
|
|
518 |
}
|
|
519 |
|
|
520 |
void QtVariantPropertyManagerPrivate::slotRegExpChanged(QtProperty *property, const QRegExp ®Exp)
|
|
521 |
{
|
|
522 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
|
|
523 |
emit q_ptr->attributeChanged(varProp, m_regExpAttribute, QVariant(regExp));
|
|
524 |
}
|
|
525 |
|
|
526 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QDate &val)
|
|
527 |
{
|
|
528 |
valueChanged(property, QVariant(val));
|
|
529 |
}
|
|
530 |
|
|
531 |
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QDate &min, const QDate &max)
|
|
532 |
{
|
|
533 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
|
|
534 |
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
|
|
535 |
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
|
|
536 |
}
|
|
537 |
}
|
|
538 |
|
|
539 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QTime &val)
|
|
540 |
{
|
|
541 |
valueChanged(property, QVariant(val));
|
|
542 |
}
|
|
543 |
|
|
544 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QDateTime &val)
|
|
545 |
{
|
|
546 |
valueChanged(property, QVariant(val));
|
|
547 |
}
|
|
548 |
|
|
549 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QKeySequence &val)
|
|
550 |
{
|
|
551 |
QVariant v;
|
|
552 |
qVariantSetValue(v, val);
|
|
553 |
valueChanged(property, v);
|
|
554 |
}
|
|
555 |
|
|
556 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QChar &val)
|
|
557 |
{
|
|
558 |
valueChanged(property, QVariant(val));
|
|
559 |
}
|
|
560 |
|
|
561 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QLocale &val)
|
|
562 |
{
|
|
563 |
valueChanged(property, QVariant(val));
|
|
564 |
}
|
|
565 |
|
|
566 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QPoint &val)
|
|
567 |
{
|
|
568 |
valueChanged(property, QVariant(val));
|
|
569 |
}
|
|
570 |
|
|
571 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QPointF &val)
|
|
572 |
{
|
|
573 |
valueChanged(property, QVariant(val));
|
|
574 |
}
|
|
575 |
|
|
576 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QSize &val)
|
|
577 |
{
|
|
578 |
valueChanged(property, QVariant(val));
|
|
579 |
}
|
|
580 |
|
|
581 |
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSize &min, const QSize &max)
|
|
582 |
{
|
|
583 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
|
|
584 |
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
|
|
585 |
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
|
|
586 |
}
|
|
587 |
}
|
|
588 |
|
|
589 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QSizeF &val)
|
|
590 |
{
|
|
591 |
valueChanged(property, QVariant(val));
|
|
592 |
}
|
|
593 |
|
|
594 |
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSizeF &min, const QSizeF &max)
|
|
595 |
{
|
|
596 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
|
|
597 |
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
|
|
598 |
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
|
|
599 |
}
|
|
600 |
}
|
|
601 |
|
|
602 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QRect &val)
|
|
603 |
{
|
|
604 |
valueChanged(property, QVariant(val));
|
|
605 |
}
|
|
606 |
|
|
607 |
void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRect &constraint)
|
|
608 |
{
|
|
609 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
|
|
610 |
emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint));
|
|
611 |
}
|
|
612 |
|
|
613 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QRectF &val)
|
|
614 |
{
|
|
615 |
valueChanged(property, QVariant(val));
|
|
616 |
}
|
|
617 |
|
|
618 |
void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRectF &constraint)
|
|
619 |
{
|
|
620 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
|
|
621 |
emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint));
|
|
622 |
}
|
|
623 |
|
|
624 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QColor &val)
|
|
625 |
{
|
|
626 |
valueChanged(property, QVariant(val));
|
|
627 |
}
|
|
628 |
|
|
629 |
void QtVariantPropertyManagerPrivate::slotEnumNamesChanged(QtProperty *property, const QStringList &enumNames)
|
|
630 |
{
|
|
631 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
|
|
632 |
emit q_ptr->attributeChanged(varProp, m_enumNamesAttribute, QVariant(enumNames));
|
|
633 |
}
|
|
634 |
|
|
635 |
void QtVariantPropertyManagerPrivate::slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &enumIcons)
|
|
636 |
{
|
|
637 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
|
|
638 |
QVariant v;
|
|
639 |
qVariantSetValue(v, enumIcons);
|
|
640 |
emit q_ptr->attributeChanged(varProp, m_enumIconsAttribute, v);
|
|
641 |
}
|
|
642 |
}
|
|
643 |
|
|
644 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QSizePolicy &val)
|
|
645 |
{
|
|
646 |
valueChanged(property, QVariant(val));
|
|
647 |
}
|
|
648 |
|
|
649 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QFont &val)
|
|
650 |
{
|
|
651 |
valueChanged(property, QVariant(val));
|
|
652 |
}
|
|
653 |
|
|
654 |
void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QCursor &val)
|
|
655 |
{
|
|
656 |
#ifndef QT_NO_CURSOR
|
|
657 |
valueChanged(property, QVariant(val));
|
|
658 |
#endif
|
|
659 |
}
|
|
660 |
|
|
661 |
void QtVariantPropertyManagerPrivate::slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames)
|
|
662 |
{
|
|
663 |
if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
|
|
664 |
emit q_ptr->attributeChanged(varProp, m_flagNamesAttribute, QVariant(flagNames));
|
|
665 |
}
|
|
666 |
|
|
667 |
/*!
|
|
668 |
\class QtVariantPropertyManager
|
|
669 |
\internal
|
|
670 |
\inmodule QtDesigner
|
|
671 |
\since 4.4
|
|
672 |
|
|
673 |
\brief The QtVariantPropertyManager class provides and manages QVariant based properties.
|
|
674 |
|
|
675 |
QtVariantPropertyManager provides the addProperty() function which
|
|
676 |
creates QtVariantProperty objects. The QtVariantProperty class is
|
|
677 |
a convenience class handling QVariant based properties inheriting
|
|
678 |
QtProperty. A QtProperty object created by a
|
|
679 |
QtVariantPropertyManager instance can be converted into a
|
|
680 |
QtVariantProperty object using the variantProperty() function.
|
|
681 |
|
|
682 |
The property's value can be retrieved using the value(), and set
|
|
683 |
using the setValue() slot. In addition the property's type, and
|
|
684 |
the type of its value, can be retrieved using the propertyType()
|
|
685 |
and valueType() functions respectively.
|
|
686 |
|
|
687 |
A property's type is a QVariant::Type enumerator value, and
|
|
688 |
usually a property's type is the same as its value type. But for
|
|
689 |
some properties the types differ, for example for enums, flags and
|
|
690 |
group types in which case QtVariantPropertyManager provides the
|
|
691 |
enumTypeId(), flagTypeId() and groupTypeId() functions,
|
|
692 |
respectively, to identify their property type (the value types are
|
|
693 |
QVariant::Int for the enum and flag types, and QVariant::Invalid
|
|
694 |
for the group type).
|
|
695 |
|
|
696 |
Use the isPropertyTypeSupported() function to check if a particular
|
|
697 |
property type is supported. The currently supported property types
|
|
698 |
are:
|
|
699 |
|
|
700 |
\table
|
|
701 |
\header
|
|
702 |
\o Property Type
|
|
703 |
\o Property Type Id
|
|
704 |
\row
|
|
705 |
\o int
|
|
706 |
\o QVariant::Int
|
|
707 |
\row
|
|
708 |
\o double
|
|
709 |
\o QVariant::Double
|
|
710 |
\row
|
|
711 |
\o bool
|
|
712 |
\o QVariant::Bool
|
|
713 |
\row
|
|
714 |
\o QString
|
|
715 |
\o QVariant::String
|
|
716 |
\row
|
|
717 |
\o QDate
|
|
718 |
\o QVariant::Date
|
|
719 |
\row
|
|
720 |
\o QTime
|
|
721 |
\o QVariant::Time
|
|
722 |
\row
|
|
723 |
\o QDateTime
|
|
724 |
\o QVariant::DateTime
|
|
725 |
\row
|
|
726 |
\o QKeySequence
|
|
727 |
\o QVariant::KeySequence
|
|
728 |
\row
|
|
729 |
\o QChar
|
|
730 |
\o QVariant::Char
|
|
731 |
\row
|
|
732 |
\o QLocale
|
|
733 |
\o QVariant::Locale
|
|
734 |
\row
|
|
735 |
\o QPoint
|
|
736 |
\o QVariant::Point
|
|
737 |
\row
|
|
738 |
\o QPointF
|
|
739 |
\o QVariant::PointF
|
|
740 |
\row
|
|
741 |
\o QSize
|
|
742 |
\o QVariant::Size
|
|
743 |
\row
|
|
744 |
\o QSizeF
|
|
745 |
\o QVariant::SizeF
|
|
746 |
\row
|
|
747 |
\o QRect
|
|
748 |
\o QVariant::Rect
|
|
749 |
\row
|
|
750 |
\o QRectF
|
|
751 |
\o QVariant::RectF
|
|
752 |
\row
|
|
753 |
\o QColor
|
|
754 |
\o QVariant::Color
|
|
755 |
\row
|
|
756 |
\o QSizePolicy
|
|
757 |
\o QVariant::SizePolicy
|
|
758 |
\row
|
|
759 |
\o QFont
|
|
760 |
\o QVariant::Font
|
|
761 |
\row
|
|
762 |
\o QCursor
|
|
763 |
\o QVariant::Cursor
|
|
764 |
\row
|
|
765 |
\o enum
|
|
766 |
\o enumTypeId()
|
|
767 |
\row
|
|
768 |
\o flag
|
|
769 |
\o flagTypeId()
|
|
770 |
\row
|
|
771 |
\o group
|
|
772 |
\o groupTypeId()
|
|
773 |
\endtable
|
|
774 |
|
|
775 |
Each property type can provide additional attributes,
|
|
776 |
e.g. QVariant::Int and QVariant::Double provides minimum and
|
|
777 |
maximum values. The currently supported attributes are:
|
|
778 |
|
|
779 |
\table
|
|
780 |
\header
|
|
781 |
\o Property Type
|
|
782 |
\o Attribute Name
|
|
783 |
\o Attribute Type
|
|
784 |
\row
|
|
785 |
\o \c int
|
|
786 |
\o minimum
|
|
787 |
\o QVariant::Int
|
|
788 |
\row
|
|
789 |
\o
|
|
790 |
\o maximum
|
|
791 |
\o QVariant::Int
|
|
792 |
\row
|
|
793 |
\o
|
|
794 |
\o singleStep
|
|
795 |
\o QVariant::Int
|
|
796 |
\row
|
|
797 |
\o \c double
|
|
798 |
\o minimum
|
|
799 |
\o QVariant::Double
|
|
800 |
\row
|
|
801 |
\o
|
|
802 |
\o maximum
|
|
803 |
\o QVariant::Double
|
|
804 |
\row
|
|
805 |
\o
|
|
806 |
\o singleStep
|
|
807 |
\o QVariant::Double
|
|
808 |
\row
|
|
809 |
\o
|
|
810 |
\o decimals
|
|
811 |
\o QVariant::Int
|
|
812 |
\row
|
|
813 |
\o QString
|
|
814 |
\o regExp
|
|
815 |
\o QVariant::RegExp
|
|
816 |
\row
|
|
817 |
\o QDate
|
|
818 |
\o minimum
|
|
819 |
\o QVariant::Date
|
|
820 |
\row
|
|
821 |
\o
|
|
822 |
\o maximum
|
|
823 |
\o QVariant::Date
|
|
824 |
\row
|
|
825 |
\o QPointF
|
|
826 |
\o decimals
|
|
827 |
\o QVariant::Int
|
|
828 |
\row
|
|
829 |
\o QSize
|
|
830 |
\o minimum
|
|
831 |
\o QVariant::Size
|
|
832 |
\row
|
|
833 |
\o
|
|
834 |
\o maximum
|
|
835 |
\o QVariant::Size
|
|
836 |
\row
|
|
837 |
\o QSizeF
|
|
838 |
\o minimum
|
|
839 |
\o QVariant::SizeF
|
|
840 |
\row
|
|
841 |
\o
|
|
842 |
\o maximum
|
|
843 |
\o QVariant::SizeF
|
|
844 |
\row
|
|
845 |
\o
|
|
846 |
\o decimals
|
|
847 |
\o QVariant::Int
|
|
848 |
\row
|
|
849 |
\o QRect
|
|
850 |
\o constraint
|
|
851 |
\o QVariant::Rect
|
|
852 |
\row
|
|
853 |
\o QRectF
|
|
854 |
\o constraint
|
|
855 |
\o QVariant::RectF
|
|
856 |
\row
|
|
857 |
\o
|
|
858 |
\o decimals
|
|
859 |
\o QVariant::Int
|
|
860 |
\row
|
|
861 |
\o \c enum
|
|
862 |
\o enumNames
|
|
863 |
\o QVariant::StringList
|
|
864 |
\row
|
|
865 |
\o
|
|
866 |
\o enumIcons
|
|
867 |
\o iconMapTypeId()
|
|
868 |
\row
|
|
869 |
\o \c flag
|
|
870 |
\o flagNames
|
|
871 |
\o QVariant::StringList
|
|
872 |
\endtable
|
|
873 |
|
|
874 |
The attributes for a given property type can be retrieved using
|
|
875 |
the attributes() function. Each attribute has a value type which
|
|
876 |
can be retrieved using the attributeType() function, and a value
|
|
877 |
accessible through the attributeValue() function. In addition, the
|
|
878 |
value can be set using the setAttribute() slot.
|
|
879 |
|
|
880 |
QtVariantManager also provides the valueChanged() signal which is
|
|
881 |
emitted whenever a property created by this manager change, and
|
|
882 |
the attributeChanged() signal which is emitted whenever an
|
|
883 |
attribute of such a property changes.
|
|
884 |
|
|
885 |
\sa QtVariantProperty, QtVariantEditorFactory
|
|
886 |
*/
|
|
887 |
|
|
888 |
/*!
|
|
889 |
\fn void QtVariantPropertyManager::valueChanged(QtProperty *property, const QVariant &value)
|
|
890 |
|
|
891 |
This signal is emitted whenever a property created by this manager
|
|
892 |
changes its value, passing a pointer to the \a property and the
|
|
893 |
new \a value as parameters.
|
|
894 |
|
|
895 |
\sa setValue()
|
|
896 |
*/
|
|
897 |
|
|
898 |
/*!
|
|
899 |
\fn void QtVariantPropertyManager::attributeChanged(QtProperty *property,
|
|
900 |
const QString &attribute, const QVariant &value)
|
|
901 |
|
|
902 |
This signal is emitted whenever an attribute of a property created
|
|
903 |
by this manager changes its value, passing a pointer to the \a
|
|
904 |
property, the \a attribute and the new \a value as parameters.
|
|
905 |
|
|
906 |
\sa setAttribute()
|
|
907 |
*/
|
|
908 |
|
|
909 |
/*!
|
|
910 |
Creates a manager with the given \a parent.
|
|
911 |
*/
|
|
912 |
QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent)
|
|
913 |
: QtAbstractPropertyManager(parent), d_ptr(new QtVariantPropertyManagerPrivate)
|
|
914 |
{
|
|
915 |
d_ptr->q_ptr = this;
|
|
916 |
|
|
917 |
d_ptr->m_creatingProperty = false;
|
|
918 |
d_ptr->m_creatingSubProperties = false;
|
|
919 |
d_ptr->m_destroyingSubProperties = false;
|
|
920 |
d_ptr->m_propertyType = 0;
|
|
921 |
|
|
922 |
// IntPropertyManager
|
|
923 |
QtIntPropertyManager *intPropertyManager = new QtIntPropertyManager(this);
|
|
924 |
d_ptr->m_typeToPropertyManager[QVariant::Int] = intPropertyManager;
|
|
925 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_minimumAttribute] = QVariant::Int;
|
|
926 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_maximumAttribute] = QVariant::Int;
|
|
927 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_singleStepAttribute] = QVariant::Int;
|
|
928 |
d_ptr->m_typeToValueType[QVariant::Int] = QVariant::Int;
|
|
929 |
connect(intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)),
|
|
930 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
931 |
connect(intPropertyManager, SIGNAL(rangeChanged(QtProperty *, int, int)),
|
|
932 |
this, SLOT(slotRangeChanged(QtProperty *, int, int)));
|
|
933 |
connect(intPropertyManager, SIGNAL(singleStepChanged(QtProperty *, int)),
|
|
934 |
this, SLOT(slotSingleStepChanged(QtProperty *, int)));
|
|
935 |
// DoublePropertyManager
|
|
936 |
QtDoublePropertyManager *doublePropertyManager = new QtDoublePropertyManager(this);
|
|
937 |
d_ptr->m_typeToPropertyManager[QVariant::Double] = doublePropertyManager;
|
|
938 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_minimumAttribute] =
|
|
939 |
QVariant::Double;
|
|
940 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_maximumAttribute] =
|
|
941 |
QVariant::Double;
|
|
942 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_singleStepAttribute] =
|
|
943 |
QVariant::Double;
|
|
944 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_decimalsAttribute] =
|
|
945 |
QVariant::Int;
|
|
946 |
d_ptr->m_typeToValueType[QVariant::Double] = QVariant::Double;
|
|
947 |
connect(doublePropertyManager, SIGNAL(valueChanged(QtProperty *, double)),
|
|
948 |
this, SLOT(slotValueChanged(QtProperty *, double)));
|
|
949 |
connect(doublePropertyManager, SIGNAL(rangeChanged(QtProperty *, double, double)),
|
|
950 |
this, SLOT(slotRangeChanged(QtProperty *, double, double)));
|
|
951 |
connect(doublePropertyManager, SIGNAL(singleStepChanged(QtProperty *, double)),
|
|
952 |
this, SLOT(slotSingleStepChanged(QtProperty *, double)));
|
|
953 |
connect(doublePropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)),
|
|
954 |
this, SLOT(slotDecimalsChanged(QtProperty *, int)));
|
|
955 |
// BoolPropertyManager
|
|
956 |
QtBoolPropertyManager *boolPropertyManager = new QtBoolPropertyManager(this);
|
|
957 |
d_ptr->m_typeToPropertyManager[QVariant::Bool] = boolPropertyManager;
|
|
958 |
d_ptr->m_typeToValueType[QVariant::Bool] = QVariant::Bool;
|
|
959 |
connect(boolPropertyManager, SIGNAL(valueChanged(QtProperty *, bool)),
|
|
960 |
this, SLOT(slotValueChanged(QtProperty *, bool)));
|
|
961 |
// StringPropertyManager
|
|
962 |
QtStringPropertyManager *stringPropertyManager = new QtStringPropertyManager(this);
|
|
963 |
d_ptr->m_typeToPropertyManager[QVariant::String] = stringPropertyManager;
|
|
964 |
d_ptr->m_typeToValueType[QVariant::String] = QVariant::String;
|
|
965 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::String][d_ptr->m_regExpAttribute] =
|
|
966 |
QVariant::RegExp;
|
|
967 |
connect(stringPropertyManager, SIGNAL(valueChanged(QtProperty *, const QString &)),
|
|
968 |
this, SLOT(slotValueChanged(QtProperty *, const QString &)));
|
|
969 |
connect(stringPropertyManager, SIGNAL(regExpChanged(QtProperty *, const QRegExp &)),
|
|
970 |
this, SLOT(slotRegExpChanged(QtProperty *, const QRegExp &)));
|
|
971 |
// DatePropertyManager
|
|
972 |
QtDatePropertyManager *datePropertyManager = new QtDatePropertyManager(this);
|
|
973 |
d_ptr->m_typeToPropertyManager[QVariant::Date] = datePropertyManager;
|
|
974 |
d_ptr->m_typeToValueType[QVariant::Date] = QVariant::Date;
|
|
975 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Date][d_ptr->m_minimumAttribute] =
|
|
976 |
QVariant::Date;
|
|
977 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Date][d_ptr->m_maximumAttribute] =
|
|
978 |
QVariant::Date;
|
|
979 |
connect(datePropertyManager, SIGNAL(valueChanged(QtProperty *, const QDate &)),
|
|
980 |
this, SLOT(slotValueChanged(QtProperty *, const QDate &)));
|
|
981 |
connect(datePropertyManager, SIGNAL(rangeChanged(QtProperty *, const QDate &, const QDate &)),
|
|
982 |
this, SLOT(slotRangeChanged(QtProperty *, const QDate &, const QDate &)));
|
|
983 |
// TimePropertyManager
|
|
984 |
QtTimePropertyManager *timePropertyManager = new QtTimePropertyManager(this);
|
|
985 |
d_ptr->m_typeToPropertyManager[QVariant::Time] = timePropertyManager;
|
|
986 |
d_ptr->m_typeToValueType[QVariant::Time] = QVariant::Time;
|
|
987 |
connect(timePropertyManager, SIGNAL(valueChanged(QtProperty *, const QTime &)),
|
|
988 |
this, SLOT(slotValueChanged(QtProperty *, const QTime &)));
|
|
989 |
// DateTimePropertyManager
|
|
990 |
QtDateTimePropertyManager *dateTimePropertyManager = new QtDateTimePropertyManager(this);
|
|
991 |
d_ptr->m_typeToPropertyManager[QVariant::DateTime] = dateTimePropertyManager;
|
|
992 |
d_ptr->m_typeToValueType[QVariant::DateTime] = QVariant::DateTime;
|
|
993 |
connect(dateTimePropertyManager, SIGNAL(valueChanged(QtProperty *, const QDateTime &)),
|
|
994 |
this, SLOT(slotValueChanged(QtProperty *, const QDateTime &)));
|
|
995 |
// KeySequencePropertyManager
|
|
996 |
QtKeySequencePropertyManager *keySequencePropertyManager = new QtKeySequencePropertyManager(this);
|
|
997 |
d_ptr->m_typeToPropertyManager[QVariant::KeySequence] = keySequencePropertyManager;
|
|
998 |
d_ptr->m_typeToValueType[QVariant::KeySequence] = QVariant::KeySequence;
|
|
999 |
connect(keySequencePropertyManager, SIGNAL(valueChanged(QtProperty *, const QKeySequence &)),
|
|
1000 |
this, SLOT(slotValueChanged(QtProperty *, const QKeySequence &)));
|
|
1001 |
// CharPropertyManager
|
|
1002 |
QtCharPropertyManager *charPropertyManager = new QtCharPropertyManager(this);
|
|
1003 |
d_ptr->m_typeToPropertyManager[QVariant::Char] = charPropertyManager;
|
|
1004 |
d_ptr->m_typeToValueType[QVariant::Char] = QVariant::Char;
|
|
1005 |
connect(charPropertyManager, SIGNAL(valueChanged(QtProperty *, const QChar &)),
|
|
1006 |
this, SLOT(slotValueChanged(QtProperty *, const QChar &)));
|
|
1007 |
// LocalePropertyManager
|
|
1008 |
QtLocalePropertyManager *localePropertyManager = new QtLocalePropertyManager(this);
|
|
1009 |
d_ptr->m_typeToPropertyManager[QVariant::Locale] = localePropertyManager;
|
|
1010 |
d_ptr->m_typeToValueType[QVariant::Locale] = QVariant::Locale;
|
|
1011 |
connect(localePropertyManager, SIGNAL(valueChanged(QtProperty *, const QLocale &)),
|
|
1012 |
this, SLOT(slotValueChanged(QtProperty *, const QLocale &)));
|
|
1013 |
connect(localePropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
|
|
1014 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1015 |
connect(localePropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1016 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1017 |
connect(localePropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1018 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1019 |
// PointPropertyManager
|
|
1020 |
QtPointPropertyManager *pointPropertyManager = new QtPointPropertyManager(this);
|
|
1021 |
d_ptr->m_typeToPropertyManager[QVariant::Point] = pointPropertyManager;
|
|
1022 |
d_ptr->m_typeToValueType[QVariant::Point] = QVariant::Point;
|
|
1023 |
connect(pointPropertyManager, SIGNAL(valueChanged(QtProperty *, const QPoint &)),
|
|
1024 |
this, SLOT(slotValueChanged(QtProperty *, const QPoint &)));
|
|
1025 |
connect(pointPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
|
|
1026 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1027 |
connect(pointPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1028 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1029 |
connect(pointPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1030 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1031 |
// PointFPropertyManager
|
|
1032 |
QtPointFPropertyManager *pointFPropertyManager = new QtPointFPropertyManager(this);
|
|
1033 |
d_ptr->m_typeToPropertyManager[QVariant::PointF] = pointFPropertyManager;
|
|
1034 |
d_ptr->m_typeToValueType[QVariant::PointF] = QVariant::PointF;
|
|
1035 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::PointF][d_ptr->m_decimalsAttribute] =
|
|
1036 |
QVariant::Int;
|
|
1037 |
connect(pointFPropertyManager, SIGNAL(valueChanged(QtProperty *, const QPointF &)),
|
|
1038 |
this, SLOT(slotValueChanged(QtProperty *, const QPointF &)));
|
|
1039 |
connect(pointFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)),
|
|
1040 |
this, SLOT(slotDecimalsChanged(QtProperty *, int)));
|
|
1041 |
connect(pointFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty *, double)),
|
|
1042 |
this, SLOT(slotValueChanged(QtProperty *, double)));
|
|
1043 |
connect(pointFPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1044 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1045 |
connect(pointFPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1046 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1047 |
// SizePropertyManager
|
|
1048 |
QtSizePropertyManager *sizePropertyManager = new QtSizePropertyManager(this);
|
|
1049 |
d_ptr->m_typeToPropertyManager[QVariant::Size] = sizePropertyManager;
|
|
1050 |
d_ptr->m_typeToValueType[QVariant::Size] = QVariant::Size;
|
|
1051 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Size][d_ptr->m_minimumAttribute] =
|
|
1052 |
QVariant::Size;
|
|
1053 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Size][d_ptr->m_maximumAttribute] =
|
|
1054 |
QVariant::Size;
|
|
1055 |
connect(sizePropertyManager, SIGNAL(valueChanged(QtProperty *, const QSize &)),
|
|
1056 |
this, SLOT(slotValueChanged(QtProperty *, const QSize &)));
|
|
1057 |
connect(sizePropertyManager, SIGNAL(rangeChanged(QtProperty *, const QSize &, const QSize &)),
|
|
1058 |
this, SLOT(slotRangeChanged(QtProperty *, const QSize &, const QSize &)));
|
|
1059 |
connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
|
|
1060 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1061 |
connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)),
|
|
1062 |
this, SLOT(slotRangeChanged(QtProperty *, int, int)));
|
|
1063 |
connect(sizePropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1064 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1065 |
connect(sizePropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1066 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1067 |
// SizeFPropertyManager
|
|
1068 |
QtSizeFPropertyManager *sizeFPropertyManager = new QtSizeFPropertyManager(this);
|
|
1069 |
d_ptr->m_typeToPropertyManager[QVariant::SizeF] = sizeFPropertyManager;
|
|
1070 |
d_ptr->m_typeToValueType[QVariant::SizeF] = QVariant::SizeF;
|
|
1071 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_minimumAttribute] =
|
|
1072 |
QVariant::SizeF;
|
|
1073 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_maximumAttribute] =
|
|
1074 |
QVariant::SizeF;
|
|
1075 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_decimalsAttribute] =
|
|
1076 |
QVariant::Int;
|
|
1077 |
connect(sizeFPropertyManager, SIGNAL(valueChanged(QtProperty *, const QSizeF &)),
|
|
1078 |
this, SLOT(slotValueChanged(QtProperty *, const QSizeF &)));
|
|
1079 |
connect(sizeFPropertyManager, SIGNAL(rangeChanged(QtProperty *, const QSizeF &, const QSizeF &)),
|
|
1080 |
this, SLOT(slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &)));
|
|
1081 |
connect(sizeFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)),
|
|
1082 |
this, SLOT(slotDecimalsChanged(QtProperty *, int)));
|
|
1083 |
connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty *, double)),
|
|
1084 |
this, SLOT(slotValueChanged(QtProperty *, double)));
|
|
1085 |
connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty *, double, double)),
|
|
1086 |
this, SLOT(slotRangeChanged(QtProperty *, double, double)));
|
|
1087 |
connect(sizeFPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1088 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1089 |
connect(sizeFPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1090 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1091 |
// RectPropertyManager
|
|
1092 |
QtRectPropertyManager *rectPropertyManager = new QtRectPropertyManager(this);
|
|
1093 |
d_ptr->m_typeToPropertyManager[QVariant::Rect] = rectPropertyManager;
|
|
1094 |
d_ptr->m_typeToValueType[QVariant::Rect] = QVariant::Rect;
|
|
1095 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::Rect][d_ptr->m_constraintAttribute] =
|
|
1096 |
QVariant::Rect;
|
|
1097 |
connect(rectPropertyManager, SIGNAL(valueChanged(QtProperty *, const QRect &)),
|
|
1098 |
this, SLOT(slotValueChanged(QtProperty *, const QRect &)));
|
|
1099 |
connect(rectPropertyManager, SIGNAL(constraintChanged(QtProperty *, const QRect &)),
|
|
1100 |
this, SLOT(slotConstraintChanged(QtProperty *, const QRect &)));
|
|
1101 |
connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
|
|
1102 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1103 |
connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)),
|
|
1104 |
this, SLOT(slotRangeChanged(QtProperty *, int, int)));
|
|
1105 |
connect(rectPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1106 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1107 |
connect(rectPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1108 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1109 |
// RectFPropertyManager
|
|
1110 |
QtRectFPropertyManager *rectFPropertyManager = new QtRectFPropertyManager(this);
|
|
1111 |
d_ptr->m_typeToPropertyManager[QVariant::RectF] = rectFPropertyManager;
|
|
1112 |
d_ptr->m_typeToValueType[QVariant::RectF] = QVariant::RectF;
|
|
1113 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::RectF][d_ptr->m_constraintAttribute] =
|
|
1114 |
QVariant::RectF;
|
|
1115 |
d_ptr->m_typeToAttributeToAttributeType[QVariant::RectF][d_ptr->m_decimalsAttribute] =
|
|
1116 |
QVariant::Int;
|
|
1117 |
connect(rectFPropertyManager, SIGNAL(valueChanged(QtProperty *, const QRectF &)),
|
|
1118 |
this, SLOT(slotValueChanged(QtProperty *, const QRectF &)));
|
|
1119 |
connect(rectFPropertyManager, SIGNAL(constraintChanged(QtProperty *, const QRectF &)),
|
|
1120 |
this, SLOT(slotConstraintChanged(QtProperty *, const QRectF &)));
|
|
1121 |
connect(rectFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)),
|
|
1122 |
this, SLOT(slotDecimalsChanged(QtProperty *, int)));
|
|
1123 |
connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty *, double)),
|
|
1124 |
this, SLOT(slotValueChanged(QtProperty *, double)));
|
|
1125 |
connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty *, double, double)),
|
|
1126 |
this, SLOT(slotRangeChanged(QtProperty *, double, double)));
|
|
1127 |
connect(rectFPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1128 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1129 |
connect(rectFPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1130 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1131 |
// ColorPropertyManager
|
|
1132 |
QtColorPropertyManager *colorPropertyManager = new QtColorPropertyManager(this);
|
|
1133 |
d_ptr->m_typeToPropertyManager[QVariant::Color] = colorPropertyManager;
|
|
1134 |
d_ptr->m_typeToValueType[QVariant::Color] = QVariant::Color;
|
|
1135 |
connect(colorPropertyManager, SIGNAL(valueChanged(QtProperty *, const QColor &)),
|
|
1136 |
this, SLOT(slotValueChanged(QtProperty *, const QColor &)));
|
|
1137 |
connect(colorPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
|
|
1138 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1139 |
connect(colorPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1140 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1141 |
connect(colorPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1142 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1143 |
// EnumPropertyManager
|
|
1144 |
int enumId = enumTypeId();
|
|
1145 |
QtEnumPropertyManager *enumPropertyManager = new QtEnumPropertyManager(this);
|
|
1146 |
d_ptr->m_typeToPropertyManager[enumId] = enumPropertyManager;
|
|
1147 |
d_ptr->m_typeToValueType[enumId] = QVariant::Int;
|
|
1148 |
d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumNamesAttribute] =
|
|
1149 |
QVariant::StringList;
|
|
1150 |
d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumIconsAttribute] =
|
|
1151 |
iconMapTypeId();
|
|
1152 |
connect(enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)),
|
|
1153 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1154 |
connect(enumPropertyManager, SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)),
|
|
1155 |
this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &)));
|
|
1156 |
connect(enumPropertyManager, SIGNAL(enumIconsChanged(QtProperty *, const QMap<int, QIcon> &)),
|
|
1157 |
this, SLOT(slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &)));
|
|
1158 |
// SizePolicyPropertyManager
|
|
1159 |
QtSizePolicyPropertyManager *sizePolicyPropertyManager = new QtSizePolicyPropertyManager(this);
|
|
1160 |
d_ptr->m_typeToPropertyManager[QVariant::SizePolicy] = sizePolicyPropertyManager;
|
|
1161 |
d_ptr->m_typeToValueType[QVariant::SizePolicy] = QVariant::SizePolicy;
|
|
1162 |
connect(sizePolicyPropertyManager, SIGNAL(valueChanged(QtProperty *, const QSizePolicy &)),
|
|
1163 |
this, SLOT(slotValueChanged(QtProperty *, const QSizePolicy &)));
|
|
1164 |
connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
|
|
1165 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1166 |
connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)),
|
|
1167 |
this, SLOT(slotRangeChanged(QtProperty *, int, int)));
|
|
1168 |
connect(sizePolicyPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
|
|
1169 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1170 |
connect(sizePolicyPropertyManager->subEnumPropertyManager(),
|
|
1171 |
SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)),
|
|
1172 |
this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &)));
|
|
1173 |
connect(sizePolicyPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1174 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1175 |
connect(sizePolicyPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1176 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1177 |
// FontPropertyManager
|
|
1178 |
QtFontPropertyManager *fontPropertyManager = new QtFontPropertyManager(this);
|
|
1179 |
d_ptr->m_typeToPropertyManager[QVariant::Font] = fontPropertyManager;
|
|
1180 |
d_ptr->m_typeToValueType[QVariant::Font] = QVariant::Font;
|
|
1181 |
connect(fontPropertyManager, SIGNAL(valueChanged(QtProperty *, const QFont &)),
|
|
1182 |
this, SLOT(slotValueChanged(QtProperty *, const QFont &)));
|
|
1183 |
connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
|
|
1184 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1185 |
connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)),
|
|
1186 |
this, SLOT(slotRangeChanged(QtProperty *, int, int)));
|
|
1187 |
connect(fontPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
|
|
1188 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1189 |
connect(fontPropertyManager->subEnumPropertyManager(),
|
|
1190 |
SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)),
|
|
1191 |
this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &)));
|
|
1192 |
connect(fontPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty *, bool)),
|
|
1193 |
this, SLOT(slotValueChanged(QtProperty *, bool)));
|
|
1194 |
connect(fontPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1195 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1196 |
connect(fontPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1197 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1198 |
// CursorPropertyManager
|
|
1199 |
QtCursorPropertyManager *cursorPropertyManager = new QtCursorPropertyManager(this);
|
|
1200 |
d_ptr->m_typeToPropertyManager[QVariant::Cursor] = cursorPropertyManager;
|
|
1201 |
d_ptr->m_typeToValueType[QVariant::Cursor] = QVariant::Cursor;
|
|
1202 |
connect(cursorPropertyManager, SIGNAL(valueChanged(QtProperty *, const QCursor &)),
|
|
1203 |
this, SLOT(slotValueChanged(QtProperty *, const QCursor &)));
|
|
1204 |
// FlagPropertyManager
|
|
1205 |
int flagId = flagTypeId();
|
|
1206 |
QtFlagPropertyManager *flagPropertyManager = new QtFlagPropertyManager(this);
|
|
1207 |
d_ptr->m_typeToPropertyManager[flagId] = flagPropertyManager;
|
|
1208 |
d_ptr->m_typeToValueType[flagId] = QVariant::Int;
|
|
1209 |
d_ptr->m_typeToAttributeToAttributeType[flagId][d_ptr->m_flagNamesAttribute] =
|
|
1210 |
QVariant::StringList;
|
|
1211 |
connect(flagPropertyManager, SIGNAL(valueChanged(QtProperty *, int)),
|
|
1212 |
this, SLOT(slotValueChanged(QtProperty *, int)));
|
|
1213 |
connect(flagPropertyManager, SIGNAL(flagNamesChanged(QtProperty *, const QStringList &)),
|
|
1214 |
this, SLOT(slotFlagNamesChanged(QtProperty *, const QStringList &)));
|
|
1215 |
connect(flagPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty *, bool)),
|
|
1216 |
this, SLOT(slotValueChanged(QtProperty *, bool)));
|
|
1217 |
connect(flagPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
|
|
1218 |
this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
|
|
1219 |
connect(flagPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
|
|
1220 |
this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
|
|
1221 |
// FlagPropertyManager
|
|
1222 |
int groupId = groupTypeId();
|
|
1223 |
QtGroupPropertyManager *groupPropertyManager = new QtGroupPropertyManager(this);
|
|
1224 |
d_ptr->m_typeToPropertyManager[groupId] = groupPropertyManager;
|
|
1225 |
d_ptr->m_typeToValueType[groupId] = QVariant::Invalid;
|
|
1226 |
}
|
|
1227 |
|
|
1228 |
/*!
|
|
1229 |
Destroys this manager, and all the properties it has created.
|
|
1230 |
*/
|
|
1231 |
QtVariantPropertyManager::~QtVariantPropertyManager()
|
|
1232 |
{
|
|
1233 |
clear();
|
|
1234 |
}
|
|
1235 |
|
|
1236 |
/*!
|
|
1237 |
Returns the given \a property converted into a QtVariantProperty.
|
|
1238 |
|
|
1239 |
If the \a property was not created by this variant manager, the
|
|
1240 |
function returns 0.
|
|
1241 |
|
|
1242 |
\sa createProperty()
|
|
1243 |
*/
|
|
1244 |
QtVariantProperty *QtVariantPropertyManager::variantProperty(const QtProperty *property) const
|
|
1245 |
{
|
|
1246 |
const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property);
|
|
1247 |
if (it == d_ptr->m_propertyToType.constEnd())
|
|
1248 |
return 0;
|
|
1249 |
return it.value().first;
|
|
1250 |
}
|
|
1251 |
|
|
1252 |
/*!
|
|
1253 |
Returns true if the given \a propertyType is supported by this
|
|
1254 |
variant manager; otherwise false.
|
|
1255 |
|
|
1256 |
\sa propertyType()
|
|
1257 |
*/
|
|
1258 |
bool QtVariantPropertyManager::isPropertyTypeSupported(int propertyType) const
|
|
1259 |
{
|
|
1260 |
if (d_ptr->m_typeToValueType.contains(propertyType))
|
|
1261 |
return true;
|
|
1262 |
return false;
|
|
1263 |
}
|
|
1264 |
|
|
1265 |
/*!
|
|
1266 |
Creates and returns a variant property of the given \a propertyType
|
|
1267 |
with the given \a name.
|
|
1268 |
|
|
1269 |
If the specified \a propertyType is not supported by this variant
|
|
1270 |
manager, this function returns 0.
|
|
1271 |
|
|
1272 |
Do not use the inherited
|
|
1273 |
QtAbstractPropertyManager::addProperty() function to create a
|
|
1274 |
variant property (that function will always return 0 since it will
|
|
1275 |
not be clear what type the property should have).
|
|
1276 |
|
|
1277 |
\sa isPropertyTypeSupported()
|
|
1278 |
*/
|
|
1279 |
QtVariantProperty *QtVariantPropertyManager::addProperty(int propertyType, const QString &name)
|
|
1280 |
{
|
|
1281 |
if (!isPropertyTypeSupported(propertyType))
|
|
1282 |
return 0;
|
|
1283 |
|
|
1284 |
bool wasCreating = d_ptr->m_creatingProperty;
|
|
1285 |
d_ptr->m_creatingProperty = true;
|
|
1286 |
d_ptr->m_propertyType = propertyType;
|
|
1287 |
QtProperty *property = QtAbstractPropertyManager::addProperty(name);
|
|
1288 |
d_ptr->m_creatingProperty = wasCreating;
|
|
1289 |
d_ptr->m_propertyType = 0;
|
|
1290 |
|
|
1291 |
if (!property)
|
|
1292 |
return 0;
|
|
1293 |
|
|
1294 |
return variantProperty(property);
|
|
1295 |
}
|
|
1296 |
|
|
1297 |
/*!
|
|
1298 |
Returns the given \a property's value.
|
|
1299 |
|
|
1300 |
If the given \a property is not managed by this manager, this
|
|
1301 |
function returns an invalid variant.
|
|
1302 |
|
|
1303 |
\sa setValue()
|
|
1304 |
*/
|
|
1305 |
QVariant QtVariantPropertyManager::value(const QtProperty *property) const
|
|
1306 |
{
|
|
1307 |
QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
|
|
1308 |
if (internProp == 0)
|
|
1309 |
return QVariant();
|
|
1310 |
|
|
1311 |
QtAbstractPropertyManager *manager = internProp->propertyManager();
|
|
1312 |
if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
|
|
1313 |
return intManager->value(internProp);
|
|
1314 |
} else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
|
|
1315 |
return doubleManager->value(internProp);
|
|
1316 |
} else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) {
|
|
1317 |
return boolManager->value(internProp);
|
|
1318 |
} else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
|
|
1319 |
return stringManager->value(internProp);
|
|
1320 |
} else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
|
|
1321 |
return dateManager->value(internProp);
|
|
1322 |
} else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) {
|
|
1323 |
return timeManager->value(internProp);
|
|
1324 |
} else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) {
|
|
1325 |
return dateTimeManager->value(internProp);
|
|
1326 |
} else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) {
|
|
1327 |
return keySequenceManager->value(internProp);
|
|
1328 |
} else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) {
|
|
1329 |
return charManager->value(internProp);
|
|
1330 |
} else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) {
|
|
1331 |
return localeManager->value(internProp);
|
|
1332 |
} else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) {
|
|
1333 |
return pointManager->value(internProp);
|
|
1334 |
} else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
|
|
1335 |
return pointFManager->value(internProp);
|
|
1336 |
} else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
|
|
1337 |
return sizeManager->value(internProp);
|
|
1338 |
} else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
|
|
1339 |
return sizeFManager->value(internProp);
|
|
1340 |
} else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
|
|
1341 |
return rectManager->value(internProp);
|
|
1342 |
} else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
|
|
1343 |
return rectFManager->value(internProp);
|
|
1344 |
} else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) {
|
|
1345 |
return colorManager->value(internProp);
|
|
1346 |
} else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
|
|
1347 |
return enumManager->value(internProp);
|
|
1348 |
} else if (QtSizePolicyPropertyManager *sizePolicyManager =
|
|
1349 |
qobject_cast<QtSizePolicyPropertyManager *>(manager)) {
|
|
1350 |
return sizePolicyManager->value(internProp);
|
|
1351 |
} else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) {
|
|
1352 |
return fontManager->value(internProp);
|
|
1353 |
#ifndef QT_NO_CURSOR
|
|
1354 |
} else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) {
|
|
1355 |
return cursorManager->value(internProp);
|
|
1356 |
#endif
|
|
1357 |
} else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
|
|
1358 |
return flagManager->value(internProp);
|
|
1359 |
}
|
|
1360 |
return QVariant();
|
|
1361 |
}
|
|
1362 |
|
|
1363 |
/*!
|
|
1364 |
Returns the given \a property's value type.
|
|
1365 |
|
|
1366 |
\sa propertyType()
|
|
1367 |
*/
|
|
1368 |
int QtVariantPropertyManager::valueType(const QtProperty *property) const
|
|
1369 |
{
|
|
1370 |
int propType = propertyType(property);
|
|
1371 |
return valueType(propType);
|
|
1372 |
}
|
|
1373 |
|
|
1374 |
/*!
|
|
1375 |
\overload
|
|
1376 |
|
|
1377 |
Returns the value type associated with the given \a propertyType.
|
|
1378 |
*/
|
|
1379 |
int QtVariantPropertyManager::valueType(int propertyType) const
|
|
1380 |
{
|
|
1381 |
if (d_ptr->m_typeToValueType.contains(propertyType))
|
|
1382 |
return d_ptr->m_typeToValueType[propertyType];
|
|
1383 |
return 0;
|
|
1384 |
}
|
|
1385 |
|
|
1386 |
/*!
|
|
1387 |
Returns the given \a property's type.
|
|
1388 |
|
|
1389 |
\sa valueType()
|
|
1390 |
*/
|
|
1391 |
int QtVariantPropertyManager::propertyType(const QtProperty *property) const
|
|
1392 |
{
|
|
1393 |
const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property);
|
|
1394 |
if (it == d_ptr->m_propertyToType.constEnd())
|
|
1395 |
return 0;
|
|
1396 |
return it.value().second;
|
|
1397 |
}
|
|
1398 |
|
|
1399 |
/*!
|
|
1400 |
Returns the given \a property's value for the specified \a
|
|
1401 |
attribute
|
|
1402 |
|
|
1403 |
If the given \a property was not created by \e this manager, or if
|
|
1404 |
the specified \a attribute does not exist, this function returns
|
|
1405 |
an invalid variant.
|
|
1406 |
|
|
1407 |
\sa attributes(), attributeType(), setAttribute()
|
|
1408 |
*/
|
|
1409 |
QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, const QString &attribute) const
|
|
1410 |
{
|
|
1411 |
int propType = propertyType(property);
|
|
1412 |
if (!propType)
|
|
1413 |
return QVariant();
|
|
1414 |
|
|
1415 |
QMap<int, QMap<QString, int> >::ConstIterator it =
|
|
1416 |
d_ptr->m_typeToAttributeToAttributeType.find(propType);
|
|
1417 |
if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd())
|
|
1418 |
return QVariant();
|
|
1419 |
|
|
1420 |
QMap<QString, int> attributes = it.value();
|
|
1421 |
QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute);
|
|
1422 |
if (itAttr == attributes.constEnd())
|
|
1423 |
return QVariant();
|
|
1424 |
|
|
1425 |
QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
|
|
1426 |
if (internProp == 0)
|
|
1427 |
return QVariant();
|
|
1428 |
|
|
1429 |
QtAbstractPropertyManager *manager = internProp->propertyManager();
|
|
1430 |
if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
|
|
1431 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1432 |
return intManager->maximum(internProp);
|
|
1433 |
if (attribute == d_ptr->m_minimumAttribute)
|
|
1434 |
return intManager->minimum(internProp);
|
|
1435 |
if (attribute == d_ptr->m_singleStepAttribute)
|
|
1436 |
return intManager->singleStep(internProp);
|
|
1437 |
return QVariant();
|
|
1438 |
} else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
|
|
1439 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1440 |
return doubleManager->maximum(internProp);
|
|
1441 |
if (attribute == d_ptr->m_minimumAttribute)
|
|
1442 |
return doubleManager->minimum(internProp);
|
|
1443 |
if (attribute == d_ptr->m_singleStepAttribute)
|
|
1444 |
return doubleManager->singleStep(internProp);
|
|
1445 |
if (attribute == d_ptr->m_decimalsAttribute)
|
|
1446 |
return doubleManager->decimals(internProp);
|
|
1447 |
return QVariant();
|
|
1448 |
} else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
|
|
1449 |
if (attribute == d_ptr->m_regExpAttribute)
|
|
1450 |
return stringManager->regExp(internProp);
|
|
1451 |
return QVariant();
|
|
1452 |
} else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
|
|
1453 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1454 |
return dateManager->maximum(internProp);
|
|
1455 |
if (attribute == d_ptr->m_minimumAttribute)
|
|
1456 |
return dateManager->minimum(internProp);
|
|
1457 |
return QVariant();
|
|
1458 |
} else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
|
|
1459 |
if (attribute == d_ptr->m_decimalsAttribute)
|
|
1460 |
return pointFManager->decimals(internProp);
|
|
1461 |
return QVariant();
|
|
1462 |
} else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
|
|
1463 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1464 |
return sizeManager->maximum(internProp);
|
|
1465 |
if (attribute == d_ptr->m_minimumAttribute)
|
|
1466 |
return sizeManager->minimum(internProp);
|
|
1467 |
return QVariant();
|
|
1468 |
} else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
|
|
1469 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1470 |
return sizeFManager->maximum(internProp);
|
|
1471 |
if (attribute == d_ptr->m_minimumAttribute)
|
|
1472 |
return sizeFManager->minimum(internProp);
|
|
1473 |
if (attribute == d_ptr->m_decimalsAttribute)
|
|
1474 |
return sizeFManager->decimals(internProp);
|
|
1475 |
return QVariant();
|
|
1476 |
} else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
|
|
1477 |
if (attribute == d_ptr->m_constraintAttribute)
|
|
1478 |
return rectManager->constraint(internProp);
|
|
1479 |
return QVariant();
|
|
1480 |
} else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
|
|
1481 |
if (attribute == d_ptr->m_constraintAttribute)
|
|
1482 |
return rectFManager->constraint(internProp);
|
|
1483 |
if (attribute == d_ptr->m_decimalsAttribute)
|
|
1484 |
return rectFManager->decimals(internProp);
|
|
1485 |
return QVariant();
|
|
1486 |
} else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
|
|
1487 |
if (attribute == d_ptr->m_enumNamesAttribute)
|
|
1488 |
return enumManager->enumNames(internProp);
|
|
1489 |
if (attribute == d_ptr->m_enumIconsAttribute) {
|
|
1490 |
QVariant v;
|
|
1491 |
qVariantSetValue(v, enumManager->enumIcons(internProp));
|
|
1492 |
return v;
|
|
1493 |
}
|
|
1494 |
return QVariant();
|
|
1495 |
} else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
|
|
1496 |
if (attribute == d_ptr->m_flagNamesAttribute)
|
|
1497 |
return flagManager->flagNames(internProp);
|
|
1498 |
return QVariant();
|
|
1499 |
}
|
|
1500 |
return QVariant();
|
|
1501 |
}
|
|
1502 |
|
|
1503 |
/*!
|
|
1504 |
Returns a list of the given \a propertyType 's attributes.
|
|
1505 |
|
|
1506 |
\sa attributeValue(), attributeType()
|
|
1507 |
*/
|
|
1508 |
QStringList QtVariantPropertyManager::attributes(int propertyType) const
|
|
1509 |
{
|
|
1510 |
QMap<int, QMap<QString, int> >::ConstIterator it =
|
|
1511 |
d_ptr->m_typeToAttributeToAttributeType.find(propertyType);
|
|
1512 |
if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd())
|
|
1513 |
return QStringList();
|
|
1514 |
return it.value().keys();
|
|
1515 |
}
|
|
1516 |
|
|
1517 |
/*!
|
|
1518 |
Returns the type of the specified \a attribute of the given \a
|
|
1519 |
propertyType.
|
|
1520 |
|
|
1521 |
If the given \a propertyType is not supported by \e this manager,
|
|
1522 |
or if the given \a propertyType does not possess the specified \a
|
|
1523 |
attribute, this function returns QVariant::Invalid.
|
|
1524 |
|
|
1525 |
\sa attributes(), valueType()
|
|
1526 |
*/
|
|
1527 |
int QtVariantPropertyManager::attributeType(int propertyType, const QString &attribute) const
|
|
1528 |
{
|
|
1529 |
QMap<int, QMap<QString, int> >::ConstIterator it =
|
|
1530 |
d_ptr->m_typeToAttributeToAttributeType.find(propertyType);
|
|
1531 |
if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd())
|
|
1532 |
return 0;
|
|
1533 |
|
|
1534 |
QMap<QString, int> attributes = it.value();
|
|
1535 |
QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute);
|
|
1536 |
if (itAttr == attributes.constEnd())
|
|
1537 |
return 0;
|
|
1538 |
return itAttr.value();
|
|
1539 |
}
|
|
1540 |
|
|
1541 |
/*!
|
|
1542 |
\fn void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &value)
|
|
1543 |
|
|
1544 |
Sets the value of the given \a property to \a value.
|
|
1545 |
|
|
1546 |
The specified \a value must be of a type returned by valueType(),
|
|
1547 |
or of type that can be converted to valueType() using the
|
|
1548 |
QVariant::canConvert() function, otherwise this function does
|
|
1549 |
nothing.
|
|
1550 |
|
|
1551 |
\sa value(), QtVariantProperty::setValue(), valueChanged()
|
|
1552 |
*/
|
|
1553 |
void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &val)
|
|
1554 |
{
|
|
1555 |
int propType = val.userType();
|
|
1556 |
if (!propType)
|
|
1557 |
return;
|
|
1558 |
|
|
1559 |
int valType = valueType(property);
|
|
1560 |
|
|
1561 |
if (propType != valType && !val.canConvert(static_cast<QVariant::Type>(valType)))
|
|
1562 |
return;
|
|
1563 |
|
|
1564 |
QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
|
|
1565 |
if (internProp == 0)
|
|
1566 |
return;
|
|
1567 |
|
|
1568 |
|
|
1569 |
QtAbstractPropertyManager *manager = internProp->propertyManager();
|
|
1570 |
if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
|
|
1571 |
intManager->setValue(internProp, qVariantValue<int>(val));
|
|
1572 |
return;
|
|
1573 |
} else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
|
|
1574 |
doubleManager->setValue(internProp, qVariantValue<double>(val));
|
|
1575 |
return;
|
|
1576 |
} else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) {
|
|
1577 |
boolManager->setValue(internProp, qVariantValue<bool>(val));
|
|
1578 |
return;
|
|
1579 |
} else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
|
|
1580 |
stringManager->setValue(internProp, qVariantValue<QString>(val));
|
|
1581 |
return;
|
|
1582 |
} else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
|
|
1583 |
dateManager->setValue(internProp, qVariantValue<QDate>(val));
|
|
1584 |
return;
|
|
1585 |
} else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) {
|
|
1586 |
timeManager->setValue(internProp, qVariantValue<QTime>(val));
|
|
1587 |
return;
|
|
1588 |
} else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) {
|
|
1589 |
dateTimeManager->setValue(internProp, qVariantValue<QDateTime>(val));
|
|
1590 |
return;
|
|
1591 |
} else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) {
|
|
1592 |
keySequenceManager->setValue(internProp, qVariantValue<QKeySequence>(val));
|
|
1593 |
return;
|
|
1594 |
} else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) {
|
|
1595 |
charManager->setValue(internProp, qVariantValue<QChar>(val));
|
|
1596 |
return;
|
|
1597 |
} else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) {
|
|
1598 |
localeManager->setValue(internProp, qVariantValue<QLocale>(val));
|
|
1599 |
return;
|
|
1600 |
} else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) {
|
|
1601 |
pointManager->setValue(internProp, qVariantValue<QPoint>(val));
|
|
1602 |
return;
|
|
1603 |
} else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
|
|
1604 |
pointFManager->setValue(internProp, qVariantValue<QPointF>(val));
|
|
1605 |
return;
|
|
1606 |
} else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
|
|
1607 |
sizeManager->setValue(internProp, qVariantValue<QSize>(val));
|
|
1608 |
return;
|
|
1609 |
} else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
|
|
1610 |
sizeFManager->setValue(internProp, qVariantValue<QSizeF>(val));
|
|
1611 |
return;
|
|
1612 |
} else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
|
|
1613 |
rectManager->setValue(internProp, qVariantValue<QRect>(val));
|
|
1614 |
return;
|
|
1615 |
} else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
|
|
1616 |
rectFManager->setValue(internProp, qVariantValue<QRectF>(val));
|
|
1617 |
return;
|
|
1618 |
} else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) {
|
|
1619 |
colorManager->setValue(internProp, qVariantValue<QColor>(val));
|
|
1620 |
return;
|
|
1621 |
} else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
|
|
1622 |
enumManager->setValue(internProp, qVariantValue<int>(val));
|
|
1623 |
return;
|
|
1624 |
} else if (QtSizePolicyPropertyManager *sizePolicyManager =
|
|
1625 |
qobject_cast<QtSizePolicyPropertyManager *>(manager)) {
|
|
1626 |
sizePolicyManager->setValue(internProp, qVariantValue<QSizePolicy>(val));
|
|
1627 |
return;
|
|
1628 |
} else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) {
|
|
1629 |
fontManager->setValue(internProp, qVariantValue<QFont>(val));
|
|
1630 |
return;
|
|
1631 |
#ifndef QT_NO_CURSOR
|
|
1632 |
} else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) {
|
|
1633 |
cursorManager->setValue(internProp, qVariantValue<QCursor>(val));
|
|
1634 |
return;
|
|
1635 |
#endif
|
|
1636 |
} else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
|
|
1637 |
flagManager->setValue(internProp, qVariantValue<int>(val));
|
|
1638 |
return;
|
|
1639 |
}
|
|
1640 |
}
|
|
1641 |
|
|
1642 |
/*!
|
|
1643 |
Sets the value of the specified \a attribute of the given \a
|
|
1644 |
property, to \a value.
|
|
1645 |
|
|
1646 |
The new \a value's type must be of the type returned by
|
|
1647 |
attributeType(), or of a type that can be converted to
|
|
1648 |
attributeType() using the QVariant::canConvert() function,
|
|
1649 |
otherwise this function does nothing.
|
|
1650 |
|
|
1651 |
\sa attributeValue(), QtVariantProperty::setAttribute(), attributeChanged()
|
|
1652 |
*/
|
|
1653 |
void QtVariantPropertyManager::setAttribute(QtProperty *property,
|
|
1654 |
const QString &attribute, const QVariant &value)
|
|
1655 |
{
|
|
1656 |
QVariant oldAttr = attributeValue(property, attribute);
|
|
1657 |
if (!oldAttr.isValid())
|
|
1658 |
return;
|
|
1659 |
|
|
1660 |
int attrType = value.userType();
|
|
1661 |
if (!attrType)
|
|
1662 |
return;
|
|
1663 |
|
|
1664 |
if (attrType != attributeType(propertyType(property), attribute) &&
|
|
1665 |
!value.canConvert((QVariant::Type)attrType))
|
|
1666 |
return;
|
|
1667 |
|
|
1668 |
QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
|
|
1669 |
if (internProp == 0)
|
|
1670 |
return;
|
|
1671 |
|
|
1672 |
QtAbstractPropertyManager *manager = internProp->propertyManager();
|
|
1673 |
if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
|
|
1674 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1675 |
intManager->setMaximum(internProp, qVariantValue<int>(value));
|
|
1676 |
else if (attribute == d_ptr->m_minimumAttribute)
|
|
1677 |
intManager->setMinimum(internProp, qVariantValue<int>(value));
|
|
1678 |
else if (attribute == d_ptr->m_singleStepAttribute)
|
|
1679 |
intManager->setSingleStep(internProp, qVariantValue<int>(value));
|
|
1680 |
return;
|
|
1681 |
} else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
|
|
1682 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1683 |
doubleManager->setMaximum(internProp, qVariantValue<double>(value));
|
|
1684 |
if (attribute == d_ptr->m_minimumAttribute)
|
|
1685 |
doubleManager->setMinimum(internProp, qVariantValue<double>(value));
|
|
1686 |
if (attribute == d_ptr->m_singleStepAttribute)
|
|
1687 |
doubleManager->setSingleStep(internProp, qVariantValue<double>(value));
|
|
1688 |
if (attribute == d_ptr->m_decimalsAttribute)
|
|
1689 |
doubleManager->setDecimals(internProp, qVariantValue<int>(value));
|
|
1690 |
return;
|
|
1691 |
} else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
|
|
1692 |
if (attribute == d_ptr->m_regExpAttribute)
|
|
1693 |
stringManager->setRegExp(internProp, qVariantValue<QRegExp>(value));
|
|
1694 |
return;
|
|
1695 |
} else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
|
|
1696 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1697 |
dateManager->setMaximum(internProp, qVariantValue<QDate>(value));
|
|
1698 |
if (attribute == d_ptr->m_minimumAttribute)
|
|
1699 |
dateManager->setMinimum(internProp, qVariantValue<QDate>(value));
|
|
1700 |
return;
|
|
1701 |
} else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
|
|
1702 |
if (attribute == d_ptr->m_decimalsAttribute)
|
|
1703 |
pointFManager->setDecimals(internProp, qVariantValue<int>(value));
|
|
1704 |
return;
|
|
1705 |
} else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
|
|
1706 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1707 |
sizeManager->setMaximum(internProp, qVariantValue<QSize>(value));
|
|
1708 |
if (attribute == d_ptr->m_minimumAttribute)
|
|
1709 |
sizeManager->setMinimum(internProp, qVariantValue<QSize>(value));
|
|
1710 |
return;
|
|
1711 |
} else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
|
|
1712 |
if (attribute == d_ptr->m_maximumAttribute)
|
|
1713 |
sizeFManager->setMaximum(internProp, qVariantValue<QSizeF>(value));
|
|
1714 |
if (attribute == d_ptr->m_minimumAttribute)
|
|
1715 |
sizeFManager->setMinimum(internProp, qVariantValue<QSizeF>(value));
|
|
1716 |
if (attribute == d_ptr->m_decimalsAttribute)
|
|
1717 |
sizeFManager->setDecimals(internProp, qVariantValue<int>(value));
|
|
1718 |
return;
|
|
1719 |
} else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
|
|
1720 |
if (attribute == d_ptr->m_constraintAttribute)
|
|
1721 |
rectManager->setConstraint(internProp, qVariantValue<QRect>(value));
|
|
1722 |
return;
|
|
1723 |
} else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
|
|
1724 |
if (attribute == d_ptr->m_constraintAttribute)
|
|
1725 |
rectFManager->setConstraint(internProp, qVariantValue<QRectF>(value));
|
|
1726 |
if (attribute == d_ptr->m_decimalsAttribute)
|
|
1727 |
rectFManager->setDecimals(internProp, qVariantValue<int>(value));
|
|
1728 |
return;
|
|
1729 |
} else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
|
|
1730 |
if (attribute == d_ptr->m_enumNamesAttribute)
|
|
1731 |
enumManager->setEnumNames(internProp, qVariantValue<QStringList>(value));
|
|
1732 |
if (attribute == d_ptr->m_enumIconsAttribute)
|
|
1733 |
enumManager->setEnumIcons(internProp, qVariantValue<QtIconMap>(value));
|
|
1734 |
return;
|
|
1735 |
} else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
|
|
1736 |
if (attribute == d_ptr->m_flagNamesAttribute)
|
|
1737 |
flagManager->setFlagNames(internProp, qVariantValue<QStringList>(value));
|
|
1738 |
return;
|
|
1739 |
}
|
|
1740 |
}
|
|
1741 |
|
|
1742 |
/*!
|
|
1743 |
\reimp
|
|
1744 |
*/
|
|
1745 |
bool QtVariantPropertyManager::hasValue(const QtProperty *property) const
|
|
1746 |
{
|
|
1747 |
if (propertyType(property) == groupTypeId())
|
|
1748 |
return false;
|
|
1749 |
return true;
|
|
1750 |
}
|
|
1751 |
|
|
1752 |
/*!
|
|
1753 |
\reimp
|
|
1754 |
*/
|
|
1755 |
QString QtVariantPropertyManager::valueText(const QtProperty *property) const
|
|
1756 |
{
|
|
1757 |
const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
|
|
1758 |
return internProp ? internProp->valueText() : QString();
|
|
1759 |
}
|
|
1760 |
|
|
1761 |
/*!
|
|
1762 |
\reimp
|
|
1763 |
*/
|
|
1764 |
QIcon QtVariantPropertyManager::valueIcon(const QtProperty *property) const
|
|
1765 |
{
|
|
1766 |
const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
|
|
1767 |
return internProp ? internProp->valueIcon() : QIcon();
|
|
1768 |
}
|
|
1769 |
|
|
1770 |
/*!
|
|
1771 |
\reimp
|
|
1772 |
*/
|
|
1773 |
void QtVariantPropertyManager::initializeProperty(QtProperty *property)
|
|
1774 |
{
|
|
1775 |
QtVariantProperty *varProp = variantProperty(property);
|
|
1776 |
if (!varProp)
|
|
1777 |
return;
|
|
1778 |
|
|
1779 |
QMap<int, QtAbstractPropertyManager *>::ConstIterator it =
|
|
1780 |
d_ptr->m_typeToPropertyManager.find(d_ptr->m_propertyType);
|
|
1781 |
if (it != d_ptr->m_typeToPropertyManager.constEnd()) {
|
|
1782 |
QtProperty *internProp = 0;
|
|
1783 |
if (!d_ptr->m_creatingSubProperties) {
|
|
1784 |
QtAbstractPropertyManager *manager = it.value();
|
|
1785 |
internProp = manager->addProperty();
|
|
1786 |
d_ptr->m_internalToProperty[internProp] = varProp;
|
|
1787 |
}
|
|
1788 |
propertyToWrappedProperty()->insert(varProp, internProp);
|
|
1789 |
if (internProp) {
|
|
1790 |
QList<QtProperty *> children = internProp->subProperties();
|
|
1791 |
QListIterator<QtProperty *> itChild(children);
|
|
1792 |
QtVariantProperty *lastProperty = 0;
|
|
1793 |
while (itChild.hasNext()) {
|
|
1794 |
QtVariantProperty *prop = d_ptr->createSubProperty(varProp, lastProperty, itChild.next());
|
|
1795 |
lastProperty = prop ? prop : lastProperty;
|
|
1796 |
}
|
|
1797 |
}
|
|
1798 |
}
|
|
1799 |
}
|
|
1800 |
|
|
1801 |
/*!
|
|
1802 |
\reimp
|
|
1803 |
*/
|
|
1804 |
void QtVariantPropertyManager::uninitializeProperty(QtProperty *property)
|
|
1805 |
{
|
|
1806 |
const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::iterator type_it = d_ptr->m_propertyToType.find(property);
|
|
1807 |
if (type_it == d_ptr->m_propertyToType.end())
|
|
1808 |
return;
|
|
1809 |
|
|
1810 |
PropertyMap::iterator it = propertyToWrappedProperty()->find(property);
|
|
1811 |
if (it != propertyToWrappedProperty()->end()) {
|
|
1812 |
QtProperty *internProp = it.value();
|
|
1813 |
if (internProp) {
|
|
1814 |
d_ptr->m_internalToProperty.remove(internProp);
|
|
1815 |
if (!d_ptr->m_destroyingSubProperties) {
|
|
1816 |
delete internProp;
|
|
1817 |
}
|
|
1818 |
}
|
|
1819 |
propertyToWrappedProperty()->erase(it);
|
|
1820 |
}
|
|
1821 |
d_ptr->m_propertyToType.erase(type_it);
|
|
1822 |
}
|
|
1823 |
|
|
1824 |
/*!
|
|
1825 |
\reimp
|
|
1826 |
*/
|
|
1827 |
QtProperty *QtVariantPropertyManager::createProperty()
|
|
1828 |
{
|
|
1829 |
if (!d_ptr->m_creatingProperty)
|
|
1830 |
return 0;
|
|
1831 |
|
|
1832 |
QtVariantProperty *property = new QtVariantProperty(this);
|
|
1833 |
d_ptr->m_propertyToType.insert(property, qMakePair(property, d_ptr->m_propertyType));
|
|
1834 |
|
|
1835 |
return property;
|
|
1836 |
}
|
|
1837 |
|
|
1838 |
/////////////////////////////
|
|
1839 |
|
|
1840 |
class QtVariantEditorFactoryPrivate
|
|
1841 |
{
|
|
1842 |
QtVariantEditorFactory *q_ptr;
|
|
1843 |
Q_DECLARE_PUBLIC(QtVariantEditorFactory)
|
|
1844 |
public:
|
|
1845 |
|
|
1846 |
QtSpinBoxFactory *m_spinBoxFactory;
|
|
1847 |
QtDoubleSpinBoxFactory *m_doubleSpinBoxFactory;
|
|
1848 |
QtCheckBoxFactory *m_checkBoxFactory;
|
|
1849 |
QtLineEditFactory *m_lineEditFactory;
|
|
1850 |
QtDateEditFactory *m_dateEditFactory;
|
|
1851 |
QtTimeEditFactory *m_timeEditFactory;
|
|
1852 |
QtDateTimeEditFactory *m_dateTimeEditFactory;
|
|
1853 |
QtKeySequenceEditorFactory *m_keySequenceEditorFactory;
|
|
1854 |
QtCharEditorFactory *m_charEditorFactory;
|
|
1855 |
QtEnumEditorFactory *m_comboBoxFactory;
|
|
1856 |
QtCursorEditorFactory *m_cursorEditorFactory;
|
|
1857 |
QtColorEditorFactory *m_colorEditorFactory;
|
|
1858 |
QtFontEditorFactory *m_fontEditorFactory;
|
|
1859 |
|
|
1860 |
QMap<QtAbstractEditorFactoryBase *, int> m_factoryToType;
|
|
1861 |
QMap<int, QtAbstractEditorFactoryBase *> m_typeToFactory;
|
|
1862 |
};
|
|
1863 |
|
|
1864 |
/*!
|
|
1865 |
\class QtVariantEditorFactory
|
|
1866 |
\internal
|
|
1867 |
\inmodule QtDesigner
|
|
1868 |
\since 4.4
|
|
1869 |
|
|
1870 |
\brief The QtVariantEditorFactory class provides widgets for properties
|
|
1871 |
created by QtVariantPropertyManager objects.
|
|
1872 |
|
|
1873 |
The variant factory provides the following widgets for the
|
|
1874 |
specified property types:
|
|
1875 |
|
|
1876 |
\table
|
|
1877 |
\header
|
|
1878 |
\o Property Type
|
|
1879 |
\o Widget
|
|
1880 |
\row
|
|
1881 |
\o \c int
|
|
1882 |
\o QSpinBox
|
|
1883 |
\row
|
|
1884 |
\o \c double
|
|
1885 |
\o QDoubleSpinBox
|
|
1886 |
\row
|
|
1887 |
\o \c bool
|
|
1888 |
\o QCheckBox
|
|
1889 |
\row
|
|
1890 |
\o QString
|
|
1891 |
\o QLineEdit
|
|
1892 |
\row
|
|
1893 |
\o QDate
|
|
1894 |
\o QDateEdit
|
|
1895 |
\row
|
|
1896 |
\o QTime
|
|
1897 |
\o QTimeEdit
|
|
1898 |
\row
|
|
1899 |
\o QDateTime
|
|
1900 |
\o QDateTimeEdit
|
|
1901 |
\row
|
|
1902 |
\o QKeySequence
|
|
1903 |
\o customized editor
|
|
1904 |
\row
|
|
1905 |
\o QChar
|
|
1906 |
\o customized editor
|
|
1907 |
\row
|
|
1908 |
\o \c enum
|
|
1909 |
\o QComboBox
|
|
1910 |
\row
|
|
1911 |
\o QCursor
|
|
1912 |
\o QComboBox
|
|
1913 |
\endtable
|
|
1914 |
|
|
1915 |
Note that QtVariantPropertyManager supports several additional property
|
|
1916 |
types for which the QtVariantEditorFactory class does not provide
|
|
1917 |
editing widgets, e.g. QPoint and QSize. To provide widgets for other
|
|
1918 |
types using the variant approach, derive from the QtVariantEditorFactory
|
|
1919 |
class.
|
|
1920 |
|
|
1921 |
\sa QtAbstractEditorFactory, QtVariantPropertyManager
|
|
1922 |
*/
|
|
1923 |
|
|
1924 |
/*!
|
|
1925 |
Creates a factory with the given \a parent.
|
|
1926 |
*/
|
|
1927 |
QtVariantEditorFactory::QtVariantEditorFactory(QObject *parent)
|
|
1928 |
: QtAbstractEditorFactory<QtVariantPropertyManager>(parent), d_ptr(new QtVariantEditorFactoryPrivate())
|
|
1929 |
{
|
|
1930 |
d_ptr->q_ptr = this;
|
|
1931 |
|
|
1932 |
d_ptr->m_spinBoxFactory = new QtSpinBoxFactory(this);
|
|
1933 |
d_ptr->m_factoryToType[d_ptr->m_spinBoxFactory] = QVariant::Int;
|
|
1934 |
d_ptr->m_typeToFactory[QVariant::Int] = d_ptr->m_spinBoxFactory;
|
|
1935 |
|
|
1936 |
d_ptr->m_doubleSpinBoxFactory = new QtDoubleSpinBoxFactory(this);
|
|
1937 |
d_ptr->m_factoryToType[d_ptr->m_doubleSpinBoxFactory] = QVariant::Double;
|
|
1938 |
d_ptr->m_typeToFactory[QVariant::Double] = d_ptr->m_doubleSpinBoxFactory;
|
|
1939 |
|
|
1940 |
d_ptr->m_checkBoxFactory = new QtCheckBoxFactory(this);
|
|
1941 |
d_ptr->m_factoryToType[d_ptr->m_checkBoxFactory] = QVariant::Bool;
|
|
1942 |
d_ptr->m_typeToFactory[QVariant::Bool] = d_ptr->m_checkBoxFactory;
|
|
1943 |
|
|
1944 |
d_ptr->m_lineEditFactory = new QtLineEditFactory(this);
|
|
1945 |
d_ptr->m_factoryToType[d_ptr->m_lineEditFactory] = QVariant::String;
|
|
1946 |
d_ptr->m_typeToFactory[QVariant::String] = d_ptr->m_lineEditFactory;
|
|
1947 |
|
|
1948 |
d_ptr->m_dateEditFactory = new QtDateEditFactory(this);
|
|
1949 |
d_ptr->m_factoryToType[d_ptr->m_dateEditFactory] = QVariant::Date;
|
|
1950 |
d_ptr->m_typeToFactory[QVariant::Date] = d_ptr->m_dateEditFactory;
|
|
1951 |
|
|
1952 |
d_ptr->m_timeEditFactory = new QtTimeEditFactory(this);
|
|
1953 |
d_ptr->m_factoryToType[d_ptr->m_timeEditFactory] = QVariant::Time;
|
|
1954 |
d_ptr->m_typeToFactory[QVariant::Time] = d_ptr->m_timeEditFactory;
|
|
1955 |
|
|
1956 |
d_ptr->m_dateTimeEditFactory = new QtDateTimeEditFactory(this);
|
|
1957 |
d_ptr->m_factoryToType[d_ptr->m_dateTimeEditFactory] = QVariant::DateTime;
|
|
1958 |
d_ptr->m_typeToFactory[QVariant::DateTime] = d_ptr->m_dateTimeEditFactory;
|
|
1959 |
|
|
1960 |
d_ptr->m_keySequenceEditorFactory = new QtKeySequenceEditorFactory(this);
|
|
1961 |
d_ptr->m_factoryToType[d_ptr->m_keySequenceEditorFactory] = QVariant::KeySequence;
|
|
1962 |
d_ptr->m_typeToFactory[QVariant::KeySequence] = d_ptr->m_keySequenceEditorFactory;
|
|
1963 |
|
|
1964 |
d_ptr->m_charEditorFactory = new QtCharEditorFactory(this);
|
|
1965 |
d_ptr->m_factoryToType[d_ptr->m_charEditorFactory] = QVariant::Char;
|
|
1966 |
d_ptr->m_typeToFactory[QVariant::Char] = d_ptr->m_charEditorFactory;
|
|
1967 |
|
|
1968 |
d_ptr->m_cursorEditorFactory = new QtCursorEditorFactory(this);
|
|
1969 |
d_ptr->m_factoryToType[d_ptr->m_cursorEditorFactory] = QVariant::Cursor;
|
|
1970 |
d_ptr->m_typeToFactory[QVariant::Cursor] = d_ptr->m_cursorEditorFactory;
|
|
1971 |
|
|
1972 |
d_ptr->m_colorEditorFactory = new QtColorEditorFactory(this);
|
|
1973 |
d_ptr->m_factoryToType[d_ptr->m_colorEditorFactory] = QVariant::Color;
|
|
1974 |
d_ptr->m_typeToFactory[QVariant::Color] = d_ptr->m_colorEditorFactory;
|
|
1975 |
|
|
1976 |
d_ptr->m_fontEditorFactory = new QtFontEditorFactory(this);
|
|
1977 |
d_ptr->m_factoryToType[d_ptr->m_fontEditorFactory] = QVariant::Font;
|
|
1978 |
d_ptr->m_typeToFactory[QVariant::Font] = d_ptr->m_fontEditorFactory;
|
|
1979 |
|
|
1980 |
d_ptr->m_comboBoxFactory = new QtEnumEditorFactory(this);
|
|
1981 |
const int enumId = QtVariantPropertyManager::enumTypeId();
|
|
1982 |
d_ptr->m_factoryToType[d_ptr->m_comboBoxFactory] = enumId;
|
|
1983 |
d_ptr->m_typeToFactory[enumId] = d_ptr->m_comboBoxFactory;
|
|
1984 |
}
|
|
1985 |
|
|
1986 |
/*!
|
|
1987 |
Destroys this factory, and all the widgets it has created.
|
|
1988 |
*/
|
|
1989 |
QtVariantEditorFactory::~QtVariantEditorFactory()
|
|
1990 |
{
|
|
1991 |
}
|
|
1992 |
|
|
1993 |
/*!
|
|
1994 |
\internal
|
|
1995 |
|
|
1996 |
Reimplemented from the QtAbstractEditorFactory class.
|
|
1997 |
*/
|
|
1998 |
void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *manager)
|
|
1999 |
{
|
|
2000 |
QList<QtIntPropertyManager *> intPropertyManagers = qFindChildren<QtIntPropertyManager *>(manager);
|
|
2001 |
QListIterator<QtIntPropertyManager *> itInt(intPropertyManagers);
|
|
2002 |
while (itInt.hasNext())
|
|
2003 |
d_ptr->m_spinBoxFactory->addPropertyManager(itInt.next());
|
|
2004 |
|
|
2005 |
QList<QtDoublePropertyManager *> doublePropertyManagers = qFindChildren<QtDoublePropertyManager *>(manager);
|
|
2006 |
QListIterator<QtDoublePropertyManager *> itDouble(doublePropertyManagers);
|
|
2007 |
while (itDouble.hasNext())
|
|
2008 |
d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itDouble.next());
|
|
2009 |
|
|
2010 |
QList<QtBoolPropertyManager *> boolPropertyManagers = qFindChildren<QtBoolPropertyManager *>(manager);
|
|
2011 |
QListIterator<QtBoolPropertyManager *> itBool(boolPropertyManagers);
|
|
2012 |
while (itBool.hasNext())
|
|
2013 |
d_ptr->m_checkBoxFactory->addPropertyManager(itBool.next());
|
|
2014 |
|
|
2015 |
QList<QtStringPropertyManager *> stringPropertyManagers = qFindChildren<QtStringPropertyManager *>(manager);
|
|
2016 |
QListIterator<QtStringPropertyManager *> itString(stringPropertyManagers);
|
|
2017 |
while (itString.hasNext())
|
|
2018 |
d_ptr->m_lineEditFactory->addPropertyManager(itString.next());
|
|
2019 |
|
|
2020 |
QList<QtDatePropertyManager *> datePropertyManagers = qFindChildren<QtDatePropertyManager *>(manager);
|
|
2021 |
QListIterator<QtDatePropertyManager *> itDate(datePropertyManagers);
|
|
2022 |
while (itDate.hasNext())
|
|
2023 |
d_ptr->m_dateEditFactory->addPropertyManager(itDate.next());
|
|
2024 |
|
|
2025 |
QList<QtTimePropertyManager *> timePropertyManagers = qFindChildren<QtTimePropertyManager *>(manager);
|
|
2026 |
QListIterator<QtTimePropertyManager *> itTime(timePropertyManagers);
|
|
2027 |
while (itTime.hasNext())
|
|
2028 |
d_ptr->m_timeEditFactory->addPropertyManager(itTime.next());
|
|
2029 |
|
|
2030 |
QList<QtDateTimePropertyManager *> dateTimePropertyManagers = qFindChildren<QtDateTimePropertyManager *>(manager);
|
|
2031 |
QListIterator<QtDateTimePropertyManager *> itDateTime(dateTimePropertyManagers);
|
|
2032 |
while (itDateTime.hasNext())
|
|
2033 |
d_ptr->m_dateTimeEditFactory->addPropertyManager(itDateTime.next());
|
|
2034 |
|
|
2035 |
QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = qFindChildren<QtKeySequencePropertyManager *>(manager);
|
|
2036 |
QListIterator<QtKeySequencePropertyManager *> itKeySequence(keySequencePropertyManagers);
|
|
2037 |
while (itKeySequence.hasNext())
|
|
2038 |
d_ptr->m_keySequenceEditorFactory->addPropertyManager(itKeySequence.next());
|
|
2039 |
|
|
2040 |
QList<QtCharPropertyManager *> charPropertyManagers = qFindChildren<QtCharPropertyManager *>(manager);
|
|
2041 |
QListIterator<QtCharPropertyManager *> itChar(charPropertyManagers);
|
|
2042 |
while (itChar.hasNext())
|
|
2043 |
d_ptr->m_charEditorFactory->addPropertyManager(itChar.next());
|
|
2044 |
|
|
2045 |
QList<QtLocalePropertyManager *> localePropertyManagers = qFindChildren<QtLocalePropertyManager *>(manager);
|
|
2046 |
QListIterator<QtLocalePropertyManager *> itLocale(localePropertyManagers);
|
|
2047 |
while (itLocale.hasNext())
|
|
2048 |
d_ptr->m_comboBoxFactory->addPropertyManager(itLocale.next()->subEnumPropertyManager());
|
|
2049 |
|
|
2050 |
QList<QtPointPropertyManager *> pointPropertyManagers = qFindChildren<QtPointPropertyManager *>(manager);
|
|
2051 |
QListIterator<QtPointPropertyManager *> itPoint(pointPropertyManagers);
|
|
2052 |
while (itPoint.hasNext())
|
|
2053 |
d_ptr->m_spinBoxFactory->addPropertyManager(itPoint.next()->subIntPropertyManager());
|
|
2054 |
|
|
2055 |
QList<QtPointFPropertyManager *> pointFPropertyManagers = qFindChildren<QtPointFPropertyManager *>(manager);
|
|
2056 |
QListIterator<QtPointFPropertyManager *> itPointF(pointFPropertyManagers);
|
|
2057 |
while (itPointF.hasNext())
|
|
2058 |
d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itPointF.next()->subDoublePropertyManager());
|
|
2059 |
|
|
2060 |
QList<QtSizePropertyManager *> sizePropertyManagers = qFindChildren<QtSizePropertyManager *>(manager);
|
|
2061 |
QListIterator<QtSizePropertyManager *> itSize(sizePropertyManagers);
|
|
2062 |
while (itSize.hasNext())
|
|
2063 |
d_ptr->m_spinBoxFactory->addPropertyManager(itSize.next()->subIntPropertyManager());
|
|
2064 |
|
|
2065 |
QList<QtSizeFPropertyManager *> sizeFPropertyManagers = qFindChildren<QtSizeFPropertyManager *>(manager);
|
|
2066 |
QListIterator<QtSizeFPropertyManager *> itSizeF(sizeFPropertyManagers);
|
|
2067 |
while (itSizeF.hasNext())
|
|
2068 |
d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itSizeF.next()->subDoublePropertyManager());
|
|
2069 |
|
|
2070 |
QList<QtRectPropertyManager *> rectPropertyManagers = qFindChildren<QtRectPropertyManager *>(manager);
|
|
2071 |
QListIterator<QtRectPropertyManager *> itRect(rectPropertyManagers);
|
|
2072 |
while (itRect.hasNext())
|
|
2073 |
d_ptr->m_spinBoxFactory->addPropertyManager(itRect.next()->subIntPropertyManager());
|
|
2074 |
|
|
2075 |
QList<QtRectFPropertyManager *> rectFPropertyManagers = qFindChildren<QtRectFPropertyManager *>(manager);
|
|
2076 |
QListIterator<QtRectFPropertyManager *> itRectF(rectFPropertyManagers);
|
|
2077 |
while (itRectF.hasNext())
|
|
2078 |
d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itRectF.next()->subDoublePropertyManager());
|
|
2079 |
|
|
2080 |
QList<QtColorPropertyManager *> colorPropertyManagers = qFindChildren<QtColorPropertyManager *>(manager);
|
|
2081 |
QListIterator<QtColorPropertyManager *> itColor(colorPropertyManagers);
|
|
2082 |
while (itColor.hasNext()) {
|
|
2083 |
QtColorPropertyManager *manager = itColor.next();
|
|
2084 |
d_ptr->m_colorEditorFactory->addPropertyManager(manager);
|
|
2085 |
d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager());
|
|
2086 |
}
|
|
2087 |
|
|
2088 |
QList<QtEnumPropertyManager *> enumPropertyManagers = qFindChildren<QtEnumPropertyManager *>(manager);
|
|
2089 |
QListIterator<QtEnumPropertyManager *> itEnum(enumPropertyManagers);
|
|
2090 |
while (itEnum.hasNext())
|
|
2091 |
d_ptr->m_comboBoxFactory->addPropertyManager(itEnum.next());
|
|
2092 |
|
|
2093 |
QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = qFindChildren<QtSizePolicyPropertyManager *>(manager);
|
|
2094 |
QListIterator<QtSizePolicyPropertyManager *> itSizePolicy(sizePolicyPropertyManagers);
|
|
2095 |
while (itSizePolicy.hasNext()) {
|
|
2096 |
QtSizePolicyPropertyManager *manager = itSizePolicy.next();
|
|
2097 |
d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager());
|
|
2098 |
d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager());
|
|
2099 |
}
|
|
2100 |
|
|
2101 |
QList<QtFontPropertyManager *> fontPropertyManagers = qFindChildren<QtFontPropertyManager *>(manager);
|
|
2102 |
QListIterator<QtFontPropertyManager *> itFont(fontPropertyManagers);
|
|
2103 |
while (itFont.hasNext()) {
|
|
2104 |
QtFontPropertyManager *manager = itFont.next();
|
|
2105 |
d_ptr->m_fontEditorFactory->addPropertyManager(manager);
|
|
2106 |
d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager());
|
|
2107 |
d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager());
|
|
2108 |
d_ptr->m_checkBoxFactory->addPropertyManager(manager->subBoolPropertyManager());
|
|
2109 |
}
|
|
2110 |
|
|
2111 |
QList<QtCursorPropertyManager *> cursorPropertyManagers = qFindChildren<QtCursorPropertyManager *>(manager);
|
|
2112 |
QListIterator<QtCursorPropertyManager *> itCursor(cursorPropertyManagers);
|
|
2113 |
while (itCursor.hasNext())
|
|
2114 |
d_ptr->m_cursorEditorFactory->addPropertyManager(itCursor.next());
|
|
2115 |
|
|
2116 |
QList<QtFlagPropertyManager *> flagPropertyManagers = qFindChildren<QtFlagPropertyManager *>(manager);
|
|
2117 |
QListIterator<QtFlagPropertyManager *> itFlag(flagPropertyManagers);
|
|
2118 |
while (itFlag.hasNext())
|
|
2119 |
d_ptr->m_checkBoxFactory->addPropertyManager(itFlag.next()->subBoolPropertyManager());
|
|
2120 |
}
|
|
2121 |
|
|
2122 |
/*!
|
|
2123 |
\internal
|
|
2124 |
|
|
2125 |
Reimplemented from the QtAbstractEditorFactory class.
|
|
2126 |
*/
|
|
2127 |
QWidget *QtVariantEditorFactory::createEditor(QtVariantPropertyManager *manager, QtProperty *property,
|
|
2128 |
QWidget *parent)
|
|
2129 |
{
|
|
2130 |
const int propType = manager->propertyType(property);
|
|
2131 |
QtAbstractEditorFactoryBase *factory = d_ptr->m_typeToFactory.value(propType, 0);
|
|
2132 |
if (!factory)
|
|
2133 |
return 0;
|
|
2134 |
return factory->createEditor(wrappedProperty(property), parent);
|
|
2135 |
}
|
|
2136 |
|
|
2137 |
/*!
|
|
2138 |
\internal
|
|
2139 |
|
|
2140 |
Reimplemented from the QtAbstractEditorFactory class.
|
|
2141 |
*/
|
|
2142 |
void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager *manager)
|
|
2143 |
{
|
|
2144 |
QList<QtIntPropertyManager *> intPropertyManagers = qFindChildren<QtIntPropertyManager *>(manager);
|
|
2145 |
QListIterator<QtIntPropertyManager *> itInt(intPropertyManagers);
|
|
2146 |
while (itInt.hasNext())
|
|
2147 |
d_ptr->m_spinBoxFactory->removePropertyManager(itInt.next());
|
|
2148 |
|
|
2149 |
QList<QtDoublePropertyManager *> doublePropertyManagers = qFindChildren<QtDoublePropertyManager *>(manager);
|
|
2150 |
QListIterator<QtDoublePropertyManager *> itDouble(doublePropertyManagers);
|
|
2151 |
while (itDouble.hasNext())
|
|
2152 |
d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itDouble.next());
|
|
2153 |
|
|
2154 |
QList<QtBoolPropertyManager *> boolPropertyManagers = qFindChildren<QtBoolPropertyManager *>(manager);
|
|
2155 |
QListIterator<QtBoolPropertyManager *> itBool(boolPropertyManagers);
|
|
2156 |
while (itBool.hasNext())
|
|
2157 |
d_ptr->m_checkBoxFactory->removePropertyManager(itBool.next());
|
|
2158 |
|
|
2159 |
QList<QtStringPropertyManager *> stringPropertyManagers = qFindChildren<QtStringPropertyManager *>(manager);
|
|
2160 |
QListIterator<QtStringPropertyManager *> itString(stringPropertyManagers);
|
|
2161 |
while (itString.hasNext())
|
|
2162 |
d_ptr->m_lineEditFactory->removePropertyManager(itString.next());
|
|
2163 |
|
|
2164 |
QList<QtDatePropertyManager *> datePropertyManagers = qFindChildren<QtDatePropertyManager *>(manager);
|
|
2165 |
QListIterator<QtDatePropertyManager *> itDate(datePropertyManagers);
|
|
2166 |
while (itDate.hasNext())
|
|
2167 |
d_ptr->m_dateEditFactory->removePropertyManager(itDate.next());
|
|
2168 |
|
|
2169 |
QList<QtTimePropertyManager *> timePropertyManagers = qFindChildren<QtTimePropertyManager *>(manager);
|
|
2170 |
QListIterator<QtTimePropertyManager *> itTime(timePropertyManagers);
|
|
2171 |
while (itTime.hasNext())
|
|
2172 |
d_ptr->m_timeEditFactory->removePropertyManager(itTime.next());
|
|
2173 |
|
|
2174 |
QList<QtDateTimePropertyManager *> dateTimePropertyManagers = qFindChildren<QtDateTimePropertyManager *>(manager);
|
|
2175 |
QListIterator<QtDateTimePropertyManager *> itDateTime(dateTimePropertyManagers);
|
|
2176 |
while (itDateTime.hasNext())
|
|
2177 |
d_ptr->m_dateTimeEditFactory->removePropertyManager(itDateTime.next());
|
|
2178 |
|
|
2179 |
QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = qFindChildren<QtKeySequencePropertyManager *>(manager);
|
|
2180 |
QListIterator<QtKeySequencePropertyManager *> itKeySequence(keySequencePropertyManagers);
|
|
2181 |
while (itKeySequence.hasNext())
|
|
2182 |
d_ptr->m_keySequenceEditorFactory->removePropertyManager(itKeySequence.next());
|
|
2183 |
|
|
2184 |
QList<QtCharPropertyManager *> charPropertyManagers = qFindChildren<QtCharPropertyManager *>(manager);
|
|
2185 |
QListIterator<QtCharPropertyManager *> itChar(charPropertyManagers);
|
|
2186 |
while (itChar.hasNext())
|
|
2187 |
d_ptr->m_charEditorFactory->removePropertyManager(itChar.next());
|
|
2188 |
|
|
2189 |
QList<QtLocalePropertyManager *> localePropertyManagers = qFindChildren<QtLocalePropertyManager *>(manager);
|
|
2190 |
QListIterator<QtLocalePropertyManager *> itLocale(localePropertyManagers);
|
|
2191 |
while (itLocale.hasNext())
|
|
2192 |
d_ptr->m_comboBoxFactory->removePropertyManager(itLocale.next()->subEnumPropertyManager());
|
|
2193 |
|
|
2194 |
QList<QtPointPropertyManager *> pointPropertyManagers = qFindChildren<QtPointPropertyManager *>(manager);
|
|
2195 |
QListIterator<QtPointPropertyManager *> itPoint(pointPropertyManagers);
|
|
2196 |
while (itPoint.hasNext())
|
|
2197 |
d_ptr->m_spinBoxFactory->removePropertyManager(itPoint.next()->subIntPropertyManager());
|
|
2198 |
|
|
2199 |
QList<QtPointFPropertyManager *> pointFPropertyManagers = qFindChildren<QtPointFPropertyManager *>(manager);
|
|
2200 |
QListIterator<QtPointFPropertyManager *> itPointF(pointFPropertyManagers);
|
|
2201 |
while (itPointF.hasNext())
|
|
2202 |
d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itPointF.next()->subDoublePropertyManager());
|
|
2203 |
|
|
2204 |
QList<QtSizePropertyManager *> sizePropertyManagers = qFindChildren<QtSizePropertyManager *>(manager);
|
|
2205 |
QListIterator<QtSizePropertyManager *> itSize(sizePropertyManagers);
|
|
2206 |
while (itSize.hasNext())
|
|
2207 |
d_ptr->m_spinBoxFactory->removePropertyManager(itSize.next()->subIntPropertyManager());
|
|
2208 |
|
|
2209 |
QList<QtSizeFPropertyManager *> sizeFPropertyManagers = qFindChildren<QtSizeFPropertyManager *>(manager);
|
|
2210 |
QListIterator<QtSizeFPropertyManager *> itSizeF(sizeFPropertyManagers);
|
|
2211 |
while (itSizeF.hasNext())
|
|
2212 |
d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itSizeF.next()->subDoublePropertyManager());
|
|
2213 |
|
|
2214 |
QList<QtRectPropertyManager *> rectPropertyManagers = qFindChildren<QtRectPropertyManager *>(manager);
|
|
2215 |
QListIterator<QtRectPropertyManager *> itRect(rectPropertyManagers);
|
|
2216 |
while (itRect.hasNext())
|
|
2217 |
d_ptr->m_spinBoxFactory->removePropertyManager(itRect.next()->subIntPropertyManager());
|
|
2218 |
|
|
2219 |
QList<QtRectFPropertyManager *> rectFPropertyManagers = qFindChildren<QtRectFPropertyManager *>(manager);
|
|
2220 |
QListIterator<QtRectFPropertyManager *> itRectF(rectFPropertyManagers);
|
|
2221 |
while (itRectF.hasNext())
|
|
2222 |
d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itRectF.next()->subDoublePropertyManager());
|
|
2223 |
|
|
2224 |
QList<QtColorPropertyManager *> colorPropertyManagers = qFindChildren<QtColorPropertyManager *>(manager);
|
|
2225 |
QListIterator<QtColorPropertyManager *> itColor(colorPropertyManagers);
|
|
2226 |
while (itColor.hasNext()) {
|
|
2227 |
QtColorPropertyManager *manager = itColor.next();
|
|
2228 |
d_ptr->m_colorEditorFactory->removePropertyManager(manager);
|
|
2229 |
d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager());
|
|
2230 |
}
|
|
2231 |
|
|
2232 |
QList<QtEnumPropertyManager *> enumPropertyManagers = qFindChildren<QtEnumPropertyManager *>(manager);
|
|
2233 |
QListIterator<QtEnumPropertyManager *> itEnum(enumPropertyManagers);
|
|
2234 |
while (itEnum.hasNext())
|
|
2235 |
d_ptr->m_comboBoxFactory->removePropertyManager(itEnum.next());
|
|
2236 |
|
|
2237 |
QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = qFindChildren<QtSizePolicyPropertyManager *>(manager);
|
|
2238 |
QListIterator<QtSizePolicyPropertyManager *> itSizePolicy(sizePolicyPropertyManagers);
|
|
2239 |
while (itSizePolicy.hasNext()) {
|
|
2240 |
QtSizePolicyPropertyManager *manager = itSizePolicy.next();
|
|
2241 |
d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager());
|
|
2242 |
d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager());
|
|
2243 |
}
|
|
2244 |
|
|
2245 |
QList<QtFontPropertyManager *> fontPropertyManagers = qFindChildren<QtFontPropertyManager *>(manager);
|
|
2246 |
QListIterator<QtFontPropertyManager *> itFont(fontPropertyManagers);
|
|
2247 |
while (itFont.hasNext()) {
|
|
2248 |
QtFontPropertyManager *manager = itFont.next();
|
|
2249 |
d_ptr->m_fontEditorFactory->removePropertyManager(manager);
|
|
2250 |
d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager());
|
|
2251 |
d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager());
|
|
2252 |
d_ptr->m_checkBoxFactory->removePropertyManager(manager->subBoolPropertyManager());
|
|
2253 |
}
|
|
2254 |
|
|
2255 |
QList<QtCursorPropertyManager *> cursorPropertyManagers = qFindChildren<QtCursorPropertyManager *>(manager);
|
|
2256 |
QListIterator<QtCursorPropertyManager *> itCursor(cursorPropertyManagers);
|
|
2257 |
while (itCursor.hasNext())
|
|
2258 |
d_ptr->m_cursorEditorFactory->removePropertyManager(itCursor.next());
|
|
2259 |
|
|
2260 |
QList<QtFlagPropertyManager *> flagPropertyManagers = qFindChildren<QtFlagPropertyManager *>(manager);
|
|
2261 |
QListIterator<QtFlagPropertyManager *> itFlag(flagPropertyManagers);
|
|
2262 |
while (itFlag.hasNext())
|
|
2263 |
d_ptr->m_checkBoxFactory->removePropertyManager(itFlag.next()->subBoolPropertyManager());
|
|
2264 |
}
|
|
2265 |
|
|
2266 |
QT_END_NAMESPACE
|
|
2267 |
|
|
2268 |
#include "moc_qtvariantproperty.cpp"
|