QListView/QTableView: attempt to move each row even after a failure
Change-Id: I039917c9fa82d356291e75abc7233b3b220a1931 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit bac5b6188fb18b0c41625d42809dd318abfc6c39) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>bb10
parent
eb2a072f91
commit
2622b7f602
|
|
@ -918,9 +918,10 @@ void QListView::dropEvent(QDropEvent *event)
|
|||
// only generate a move when not same row or behind itself
|
||||
if (r != pIndex.row() && r != pIndex.row() + 1) {
|
||||
// try to move (preserves selection)
|
||||
dataMoved |= model()->moveRow(QModelIndex(), pIndex.row(), QModelIndex(), r);
|
||||
if (!dataMoved) // can't move - abort and let QAbstractItemView handle this
|
||||
break;
|
||||
const bool moved = model()->moveRow(QModelIndex(), pIndex.row(), QModelIndex(), r);
|
||||
if (!moved)
|
||||
continue; // maybe it'll work for other rows
|
||||
dataMoved = true; // success
|
||||
} else {
|
||||
// move onto itself is blocked, don't delete anything
|
||||
dataMoved = true;
|
||||
|
|
|
|||
|
|
@ -3155,9 +3155,10 @@ void QTableView::dropEvent(QDropEvent *event)
|
|||
// only generate a move when not same row or behind itself
|
||||
if (r != pIndex.row() && r != pIndex.row() + 1) {
|
||||
// try to move (preserves selection)
|
||||
dataMoved |= model()->moveRow(QModelIndex(), pIndex.row(), QModelIndex(), r);
|
||||
if (!dataMoved) // can't move - abort and let QAbstractItemView handle this
|
||||
break;
|
||||
const bool moved = model()->moveRow(QModelIndex(), pIndex.row(), QModelIndex(), r);
|
||||
if (!moved)
|
||||
continue; // maybe it'll work for other rows
|
||||
dataMoved = true; // success
|
||||
} else {
|
||||
// move onto itself is blocked, don't delete anything
|
||||
dataMoved = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue