QListView: don't ignore an event accepted by a subclass
If a subclass reimplements dropEvent() to accept a CopyAction, then don't ignore the event again in the QListView implementation. We only have to ignore a MoveAction event if the handling so far didn't actually move the data, so that the QAIV implementation can handle the removal of the source data if needed. Complex interaction between QListView and QAbstractItemView, especially in IconView mode, and sadly not generally unit-testable, like all drag'n'drop interactions (due to modally blocking QDrag::exec on most platforms). Fixes: QTBUG-103898 Change-Id: I032c27e2788ec7e652a830383d8400b06b57d8cb Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 690184cf25902e5351189c37ef823a97aaf8135a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>bb10
parent
fdaf9c1a2e
commit
608abab511
|
|
@ -886,8 +886,9 @@ void QListView::dropEvent(QDropEvent *event)
|
|||
{
|
||||
Q_D(QListView);
|
||||
|
||||
if (event->source() == this && (event->dropAction() == Qt::MoveAction ||
|
||||
dragDropMode() == QAbstractItemView::InternalMove)) {
|
||||
const bool moveAction = event->dropAction() == Qt::MoveAction
|
||||
|| dragDropMode() == QAbstractItemView::InternalMove;
|
||||
if (event->source() == this && moveAction) {
|
||||
QModelIndex topIndex;
|
||||
bool topIndexDropped = false;
|
||||
int col = -1;
|
||||
|
|
@ -941,7 +942,7 @@ void QListView::dropEvent(QDropEvent *event)
|
|||
|
||||
if (!d->commonListView->filterDropEvent(event) || !d->dropEventMoved) {
|
||||
// icon view didn't move the data, and moveRows not implemented, so fall back to default
|
||||
if (!d->dropEventMoved)
|
||||
if (!d->dropEventMoved && moveAction)
|
||||
event->ignore();
|
||||
QAbstractItemView::dropEvent(event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue