summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-05 00:20:48 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-19 10:32:09 +0000
commit04cc12e26f8ee356ae666f50a85f0db3804d9c8a (patch)
treec50c6c39fe3b618e0f166382acb8636c1531df53 /src
parent4b42bca2092125071092f2de0a193ed945de58eb (diff)
Fix rearranging of icons in listview via drag'n'drop
Since 0f1008a5936c903ca9448193df7df6117e2c617b, views record if they moved the item in the model, and prevent the deletion of the source item in QAbstractItemView by setting the dropEventMoved private data member. However, QListView in icon mode is special: it doesn't rearrange the model, it repositions the icons in the view. While the dropEventMoved logic was applied to the drag event filter to prevent deletion, the variable was never set in the filterDropEvent handler. The drop event got ignored, breaking rearranging of icons. Fix this by setting the dropEventMoved member in filterDropEvent. Fixes: QTBUG-94226 Change-Id: I963f5db0f81bcd0d25eef05d9a265be00a5871f6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> (cherry picked from commit 14e09ada69fc3f1b09a8ad8228c3b8ebb542b220) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/itemviews/qlistview.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index b0de33afaf..526c54984a 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -2972,6 +2972,8 @@ bool QIconModeViewBase::filterDropEvent(QDropEvent *e)
dd->stopAutoScroll();
draggedItems.clear();
dd->emitIndexesMoved(indexes);
+ // do not delete item on internal move, see filterStartDrag()
+ dd->dropEventMoved = true;
e->accept(); // we have handled the event
// if the size has not grown, we need to check if it has shrinked
if (contentsSize != contents) {