diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-25 06:27:30 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-25 06:29:33 +0200 |
commit | 5d5bb33a9d5768d359325a3f00b746018e9033da (patch) | |
tree | d02cbb6f1697e61afc6ef7c5629b446c400529f2 /framework/qml/MailListView.qml | |
parent | 963e54fbfa9e734088d559a8746b3095705065d3 (diff) | |
download | kube-5d5bb33a9d5768d359325a3f00b746018e9033da.tar.gz kube-5d5bb33a9d5768d359325a3f00b746018e9033da.zip |
Use the ListDelegate for the MailListView delegate
Diffstat (limited to 'framework/qml/MailListView.qml')
-rw-r--r-- | framework/qml/MailListView.qml | 294 |
1 files changed, 119 insertions, 175 deletions
diff --git a/framework/qml/MailListView.qml b/framework/qml/MailListView.qml index 73caef72..efc86a77 100644 --- a/framework/qml/MailListView.qml +++ b/framework/qml/MailListView.qml | |||
@@ -102,210 +102,154 @@ FocusScope { | |||
102 | parentFolder: root.parentFolder | 102 | parentFolder: root.parentFolder |
103 | } | 103 | } |
104 | 104 | ||
105 | delegate: Item { | 105 | delegate: Kube.ListDelegate { |
106 | id: origin | 106 | id: delegateRoot |
107 | //Required for D&D | ||
108 | property var mail: model.mail | ||
107 | 109 | ||
108 | property variant currentData: model | 110 | onClicked: ListView.view.currentIndex = index |
109 | 111 | ||
110 | width: delegateRoot.width | 112 | width: scrollbar.visible ? listView.width - scrollbar.width : listView.width |
111 | height: delegateRoot.height | 113 | height: Kube.Units.gridUnit * 5 |
112 | 114 | ||
113 | Item { | 115 | color: Kube.Colors.viewBackgroundColor |
114 | id: delegateRoot | 116 | border.color: Kube.Colors.backgroundColor |
115 | 117 | border.width: 1 | |
116 | property variant mail : model.domainObject | ||
117 | |||
118 | width: scrollbar.visible ? listView.width - scrollbar.width : listView.width | ||
119 | height: Kube.Units.gridUnit * 5 | ||
120 | |||
121 | states: [ | ||
122 | State { | ||
123 | name: "dnd" | ||
124 | when: mouseArea.drag.active | ||
125 | |||
126 | PropertyChanges {target: mouseArea; cursorShape: Qt.ClosedHandCursor} | ||
127 | PropertyChanges {target: delegateRoot; x: x; y:y} | ||
128 | PropertyChanges {target: delegateRoot; parent: root} | ||
129 | |||
130 | PropertyChanges {target: delegateRoot; opacity: 0.7} | ||
131 | PropertyChanges {target: background; color: Kube.Colors.highlightColor} | ||
132 | PropertyChanges {target: subject; color: Kube.Colors.highlightedTextColor} | ||
133 | PropertyChanges {target: sender; color: Kube.Colors.highlightedTextColor} | ||
134 | PropertyChanges {target: date; color: Kube.Colors.highlightedTextColor} | ||
135 | PropertyChanges {target: threadCounter; color: Kube.Colors.highlightedTextColor} | ||
136 | }, | ||
137 | State { | ||
138 | name: "selected" | ||
139 | when: listView.currentIndex == index && !mouseArea.drag.active | ||
140 | |||
141 | PropertyChanges {target: background; color: Kube.Colors.highlightColor} | ||
142 | PropertyChanges {target: subject; color: Kube.Colors.highlightedTextColor; font.underline: listView.activeFocus} | ||
143 | PropertyChanges {target: sender; color: Kube.Colors.highlightedTextColor} | ||
144 | PropertyChanges {target: threadCounter; color: Kube.Colors.highlightedTextColor} | ||
145 | PropertyChanges {target: date; visible: false} | ||
146 | PropertyChanges {target: buttons; visible: true} | ||
147 | }, | ||
148 | State { | ||
149 | name: "hovered" | ||
150 | when: ( mouseArea.containsMouse || buttons.containsMouse ) && !mouseArea.drag.active | ||
151 | |||
152 | PropertyChanges {target: background; color: Kube.Colors.highlightColor; opacity: 0.6} | ||
153 | PropertyChanges {target: subject; color: Kube.Colors.highlightedTextColor} | ||
154 | PropertyChanges {target: sender; color: Kube.Colors.highlightedTextColor} | ||
155 | PropertyChanges {target: date; visible: false} | ||
156 | PropertyChanges {target: threadCounter; color: Kube.Colors.highlightedTextColor} | ||
157 | PropertyChanges {target: buttons; visible: true} | ||
158 | } | ||
159 | ] | ||
160 | |||
161 | Drag.active: mouseArea.drag.active | ||
162 | Drag.hotSpot.x: mouseArea.mouseX | ||
163 | Drag.hotSpot.y: mouseArea.mouseY | ||
164 | Drag.source: delegateRoot | ||
165 | |||
166 | MouseArea { | ||
167 | id: mouseArea | ||
168 | |||
169 | anchors.fill: parent | ||
170 | 118 | ||
171 | hoverEnabled: true | 119 | states: [ |
172 | drag.target: parent | 120 | State { |
121 | name: "dnd" | ||
122 | when: mouseArea.drag.active | ||
173 | 123 | ||
174 | onClicked: { | 124 | PropertyChanges {target: mouseArea; cursorShape: Qt.ClosedHandCursor} |
175 | listView.currentIndex = index | 125 | PropertyChanges {target: delegateRoot; x: x; y: y} |
176 | } | 126 | PropertyChanges {target: delegateRoot; parent: root} |
177 | onReleased: parent.Drag.drop() | 127 | PropertyChanges {target: delegateRoot; opacity: 0.7} |
178 | } | 128 | } |
179 | 129 | ] | |
180 | Rectangle { | 130 | |
181 | id: background | 131 | Drag.active: mouseArea.drag.active |
182 | 132 | Drag.hotSpot.x: mouseArea.mouseX | |
183 | anchors.fill: parent | 133 | Drag.hotSpot.y: mouseArea.mouseY |
134 | Drag.source: delegateRoot | ||
135 | |||
136 | MouseArea { | ||
137 | id: mouseArea | ||
138 | anchors.fill: parent | ||
139 | drag.target: parent | ||
140 | onReleased: parent.Drag.drop() | ||
141 | } | ||
184 | 142 | ||
185 | color: Kube.Colors.viewBackgroundColor | 143 | Item { |
144 | id: content | ||
186 | 145 | ||
187 | border.color: Kube.Colors.backgroundColor | 146 | anchors { |
188 | border.width: 1 | 147 | fill: parent |
148 | margins: Kube.Units.smallSpacing | ||
189 | } | 149 | } |
150 | property color unreadColor: (model.unread && !delegateRoot.ListView.isCurrentItem) ? Kube.Colors.highlightColor : delegateRoot.textColor | ||
190 | 151 | ||
191 | Item { | 152 | Column { |
192 | id: content | ||
193 | |||
194 | anchors { | 153 | anchors { |
195 | top: parent.top | 154 | verticalCenter: parent.verticalCenter |
196 | bottom: parent.bottom | ||
197 | left: parent.left | 155 | left: parent.left |
198 | right: parent.right | 156 | leftMargin: Kube.Units.largeSpacing |
199 | margins: Kube.Units.smallSpacing | ||
200 | } | 157 | } |
201 | 158 | ||
202 | Column { | 159 | Kube.Label{ |
203 | anchors { | 160 | id: subject |
204 | verticalCenter: parent.verticalCenter | 161 | width: content.width - Kube.Units.gridUnit * 3 |
205 | left: parent.left | 162 | text: model.subject |
206 | leftMargin: Kube.Units.largeSpacing | 163 | color: content.unreadColor |
207 | } | 164 | maximumLineCount: 2 |
208 | 165 | wrapMode: Text.WordWrap | |
209 | Kube.Label{ | 166 | elide: Text.ElideRight |
210 | id: subject | ||
211 | |||
212 | width: content.width - Kube.Units.gridUnit * 3 | ||
213 | |||
214 | text: model.subject | ||
215 | color: model.unread ? Kube.Colors.highlightColor : Kube.Colors.textColor | ||
216 | maximumLineCount: 2 | ||
217 | wrapMode: Text.WordWrap | ||
218 | elide: Text.ElideRight | ||
219 | } | ||
220 | |||
221 | Kube.Label { | ||
222 | id: sender | ||
223 | |||
224 | text: model.senderName | ||
225 | font.italic: true | ||
226 | width: delegateRoot.width - Kube.Units.gridUnit * 3 | ||
227 | elide: Text.ElideRight | ||
228 | } | ||
229 | } | 167 | } |
230 | 168 | ||
231 | Kube.Label { | 169 | Kube.Label { |
232 | id: date | 170 | id: sender |
233 | 171 | text: model.senderName | |
234 | anchors { | 172 | color: delegateRoot.textColor |
235 | right: parent.right | ||
236 | bottom: parent.bottom | ||
237 | } | ||
238 | text: Qt.formatDateTime(model.date, "dd MMM yyyy") | ||
239 | font.italic: true | 173 | font.italic: true |
240 | color: Kube.Colors.disabledTextColor | 174 | width: delegateRoot.width - Kube.Units.gridUnit * 3 |
241 | font.pointSize: Kube.Units.tinyFontSize | 175 | elide: Text.ElideRight |
242 | } | ||
243 | |||
244 | Kube.Label { | ||
245 | id: threadCounter | ||
246 | |||
247 | anchors { | ||
248 | right: parent.right | ||
249 | } | ||
250 | text: model.threadSize | ||
251 | color: model.unread ? Kube.Colors.highlightColor : Kube.Colors.disabledTextColor | ||
252 | visible: model.threadSize > 1 | ||
253 | } | 176 | } |
254 | } | 177 | } |
255 | 178 | ||
256 | Row { | 179 | Kube.Label { |
257 | id: buttons | 180 | id: date |
258 | |||
259 | property bool containsMouse: importantButton.hovered || deleteButton.hovered || unreadButton.hovered || readButton.hovered | ||
260 | |||
261 | anchors { | 181 | anchors { |
262 | right: parent.right | 182 | right: parent.right |
263 | bottom: parent.bottom | 183 | bottom: parent.bottom |
264 | margins: Kube.Units.smallSpacing | ||
265 | } | 184 | } |
185 | visible: !delegateRoot.hovered | ||
186 | text: Qt.formatDateTime(model.date, "dd MMM yyyy") | ||
187 | font.italic: true | ||
188 | color: Kube.Colors.disabledTextColor | ||
189 | font.pointSize: Kube.Units.tinyFontSize | ||
190 | } | ||
266 | 191 | ||
267 | visible: false | 192 | Kube.Label { |
268 | spacing: Kube.Units.smallSpacing | 193 | id: threadCounter |
269 | opacity: 0.7 | 194 | anchors.right: parent.right |
195 | text: model.threadSize | ||
196 | color: content.unreadColor | ||
197 | visible: model.threadSize > 1 | ||
198 | } | ||
199 | } | ||
270 | 200 | ||
271 | Kube.IconButton { | 201 | Row { |
272 | id: readButton | 202 | id: buttons |
273 | iconName: Kube.Icons.markAsRead | ||
274 | visible: enabled | ||
275 | enabled: model.unread | ||
276 | onClicked: Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": model.mail}) | ||
277 | } | ||
278 | Kube.IconButton { | ||
279 | id: unreadButton | ||
280 | iconName: Kube.Icons.markAsUnread | ||
281 | visible: enabled | ||
282 | enabled: !model.unread | ||
283 | onClicked: Kube.Fabric.postMessage(Kube.Messages.markAsUnread, {"mail": model.mail}) | ||
284 | } | ||
285 | 203 | ||
286 | Kube.IconButton { | 204 | anchors { |
287 | id: importantButton | 205 | right: parent.right |
288 | iconName: Kube.Icons.markImportant | 206 | bottom: parent.bottom |
289 | visible: enabled | 207 | margins: Kube.Units.smallSpacing |
290 | enabled: !!model.mail | 208 | } |
291 | onClicked: Kube.Fabric.postMessage(Kube.Messages.toggleImportant, {"mail": model.mail, "important": model.important}) | ||
292 | } | ||
293 | 209 | ||
294 | Kube.IconButton { | 210 | visible: delegateRoot.hovered |
295 | id: deleteButton | ||
296 | iconName: Kube.Icons.moveToTrash | ||
297 | visible: enabled | ||
298 | enabled: !!model.mail | ||
299 | onClicked: Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": model.mail}) | ||
300 | } | ||
301 | 211 | ||
302 | Kube.IconButton { | 212 | spacing: Kube.Units.smallSpacing |
303 | id: restoreButton | 213 | opacity: 0.7 |
304 | iconName: Kube.Icons.undo | 214 | |
305 | visible: enabled | 215 | Kube.IconButton { |
306 | enabled: !!model.trash | 216 | id: readButton |
307 | onClicked: Kube.Fabric.postMessage(Kube.Messages.restoreFromTrash, {"mail": model.mail}) | 217 | iconName: Kube.Icons.markAsRead |
308 | } | 218 | //FIXME workaround for invisble icon |
219 | color: Kube.Colors.highlightColor | ||
220 | visible: model.unread | ||
221 | onClicked: Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": model.mail}) | ||
222 | } | ||
223 | Kube.IconButton { | ||
224 | id: unreadButton | ||
225 | iconName: Kube.Icons.markAsUnread | ||
226 | //FIXME workaround for invisble icon | ||
227 | color: Kube.Colors.highlightColor | ||
228 | visible: !model.unread | ||
229 | onClicked: Kube.Fabric.postMessage(Kube.Messages.markAsUnread, {"mail": model.mail}) | ||
230 | } | ||
231 | |||
232 | Kube.IconButton { | ||
233 | id: importantButton | ||
234 | iconName: Kube.Icons.markImportant | ||
235 | //FIXME workaround for invisble icon | ||
236 | color: Kube.Colors.highlightColor | ||
237 | visible: !!model.mail | ||
238 | onClicked: Kube.Fabric.postMessage(Kube.Messages.toggleImportant, {"mail": model.mail, "important": model.important}) | ||
239 | } | ||
240 | |||
241 | Kube.IconButton { | ||
242 | id: deleteButton | ||
243 | iconName: Kube.Icons.moveToTrash | ||
244 | visible: !!model.mail | ||
245 | onClicked: Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": model.mail}) | ||
246 | } | ||
247 | |||
248 | Kube.IconButton { | ||
249 | id: restoreButton | ||
250 | iconName: Kube.Icons.undo | ||
251 | visible: !!model.trash | ||
252 | onClicked: Kube.Fabric.postMessage(Kube.Messages.restoreFromTrash, {"mail": model.mail}) | ||
309 | } | 253 | } |
310 | } | 254 | } |
311 | } | 255 | } |