qt6-bb10/tests/auto/widgets/itemviews
Volker Hilsheimer 0f1008a593 QAbstractItemView: don't lose items if model only allows MoveAction
If a model only allows MoveAction, then calls in the view/widget subclasses'
dropEvent implementation to set the event's drop action to CopyAction
will fail. QAbstractItemView will then remove the item when QDrag::exec
returns.

Instead of abusing the event actions for this, store explicitly that the
dropEvent implementation already moved the item. If the flag is set,
don't remove the item.

In QListView, which uses moveRow to move items in the dropEvent handler,
handle the case that the model might not implement moveRows. In that
case, or when dropping an item onto another item (to overwrite data),
fall back to the default implementation of QAbstractItemView. Sadly, it
is impossible to know whether a model doesn't implement moveRows, or
whether the move failed for other reasons, so this requires a bit of
extra special case handling. QListView in IconMode is particularly odd
in that it moves the item in the view, but not in the model.

This follows up on fd894fd68e and fixes
additional issues discovered during debugging. Extend the existing unit
test; since drag'n'drop runs a modal, native event loop on most systems,
it still only runs on the Xcb platform.

Change-Id: I6c5377e2b097c8080001afe904d6d3e4aed33df4
Pick-to: 5.15
Fixes: QTBUG-87057
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2020-10-16 13:53:03 +02:00
..
qabstractitemview CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02: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 CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qheaderview Get rid of all usage of QApplication:desktop 2020-10-14 06:38:43 +02:00
qitemdelegate tests: blacklist two tests on Ubuntu 20.04 2020-10-14 15:58:16 +02:00
qitemeditorfactory CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qitemview CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qlistview QAbstractItemView: don't lose items if model only allows MoveAction 2020-10-16 13:53:03 +02:00
qlistwidget CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qtableview Fix compiler warnings from QKeyCombination 2020-09-28 17:23:20 +02:00
qtablewidget CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qtreeview Get rid of all usage of QApplication:desktop 2020-10-14 06:38:43 +02:00
qtreewidget CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +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