diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-28 01:51:53 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-28 01:51:53 (GMT) |
commit | 3903deaad92f7c4c9e9258a86aeb50c5adca41c8 (patch) | |
tree | 2af8d65a4c3f8ac2ed8727f566ad2d91dcf0beff /src/declarative/qml | |
parent | 7c1717ec03dc2943c3018bcf761823f17cd9b999 (diff) | |
download | Qt-3903deaad92f7c4c9e9258a86aeb50c5adca41c8.zip Qt-3903deaad92f7c4c9e9258a86aeb50c5adca41c8.tar.gz Qt-3903deaad92f7c4c9e9258a86aeb50c5adca41c8.tar.bz2 |
Add reset methods to QmlMetaProperty
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlmetaproperty.cpp | 25 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetaproperty.h | 2 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 4717782..dbf6548 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -435,6 +435,17 @@ bool QmlMetaProperty::isDesignable() const } /*! + Returns true if the property is resettable, otherwise false. +*/ +bool QmlMetaProperty::isResettable() const +{ + if (type() & Property && d->core.isValid() && d->object) + return d->core.flags & QmlPropertyCache::Data::IsResettable; + else + return false; +} + +/*! Returns true if the QmlMetaProperty refers to a valid property, otherwise false. */ @@ -967,6 +978,20 @@ bool QmlMetaProperty::write(const QVariant &value) const return write(value, 0); } +/*! + Resets the property value. +*/ +bool QmlMetaProperty::reset() const +{ + if (isResettable()) { + void *args[] = { 0 }; + QMetaObject::metacall(d->object, QMetaObject::ResetProperty, d->core.coreIndex, args); + return true; + } else { + return false; + } +} + bool QmlMetaProperty::write(const QVariant &value, QmlMetaProperty::WriteFlags flags) const { if (d->object && type() & Property && d->core.isValid() && isWritable()) diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h index dcb5905..240f5a2 100644 --- a/src/declarative/qml/qmlmetaproperty.h +++ b/src/declarative/qml/qmlmetaproperty.h @@ -88,6 +88,7 @@ public: enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02 }; Q_DECLARE_FLAGS(WriteFlags, WriteFlag) bool write(const QVariant &, QmlMetaProperty::WriteFlags) const; + bool reset() const; bool hasChangedNotifier() const; bool needsChangedNotifier() const; @@ -108,6 +109,7 @@ public: bool isDefault() const; bool isWritable() const; bool isDesignable() const; + bool isResettable() const; bool isValid() const; QObject *object() const; |