summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlmetaproperty.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-08-10 05:37:19 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-08-10 08:01:37 (GMT)
commit8c3405bbf65826f0ab0be0bd090d723f8efaa3af (patch)
treef6886a2b8a86f567b98728bba9cdc3d1be780dcf /src/declarative/qml/qmlmetaproperty.cpp
parent12ffa33ddc725cd94662a383af6e1793049c807c (diff)
downloadQt-8c3405bbf65826f0ab0be0bd090d723f8efaa3af.zip
Qt-8c3405bbf65826f0ab0be0bd090d723f8efaa3af.tar.gz
Qt-8c3405bbf65826f0ab0be0bd090d723f8efaa3af.tar.bz2
Abstract expression and binding APIs
By splitting the interface through which the system interacts with bindings away from a specific implementation, we can introduce highly specialized implementations for specific optimizations. This commit also includes a sample optimization for object properties being assigned directly from a local id.
Diffstat (limited to 'src/declarative/qml/qmlmetaproperty.cpp')
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp63
1 files changed, 28 insertions, 35 deletions
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 64dd9cd..d986077 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -51,6 +51,7 @@
#include <QtCore/qdebug.h>
#include <QtDeclarative/qmlengine.h>
#include <private/qmlengine_p.h>
+#include <private/qmldeclarativedata_p.h>
Q_DECLARE_METATYPE(QList<QObject *>);
@@ -509,20 +510,21 @@ QMetaProperty QmlMetaProperty::property() const
Returns the binding associated with this property, or 0 if no binding
exists.
*/
-QmlBinding *QmlMetaProperty::binding() const
+QmlAbstractBinding *QmlMetaProperty::binding() const
{
if (!isProperty() || (type() & Attached) || !d->object)
return 0;
- const QObjectList &children = object()->children();
- for (QObjectList::ConstIterator iter = children.begin();
- iter != children.end(); ++iter) {
- QObject *child = *iter;
- if (child->metaObject() == &QmlBinding::staticMetaObject) {
- QmlBinding *v = static_cast<QmlBinding *>(child);
- if (v->property() == *this && v->enabled())
- return v;
- }
+ QmlDeclarativeData *data = QmlDeclarativeData::get(d->object);
+ if (!data)
+ return 0;
+
+ QmlAbstractBinding *binding = data->bindings;
+ while (binding) {
+ // ### This wont work for value types
+ if (binding->propertyIndex() == d->coreIdx)
+ return binding;
+ binding = binding->m_nextBinding;
}
return 0;
}
@@ -534,41 +536,32 @@ QmlBinding *QmlMetaProperty::binding() const
\a binding will be enabled, and the returned binding (if any) will be
disabled.
*/
-QmlBinding *QmlMetaProperty::setBinding(QmlBinding *binding) const
+QmlAbstractBinding *
+QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding) const
{
if (!isProperty() || (type() & Attached) || !d->object)
return 0;
- const QObjectList &children = object()->children();
- for (QObjectList::ConstIterator iter = children.begin();
- iter != children.end(); ++iter) {
- QObject *child = *iter;
- if (child->metaObject() == &QmlBinding::staticMetaObject) {
- QmlBinding *v = static_cast<QmlBinding *>(child);
- if (v->property() == *this && v->enabled()) {
-
- v->setEnabled(false);
-
- if (binding) {
- binding->setParent(object());
- binding->setTarget(*this);
- binding->setEnabled(true);
- binding->forceUpdate();
- }
+ QmlDeclarativeData *data = QmlDeclarativeData::get(d->object, true);
- return v;
+ QmlAbstractBinding *binding = data->bindings;
+ while (binding) {
+ // ### This wont work for value types
+ if (binding->propertyIndex() == d->coreIdx) {
+ binding->setEnabled(false);
- }
+ if (newBinding)
+ newBinding->setEnabled(true);
+
+ return binding; // ### QmlAbstractBinding;
}
- }
- if (binding) {
- binding->setParent(object());
- binding->setTarget(*this);
- binding->setEnabled(true);
- binding->forceUpdate();
+ binding = binding->m_nextBinding;
}
+ if (newBinding)
+ newBinding->setEnabled(true);
+
return 0;
}