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/qmlmetaproperty.cpp | |
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/qmlmetaproperty.cpp')
-rw-r--r-- | src/declarative/qml/qmlmetaproperty.cpp | 25 |
1 files changed, 25 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()) |