diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2013-07-04 12:14:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-09 10:25:34 +0200 |
commit | ddcf9fc80e074c5a9d1ecbbf3c60ca27f250ce98 (patch) | |
tree | 693ce9ea643a8e3db6b4089cc4a8db8bce6a316b /tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp | |
parent | cc2d34486360a1a65312f72ca4959228b9ab0c75 (diff) |
Don't assume that the last step of the XPath is an element name
In order to find the number of items in the model, the model did a
second query on the document representing the result set.
So, suppose the user queried for //a/b/c, the result set would contain
all the 'c' elements from the input document.
In order to find the number of items in the result set, it did a second
query with the expression "count(/dummy:items/c)", where 'c' was
extracted from the last step in the original XPath expression
For simple expressions, this worked fine.
However, if the last step had a predicate such as "//c/parent::b" it
didn't work.
The solution is to not filter *again* the last step when we query for
the count, since we know that all result items are direct children of
"dummy:items", and instead just execute the query
"count(dummy::items/*)".
This should also potentially improve performance.
Task-number: QTBUG-17588
Change-Id: Ib2fdf1ec8b91022df0597e089ad34d34b04428b0
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp')
-rw-r--r-- | tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp index 847cc5078d..1f7a8029dc 100644 --- a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp +++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp @@ -101,6 +101,7 @@ private slots: void threading(); void threading_data(); void propertyChanges(); + void selectAncestor(); void roleCrash(); @@ -964,6 +965,18 @@ void tst_qquickxmllistmodel::propertyChanges() delete model; } +void tst_qquickxmllistmodel::selectAncestor() +{ + QQmlComponent component(&engine, testFileUrl("groups.qml")); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->rowCount(), 1); + + QModelIndex index = model->index(0, 0); + QCOMPARE(model->data(index, Qt::UserRole).toInt(), 12); + QCOMPARE(model->data(index, Qt::UserRole+1).toString(), QLatin1String("cats")); +} + void tst_qquickxmllistmodel::roleCrash() { // don't crash |