diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-03-15 03:53:34 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-03-15 04:25:29 (GMT) |
commit | ce38c6e3a9b7eb336cbd9cd1e9520a5000c8f8ac (patch) | |
tree | 44800499f1f732c440260500022fe15ada05fd74 /src/declarative/graphicsitems/qdeclarativelistview.cpp | |
parent | 774cb9eca9ea243436dbf61cdb7081fc270cdec9 (diff) | |
download | Qt-ce38c6e3a9b7eb336cbd9cd1e9520a5000c8f8ac.zip Qt-ce38c6e3a9b7eb336cbd9cd1e9520a5000c8f8ac.tar.gz Qt-ce38c6e3a9b7eb336cbd9cd1e9520a5000c8f8ac.tar.bz2 |
Regression: currentIndex was not set correctly after model cleared.
Change b3080d78f2ff2d98410249e09d5d7d6e20fd155c stopped the
currentIndex from being updated when a new item is added to an empty
view.
Change-Id: I77a0789fcf3693034a2d7aca173fec669b913b18
Task-number: QTBUG-18123
Reviewed-by: Bea Lam
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativelistview.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 2c23a1b..6ae1ddc 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -3272,10 +3272,10 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) if (d->currentItem) { d->currentItem->index = d->currentIndex; d->currentItem->setPosition(d->currentItem->position() + diff); - } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) { - d->updateCurrent(0); } emit currentIndexChanged(); + } else if (!d->itemCount && (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared))) { + d->updateCurrent(0); } // Update the indexes of the following visible items. for (; index < d->visibleItems.count(); ++index) { @@ -3356,6 +3356,8 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count) d->currentIndex = -1; if (d->itemCount) d->updateCurrent(qMin(modelIndex, d->itemCount-1)); + else + emit currentIndexChanged(); } // update visibleIndex |