summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-04-27 03:10:34 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-04-27 03:54:04 (GMT)
commit8878e2c53a0c9408d4b468e2dad485743c32f58b (patch)
treeb6bdd0c5a78e6f5f255b8b0d311b82d919cbc7ac
parent10830210607d08eeb2af5d091639506a7d8cc634 (diff)
downloadQt-8878e2c53a0c9408d4b468e2dad485743c32f58b.zip
Qt-8878e2c53a0c9408d4b468e2dad485743c32f58b.tar.gz
Qt-8878e2c53a0c9408d4b468e2dad485743c32f58b.tar.bz2
PathView offset out of sync with currentIndex when items are removed.
If the view is animating due to currentIndex change and items are removed the target offset must be recalculated. Change-Id: Iee105712488070c086a24561a49daf17bcf14076 Task-number: QTBUG-18825 Reviewed-by: Michael Brasser
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp10
2 files changed, 12 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 778b8b9..aed849b 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -1525,6 +1525,8 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count)
} else {
d->regenerate();
d->updateCurrent();
+ if (!d->flicking && !d->moving && d->haveHighlightRange && d->highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange)
+ d->snapToCurrent();
}
if (changedOffset)
emit offsetChanged();
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 8000137..46c3519 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -458,6 +458,16 @@ void tst_QDeclarativePathView::dataModel()
model.removeItem(model.count()-1);
QCOMPARE(pathview->currentIndex(), model.count()-1);
+ // QTBUG-18825
+ // Confirm that the target offset is adjusted when removing items
+ pathview->setCurrentIndex(model.count()-1);
+ QTRY_COMPARE(pathview->offset(), 1.);
+ pathview->setCurrentIndex(model.count()-5);
+ model.removeItem(model.count()-1);
+ model.removeItem(model.count()-1);
+ model.removeItem(model.count()-1);
+ QTRY_COMPARE(pathview->offset(), 2.);
+
delete canvas;
}