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