Jump to same model index (if it exists) when the model changes
authorAlan Alpert <alan.alpert@nokia.com>
Thu, 28 Jul 2011 10:11:52 +0000 (20:11 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 29 Jul 2011 00:47:11 +0000 (02:47 +0200)
For PathView, ListView does this already.

Task-number: QTBUG-19059
Change-Id: Id09087ad372e46661794b0cb15cb30fc88802c4b
Reviewed-on: http://codereview.qt.nokia.com/2330
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/declarative/items/qsgpathview.cpp

index 7dd58c5..e10575c 100644 (file)
@@ -418,7 +418,10 @@ void QSGPathView::setModel(const QVariant &model)
             d->offset = d->model->count() + d->offset;
 }
     d->regenerate();
-    d->fixOffset();
+    if (d->currentIndex < d->modelCount)
+        setOffset(qmlMod(d->modelCount - d->currentIndex, d->modelCount));
+    else
+        d->fixOffset();
     emit countChanged();
     emit modelChanged();
 }