Dekko
Loading...
Searching...
No Matches
FolderListDelegate.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 QtQuick.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import Dekko.Mail 1.0
22import Dekko.Components 1.0
23import Dekko.Lomiri.Components 1.0
25ListItemWithActions {
26
27 property var folder
28 property bool actionsEnabled: false
29
30
31 function getIconForFolderType(f) {
32 switch (f.type) {
33 case Folder.StandardFolder:
34 return Icons.InboxIcon
35 case Folder.SpecialUseInboxFolder:
36 return Icons.CombineInboxIcon
37 case Folder.SpecialUseOutboxFolder:
38 return Icons.InboxIcon
39 case Folder.SpecialUseDraftsFolder:
40 return Icons.DraftIcon
41 case Folder.SpecialUseSentFolder:
42 return Icons.SendIcon;
43 case Folder.SpecialUseTrashFolder:
44 return Icons.DeleteIcon
45 case Folder.SpecialUseJunkFolder:
46 return Icons.JunkIcon
47 }
48 }
49
50 property list<Action> ctxtActions: [
51 Action {
52 id: favouriteFolder
53 text: folder && folder.isFavourite ? qsTr("Un-favourite") : qsTr("Favourite")
54 iconSource: folder && folder.isFavourite ? Paths.actionIconUrl(Paths.UnStarredIcon) :
55 Paths.actionIconUrl(Paths.StarredIcon)
56 onTriggered: folder.isFavourite = !folder.isFavourite
57 }
58 ]
59
60
61 rightSideActions: actionsEnabled ? ctxtActions : []
62
63 height: layout.height
64 anchors {
65 left: parent.left
66 right: parent.right
67 }
68 showDivider: false
69 showActionHighlight: false
70
71 ListItemLayout {
72 id: layout
73 height: units.gu(5)
74 title.text: folder ? folder.name : ""
76 id: attachmentImg
77 height: units.gu(3)
78 width: height
79 name: getIconForFolderType(folder)
80 color: LomiriColors.ash
81 SlotsLayout.position: SlotsLayout.Leading
83 id: favoriteIcon
84 height: units.gu(1.75)
85 width: height
86 visible: folder.isFavourite
87 anchors {
88 bottom: parent.top
89 bottomMargin: -units.gu(1.25)
90 leftMargin: -units.gu(1.25)
91 left: parent.right
92 }
93 color: "#f0e442"
94 name: Icons.StarredIcon
95 }
96 }
97 LomiriShape {
98 id: shape
99 visible: folder.unreadCount > 0
100 aspect: LomiriShape.Flat
101 color: Suru.secondaryBackgroundColor
102 height: units.gu(2.2)
103 width: countLable.width < height ? height : countLable.width + units.gu(1)
104 Label {
105 id: countLable
106 anchors.margins: units.gu(0.5)
107 anchors.centerIn: parent
108 fontSize: "small"
109 text: folder.unreadCount
110 }
111 }
112 padding.leading: 1 * units.gu(folder.nestingDepth) + units.gu(2)
113 }
114}
115