diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-26 21:49:52 -0600 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-27 11:01:21 -0600 |
commit | 9c147a4d8a3f5054f727e2997180ae2ea6ec2549 (patch) | |
tree | 03cebeaeb93a625d3f44a3e8d35a1ca1f46865df /framework/qml/TreeView.qml | |
parent | 04aeb70a899a1ea2ad81ac579b310dcb1052a1cc (diff) | |
download | kube-9c147a4d8a3f5054f727e2997180ae2ea6ec2549.tar.gz kube-9c147a4d8a3f5054f727e2997180ae2ea6ec2549.zip |
The standard keyboard navigation seems to work fine now
Diffstat (limited to 'framework/qml/TreeView.qml')
-rw-r--r-- | framework/qml/TreeView.qml | 47 |
1 files changed, 0 insertions, 47 deletions
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 { | |||
92 | treeView.selection.setCurrentIndex(model.index(0, 0), ItemSelectionModel.ClearAndSelect) | 92 | treeView.selection.setCurrentIndex(model.index(0, 0), ItemSelectionModel.ClearAndSelect) |
93 | } | 93 | } |
94 | 94 | ||
95 | function selectNext() | ||
96 | { | ||
97 | //If we have already expanded children go to them instead | ||
98 | var childIndex = model.index(0, 0, selection.currentIndex) | ||
99 | if (childIndex.valid && treeView.isExpanded(selection.currentIndex)) { | ||
100 | treeView.selection.setCurrentIndex(childIndex, ItemSelectionModel.ClearAndSelect) | ||
101 | } else { | ||
102 | //Otherwise just advance to the next index, if we can | ||
103 | var nextIndex = model.sibling(selection.currentIndex.row + 1, 0, selection.currentIndex) | ||
104 | if (nextIndex.valid) { | ||
105 | treeView.selection.setCurrentIndex(nextIndex, ItemSelectionModel.ClearAndSelect) | ||
106 | } else { | ||
107 | //Try to go to the next of the parent instead TODO do this recursively | ||
108 | var parentIndex = model.parent(selection.currentIndex) | ||
109 | if (parentIndex.valid) { | ||
110 | var parentNext = model.sibling(parentIndex.row + 1, 0, parentIndex) | ||
111 | treeView.selection.setCurrentIndex(parentNext, ItemSelectionModel.ClearAndSelect) | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | function selectPrevious() | ||
118 | { | ||
119 | var previousIndex = model.sibling(selection.currentIndex.row - 1, 0, selection.currentIndex) | ||
120 | if (previousIndex.valid) { | ||
121 | treeView.selection.setCurrentIndex(previousIndex, ItemSelectionModel.ClearAndSelect) | ||
122 | //TODO if the previous index is expanded, go to the last visible child instead (recursively) | ||
123 | } else { | ||
124 | var parentIndex = model.parent(selection.currentIndex) | ||
125 | if (parentIndex.valid) { | ||
126 | treeView.selection.setCurrentIndex(parentIndex, ItemSelectionModel.ClearAndSelect) | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | |||
131 | onActiveFocusChanged: { | 95 | onActiveFocusChanged: { |
132 | //Set an initially focused item when the list view receives focus | 96 | //Set an initially focused item when the list view receives focus |
133 | if (activeFocus && !selection.hasSelection) { | 97 | if (activeFocus && !selection.hasSelection) { |
@@ -138,18 +102,7 @@ FocusScope { | |||
138 | } | 102 | } |
139 | } | 103 | } |
140 | 104 | ||
141 | Keys.onDownPressed: { | ||
142 | if (!selection.hasSelection) { | ||
143 | selectFirst() | ||
144 | } else { | ||
145 | selectNext(); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | Keys.onUpPressed: selectPrevious() | ||
150 | Keys.onReturnPressed: treeView.activated(selection.currentIndex) | 105 | Keys.onReturnPressed: treeView.activated(selection.currentIndex) |
151 | Keys.onRightPressed: treeView.expand(selection.currentIndex) | ||
152 | Keys.onLeftPressed: treeView.collapse(selection.currentIndex) | ||
153 | 106 | ||
154 | //Forward the signal because on a desktopsystem activated is only triggerd by double clicks | 107 | //Forward the signal because on a desktopsystem activated is only triggerd by double clicks |
155 | onClicked: treeView.activated(index) | 108 | onClicked: treeView.activated(index) |