diff options
Diffstat (limited to 'src/widgets/itemviews/qabstractitemview_p.h')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview_p.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index bb88b25652..2b28d8db84 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -73,7 +73,13 @@ struct QEditorInfo { typedef QHash<QWidget *, QPersistentModelIndex> QEditorIndexHash; typedef QHash<QPersistentModelIndex, QEditorInfo> QIndexEditorHash; -typedef QPair<QRect, QModelIndex> QItemViewPaintPair; +struct QItemViewPaintPair { + QRect rect; + QModelIndex index; +}; +template <> +class QTypeInfo<QItemViewPaintPair> : public QTypeInfoMerger<QItemViewPaintPair, QRect, QModelIndex> {}; + typedef QVector<QItemViewPaintPair> QItemViewPaintPairs; class QEmptyModel : public QAbstractItemModel @@ -165,21 +171,21 @@ public: virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; inline bool canDrop(QDropEvent *event) { - 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) { + if (event->type() == QEvent::DragEnter && (event->dropAction() & model->supportedDropActions())) { const QStringList modelTypes = model->mimeTypes(); - for (int i = 0; i < modelTypes.count(); ++i) - if (mime->hasFormat(modelTypes.at(i)) - && (event->dropAction() & model->supportedDropActions())) + for (const auto &modelType : modelTypes) { + if (mime->hasFormat(modelType)) return true; + } } + QModelIndex index; + int col = -1; + int row = -1; if (dropOn(event, &row, &col, &index)) { return model->canDropMimeData(mime, dragDropMode == QAbstractItemView::InternalMove ? Qt::MoveAction : event->dropAction(), |