summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-01 04:51:29 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-01 04:51:29 (GMT)
commit926155a45d40ba38f1f525751708d89438477bb9 (patch)
tree31ca78521af05095ba2eac2814b27d691250a0a7 /src
parent31c8459d65aaca9131a8aa32e29e0591ed7892cb (diff)
downloadQt-926155a45d40ba38f1f525751708d89438477bb9.zip
Qt-926155a45d40ba38f1f525751708d89438477bb9.tar.gz
Qt-926155a45d40ba38f1f525751708d89438477bb9.tar.bz2
Fix reload() when keys are not specified, and add extra tests.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 386df46..162a669 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -709,8 +709,24 @@ void QDeclarativeXmlListModel::reload()
d->qmlXmlQuery.abort();
d->queryId = -1;
- if (d->size < 0)
+ int count = d->size;
+ if (count < 0)
d->size = 0;
+ bool hasKeys = false;
+ for (int i=0; i<d->roleObjects.count(); i++) {
+ if (d->roleObjects[i]->isKey()) {
+ hasKeys = true;
+ break;
+ }
+ }
+ if (!hasKeys) {
+ d->data.clear();
+ d->size = 0;
+ if (count > 0) {
+ emit itemsRemoved(0, count);
+ emit countChanged();
+ }
+ }
if (d->src.isEmpty() && d->xml.isEmpty())
return;
@@ -782,9 +798,10 @@ void QDeclarativeXmlListModel::queryCompleted(int id, int size)
d->data = d->qmlXmlQuery.modelData();
QList<QDeclarativeXmlListRange> removed = d->qmlXmlQuery.removedItemRanges();
+ QList<QDeclarativeXmlListRange> inserted = d->qmlXmlQuery.insertedItemRanges();
+
for (int i=0; i<removed.count(); i++)
emit itemsRemoved(removed[i].first, removed[i].second);
- QList<QDeclarativeXmlListRange> inserted = d->qmlXmlQuery.insertedItemRanges();
for (int i=0; i<inserted.count(); i++)
emit itemsInserted(inserted[i].first, inserted[i].second);