QQuickSelectionRectangle: ensure we start the selection where the drag started
We should start the selection in TableView at the position where the user started the drag, and not where the centroid at the time when the dragging gets active (which is an offset equal to the mousePressAndHoldInterval property in QStyleHints). Pick-to: 6.3 6.2 Change-Id: Ibe330d31c1e2c8022006a56b7119b1dcb3e0e5b9 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
8ef0407ddd
commit
6d2d4914f8
|
@ -210,11 +210,12 @@ QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate()
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(m_dragHandler, &QQuickDragHandler::activeChanged, [this]() {
|
QObject::connect(m_dragHandler, &QQuickDragHandler::activeChanged, [this]() {
|
||||||
const QPointF pos = m_dragHandler->centroid().position();
|
const QPointF startPos = m_dragHandler->centroid().pressPosition();
|
||||||
|
const QPointF dragPos = m_dragHandler->centroid().position();
|
||||||
if (m_dragHandler->active()) {
|
if (m_dragHandler->active()) {
|
||||||
m_selectable->clearSelection();
|
m_selectable->clearSelection();
|
||||||
m_selectable->setSelectionStartPos(pos);
|
m_selectable->setSelectionStartPos(startPos);
|
||||||
m_selectable->setSelectionEndPos(pos);
|
m_selectable->setSelectionEndPos(dragPos);
|
||||||
m_draggedHandle = nullptr;
|
m_draggedHandle = nullptr;
|
||||||
updateHandles();
|
updateHandles();
|
||||||
updateActiveState(true);
|
updateActiveState(true);
|
||||||
|
|
|
@ -337,7 +337,7 @@ TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drag on the bottom right handle, so that the selection shrinks to cell 1, 1
|
// Drag on the bottom right handle, so that the selection shrinks to cell 1, 1
|
||||||
mouseDrag(tableView, cellWidth * 2, cellHeight * 2, -cellWidth / 2, -cellHeight / 2, Qt.LeftButton)
|
mouseDrag(tableView, (cellWidth * 3) - 1, (cellHeight * 3) - 1, -cellWidth, -cellHeight, Qt.LeftButton)
|
||||||
compare(tableView.selectionModel.selectedIndexes.length, 1)
|
compare(tableView.selectionModel.selectedIndexes.length, 1)
|
||||||
verify(tableView.selectionModel.isSelected(tableView.model.index(1, 1)))
|
verify(tableView.selectionModel.isSelected(tableView.model.index(1, 1)))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue