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