aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@digia.com>2012-10-15 18:34:10 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-18 18:46:30 +0200
commitaccda18246c0116afe27275deabbc91f59506555 (patch)
treeefc139ec410a5fefd2ea1395d4cc44e3fb6704d4
parentc4503ab9be4748e6f6200dca9e28a6f2af4dec68 (diff)
Fix list functions for the data property
The Qml Designer needs this functions. Task-number: QTCREATORBUG-8039 Change-Id: I6e072723630cf971ad3eda921497699611ae934e Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
-rw-r--r--src/quick/items/qquickitem.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 8985b7b7f8..62fc81fb67 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -2509,25 +2509,41 @@ void QQuickItemPrivate::data_append(QQmlListProperty<QObject> *prop, QObject *o)
automatically assigned to this property.
*/
-int QQuickItemPrivate::data_count(QQmlListProperty<QObject> *prop)
+int QQuickItemPrivate::data_count(QQmlListProperty<QObject> *property)
{
- Q_UNUSED(prop);
- // XXX todo
- return 0;
+ QQuickItem *item = static_cast<QQuickItem*>(property->object);
+ QQuickItemPrivate *privateItem = QQuickItemPrivate::get(item);
+ QQmlListProperty<QObject> resourcesProperty = privateItem->resources();
+ QQmlListProperty<QQuickItem> childrenProperty = privateItem->children();
+
+ return resources_count(&resourcesProperty) + children_count(&childrenProperty);
}
-QObject *QQuickItemPrivate::data_at(QQmlListProperty<QObject> *prop, int i)
+QObject *QQuickItemPrivate::data_at(QQmlListProperty<QObject> *property, int i)
{
- Q_UNUSED(prop);
- Q_UNUSED(i);
- // XXX todo
+ QQuickItem *item = static_cast<QQuickItem*>(property->object);
+ QQuickItemPrivate *privateItem = QQuickItemPrivate::get(item);
+ QQmlListProperty<QObject> resourcesProperty = privateItem->resources();
+ QQmlListProperty<QQuickItem> childrenProperty = privateItem->children();
+
+ int resourcesCount = resources_count(&resourcesProperty);
+ if (i < resourcesCount)
+ return resources_at(&resourcesProperty, i);
+ const int j = i - resourcesCount;
+ if (j < children_count(&childrenProperty))
+ return children_at(&childrenProperty, j);
return 0;
}
-void QQuickItemPrivate::data_clear(QQmlListProperty<QObject> *prop)
+void QQuickItemPrivate::data_clear(QQmlListProperty<QObject> *property)
{
- Q_UNUSED(prop);
- // XXX todo
+ QQuickItem *item = static_cast<QQuickItem*>(property->object);
+ QQuickItemPrivate *privateItem = QQuickItemPrivate::get(item);
+ QQmlListProperty<QObject> resourcesProperty = privateItem->resources();
+ QQmlListProperty<QQuickItem> childrenProperty = privateItem->children();
+
+ resources_clear(&resourcesProperty);
+ children_clear(&childrenProperty);
}
QObject *QQuickItemPrivate::resources_at(QQmlListProperty<QObject> *prop, int index)