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