diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-02-08 04:10:44 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-02-08 04:10:44 (GMT) |
commit | 5c238b1260f589a906aae3f20d9b412ed2f76a65 (patch) | |
tree | a536eadec34840b2e0dcdde5f80111dd5611171c /tests/auto | |
parent | 6fb18bf757ca3c0c774ffdcb5004eac4a165e415 (diff) | |
download | Qt-5c238b1260f589a906aae3f20d9b412ed2f76a65.zip Qt-5c238b1260f589a906aae3f20d9b412ed2f76a65.tar.gz Qt-5c238b1260f589a906aae3f20d9b412ed2f76a65.tar.bz2 |
Fix test.
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp index f389d2c..9d79407 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -73,6 +73,7 @@ private: T *findItem(QmlGraphicsItem *parent, const QString &id, int index=-1); template<typename T> QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName); + void dumpTree(QmlGraphicsItem *parent, int depth = 0); }; class TestModel : public QAbstractListModel @@ -923,17 +924,19 @@ T *tst_QmlGraphicsGridView::findItem(QmlGraphicsItem *parent, const QString &obj { const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->QGraphicsObject::children().count() << "children"; - for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) { - QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->QGraphicsObject::children().at(i)); + for (int i = 0; i < parent->childItems().count(); ++i) { + QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i)); if(!item) continue; //qDebug() << "try" << item; if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { - QmlExpression e(qmlContext(item), "index", item); - e.setTrackChange(false); - if (e.value().toInt() == index) - return static_cast<T*>(item); + QmlContext *context = QmlEngine::contextForObject(item); + if (context) { + if (context->contextProperty("index").toInt() == index) { + return static_cast<T*>(item); + } + } } else { return static_cast<T*>(item); } @@ -967,6 +970,19 @@ QList<T*> tst_QmlGraphicsGridView::findItems(QmlGraphicsItem *parent, const QStr return items; } +void tst_QmlGraphicsGridView::dumpTree(QmlGraphicsItem *parent, int depth) +{ + static QString padding(" "); + for (int i = 0; i < parent->childItems().count(); ++i) { + QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i)); + if(!item) + continue; + QmlContext *context = QmlEngine::contextForObject(item); + qDebug() << padding.left(depth*2) << item << (context ? context->contextProperty("index").toInt() : -1); + dumpTree(item, depth+1); + } +} + QTEST_MAIN(tst_QmlGraphicsGridView) |