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