Skip to content
Snippets Groups Projects
Commit bdd4ca71 authored by Fatih Uzunoğlu's avatar Fatih Uzunoğlu Committed by Steve Lhomme
Browse files

qml: fix dragging multiple items in KeyNavigableTableView

This already works fine in other places, I must have missed
updating this in the last iteration.

Brief explanation of how this works:

- Tap handler should set the focus, even if the drag handler
  takes over. This means that the focus should be set in
  both `canceled()` and `singleTapped()` handlers. This
  merely corresponds to `pressed()` signal of mouse area.
- Tap handler should not update the selection if the drag
  handler takes over. This means that the selection should
  not be updated upon `canceled()` but `singleTapped()`
- Drag handler must update the selection when it becomes
  active, as long as the dragged item is not already
  selected.
parent ac60f455
No related branches found
No related tags found
No related merge requests found
......@@ -112,6 +112,10 @@ T.Control {
onActiveChanged: {
if (dragItem) {
if (active) {
if (!selected) {
delegate.ListView.view.selectionModel.select(index, ItemSelectionModel.ClearAndSelect)
}
dragItem.Drag.active = true
} else {
dragItem.Drag.drop()
......@@ -129,11 +133,17 @@ T.Control {
grabPermissions: TapHandler.CanTakeOverFromHandlersOfDifferentType | TapHandler.ApprovesTakeOverByAnything
onSingleTapped: (point, button) => {
onSingleTapped: (eventPoint, button) => {
initialAction()
if (!(delegate.selected && button === Qt.RightButton)) {
const view = delegate.ListView.view
view.selectionModel.updateSelection(point.modifiers, view.currentIndex, index)
view.currentIndex = index
}
if (button === Qt.RightButton)
delegate.rightClick(delegate, delegate.rowModel, parent.mapToGlobal(point.position.x, point.position.y))
delegate.rightClick(delegate, delegate.rowModel, parent.mapToGlobal(eventPoint.position.x, eventPoint.position.y))
}
onDoubleTapped: (point, button) => {
......@@ -146,9 +156,7 @@ T.Control {
}
function initialAction() {
if ((point.pressedButtons === Qt.LeftButton) || !delegate.selected) {
delegate.selectAndFocus(point.modifiers, Qt.MouseFocusReason)
}
delegate.forceActiveFocus(Qt.MouseFocusReason)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment