Commit a60d3e0d authored by Shawn Rutledge's avatar Shawn Rutledge
Browse files

TreeView: allow selecting items by touch


Only single items can be selected via an actual touchscreen, because
the keyboard modifiers are not accessible in a mouse event synthesized
from touch.  With a mouse, if the system has a touchscreen, then
selections done by consecutive clicking (with or without modifiers)
will work, whereas dragging across a consecutive range will not work
because dragging is the same as flicking.  But on systems which do
not have a touchscreen at all, the behavior is the same as before.

Task-number: QTBUG-47243
Change-Id: Ib0fa1a75592b982fe93da46f0c2e3018219947d0
Reviewed-by: default avatarGabriel de Dietrich <gabriel.dedietrich@qt.io>
Reviewed-by: default avatarJan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: default avatarShawn Rutledge <shawn.rutledge@qt.io>
Showing with 18 additions and 4 deletions
......@@ -118,8 +118,8 @@ BasicTableView {
z: -1
propagateComposedEvents: true
focus: true
// Note: with boolean preventStealing we are keeping
// the flickable from eating our mouse press events
// If there is not a touchscreen, keep the flickable from eating our mouse drags.
// If there is a touchscreen, flicking is possible, but selection can be done only by tapping, not by dragging.
preventStealing: !Settings.hasTouchScreen
property var clickedIndex: undefined
......@@ -323,8 +323,22 @@ BasicTableView {
modelAdaptor.collapse(modelIndex)
else
modelAdaptor.expand(modelIndex)
} else if (root.__activateItemOnSingleClick) {
root.activated(modelIndex)
} else {
if (Settings.hasTouchScreen) {
// compensate for the fact that onPressed didn't select on press: do it here instead
pressedIndex = modelAdaptor.mapRowToModelIndex(clickIndex)
pressedColumn = __listView.columnAt(mouseX)
selectOnRelease = false
__listView.forceActiveFocus()
__listView.currentIndex = clickIndex
if (!clickedIndex)
clickedIndex = pressedIndex
mouseSelect(pressedIndex, mouse.modifiers, false)
if (!mouse.modifiers)
clickedIndex = pressedIndex
}
if (root.__activateItemOnSingleClick && !mouse.modifiers)
root.activated(modelIndex)
}
root.clicked(modelIndex)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment