summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-09-03 07:10:45 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-09-03 07:10:45 (GMT)
commit982d7f659750f0864e2d874ce41289125f40a36b (patch)
tree1ce6d49ff7f13512d331c51b8a34c9b482c180f7 /src/declarative
parentc8c8fd92baee91d3079e9696c3c05d0fa455f7ab (diff)
downloadQt-982d7f659750f0864e2d874ce41289125f40a36b.zip
Qt-982d7f659750f0864e2d874ce41289125f40a36b.tar.gz
Qt-982d7f659750f0864e2d874ce41289125f40a36b.tar.bz2
Keep ListView position sensible when all visible items are removed.
Previously it would always jump back to 0. Now it stays at the nearest remaining index. Task-number: QTBUG-12664
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index ef28ab2..1c634d2 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -2916,14 +2916,18 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
}
if (removedVisible && d->visibleItems.isEmpty()) {
- d->visibleIndex = 0;
- d->visiblePos = d->header ? d->header->size() : 0;
d->timeline.clear();
- d->setPosition(0);
if (d->itemCount == 0) {
+ d->visibleIndex = 0;
+ d->visiblePos = d->header ? d->header->size() : 0;
+ d->setPosition(0);
d->updateHeader();
d->updateFooter();
update();
+ } else {
+ if (modelIndex < d->visibleIndex)
+ d->visibleIndex = modelIndex+1;
+ d->visibleIndex = qMax(qMin(d->visibleIndex, d->itemCount-1), 0);
}
}