Dekko
Loading...
Searching...
No Matches
ContactFilterView.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.Mail.API 1.0
23import Dekko.Components 1.0
24import Dekko.Lomiri.Components 1.0
25import "../delegates"
26import Dekko.Lomiri.Constants 1.0
27
28DekkoPage {
29 id: contactFilterView
30
31 property var sender
32 property string title: ""
33 property alias filterKey: msgList.messageKey
34 property string name: title
35 property string email: ""
36 property string initials: ""
37
38 pageHeader.title: title
39 pageHeader.backAction: Action {
40 iconName: "back"
41 onTriggered: ViewActions.popStageArea(ViewKeys.messageListStack)
42 }
43 extendHeader: !dekko.isSmallFF
44
45 MessageList {
46 id: msgList
47 sortOrder: Qt.DescendingOrder
48 filter: MessageList.All
49 }
50
51 ListItem {
52 id: contactHeader
53 anchors {
54 left: parent.left
55 top: pageHeader.bottom
56 right: parent.right
57 }
58
59 height: c.height + Style.defaultSpacing
60
61 Column {
62 id: c
63 anchors {
64 left: parent.left
65 top: parent.top
66 right: parent.right
67 }
68 spacing: Style.smallSpacing
69
70 Item {
71 anchors {
72 left: parent.left
73 right: parent.right
74 }
75 height: avatar.height + units.gu(3)
76 Avatar {
77 id: avatar
78 anchors {
79 centerIn: parent
80 }
81 width: units.gu(10)
82 height: width
83 fontSize: "x-large"
84 name: contactFilterView.name
85 email: contactFilterView.email
86 initials: contactFilterView.initials
87 }
88 }
89 Item {
90 anchors {
91 left: parent.left
92 right: parent.right
93 }
94 height: addressLabel.height
95 Label {
96 id: addressLabel
97 anchors {
98 centerIn: parent
99 }
100 text: name ? email : ""
101 }
102 }
103
104 Item {
105 anchors {
106 left: parent.left
107 right: parent.right
108 }
109 height: addEditButton.height
110
111 Button {
112 id: addEditButton
113 text: qsTr("Add contact")
114 width: parent.width / 2 - Style.largeSpacing
115 anchors {
116 left: parent.left
117 leftMargin: Style.defaultSpacing
118 }
119 Suru.highlightType: Suru.PositiveHighlight
120 color: Suru.highlightColor
121 onTriggered: ViewActions.openUris([Uris.newContactUri(sender.completeAddress)])
122 }
123 Button {
124 id: sendButton
125 text: qsTr("Send message")
126 width: parent.width / 2 - Style.smallSpacing
127 anchors {
128 right: parent.right
129 rightMargin: Style.defaultSpacing
130 }
131 Suru.highlightType: Suru.PositiveHighlight
132 color: Suru.highlightColor
133 onTriggered: ViewActions.openUris([sender.toRfc6068Mailto()])
134 }
135 }
136 }
137 }
138
139 ScrollView {
140 anchors {
141 left: parent.left
142 top: contactHeader.bottom
143 right: parent.right
144 bottom: parent.bottom
145 }
146
147 ListView {
148 id: lv
149 anchors.fill: parent
150 clip: true
151 add: DekkoAnimation.listViewAddTransition
152 addDisplaced: DekkoAnimation.listViewAddDisplacedTransition
153 remove: DekkoAnimation.listViewRemoveTransition
154 removeDisplaced: DekkoAnimation.listViewRemoveDisplacedTransition
155 highlight: !dekko.isSmallFF ? Style.highlightBar : null
156 highlightFollowsCurrentItem: true
157 highlightMoveDuration: 200
158 model: msgList.model
159 currentIndex: -1
160 delegate: MessageListDelegate {
161 id: msgListDelegate
162 anchors {
163 left: parent.left
164 right: parent.right
165 }
166 avatarVisible: false
167 msg: model.qtObject
168 leftSideAction: Action {
169 iconName: "delete"
170 onTriggered: {
171 MessageActions.deleteMessage(msgListDelegate.msg.messageId)
172 }
173 }
174 rightSideActions: [flagAction, readAction, contextAction]
175 onItemClicked: {
176 if (mouse.button === Qt.RightButton) {
177 rightClickActions.trigger()
178 return;
179 }
180 lv.currentIndex = model.index
181 MessageActions.openMessage(msgListDelegate.msg.messageId)
182 }
183 }
184
185 Component.onCompleted: positionViewAtBeginning()
186 }
187 }
188}
189