summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2011-01-28 08:18:38 (GMT)
committerBea Lam <bea.lam@nokia.com>2011-01-28 08:24:35 (GMT)
commitc22ec835589a2484059bcb94b5536cf3b9a7f69f (patch)
treed0679f8f24bf699898eb590d5c9cc75d0429debe /src/declarative
parentc98bd0ae192cac1254b2c98b497002e6256f0fbc (diff)
downloadQt-c22ec835589a2484059bcb94b5536cf3b9a7f69f.zip
Qt-c22ec835589a2484059bcb94b5536cf3b9a7f69f.tar.gz
Qt-c22ec835589a2484059bcb94b5536cf3b9a7f69f.tar.bz2
Allow functions to be passed in as values for grouped properties
Using QDeclarativeProperty::write() works for grouped properties but stops functions values from being passed in, and using QScriptValue::setProperty() on the object being created allows functions to be passed in but doesn't work for grouped properties. This fix walks down the tree for grouped properties to find the property that should be set so that functions can be set for grouped property values. Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 06bf3fd..5840f70 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -715,10 +715,21 @@ QScriptValue QDeclarativeComponentPrivate::createObject(QObject *publicParent, c
QScriptValueIterator it(valuemap);
while (it.hasNext()) {
it.next();
- if (it.value().isFunction()) { // To allow property binding from javascript to work
- newObject.setProperty(it.name(), it.value());
+ QScriptValue prop = newObject;
+ QString propName = it.name();
+ int index = propName.indexOf(QLatin1Char('.'));
+ if (index > 0) {
+ QString subProp = propName;
+ int lastIndex = 0;
+ while (index > 0) {
+ subProp = propName.mid(lastIndex, index - lastIndex);
+ prop = prop.property(subProp);
+ lastIndex = index + 1;
+ index = propName.indexOf(QLatin1Char('.'), index + 1);
+ }
+ prop.setProperty(propName.mid(propName.lastIndexOf(QLatin1Char('.')) + 1), it.value());
} else {
- QDeclarativeProperty::write(ret,it.name(),it.value().toVariant());
+ newObject.setProperty(propName, it.value());
}
}
}