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