diff options
author | Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com> | 2015-04-18 14:39:18 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2015-05-01 19:11:02 +0000 |
commit | 1f281bfd63402b50f3db378a027da26ca52ffb27 (patch) | |
tree | 62dd5e53a72cf2d733f98f8b79064850b6a9ea19 /src/widgets/itemviews/qabstractitemview_p.h | |
parent | 119c5ec93f3b32cb62456c3a42c54ebb2c42e567 (diff) |
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>
Diffstat (limited to 'src/widgets/itemviews/qabstractitemview_p.h')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview_p.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index c3bd1fb504..be5d4b7b71 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -168,8 +168,20 @@ public: QModelIndex index; int col = -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)) { - return model->canDropMimeData(event->mimeData(), + return model->canDropMimeData(mime, dragDropMode == QAbstractItemView::InternalMove ? Qt::MoveAction : event->dropAction(), row, col, index); } |