diff options
author | Bea Lam <bea.lam@nokia.com> | 2011-01-27 05:34:34 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2011-01-27 05:37:10 (GMT) |
commit | 43b8305367156c1ceb09eb4a056bdae3f325b5eb (patch) | |
tree | 8d792838920476495cba22c802939b719619a55d /src/declarative/qml/qdeclarativeproperty.cpp | |
parent | 357f1163f75e4b23a5b87dd6b3d742d167cd9c10 (diff) | |
download | Qt-43b8305367156c1ceb09eb4a056bdae3f325b5eb.zip Qt-43b8305367156c1ceb09eb4a056bdae3f325b5eb.tar.gz Qt-43b8305367156c1ceb09eb4a056bdae3f325b5eb.tar.bz2 |
Allow property bindings to be easily created from JavaScript
Properties can now be assigned a function that returns the binding
value.
Task-number: QTBUG-14964
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src/declarative/qml/qdeclarativeproperty.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativeproperty.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 76829b7..61e3002 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1480,19 +1480,28 @@ QDeclarativePropertyPrivate::restore(const QByteArray &data, QObject *object, QD if (data.isEmpty()) return prop; - prop.d = new QDeclarativePropertyPrivate; - prop.d->object = object; - prop.d->context = ctxt; - prop.d->engine = ctxt->engine; - const SerializedData *sd = (const SerializedData *)data.constData(); if (sd->isValueType) { const ValueTypeSerializedData *vt = (const ValueTypeSerializedData *)sd; - prop.d->core = vt->core; - prop.d->valueType = vt->valueType; + return restore(vt->core, vt->valueType, object, ctxt); } else { - prop.d->core = sd->core; + QDeclarativePropertyCache::ValueTypeData data; + return restore(sd->core, data, object, ctxt); } +} + +QDeclarativeProperty +QDeclarativePropertyPrivate::restore(const QDeclarativePropertyCache::Data &data, const QDeclarativePropertyCache::ValueTypeData &valueType, QObject *object, QDeclarativeContextData *ctxt) +{ + QDeclarativeProperty prop; + + prop.d = new QDeclarativePropertyPrivate; + prop.d->object = object; + prop.d->context = ctxt; + prop.d->engine = ctxt->engine; + + prop.d->core = data; + prop.d->valueType = valueType; return prop; } |