diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-04 19:19:41 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-04 19:19:41 +0200 |
commit | d9295fc8f19e4005f8454e7f193f80316550ac0c (patch) | |
tree | f27c370d54bced09212b9c4a12b827d1cebb6110 /framework/qml/FolderListView.qml | |
parent | d002eae7f8b443dd1bad914444c296088c2b6e85 (diff) | |
download | kube-d9295fc8f19e4005f8454e7f193f80316550ac0c.tar.gz kube-d9295fc8f19e4005f8454e7f193f80316550ac0c.zip |
One framework plugin to rule them all
Diffstat (limited to 'framework/qml/FolderListView.qml')
-rw-r--r-- | framework/qml/FolderListView.qml | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/framework/qml/FolderListView.qml b/framework/qml/FolderListView.qml new file mode 100644 index 00000000..b35b52ed --- /dev/null +++ b/framework/qml/FolderListView.qml | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | |||
4 | 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 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.4 | ||
20 | import QtQuick.Controls 1.4 | ||
21 | import QtQuick.Controls.Styles 1.4 | ||
22 | import QtQuick.Layouts 1.1 | ||
23 | |||
24 | import org.kde.kirigami 1.0 as Kirigami | ||
25 | import org.kube.components 1.0 as KubeComponents | ||
26 | import org.kube.components.theme 1.0 as KubeTheme | ||
27 | import org.kube.framework.domain 1.0 as KubeFramework | ||
28 | |||
29 | Rectangle { | ||
30 | id: root | ||
31 | |||
32 | property variant currentFolder: null | ||
33 | property variant accountId | ||
34 | |||
35 | color: KubeTheme.Colors.textColor | ||
36 | |||
37 | KubeFramework.FolderController { | ||
38 | id: folderController | ||
39 | Binding on folder { | ||
40 | //!! checks for the availability of the type | ||
41 | when: !!root.currentFolder | ||
42 | value: root.currentFolder | ||
43 | } | ||
44 | } | ||
45 | |||
46 | Menu { | ||
47 | id: contextMenu | ||
48 | title: "Edit" | ||
49 | |||
50 | MenuItem { | ||
51 | text: "Synchronize" | ||
52 | onTriggered: { | ||
53 | folderController.synchronizeAction.execute() | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | TreeView { | ||
59 | id: treeView | ||
60 | |||
61 | anchors { | ||
62 | top: parent.top | ||
63 | left: parent.left | ||
64 | right: parent.right | ||
65 | } | ||
66 | |||
67 | height: parent.height | ||
68 | |||
69 | TableViewColumn { | ||
70 | title: "Name" | ||
71 | role: "name" | ||
72 | } | ||
73 | |||
74 | model: KubeFramework.FolderListModel { | ||
75 | id: folderListModel | ||
76 | accountId: root.accountId | ||
77 | } | ||
78 | |||
79 | onCurrentIndexChanged: { | ||
80 | model.fetchMore(currentIndex) | ||
81 | root.currentFolder = model.data(currentIndex, KubeFramework.FolderListModel.DomainObject) | ||
82 | } | ||
83 | |||
84 | alternatingRowColors: false | ||
85 | headerVisible: false | ||
86 | |||
87 | MouseArea { | ||
88 | anchors.fill: parent | ||
89 | acceptedButtons: Qt.RightButton | ||
90 | onClicked: { | ||
91 | var index = parent.indexAt(mouse.x, mouse.y) | ||
92 | if (index.valid) { | ||
93 | folderController.folder = treeView.model.data(index, KubeFramework.FolderListModel.DomainObject) | ||
94 | contextMenu.popup() | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | style: TreeViewStyle { | ||
100 | |||
101 | rowDelegate: Rectangle { | ||
102 | color: styleData.selected ? KubeTheme.Colors.highlightColor : KubeTheme.Colors.textColor | ||
103 | |||
104 | height: Kirigami.Units.gridUnit * 1.5 | ||
105 | width: 20 | ||
106 | |||
107 | } | ||
108 | |||
109 | frame: Rectangle { | ||
110 | color: KubeTheme.Colors.textColor | ||
111 | } | ||
112 | |||
113 | branchDelegate: Item { | ||
114 | |||
115 | width: 16; height: 16 | ||
116 | |||
117 | Text { | ||
118 | |||
119 | anchors.centerIn: parent | ||
120 | |||
121 | color: KubeTheme.Colors.viewBackgroundColor | ||
122 | text: styleData.isExpanded ? "-" : "+" | ||
123 | } | ||
124 | |||
125 | //radius: styleData.isExpanded ? 0 : 100 | ||
126 | } | ||
127 | |||
128 | itemDelegate: Rectangle { | ||
129 | |||
130 | color: styleData.selected ? KubeTheme.Colors.highlightColor : KubeTheme.Colors.textColor | ||
131 | |||
132 | DropArea { | ||
133 | anchors.fill: parent | ||
134 | |||
135 | Rectangle { | ||
136 | anchors.fill: parent | ||
137 | color: KubeTheme.Colors.viewBackgroundColor | ||
138 | |||
139 | opacity: 0.3 | ||
140 | |||
141 | visible: parent.containsDrag | ||
142 | } | ||
143 | onDropped: { | ||
144 | folderController.folder = model.domainObject | ||
145 | folderController.mail = drop.source.mail | ||
146 | folderController.moveToFolderAction.execute() | ||
147 | drop.accept(Qt.MoveAction) | ||
148 | drop.source.visible = false | ||
149 | } | ||
150 | } | ||
151 | |||
152 | Row { | ||
153 | anchors { | ||
154 | verticalCenter: parent.verticalCenter | ||
155 | left: parent.left | ||
156 | } | ||
157 | Text { | ||
158 | anchors { | ||
159 | verticalCenter: parent.verticalCenter | ||
160 | leftMargin: Kirigami.Units.smallSpacing | ||
161 | } | ||
162 | |||
163 | text: styleData.value | ||
164 | |||
165 | color: KubeTheme.Colors.viewBackgroundColor | ||
166 | } | ||
167 | KubeComponents.Icon { | ||
168 | id: statusIcon | ||
169 | visible: false | ||
170 | iconName: "" | ||
171 | states: [ | ||
172 | State { | ||
173 | name: "busy"; when: model.status == KubeFramework.FolderListModel.InProgressStatus | ||
174 | PropertyChanges { target: statusIcon; iconName: KubeTheme.Icons.busy ; visible: styleData.selected } | ||
175 | }, | ||
176 | State { | ||
177 | name: "error"; when: model.status == KubeFramework.FolderListModel.ErrorStatus | ||
178 | //The error status should only be visible for a moment, otherwise we'll eventually always show errors everywhere. | ||
179 | PropertyChanges { target: statusIcon; iconName: KubeTheme.Icons.error; visible: styleData.selected } | ||
180 | }, | ||
181 | State { | ||
182 | name: "checkmark"; when: model.status == KubeFramework.FolderListModel.SuccessStatus | ||
183 | //The success status should only be visible for a moment, otherwise we'll eventually always show checkmarks everywhere. | ||
184 | PropertyChanges { target: statusIcon; iconName: KubeTheme.Icons.success; visible: styleData.selected } | ||
185 | } | ||
186 | ] | ||
187 | } | ||
188 | } | ||
189 | } | ||
190 | |||
191 | backgroundColor: KubeTheme.Colors.textColor | ||
192 | highlightedTextColor: KubeTheme.Colors.highlightedTextColor | ||
193 | } | ||
194 | } | ||
195 | } | ||