Dekko
Loading...
Searching...
No Matches
NavMenuModel.qml
1/* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
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
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18import QtQuick 2.4
19import Lomiri.Components 1.3
20import Dekko.Mail 1.0
21import Dekko.Mail.API 1.0
22import Dekko.Mail.Settings 1.0
23import Dekko.Mail.Stores.Views 1.0
24import Dekko.Mail.Stores.Mail 1.0
25import Dekko.Mail.Stores.Accounts 1.0
26import "../delegates"
27import Dekko.Lomiri.Components 1.0
28
29VisualItemModel {
30
31 id: navModel
32
33 property bool panelIsParent: true
34 readonly property bool showGroups: MailboxStore.standardFoldersModel.count &&
35 MailboxStore.smartFoldersModel.count &&
36 AccountStore.receiveAccountsModel.count
37
38 Item {
39 width: navDrawer.width
40 height: panelIsParent ? navDrawer.topListViewHandle.height : navDrawer.height
41 visible: showGroups
42 Loader {
43 anchors.fill: parent
44 asynchronous: true
45 sourceComponent: Component {
46
47 ScrollView {
48 anchors.fill: parent
49 Flickable {
50 id: flicker
51 anchors.fill: parent
52 clip: true
53 contentHeight: col.height + units.gu(5)
54 interactive: col.height > parent.height
55 Column {
56 id: col
57 anchors {left: parent.left; right: parent.right; top: parent.top}
58 Column {
59 anchors {
60 left: parent.left
61 right: parent.right
62 }
63 Repeater {
64 id: inboxList
65 model: MailboxStore.standardFoldersModel
67 id: folderDelegate
68 folder: qtObject
69 supportsDescendents: true
70 onClicked: {
71 if (model.index === 0) {
72 MessageActions.openFolder(folder.displayName, folder.descendentsKey)
73 } else {
74 MessageActions.openFolder(folder.displayName, folder.messageKey)
75 }
76 }
77 onSubFolderClicked: MessageActions.openFolder(name, key)
78 Component.onCompleted: {
79 if (model.index === 0 && !panelIsParent) {
80 ViewActions.delayCallWithArgs(MessageKeys.openFolder, {
81 folderName: folder.displayName,
82 folderKey: folder.descendentsKey
83 })
84 }
85 }
86 }
87 }
88 }
89 Item {
90 anchors {
91 left: parent.left
92 right: parent.right
93 }
94 height: smf.height
95 visible: PolicyManager.views.smartFoldersVisible
97 id: smf
98 title: qsTr("Smart folders")
99 model: MailboxStore.smartFoldersModel
100// expansion.expanded: PolicyManager.views.smartFoldersExpanded
101// onExpandClicked: PolicyManager.views.smartFoldersExpanded = !PolicyManager.views.smartFoldersExpanded
103 id: smartFolderDelegate
104 folder: qtObject
105 smartFolder: true
106 onClicked: MessageActions.openFolder(folder.displayName, folder.messageKey)
107 }
108 }
109 }
110
111 Item {
112 anchors {
113 left: parent.left
114 right: parent.right
115 }
116 height: acg.height
117 visible: PolicyManager.views.accountsVisible
119 id: acg
120 title: qsTr("Folders")
121 model: AccountStore.receiveAccountsModel
122// expansion.expanded: PolicyManager.views.accountsExpanded
123// onExpandClicked: PolicyManager.views.accountsExpanded = !PolicyManager.views.accountsExpanded
124 delegate: ListItem {
125 height: dLayout.height
126 divider.visible: false
127 onClicked: MessageActions.openAccountFolder(qtObject.name, qtObject.id)
128 Rectangle {
129 anchors.fill: parent
130 color: Qt.rgba(0, 0, 0, 0.05)
131 visible: dLayout ? dLayout.title.text === ViewStore.selectedNavFolder : false
132 }
133 ListItemLayout {
134 id: dLayout
135 height: units.gu(6)
136 title.text: qtObject.name
137 Icon {
138 height: units.gu(2.5)
139 width: height
140 name: "contact"
141 SlotsLayout.position: SlotsLayout.Leading
142 }
143 ProgressionSlot{}
144 }
145 }
146 }
147 }
148 }
149 }
150 }
151 }
152 }
153 }
154
155 Item {
156 width: navDrawer.width
157 height: panelIsParent ? navDrawer.topListViewHandle.height : navDrawer.height
158 Loader {
159 anchors.fill: parent
160 asynchronous: true
161 sourceComponent: Component {
162 ScrollView {
163 anchors.fill: parent
164 ListView {
165 anchors.fill: parent
166 model: NavMenuContactsModel{}
167 }
168 }
169 }
170 }
171 }
172 Item {
173 width: navDrawer.width
174 height: panelIsParent ? navDrawer.topListViewHandle.height : navDrawer.height
175 Loader {
176 anchors.fill: parent
177 asynchronous: true
178 sourceComponent: Component {
179 ScrollView {
180 anchors.fill: parent
181 ListView {
182 anchors.fill: parent
184 }
185 }
186 }
187 }
188 }
189 Item {
190 width: navDrawer.width
191 height: panelIsParent ? navDrawer.topListViewHandle.height : navDrawer.height
192 Loader {
193 anchors.fill: parent
194 asynchronous: true
195 sourceComponent: Component {
196 ScrollView {
197 anchors.fill: parent
198 ListView {
199 anchors.fill: parent
201 }
202 }
203 }
204 }
205 }
206}