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