Make use of defaultDropAction in QListView icon mode
Before this patch, using setDefaultDropAction on QListView in icon mode would not have any effect. Now the drag behaves properly. The default action is set to CopyAction rather than IgnoreAction to keep the current behavior and avoid breaking user code. [ChangeLog][QtWidgets][QListWidget] Fixed a bug that caused the default drop action to be ignored when using icon mode. Task-number: QTBUG-15741 Change-Id: I49654cde382af344ffc4594699303c928e27e05d Reviewed-by: Marc Mutz <marc.mutz@kdab.com>bb10
parent
559152d911
commit
a90485dd01
|
|
@ -1978,6 +1978,11 @@ int QCommonListViewBase::horizontalScrollToValue(const int /*index*/, QListView:
|
|||
/*
|
||||
* ListMode ListView Implementation
|
||||
*/
|
||||
QListModeViewBase::QListModeViewBase(QListView *q, QListViewPrivate *d)
|
||||
: QCommonListViewBase(q, d)
|
||||
{
|
||||
dd->defaultDropAction = Qt::CopyAction;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DRAGANDDROP
|
||||
QAbstractItemView::DropIndicatorPosition QListModeViewBase::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const
|
||||
|
|
@ -2744,7 +2749,7 @@ bool QIconModeViewBase::filterStartDrag(Qt::DropActions supportedActions)
|
|||
drag->setMimeData(dd->model->mimeData(indexes));
|
||||
drag->setPixmap(pixmap);
|
||||
drag->setHotSpot(dd->pressedPosition - rect.topLeft());
|
||||
Qt::DropAction action = drag->exec(supportedActions, Qt::CopyAction);
|
||||
Qt::DropAction action = drag->exec(supportedActions, dd->defaultDropAction);
|
||||
draggedItems.clear();
|
||||
if (action == Qt::MoveAction)
|
||||
dd->clearOrRemove();
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ public:
|
|||
class QListModeViewBase : public QCommonListViewBase
|
||||
{
|
||||
public:
|
||||
QListModeViewBase(QListView *q, QListViewPrivate *d) : QCommonListViewBase(q, d) {}
|
||||
QListModeViewBase(QListView *q, QListViewPrivate *d);
|
||||
|
||||
QVector<int> flowPositions;
|
||||
QVector<int> segmentPositions;
|
||||
|
|
|
|||
Loading…
Reference in New Issue