Immediately drag when start distance is 0 in abstract item view
This change makes system drag become initiated right after dragging is detected when drag start distance from QApplication::startDragDistance is 0. Otherwise the starting distance is ignored and the value of 1 is implicitly used. The startDragDistance of 0 is needed on WASM, as the native dragstart event arrives exactly after the first mousemove event. With this change, it is possible to set up drag correctly prior to the native dragstart event arriving. Fixes: QTBUG-114947 Change-Id: I112d97d251c9e9b1a39196ddcc39a37024b441f6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
3f6041a24f
commit
844009f8e0
|
|
@ -1857,7 +1857,6 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event)
|
|||
void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_D(QAbstractItemView);
|
||||
QPoint topLeft;
|
||||
QPoint bottomRight = event->position().toPoint();
|
||||
|
||||
d->draggedPosition = bottomRight + d->offset();
|
||||
|
|
@ -1867,13 +1866,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)
|
|||
|
||||
#if QT_CONFIG(draganddrop)
|
||||
if (state() == DraggingState) {
|
||||
topLeft = d->pressedPosition - d->offset();
|
||||
if ((topLeft - bottomRight).manhattanLength() > QApplication::startDragDistance()) {
|
||||
d->pressedIndex = QModelIndex();
|
||||
startDrag(d->model->supportedDragActions());
|
||||
setState(NoState); // the startDrag will return when the dnd operation is done
|
||||
stopAutoScroll();
|
||||
}
|
||||
d->maybeStartDrag(bottomRight);
|
||||
return;
|
||||
}
|
||||
#endif // QT_CONFIG(draganddrop)
|
||||
|
|
@ -1884,10 +1877,8 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)
|
|||
|| edit(index, NoEditTriggers, event))
|
||||
return;
|
||||
|
||||
if (d->selectionMode != SingleSelection)
|
||||
topLeft = d->pressedPosition - d->offset();
|
||||
else
|
||||
topLeft = bottomRight;
|
||||
const QPoint topLeft =
|
||||
d->selectionMode != SingleSelection ? d->pressedPosition - d->offset() : bottomRight;
|
||||
|
||||
d->checkMouseMove(index);
|
||||
|
||||
|
|
@ -1898,6 +1889,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)
|
|||
&& (event->buttons() != Qt::NoButton)
|
||||
&& !d->selectedDraggableIndexes().isEmpty()) {
|
||||
setState(DraggingState);
|
||||
d->maybeStartDrag(bottomRight);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -4701,6 +4693,20 @@ QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const
|
|||
indexes.removeIf(isNotDragEnabled);
|
||||
return indexes;
|
||||
}
|
||||
|
||||
void QAbstractItemViewPrivate::maybeStartDrag(QPoint eventPosition)
|
||||
{
|
||||
Q_Q(QAbstractItemView);
|
||||
|
||||
const QPoint topLeft = pressedPosition - offset();
|
||||
if ((topLeft - eventPosition).manhattanLength() > QApplication::startDragDistance()) {
|
||||
pressedIndex = QModelIndex();
|
||||
q->startDrag(model->supportedDragActions());
|
||||
q->setState(QAbstractItemView::NoState); // the startDrag will return when the dnd operation
|
||||
// is done
|
||||
q->stopAutoScroll();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -309,6 +309,7 @@ public:
|
|||
|
||||
#if QT_CONFIG(draganddrop)
|
||||
QModelIndexList selectedDraggableIndexes() const;
|
||||
void maybeStartDrag(QPoint eventPoint);
|
||||
#endif
|
||||
|
||||
void doDelayedReset()
|
||||
|
|
|
|||
Loading…
Reference in New Issue