summaryrefslogtreecommitdiffstats
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
parent9895d72ea197c3bdc7e5465f1d96a249081b0e77 (diff)
downloadkube-0f01c1ea421eafc96630d1d9eded8bb044f3a88d.tar.gz
kube-0f01c1ea421eafc96630d1d9eded8bb044f3a88d.zip
Moved non-folder specific treeview to separate file
-rw-r--r--framework/qml/FolderListView.qml103
-rw-r--r--framework/qml/TreeView.qml126
-rw-r--r--framework/qmldir1
3 files changed, 133 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}
diff --git a/framework/qml/TreeView.qml b/framework/qml/TreeView.qml
new file mode 100644
index 00000000..aef0ee92
--- /dev/null
+++ b/framework/qml/TreeView.qml
@@ -0,0 +1,126 @@
1/*
2 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsystems.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20import QtQuick 2.4
21import QtQuick.Controls 1.4
22import QtQuick.Controls.Styles 1.4
23import QtQuick.Layouts 1.1
24import QtQml.Models 2.2
25
26import org.kube.framework 1.0 as Kube
27
28TreeView {
29 id: root
30
31 signal dropped(QtObject drop, QtObject model)
32
33 flickableItem.boundsBehavior: Flickable.StopAtBounds
34
35 selection: ItemSelectionModel {
36 model: root.model
37 //TODO once we don't loose focus to the next view
38 // onCurrentChanged: {
39 // treeView.activated(selection.currentIndex)
40 // }
41 }
42
43 onActiveFocusChanged: {
44 //Set an initially focused item when the list view receives focus
45 if (activeFocus && !selection.hasSelection) {
46 root.selection.setCurrentIndex(model.index(0, 0), ItemSelectionModel.ClearAndSelect)
47 }
48 }
49
50 Keys.onDownPressed: {
51 if (!selection.hasSelection) {
52 root.selection.setCurrentIndex(model.index(0, 0), ItemSelectionModel.ClearAndSelect)
53 } else {
54 root.selection.setCurrentIndex(model.sibling(selection.currentIndex.row + 1, 0, selection.currentIndex), ItemSelectionModel.ClearAndSelect)
55 }
56 }
57
58 Keys.onUpPressed: {
59 root.selection.setCurrentIndex(model.sibling(selection.currentIndex.row - 1, 0, selection.currentIndex), ItemSelectionModel.ClearAndSelect)
60 }
61
62 Keys.onReturnPressed: {
63 root.activated(selection.currentIndex)
64 }
65
66 //Forward the signal because on a desktopsystem activated is only triggerd by double clicks
67 onClicked: treeView.activated(index)
68
69 alternatingRowColors: false
70 headerVisible: false
71
72 style: TreeViewStyle {
73
74 rowDelegate: Rectangle {
75 color: styleData.selected ? Kube.Colors.highlightColor : Kube.Colors.textColor
76 height: Kube.Units.gridUnit * 1.5
77 width: 20
78 }
79
80 frame: Rectangle {
81 color: Kube.Colors.textColor
82 }
83
84 branchDelegate: Item {
85 width: 16
86 height: 16
87
88 Kube.Label {
89 anchors.centerIn: parent
90
91 color: Kube.Colors.viewBackgroundColor
92 text: styleData.isExpanded ? "-" : "+"
93 }
94
95 //radius: styleData.isExpanded ? 0 : 100
96 }
97
98 itemDelegate: Rectangle {
99 color: styleData.selected ? Kube.Colors.highlightColor : Kube.Colors.textColor
100
101 DropArea {
102 anchors.fill: parent
103
104 Rectangle {
105 anchors.fill: parent
106 color: Kube.Colors.viewBackgroundColor
107 opacity: 0.3
108 visible: parent.containsDrag
109 }
110 onDropped: root.dropped(drop, model)
111 }
112
113 Kube.Label {
114 anchors {
115 verticalCenter: parent.verticalCenter
116 left: parent.left
117 }
118 text: styleData.value
119 color: Kube.Colors.viewBackgroundColor
120 }
121 }
122
123 backgroundColor: Kube.Colors.textColor
124 highlightedTextColor: Kube.Colors.highlightedTextColor
125 }
126}
diff --git a/framework/qmldir b/framework/qmldir
index 04893ec9..874bdf78 100644
--- a/framework/qmldir
+++ b/framework/qmldir
@@ -30,6 +30,7 @@ View 1.0 View.qml
30AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml 30AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml
31AttachmentDelegate 1.0 AttachmentDelegate.qml 31AttachmentDelegate 1.0 AttachmentDelegate.qml
32ListView 1.0 ListView.qml 32ListView 1.0 ListView.qml
33TreeView 1.0 TreeView.qml
33ScrollHelper 1.0 ScrollHelper.qml 34ScrollHelper 1.0 ScrollHelper.qml
34singleton Messages 1.0 Messages.qml 35singleton Messages 1.0 Messages.qml
35singleton Colors 1.0 Colors.qml 36singleton Colors 1.0 Colors.qml