ItemViews: Fix acceptance of drag enter events
Always accept drag enter events if the mime type and the drop actions matches. Whether the drop can actually happen on the currently hovered index will be decided in the following drag move event. Change-Id: I27e865cb65513dfe3f57ad3f1bc8cebf4c29a692 Task-number: QTBUG-45037 Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
119c5ec93f
commit
1f281bfd63
@ -168,8 +168,20 @@ public:
|
|||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
int col = -1;
|
int col = -1;
|
||||||
int row = -1;
|
int row = -1;
|
||||||
|
const QMimeData *mime = event->mimeData();
|
||||||
|
|
||||||
|
// Drag enter event shall always be accepted, if mime type and action match.
|
||||||
|
// Whether the data can actually be dropped will be checked in drag move.
|
||||||
|
if (event->type() == QEvent::DragEnter) {
|
||||||
|
const QStringList modelTypes = model->mimeTypes();
|
||||||
|
for (int i = 0; i < modelTypes.count(); ++i)
|
||||||
|
if (mime->hasFormat(modelTypes.at(i))
|
||||||
|
&& (event->dropAction() & model->supportedDropActions()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (dropOn(event, &row, &col, &index)) {
|
if (dropOn(event, &row, &col, &index)) {
|
||||||
return model->canDropMimeData(event->mimeData(),
|
return model->canDropMimeData(mime,
|
||||||
dragDropMode == QAbstractItemView::InternalMove ? Qt::MoveAction : event->dropAction(),
|
dragDropMode == QAbstractItemView::InternalMove ? Qt::MoveAction : event->dropAction(),
|
||||||
row, col, index);
|
row, col, index);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user