From: Marco Bubke Date: Mon, 15 Oct 2012 16:34:10 +0000 (+0200) Subject: Fix list functions for the data property X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=accda18246c0116afe27275deabbc91f59506555;p=profile%2Fivi%2Fqtdeclarative.git Fix list functions for the data property The Qml Designer needs this functions. Task-number: QTCREATORBUG-8039 Change-Id: I6e072723630cf971ad3eda921497699611ae934e Reviewed-by: Thomas Hartmann --- 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)