From 9c147a4d8a3f5054f727e2997180ae2ea6ec2549 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 26 Jul 2017 21:49:52 -0600 Subject: The standard keyboard navigation seems to work fine now --- framework/qml/TreeView.qml | 47 ---------------------------------------------- 1 file changed, 47 deletions(-) (limited to 'framework') diff --git a/framework/qml/TreeView.qml b/framework/qml/TreeView.qml index 6063d8c1..5bfa7600 100644 --- a/framework/qml/TreeView.qml +++ b/framework/qml/TreeView.qml @@ -92,42 +92,6 @@ FocusScope { treeView.selection.setCurrentIndex(model.index(0, 0), ItemSelectionModel.ClearAndSelect) } - function selectNext() - { - //If we have already expanded children go to them instead - var childIndex = model.index(0, 0, selection.currentIndex) - if (childIndex.valid && treeView.isExpanded(selection.currentIndex)) { - treeView.selection.setCurrentIndex(childIndex, ItemSelectionModel.ClearAndSelect) - } else { - //Otherwise just advance to the next index, if we can - var nextIndex = model.sibling(selection.currentIndex.row + 1, 0, selection.currentIndex) - if (nextIndex.valid) { - treeView.selection.setCurrentIndex(nextIndex, ItemSelectionModel.ClearAndSelect) - } else { - //Try to go to the next of the parent instead TODO do this recursively - var parentIndex = model.parent(selection.currentIndex) - if (parentIndex.valid) { - var parentNext = model.sibling(parentIndex.row + 1, 0, parentIndex) - treeView.selection.setCurrentIndex(parentNext, ItemSelectionModel.ClearAndSelect) - } - } - } - } - - function selectPrevious() - { - var previousIndex = model.sibling(selection.currentIndex.row - 1, 0, selection.currentIndex) - if (previousIndex.valid) { - treeView.selection.setCurrentIndex(previousIndex, ItemSelectionModel.ClearAndSelect) - //TODO if the previous index is expanded, go to the last visible child instead (recursively) - } else { - var parentIndex = model.parent(selection.currentIndex) - if (parentIndex.valid) { - treeView.selection.setCurrentIndex(parentIndex, ItemSelectionModel.ClearAndSelect) - } - } - } - onActiveFocusChanged: { //Set an initially focused item when the list view receives focus if (activeFocus && !selection.hasSelection) { @@ -138,18 +102,7 @@ FocusScope { } } - Keys.onDownPressed: { - if (!selection.hasSelection) { - selectFirst() - } else { - selectNext(); - } - } - - Keys.onUpPressed: selectPrevious() Keys.onReturnPressed: treeView.activated(selection.currentIndex) - Keys.onRightPressed: treeView.expand(selection.currentIndex) - Keys.onLeftPressed: treeView.collapse(selection.currentIndex) //Forward the signal because on a desktopsystem activated is only triggerd by double clicks onClicked: treeView.activated(index) -- cgit v1.2.3