qt5base-lts/tests/auto/widgets/itemviews
Volker Hilsheimer 26bebd2037 QListView: don't scroll if selected items are removed
For SingleSelection, removing the selected item will select the nearest
item and, if autoScroll is enabled, ensures that the newly selected
item is visible in the viewport. This may result in scrolling.

For Multi- or ExtendedSelection, this should not happen, as having no
selection is perfectly fine in those modes.
However, QListView still tried to scroll to the current item in response
to the currentIndexChanged signal. Since the currentIndex is at this
point already hidden, the rectangle for it became invalid, and the
attempt to scroll resulted in a one-pixel up-movement of the viewport
(since the invalid rectangle has width == height == -1).

Fix this by not scrolling if the rect for the index is invalid. Note that
the index is still valid at this point, so we can't shortcut the call
stack earlier. Add test that exercises the different combinations of
ViewMode and SelectionMode, and demonstrates the one-pixel
movement without the fix.

Fixes: QTBUG-94788
Pick-to: 6.2 6.1 5.15
Change-Id: I1f36973eadb46e8c9b8b8068bc76ee09e9f490dd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-07-16 17:01:25 +02:00
..
qabstractitemview Stabilize flaky scrollerSmoothScroll test case 2021-06-15 16:03:38 +02:00
qcolumnview Remove the qmake project files 2021-01-07 15:32:28 +01:00
qdatawidgetmapper Remove the qmake project files 2021-01-07 15:32:28 +01:00
qfileiconprovider Verify that QFileIconProvider returns valid pixmaps 2021-02-23 15:34:05 +01:00
qheaderview Remove the qmake project files 2021-01-07 15:32:28 +01:00
qitemdelegate QAbstractItemView: don't toggle extended selection on Ctrl+Press 2021-06-07 20:23:17 +02:00
qitemeditorfactory Remove the qmake project files 2021-01-07 15:32:28 +01:00
qitemview Remove the qmake project files 2021-01-07 15:32:28 +01:00
qlistview QListView: don't scroll if selected items are removed 2021-07-16 17:01:25 +02:00
qlistwidget Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtableview QTableView: fix selection with rows and cells in ExtendedSelection mode 2021-07-12 08:19:16 +00:00
qtablewidget Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtreeview Prefer QFAIL("Informative message") over QVERIFY(false) 2021-06-14 15:57:16 +02:00
qtreewidget Prefer QFAIL("Informative message") over QVERIFY(false) 2021-06-14 15:57:16 +02:00
qtreewidgetitemiterator Remove the qmake project files 2021-01-07 15:32:28 +01:00
CMakeLists.txt CMake: Regenerate subdir test projects 2020-07-09 09:38:39 +02:00