diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-26 09:59:26 -0600 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-26 11:08:29 -0600 |
commit | 1ca05b0bc78c8f17dda7a4026ab3983a07a25be1 (patch) | |
tree | f4c54935f472112bab60ab8aa0476e9e8f189840 /framework/qml/TreeView.qml | |
parent | 195d5ca8aca4b82827240609d3a62b77df11939f (diff) | |
download | kube-1ca05b0bc78c8f17dda7a4026ab3983a07a25be1.tar.gz kube-1ca05b0bc78c8f17dda7a4026ab3983a07a25be1.zip |
TreeView: activeIndex instead of focus to highlight focused index
Diffstat (limited to 'framework/qml/TreeView.qml')
-rw-r--r-- | framework/qml/TreeView.qml | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/framework/qml/TreeView.qml b/framework/qml/TreeView.qml index 871a21975..5dc05f3a 100644 --- a/framework/qml/TreeView.qml +++ b/framework/qml/TreeView.qml | |||
@@ -30,8 +30,16 @@ FocusScope { | |||
30 | default property alias __columns: treeView.__columns | 30 | default property alias __columns: treeView.__columns |
31 | property alias model: treeView.model | 31 | property alias model: treeView.model |
32 | property alias currentIndex: treeView.currentIndex | 32 | property alias currentIndex: treeView.currentIndex |
33 | signal dropped(QtObject drop, QtObject model) | 33 | /* |
34 | * Because active focus is useless in list/treeviews we use the concept of an activeIndex. | ||
35 | * The current selection represents the focused index. The activeIndex represents the selected index. | ||
36 | */ | ||
37 | property var activeIndex: null | ||
38 | signal dropped(var drop, var model) | ||
34 | signal activated(var index) | 39 | signal activated(var index) |
40 | onActivated: { | ||
41 | activeIndex = index | ||
42 | } | ||
35 | 43 | ||
36 | Flickable { | 44 | Flickable { |
37 | id: flickableItem | 45 | id: flickableItem |
@@ -147,16 +155,27 @@ FocusScope { | |||
147 | alternatingRowColors: false | 155 | alternatingRowColors: false |
148 | headerVisible: false | 156 | headerVisible: false |
149 | 157 | ||
150 | //TODO instead of highlighting the current selection: underline the current selection, and highlight the last activated index, so it corresponds | ||
151 | //to what we have in the maillist view. | ||
152 | //* underline: activefocus | ||
153 | //* glow: hover | ||
154 | //* highlight: selected | ||
155 | style: TreeViewStyle { | 158 | style: TreeViewStyle { |
156 | rowDelegate: Rectangle { | 159 | rowDelegate: Rectangle { |
157 | color: styleData.selected ? Kube.Colors.highlightColor : Kube.Colors.textColor | 160 | //FIXME Uses internal API to get to the model index |
161 | property bool isActive: root.activeIndex === treeView.__model.mapRowToModelIndex(styleData.row) | ||
162 | |||
158 | height: Kube.Units.gridUnit * 1.5 | 163 | height: Kube.Units.gridUnit * 1.5 |
159 | width: parent.width | 164 | width: parent.width |
165 | color: Kube.Colors.textColor | ||
166 | |||
167 | Rectangle { | ||
168 | anchors.fill: parent | ||
169 | color: Kube.Colors.highlightColor | ||
170 | visible: isActive | ||
171 | } | ||
172 | Rectangle { | ||
173 | anchors.fill: parent | ||
174 | border.width: 2 | ||
175 | border.color: Kube.Colors.focusedButtonColor | ||
176 | color: "transparent" | ||
177 | visible: styleData.selected | ||
178 | } | ||
160 | } | 179 | } |
161 | 180 | ||
162 | frame: Rectangle { | 181 | frame: Rectangle { |