summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/controls/TableView.qml2
-rw-r--r--tests/auto/controls/data/tst_tableview.qml31
2 files changed, 32 insertions, 1 deletions
diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml
index 39c954bf9..6ade774d0 100644
--- a/src/controls/TableView.qml
+++ b/src/controls/TableView.qml
@@ -695,7 +695,7 @@ ScrollView {
function keySelect(shiftPressed, row) {
if (row < 0 || row === rowCount - 1)
return
- if (shiftPressed) {
+ if (shiftPressed && (selectionMode >= SelectionMode.ExtendedSelection)) {
selection.__ranges = new Array()
selection.select(mousearea.firstKeyRow, row)
} else {
diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml
index 6ec9fa5f5..7f1b48dca 100644
--- a/tests/auto/controls/data/tst_tableview.qml
+++ b/tests/auto/controls/data/tst_tableview.qml
@@ -120,6 +120,37 @@ TestCase {
return true;
}
+
+ function test_keyboardSelection() {
+ var component = Qt.createComponent("tableview/table6_countmodel.qml")
+ compare(component.status, Component.Ready)
+ var table = component.createObject(container);
+ verify(table !== null, "table created is null")
+ table.model = 30
+ table.width = container.width
+ table.height = container.height
+ table.selectionMode = SelectionMode.SingleSelection
+ table.forceActiveFocus();
+ keyClick(Qt.Key_Down);
+ verify(table.selection.contains(1))
+ verify(table.selection.count === 1)
+ keyClick(Qt.Key_Down, Qt.ShiftModifier);
+ verify(table.selection.contains(2))
+ verify(table.selection.count === 1)
+ table.selectionMode = SelectionMode.ExtendedSelection
+ keyClick(Qt.Key_Down, Qt.ShiftModifier);
+ verify(table.selection.contains(2))
+ verify(table.selection.contains(3))
+ verify(table.selection.count === 2)
+ table.selectionMode = SelectionMode.MultiSelection
+ keyClick(Qt.Key_Down);
+ keyClick(Qt.Key_Down, Qt.ShiftModifier);
+ verify(table.selection.contains(4))
+ verify(table.selection.contains(5))
+ verify(table.selection.count === 2)
+ table.destroy()
+ }
+
function test_selection() {
var component = Qt.createComponent("tableview/table2_qabstractitemmodel.qml")