From accda18246c0116afe27275deabbc91f59506555 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Mon, 15 Oct 2012 18:34:10 +0200 Subject: [PATCH] Fix list functions for the data property The Qml Designer needs this functions. Task-number: QTCREATORBUG-8039 Change-Id: I6e072723630cf971ad3eda921497699611ae934e Reviewed-by: Thomas Hartmann --- src/quick/items/qquickitem.cpp | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 8985b7b..62fc81f 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2509,25 +2509,41 @@ void QQuickItemPrivate::data_append(QQmlListProperty *prop, QObject *o) automatically assigned to this property. */ -int QQuickItemPrivate::data_count(QQmlListProperty *prop) +int QQuickItemPrivate::data_count(QQmlListProperty *property) { - Q_UNUSED(prop); - // XXX todo - return 0; + QQuickItem *item = static_cast(property->object); + QQuickItemPrivate *privateItem = QQuickItemPrivate::get(item); + QQmlListProperty resourcesProperty = privateItem->resources(); + QQmlListProperty childrenProperty = privateItem->children(); + + return resources_count(&resourcesProperty) + children_count(&childrenProperty); } -QObject *QQuickItemPrivate::data_at(QQmlListProperty *prop, int i) +QObject *QQuickItemPrivate::data_at(QQmlListProperty *property, int i) { - Q_UNUSED(prop); - Q_UNUSED(i); - // XXX todo + QQuickItem *item = static_cast(property->object); + QQuickItemPrivate *privateItem = QQuickItemPrivate::get(item); + QQmlListProperty resourcesProperty = privateItem->resources(); + QQmlListProperty 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 *prop) +void QQuickItemPrivate::data_clear(QQmlListProperty *property) { - Q_UNUSED(prop); - // XXX todo + QQuickItem *item = static_cast(property->object); + QQuickItemPrivate *privateItem = QQuickItemPrivate::get(item); + QQmlListProperty resourcesProperty = privateItem->resources(); + QQmlListProperty childrenProperty = privateItem->children(); + + resources_clear(&resourcesProperty); + children_clear(&childrenProperty); } QObject *QQuickItemPrivate::resources_at(QQmlListProperty *prop, int index) -- 2.7.4