aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitemview.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-07-23 13:19:04 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-23 06:38:28 +0200
commit22c68738bf2a83eb228b412fbd251bcdf8e7056e (patch)
tree14f0c0efa6a7134a1f98c49f53ce813cf10f2346 /src/quick/items/qquickitemview.cpp
parent2a4bb9608498876c3c2229eef91b8723a7fd8e47 (diff)
Changing model after componentComplete should reset currentIndex
When the model is changed reset currentIndex back to 0. Task-number: QTBUG-26604 Change-Id: I1934e083819537d416acd85c75362daff382aa04 Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'src/quick/items/qquickitemview.cpp')
-rw-r--r--src/quick/items/qquickitemview.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index a9022bda59..8f1687f4e6 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -309,18 +309,8 @@ void QQuickItemView::setModel(const QVariant &model)
if (isComponentComplete()) {
d->updateSectionCriteria();
d->refill();
- if ((d->currentIndex >= d->model->count() || d->currentIndex < 0) && !d->currentIndexCleared) {
- setCurrentIndex(0);
- } else {
- d->moveReason = QQuickItemViewPrivate::SetIndex;
- d->updateCurrent(d->currentIndex);
- if (d->highlight && d->currentItem) {
- if (d->autoHighlight)
- d->resetHighlightPosition();
- d->updateTrackedItem();
- }
- d->moveReason = QQuickItemViewPrivate::Other;
- }
+ d->currentIndex = -1;
+ setCurrentIndex(0);
d->updateViewport();
if (d->transitioner && d->transitioner->populateTransition) {
@@ -328,6 +318,7 @@ void QQuickItemView::setModel(const QVariant &model)
d->forceLayoutPolish();
}
}
+
connect(d->model, SIGNAL(modelUpdated(QQuickChangeSet,bool)),
this, SLOT(modelUpdated(QQuickChangeSet,bool)));
emit countChanged();