summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlmetaproperty.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-06-30 02:55:10 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-06-30 02:55:10 (GMT)
commit3c6648385e8637536292c1351ef0d52708bd07d2 (patch)
tree305f4c065d83129f65545ef436c79f9492692226 /src/declarative/qml/qmlmetaproperty.cpp
parent6856dd2850245414fb610e651391f5fe141605de (diff)
downloadQt-3c6648385e8637536292c1351ef0d52708bd07d2.zip
Qt-3c6648385e8637536292c1351ef0d52708bd07d2.tar.gz
Qt-3c6648385e8637536292c1351ef0d52708bd07d2.tar.bz2
Support animating dot properties.
Make sure we can handle things like PropertyAnimation { property: "anchors.leftMargin" }
Diffstat (limited to 'src/declarative/qml/qmlmetaproperty.cpp')
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 30e818b..682b8ad 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -1035,4 +1035,34 @@ QMetaMethod QmlMetaProperty::method() const
return d->signal;
}
+/*!
+ \internal
+
+ Creates a QmlMetaProperty for the property \a name of \a obj. Unlike
+ the QmlMetaProperty(QObject*, QString) constructor, this static function
+ will correctly handle dot properties.
+*/
+QmlMetaProperty QmlMetaProperty::createProperty(QObject *obj, const QString &name)
+{
+ QStringList path = name.split('.');
+
+ QObject *object = obj;
+
+ for (int jj = 0; jj < path.count() - 1; ++jj) {
+ const QString &pathName = path.at(jj);
+ QmlMetaProperty prop(object, pathName);
+ QObject *objVal = QmlMetaType::toQObject(prop.read());
+ if (!objVal)
+ return QmlMetaProperty();
+ object = objVal;
+ }
+
+ const QString &propName = path.last();
+ QmlMetaProperty prop(object, propName);
+ if (!prop.isValid())
+ return QmlMetaProperty();
+ else
+ return prop;
+}
+
QT_END_NAMESPACE