summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativegridview.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-03-15 03:53:34 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-03-15 04:25:29 (GMT)
commitce38c6e3a9b7eb336cbd9cd1e9520a5000c8f8ac (patch)
tree44800499f1f732c440260500022fe15ada05fd74 /src/declarative/graphicsitems/qdeclarativegridview.cpp
parent774cb9eca9ea243436dbf61cdb7081fc270cdec9 (diff)
downloadQt-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/qdeclarativegridview.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 5c2f781..c0cbed0 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -2834,11 +2834,9 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
if (d->currentItem) {
d->currentItem->index = d->currentIndex;
d->currentItem->setPosition(d->colPosAt(d->currentIndex), d->rowPosAt(d->currentIndex));
- } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) {
- d->updateCurrent(0);
}
emit currentIndexChanged();
- } else if (d->itemCount == 0 && d->currentIndex == -1) {
+ } else if (d->itemCount == 0 && (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared))) {
setCurrentIndex(0);
}
@@ -2906,6 +2904,8 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
d->currentIndex = -1;
if (d->itemCount)
d->updateCurrent(qMin(modelIndex, d->itemCount-1));
+ else
+ emit currentIndexChanged();
}
// update visibleIndex