diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-11-30 13:57:14 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-12-01 12:45:29 +0000 |
commit | cb7d397e3dbc769f8332a03858b28eddc7519279 (patch) | |
tree | bae3e0010ce8182746de10afecb5e664ae4f1456 /src/widgets/itemviews/qabstractitemview_p.h | |
parent | 9cbee306618a63309d5b2bcb3060836c33cc4274 (diff) |
Simplify QAbstractItemViewPrivate::canDrop()
Scope some variables better and drag a constant
expression out of the loop, at the expense of
executing it unconditionally. That should not
be a problem, as all operands of the expression
are calls to const member functions.
Change-Id: Ibcf54b2e2faf9a818df7d12c0790c1f173c8a8ca
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/widgets/itemviews/qabstractitemview_p.h')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview_p.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index bb88b25652..861a0f9ff1 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -165,21 +165,20 @@ 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())) + if (mime->hasFormat(modelTypes.at(i))) 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(), |