Fix rearranging of icons in listview via drag'n'drop
Since 0f1008a593
, 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
Pick-to: 5.15 6.1
Change-Id: I963f5db0f81bcd0d25eef05d9a265be00a5871f6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
parent
efdaba37d6
commit
14e09ada69
@ -2969,6 +2969,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) {
|
||||
|
@ -2594,6 +2594,7 @@ void tst_QListView::internalDragDropMove_data()
|
||||
| Qt::ItemIsEditable
|
||||
| Qt::ItemIsDragEnabled;
|
||||
|
||||
const QStringList unchanged = QStringList{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
||||
const QStringList reordered = QStringList{"0", "2", "3", "4", "5", "6", "7", "8", "9", "1"};
|
||||
const QStringList replaced = QStringList{"0", "2", "3", "4", "1", "6", "7", "8", "9"};
|
||||
|
||||
@ -2608,7 +2609,8 @@ void tst_QListView::internalDragDropMove_data()
|
||||
<< Qt::MoveAction
|
||||
<< defaultFlags
|
||||
<< modelMoves
|
||||
<< reordered;
|
||||
// listview in IconMode doesn't change the model
|
||||
<< ((viewMode == QListView::IconMode && !modelMoves) ? unchanged : reordered);
|
||||
|
||||
QTest::newRow((rowName + ", only move").constData())
|
||||
<< viewMode
|
||||
@ -2617,7 +2619,8 @@ void tst_QListView::internalDragDropMove_data()
|
||||
<< Qt::MoveAction
|
||||
<< defaultFlags
|
||||
<< modelMoves
|
||||
<< reordered;
|
||||
// listview in IconMode doesn't change the model
|
||||
<< ((viewMode == QListView::IconMode && !modelMoves) ? unchanged : reordered);
|
||||
|
||||
QTest::newRow((rowName + ", replace item").constData())
|
||||
<< viewMode
|
||||
|
Loading…
Reference in New Issue
Block a user