qt5base-lts/tests/auto/widgets/itemviews
Giuseppe D'Angelo b5b2640a65 QHeaderView: fix spurious sorting
QHeaderView sorting may be triggered when the user performs
some mouse interactions that should really not result in sorting.

Generally speaking, this happens when the user:

* presses on a non-movable section (A)
* moves on another section (B)
* releases on that section

resulting in B becoming sorted / flipping sorting.

(Non-movable is required, otherwise dragging would cause section moving,
not sorting.)

To make the matter worse, QHeaderView doesn't check that the release
happens within its geometry. This makes sense when moving sections: one
is able to drag a section horizontally/vertically even if the mouse
leaves the QHeaderView.

But when not moving sections, this means that one can

* press on section (A),
* move the mouse anywhere vertically (for a horizontal bar, mut.mut
  for a vertical) above or below another section (B), that is,
  outside QHeaderView's geometry
* release the mouse

and cause B to be sorted.

Fix it by

1) remembering which one was the section that the user originally
clicked on; that's the only one that can possibly become sorted
(if we're not moving and other conditions hold). No other variable
seemed to remember this.

2) on release, check that it happens within that section's geometry.
If so, sort.

Pick-to: 6.0 5.15
Change-Id: Icfb67662221efbde019711f933781ee1e7d9ac43
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-12-01 15:57:10 +01:00
..
qabstractitemview Fix a mistake when using QLatin1String::arg 2020-11-07 06:25:36 +01:00
qcolumnview CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qdatawidgetmapper CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qfileiconprovider QFileInfo: mark constructors as explicit 2020-11-15 18:30:16 +01:00
qheaderview QHeaderView: fix spurious sorting 2020-12-01 15:57:10 +01:00
qitemdelegate Deprecate QVariant::Type 2020-10-23 09:58:57 +02:00
qitemeditorfactory Deprecate QVariant::Type 2020-10-23 09:58:57 +02:00
qitemview CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qlistview Use QTRY_COMPARE in an attempt to make the test less flaky 2020-11-10 23:05:23 +01:00
qlistwidget CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qtableview Android: blacklist a list of failing tests for android 2020-11-04 12:27:49 +02:00
qtablewidget Stop copying events in tests 2020-11-12 15:25:06 +01:00
qtreeview Fix a mistake when using QLatin1String::arg 2020-11-07 06:25:36 +01:00
qtreewidget Deprecate QVariant::Type 2020-10-23 09:58:57 +02:00
qtreewidgetitemiterator CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
CMakeLists.txt CMake: Regenerate subdir test projects 2020-07-09 09:38:39 +02:00
itemviews.pro Remove the deprecated QDirModel 2020-06-04 19:11:19 +02:00