summaryrefslogtreecommitdiffstats
path: root/framework/qml/FolderListView.qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-14 23:29:31 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-15 20:14:49 +0200
commit0f01c1ea421eafc96630d1d9eded8bb044f3a88d (patch)
tree246ce8473995700dfd6838a3ba8c642359a2728a /framework/qml/FolderListView.qml
parent9895d72ea197c3bdc7e5465f1d96a249081b0e77 (diff)
downloadkube-0f01c1ea421eafc96630d1d9eded8bb044f3a88d.tar.gz
kube-0f01c1ea421eafc96630d1d9eded8bb044f3a88d.zip
Moved non-folder specific treeview to separate file
Diffstat (limited to 'framework/qml/FolderListView.qml')
-rw-r--r--framework/qml/FolderListView.qml103
1 files changed, 6 insertions, 97 deletions
diff --git a/framework/qml/FolderListView.qml b/framework/qml/FolderListView.qml
index e5ab018f..7800e98d 100644
--- a/framework/qml/FolderListView.qml
+++ b/framework/qml/FolderListView.qml
@@ -1,5 +1,6 @@
1/* 1/*
2 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> 2 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsystems.com>
3 4
4 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -24,11 +25,9 @@ import QtQml.Models 2.2
24 25
25import org.kube.framework 1.0 as Kube 26import org.kube.framework 1.0 as Kube
26 27
27TreeView { 28Kube.TreeView {
28 id: treeView 29 id: treeView
29 property variant accountId 30 property variant accountId
30 visible: true
31 flickableItem.boundsBehavior: Flickable.StopAtBounds
32 31
33 TableViewColumn { 32 TableViewColumn {
34 title: "Name" 33 title: "Name"
@@ -39,34 +38,6 @@ TreeView {
39 id: folderListModel 38 id: folderListModel
40 accountId: treeView.accountId 39 accountId: treeView.accountId
41 } 40 }
42 selection: ItemSelectionModel {
43 model: treeView.model
44 //TODO once we don't loose focus to the next view
45 // onCurrentChanged: {
46 // treeView.activated(selection.currentIndex)
47 // }
48 }
49
50 onActiveFocusChanged: {
51 //Set an initially focused item when the list view receives focus
52 if (activeFocus && !selection.hasSelection) {
53 treeView.selection.setCurrentIndex(model.index(0, 0), ItemSelectionModel.ClearAndSelect)
54 }
55 }
56
57 Keys.onDownPressed: {
58 if (!selection.hasSelection) {
59 treeView.selection.setCurrentIndex(model.index(0, 0), ItemSelectionModel.ClearAndSelect)
60 } else {
61 treeView.selection.setCurrentIndex(model.sibling(selection.currentIndex.row + 1, 0, selection.currentIndex), ItemSelectionModel.ClearAndSelect)
62 }
63 }
64 Keys.onUpPressed: {
65 treeView.selection.setCurrentIndex(model.sibling(selection.currentIndex.row - 1, 0, selection.currentIndex), ItemSelectionModel.ClearAndSelect)
66 }
67 Keys.onReturnPressed: {
68 treeView.activated(selection.currentIndex)
69 }
70 41
71 onActivated: { 42 onActivated: {
72 //TODO do some event compression in case of double clicks 43 //TODO do some event compression in case of double clicks
@@ -75,73 +46,11 @@ TreeView {
75 "trash": model.data(index, Kube.FolderListModel.Trash)}); 46 "trash": model.data(index, Kube.FolderListModel.Trash)});
76 Kube.Fabric.postMessage(Kube.Messages.synchronize, {"folder": model.data(index, Kube.FolderListModel.DomainObject)}); 47 Kube.Fabric.postMessage(Kube.Messages.synchronize, {"folder": model.data(index, Kube.FolderListModel.DomainObject)});
77 } 48 }
78 //Forward the signal because on a desktopsystem activated is only triggerd by double clicks
79 onClicked: treeView.activated(index)
80
81 alternatingRowColors: false
82 headerVisible: false
83
84 style: TreeViewStyle {
85
86 rowDelegate: Rectangle {
87 color: styleData.selected ? Kube.Colors.highlightColor : Kube.Colors.textColor
88
89 height: Kube.Units.gridUnit * 1.5
90 width: 20
91
92 }
93
94 frame: Rectangle {
95 color: Kube.Colors.textColor
96 }
97
98 branchDelegate: Item {
99
100 width: 16; height: 16
101
102 Kube.Label {
103 anchors.centerIn: parent
104
105 color: Kube.Colors.viewBackgroundColor
106 text: styleData.isExpanded ? "-" : "+"
107 }
108
109 //radius: styleData.isExpanded ? 0 : 100
110 }
111
112 itemDelegate: Rectangle {
113
114 color: styleData.selected ? Kube.Colors.highlightColor : Kube.Colors.textColor
115
116 DropArea {
117 anchors.fill: parent
118
119 Rectangle {
120 anchors.fill: parent
121 color: Kube.Colors.viewBackgroundColor
122
123 opacity: 0.3
124
125 visible: parent.containsDrag
126 }
127 onDropped: {
128 Kube.Fabric.postMessage(Kube.Messages.moveToFolder, {"mail": drop.source.mail, "folder":model.domainObject})
129 drop.accept(Qt.MoveAction)
130 drop.source.visible = false
131 }
132 }
133 49
134 Kube.Label {
135 anchors {
136 verticalCenter: parent.verticalCenter
137 left: parent.left
138 }
139 text: styleData.value
140 color: Kube.Colors.viewBackgroundColor
141 }
142 }
143 50
144 backgroundColor: Kube.Colors.textColor 51 onDropped: {
145 highlightedTextColor: Kube.Colors.highlightedTextColor 52 Kube.Fabric.postMessage(Kube.Messages.moveToFolder, {"mail": drop.source.mail, "folder": model.domainObject})
53 drop.accept(Qt.MoveAction)
54 drop.source.visible = false
146 } 55 }
147} 56}