Merge lp:~ubuntu-clock-dev/ubuntu-clock-app/4-migrate-alarm-listitems into lp:ubuntu-clock-app
- 4-migrate-alarm-listitems
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Bartosz Kosiorek | ||||
Approved revision: | 278 | ||||
Merged at revision: | 311 | ||||
Proposed branch: | lp:~ubuntu-clock-dev/ubuntu-clock-app/4-migrate-alarm-listitems | ||||
Merge into: | lp:ubuntu-clock-app | ||||
Prerequisite: | lp:~ubuntu-clock-dev/ubuntu-clock-app/3-migrate-settings-page-listitems | ||||
Diff against target: |
749 lines (+112/-490) 7 files modified
app/alarm/AlarmDelegate.qml (+4/-4) app/alarm/AlarmList.qml (+48/-106) app/alarm/AlarmPage.qml (+52/-77) app/components/HeaderButton.qml (+0/-65) app/upstreamcomponents/MultipleSelectionListView.qml (+0/-199) app/upstreamcomponents/MultipleSelectionVisualModel.qml (+0/-31) po/com.ubuntu.clock.pot (+8/-8) |
||||
To merge this branch: | bzr merge lp:~ubuntu-clock-dev/ubuntu-clock-app/4-migrate-alarm-listitems | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Bartosz Kosiorek | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+263889@code.launchpad.net |
Commit message
- Transitions AlarmDelegate, AlarmList to using the new 15.04 ListItems
- Updated multi-select mode design to be similar to what Dekko and Music app have
- Removed custom components like MultipleSelecti
Description of the change
This MP implements the following,
- Transitions AlarmDelegate, AlarmList to using the new 15.04 ListItems
- Updated multi-select mode design to be similar to what Dekko and Music app have
- Removed custom components like MultipleSelecti
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
- 278. By Nekhelesh Ramananthan
-
merged prerequisite
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:278
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Bartosz Kosiorek (gang65) wrote : | # |
It is working perfectly for me
Preview Diff
1 | === modified file 'app/alarm/AlarmDelegate.qml' | |||
2 | --- app/alarm/AlarmDelegate.qml 2015-06-18 13:36:42 +0000 | |||
3 | +++ app/alarm/AlarmDelegate.qml 2015-07-24 13:32:56 +0000 | |||
4 | @@ -18,17 +18,15 @@ | |||
5 | 18 | 18 | ||
6 | 19 | import QtQuick 2.4 | 19 | import QtQuick 2.4 |
7 | 20 | import Ubuntu.Components 1.2 | 20 | import Ubuntu.Components 1.2 |
8 | 21 | import "../upstreamcomponents" | ||
9 | 22 | 21 | ||
11 | 23 | ListItemWithActions { | 22 | ListItem { |
12 | 24 | id: root | 23 | id: root |
13 | 25 | 24 | ||
14 | 26 | property var localTime | 25 | property var localTime |
15 | 27 | 26 | ||
16 | 28 | width: parent ? parent.width : 0 | 27 | width: parent ? parent.width : 0 |
17 | 29 | height: units.gu(6) | 28 | height: units.gu(6) |
20 | 30 | color: "Transparent" | 29 | divider.visible: false |
19 | 31 | selectedColor: "Transparent" | ||
21 | 32 | 30 | ||
22 | 33 | Label { | 31 | Label { |
23 | 34 | id: alarmTime | 32 | id: alarmTime |
24 | @@ -37,6 +35,7 @@ | |||
25 | 37 | anchors { | 35 | anchors { |
26 | 38 | top: alarmDetailsColumn.top | 36 | top: alarmDetailsColumn.top |
27 | 39 | left: parent.left | 37 | left: parent.left |
28 | 38 | leftMargin: units.gu(2) | ||
29 | 40 | } | 39 | } |
30 | 41 | 40 | ||
31 | 42 | fontSize: "medium" | 41 | fontSize: "medium" |
32 | @@ -87,6 +86,7 @@ | |||
33 | 87 | 86 | ||
34 | 88 | anchors { | 87 | anchors { |
35 | 89 | right: parent.right | 88 | right: parent.right |
36 | 89 | rightMargin: units.gu(2) | ||
37 | 90 | verticalCenter: parent.verticalCenter | 90 | verticalCenter: parent.verticalCenter |
38 | 91 | } | 91 | } |
39 | 92 | 92 | ||
40 | 93 | 93 | ||
41 | === modified file 'app/alarm/AlarmList.qml' | |||
42 | --- app/alarm/AlarmList.qml 2015-05-27 16:03:23 +0000 | |||
43 | +++ app/alarm/AlarmList.qml 2015-07-24 13:32:56 +0000 | |||
44 | @@ -18,127 +18,69 @@ | |||
45 | 18 | 18 | ||
46 | 19 | import QtQuick 2.4 | 19 | import QtQuick 2.4 |
47 | 20 | import Ubuntu.Components 1.2 | 20 | import Ubuntu.Components 1.2 |
48 | 21 | import Ubuntu.Components.ListItems 1.0 as ListItem | ||
49 | 22 | import "../components" | ||
50 | 23 | import "../upstreamcomponents" | ||
51 | 24 | 21 | ||
53 | 25 | MultipleSelectionListView { | 22 | UbuntuListView { |
54 | 26 | id: alarmListView | 23 | id: alarmListView |
55 | 27 | objectName: "alarmListView" | 24 | objectName: "alarmListView" |
56 | 28 | 25 | ||
57 | 29 | property var _currentSwipedItem: null | ||
58 | 30 | property var localTime | 26 | property var localTime |
59 | 31 | 27 | ||
78 | 32 | function _updateSwipeState(item) | 28 | signal clearSelection() |
79 | 33 | { | 29 | signal closeSelection() |
80 | 34 | if (item.swipping) { | 30 | signal selectAll() |
63 | 35 | return | ||
64 | 36 | } | ||
65 | 37 | |||
66 | 38 | if (item.swipeState !== "Normal") { | ||
67 | 39 | if (alarmListView._currentSwipedItem !== item) { | ||
68 | 40 | if (alarmListView._currentSwipedItem) { | ||
69 | 41 | alarmListView._currentSwipedItem.resetSwipe() | ||
70 | 42 | } | ||
71 | 43 | alarmListView._currentSwipedItem = item | ||
72 | 44 | } | ||
73 | 45 | } else if (item.swipeState !== "Normal" | ||
74 | 46 | && alarmListView._currentSwipedItem === item) { | ||
75 | 47 | alarmListView._currentSwipedItem = null | ||
76 | 48 | } | ||
77 | 49 | } | ||
81 | 50 | 31 | ||
82 | 51 | clip: true | 32 | clip: true |
83 | 52 | anchors.fill: parent | 33 | anchors.fill: parent |
84 | 53 | 34 | ||
86 | 54 | listDelegate: AlarmDelegate { | 35 | delegate: AlarmDelegate { |
87 | 55 | id: alarmDelegate | 36 | id: alarmDelegate |
88 | 56 | objectName: "alarm" + index | 37 | objectName: "alarm" + index |
89 | 57 | 38 | ||
90 | 58 | property var removalAnimation | ||
91 | 59 | localTime: alarmListView.localTime | 39 | localTime: alarmListView.localTime |
92 | 60 | 40 | ||
174 | 61 | function remove() { | 41 | leadingActions: ListItemActions { |
175 | 62 | removalAnimation.start() | 42 | actions: [ |
176 | 63 | } | 43 | Action { |
177 | 64 | 44 | iconName: "delete" | |
178 | 65 | selectionMode: alarmListView.isInSelectionMode | 45 | text: i18n.tr("Delete") |
179 | 66 | selected: alarmListView.isSelected(alarmDelegate) | 46 | onTriggered: { |
180 | 67 | 47 | var alarm = alarmModel.get(index) | |
181 | 68 | onSwippingChanged: { | 48 | alarm.cancel() |
182 | 69 | _updateSwipeState(alarmDelegate) | 49 | } |
183 | 70 | } | 50 | } |
184 | 71 | 51 | ] | |
185 | 72 | onSwipeStateChanged: { | 52 | } |
186 | 73 | _updateSwipeState(alarmDelegate) | 53 | |
187 | 74 | } | 54 | onClicked: { |
188 | 75 | 55 | if (selectMode) { | |
189 | 76 | leftSideAction: Action { | 56 | selected = !selected |
190 | 77 | iconName: "delete" | 57 | } else { |
191 | 78 | text: i18n.tr("Delete") | 58 | pageStack.push(Qt.resolvedUrl("EditAlarmPage.qml"), {isNewAlarm: false, tempAlarm: model}) |
192 | 79 | onTriggered: { | 59 | } |
193 | 80 | alarmDelegate.remove() | 60 | } |
194 | 81 | } | 61 | |
195 | 82 | } | 62 | onPressAndHold: { |
196 | 83 | 63 | ListView.view.ViewItems.selectMode = !ListView.view.ViewItems.selectMode | |
197 | 84 | ListView.onRemove: ScriptAction { | 64 | } |
198 | 85 | script: { | 65 | } |
199 | 86 | if (_currentSwipedItem | 66 | |
200 | 87 | === alarmDelegate) { | 67 | onClearSelection: { |
201 | 88 | _currentSwipedItem = null | 68 | ViewItems.selectedIndices = [] |
202 | 89 | } | 69 | } |
203 | 90 | } | 70 | |
204 | 91 | } | 71 | onSelectAll: { |
205 | 92 | 72 | var tmp = [] | |
206 | 93 | removalAnimation: SequentialAnimation { | 73 | |
207 | 94 | alwaysRunToEnd: true | 74 | for (var i=0; i < model.count; i++) { |
208 | 95 | 75 | tmp.push(i) | |
209 | 96 | PropertyAction { | 76 | } |
210 | 97 | target: alarmDelegate | 77 | |
211 | 98 | property: "ListView.delayRemove" | 78 | ViewItems.selectedIndices = tmp |
212 | 99 | value: true | 79 | } |
213 | 100 | } | 80 | |
214 | 101 | 81 | onCloseSelection: { | |
215 | 102 | UbuntuNumberAnimation { | 82 | clearSelection() |
216 | 103 | target: alarmDelegate | 83 | ViewItems.selectMode = false |
136 | 104 | property: "height" | ||
137 | 105 | to: 0 | ||
138 | 106 | } | ||
139 | 107 | |||
140 | 108 | PropertyAction { | ||
141 | 109 | target: alarmDelegate | ||
142 | 110 | property: "ListView.delayRemove" | ||
143 | 111 | value: false | ||
144 | 112 | } | ||
145 | 113 | |||
146 | 114 | ScriptAction { | ||
147 | 115 | script: { | ||
148 | 116 | var alarm = alarmModel.get(index) | ||
149 | 117 | alarm.cancel() | ||
150 | 118 | } | ||
151 | 119 | } | ||
152 | 120 | } | ||
153 | 121 | |||
154 | 122 | onItemClicked: { | ||
155 | 123 | if(alarmListView.isInSelectionMode) { | ||
156 | 124 | if(!alarmListView.selectItem(alarmDelegate)) { | ||
157 | 125 | alarmListView.deselectItem(alarmDelegate) | ||
158 | 126 | } | ||
159 | 127 | return | ||
160 | 128 | } | ||
161 | 129 | |||
162 | 130 | else { | ||
163 | 131 | pageStack.push(Qt.resolvedUrl("EditAlarmPage.qml"), | ||
164 | 132 | {isNewAlarm: false, tempAlarm: model}) | ||
165 | 133 | } | ||
166 | 134 | } | ||
167 | 135 | |||
168 | 136 | onItemPressAndHold: { | ||
169 | 137 | if (!alarmListView.isInSelectionMode) { | ||
170 | 138 | alarmListView.startSelection() | ||
171 | 139 | alarmListView.selectItem(alarmDelegate) | ||
172 | 140 | } | ||
173 | 141 | } | ||
217 | 142 | } | 84 | } |
218 | 143 | } | 85 | } |
219 | 144 | 86 | ||
220 | 145 | 87 | ||
221 | === modified file 'app/alarm/AlarmPage.qml' | |||
222 | --- app/alarm/AlarmPage.qml 2015-07-16 21:02:18 +0000 | |||
223 | +++ app/alarm/AlarmPage.qml 2015-07-24 13:32:56 +0000 | |||
224 | @@ -18,23 +18,21 @@ | |||
225 | 18 | 18 | ||
226 | 19 | import QtQuick 2.4 | 19 | import QtQuick 2.4 |
227 | 20 | import Ubuntu.Components 1.2 | 20 | import Ubuntu.Components 1.2 |
228 | 21 | import "../components" | ||
229 | 22 | 21 | ||
230 | 23 | Page { | 22 | Page { |
231 | 24 | id: alarmPage | 23 | id: alarmPage |
232 | 25 | 24 | ||
233 | 26 | title: i18n.tr("Alarms") | 25 | title: i18n.tr("Alarms") |
234 | 27 | objectName: 'AlarmPage' | 26 | objectName: 'AlarmPage' |
235 | 27 | flickable: null | ||
236 | 28 | 28 | ||
237 | 29 | Component.onCompleted: console.log("[LOG]: Alarm Page loaded") | 29 | Component.onCompleted: console.log("[LOG]: Alarm Page loaded") |
238 | 30 | 30 | ||
239 | 31 | flickable: null | ||
240 | 32 | |||
241 | 33 | states: [ | 31 | states: [ |
242 | 34 | PageHeadState { | 32 | PageHeadState { |
243 | 35 | name: "default" | 33 | name: "default" |
244 | 36 | head: alarmPage.head | 34 | head: alarmPage.head |
246 | 37 | when: !alarmListView.isInSelectionMode | 35 | when: !alarmListView.ViewItems.selectMode |
247 | 38 | 36 | ||
248 | 39 | backAction: Action { | 37 | backAction: Action { |
249 | 40 | iconName: "down" | 38 | iconName: "down" |
250 | @@ -59,89 +57,66 @@ | |||
251 | 59 | PageHeadState { | 57 | PageHeadState { |
252 | 60 | name: "selection" | 58 | name: "selection" |
253 | 61 | head: alarmPage.head | 59 | head: alarmPage.head |
255 | 62 | when: alarmListView.isInSelectionMode | 60 | when: alarmListView.ViewItems.selectMode |
256 | 63 | 61 | ||
257 | 64 | backAction: Action { | 62 | backAction: Action { |
258 | 65 | iconName: "back" | 63 | iconName: "back" |
259 | 66 | text: i18n.tr("Back") | 64 | text: i18n.tr("Back") |
260 | 67 | onTriggered: { | 65 | onTriggered: { |
272 | 68 | alarmListView.cancelSelection() | 66 | alarmListView.ViewItems.selectMode = false |
273 | 69 | } | 67 | } |
274 | 70 | } | 68 | } |
275 | 71 | 69 | ||
276 | 72 | contents: Loader { | 70 | actions: [ |
277 | 73 | id: selectionStateLoader | 71 | Action { |
278 | 74 | active: alarmPage.state === "selection" | 72 | text: { |
279 | 75 | sourceComponent: selectionStateComponent | 73 | if(alarmListView.ViewItems.selectedIndices.length === alarmListView.count) { |
280 | 76 | height: parent ? parent.height : undefined | 74 | return i18n.tr("Select None") |
281 | 77 | anchors.right: parent ? parent.right: undefined | 75 | } else { |
282 | 78 | } | 76 | return i18n.tr("Select All") |
283 | 77 | } | ||
284 | 78 | } | ||
285 | 79 | |||
286 | 80 | iconSource: { | ||
287 | 81 | if(alarmListView.ViewItems.selectedIndices.length === alarmListView.count) { | ||
288 | 82 | return Qt.resolvedUrl("../graphics/select-none.svg") | ||
289 | 83 | } else { | ||
290 | 84 | return Qt.resolvedUrl("../graphics/select.svg") | ||
291 | 85 | } | ||
292 | 86 | } | ||
293 | 87 | |||
294 | 88 | onTriggered: { | ||
295 | 89 | if(alarmListView.ViewItems.selectedIndices.length === alarmListView.count) { | ||
296 | 90 | alarmListView.clearSelection() | ||
297 | 91 | } else { | ||
298 | 92 | alarmListView.selectAll() | ||
299 | 93 | } | ||
300 | 94 | } | ||
301 | 95 | }, | ||
302 | 96 | |||
303 | 97 | Action { | ||
304 | 98 | iconName: "delete" | ||
305 | 99 | text: i18n.tr("Delete") | ||
306 | 100 | enabled: alarmListView.ViewItems.selectedIndices.length !== 0 | ||
307 | 101 | |||
308 | 102 | onTriggered: { | ||
309 | 103 | var items = alarmListView.ViewItems.selectedIndices | ||
310 | 104 | |||
311 | 105 | for(var i=0; i < alarmListView.ViewItems.selectedIndices.length; i++) { | ||
312 | 106 | var alarm = alarmModel.get(alarmListView.ViewItems.selectedIndices[i]) | ||
313 | 107 | alarm.cancel() | ||
314 | 108 | } | ||
315 | 109 | |||
316 | 110 | alarmListView.closeSelection() | ||
317 | 111 | } | ||
318 | 112 | } | ||
319 | 113 | ] | ||
320 | 79 | } | 114 | } |
321 | 80 | ] | 115 | ] |
322 | 81 | 116 | ||
323 | 82 | Component { | ||
324 | 83 | id: selectionStateComponent | ||
325 | 84 | Item { | ||
326 | 85 | HeaderButton { | ||
327 | 86 | id: selectButton | ||
328 | 87 | |||
329 | 88 | anchors { | ||
330 | 89 | right: deleteButton.left | ||
331 | 90 | rightMargin: units.gu(1) | ||
332 | 91 | } | ||
333 | 92 | |||
334 | 93 | text: { | ||
335 | 94 | if(alarmListView.selectedItems.count === alarmListView.count) { | ||
336 | 95 | return i18n.tr("Select None") | ||
337 | 96 | } else { | ||
338 | 97 | return i18n.tr("Select All") | ||
339 | 98 | } | ||
340 | 99 | } | ||
341 | 100 | |||
342 | 101 | iconSource: { | ||
343 | 102 | if(alarmListView.selectedItems.count === alarmListView.count) { | ||
344 | 103 | return Qt.resolvedUrl("../graphics/select-none.svg") | ||
345 | 104 | } else { | ||
346 | 105 | return Qt.resolvedUrl("../graphics/select.svg") | ||
347 | 106 | } | ||
348 | 107 | } | ||
349 | 108 | |||
350 | 109 | onTriggered: { | ||
351 | 110 | if(alarmListView.selectedItems.count === alarmListView.count) { | ||
352 | 111 | alarmListView.clearSelection() | ||
353 | 112 | } else { | ||
354 | 113 | alarmListView.selectAll() | ||
355 | 114 | } | ||
356 | 115 | } | ||
357 | 116 | } | ||
358 | 117 | |||
359 | 118 | HeaderButton { | ||
360 | 119 | id: deleteButton | ||
361 | 120 | |||
362 | 121 | anchors.right: parent.right | ||
363 | 122 | anchors.rightMargin: units.gu(2) | ||
364 | 123 | |||
365 | 124 | iconName: "delete" | ||
366 | 125 | text: i18n.tr("Delete") | ||
367 | 126 | enabled: alarmListView.selectedItems.count !== 0 | ||
368 | 127 | |||
369 | 128 | onTriggered: { | ||
370 | 129 | var items = alarmListView.selectedItems | ||
371 | 130 | |||
372 | 131 | for(var i=0; i < items.count; i++) { | ||
373 | 132 | var alarm = alarmModel.get(items.get(i).itemsIndex) | ||
374 | 133 | alarm.cancel() | ||
375 | 134 | } | ||
376 | 135 | |||
377 | 136 | alarmListView.endSelection() | ||
378 | 137 | } | ||
379 | 138 | } | ||
380 | 139 | } | ||
381 | 140 | } | ||
382 | 141 | |||
383 | 142 | AlarmList { | 117 | AlarmList { |
384 | 143 | id: alarmListView | 118 | id: alarmListView |
386 | 144 | listModel: alarmModel | 119 | model: alarmModel |
387 | 145 | anchors.fill: parent | 120 | anchors.fill: parent |
388 | 146 | localTime: clockTime | 121 | localTime: clockTime |
389 | 147 | } | 122 | } |
390 | 148 | 123 | ||
391 | === removed file 'app/components/HeaderButton.qml' | |||
392 | --- app/components/HeaderButton.qml 2015-05-27 16:03:23 +0000 | |||
393 | +++ app/components/HeaderButton.qml 1970-01-01 00:00:00 +0000 | |||
394 | @@ -1,65 +0,0 @@ | |||
395 | 1 | /* | ||
396 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
397 | 3 | * | ||
398 | 4 | * This file is part of Ubuntu Clock App | ||
399 | 5 | * | ||
400 | 6 | * Ubuntu Clock App is free software: you can redistribute it and/or modify | ||
401 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
402 | 8 | * published by the Free Software Foundation. | ||
403 | 9 | * | ||
404 | 10 | * Ubuntu Clock App is distributed in the hope that it will be useful, | ||
405 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
406 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
407 | 13 | * GNU General Public License for more details. | ||
408 | 14 | * | ||
409 | 15 | * You should have received a copy of the GNU General Public License | ||
410 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
411 | 17 | */ | ||
412 | 18 | |||
413 | 19 | import QtQuick 2.4 | ||
414 | 20 | import Ubuntu.Components 1.2 | ||
415 | 21 | |||
416 | 22 | AbstractButton { | ||
417 | 23 | id: headerButton | ||
418 | 24 | |||
419 | 25 | property alias iconSource: _icon.source | ||
420 | 26 | property alias iconName: _icon.name | ||
421 | 27 | property alias text: _label.text | ||
422 | 28 | |||
423 | 29 | width: units.gu(6) | ||
424 | 30 | height: parent ? parent.height : undefined | ||
425 | 31 | |||
426 | 32 | Rectangle { | ||
427 | 33 | anchors.fill: parent | ||
428 | 34 | visible: headerButton.pressed | ||
429 | 35 | color: Theme.palette.selected.background | ||
430 | 36 | } | ||
431 | 37 | |||
432 | 38 | Column { | ||
433 | 39 | id: buttonHolder | ||
434 | 40 | |||
435 | 41 | width: _label.width | ||
436 | 42 | height: childrenRect.height | ||
437 | 43 | |||
438 | 44 | spacing: units.gu(0.2) | ||
439 | 45 | anchors.centerIn: parent | ||
440 | 46 | anchors.verticalCenterOffset: units.gu(0.3) | ||
441 | 47 | |||
442 | 48 | Icon { | ||
443 | 49 | id: _icon | ||
444 | 50 | color: UbuntuColors.darkGrey | ||
445 | 51 | width: units.gu(2.5) | ||
446 | 52 | height: width | ||
447 | 53 | opacity: headerButton.enabled ? 1.0 : 0.3 | ||
448 | 54 | anchors.horizontalCenter: parent.horizontalCenter | ||
449 | 55 | } | ||
450 | 56 | |||
451 | 57 | Label { | ||
452 | 58 | id: _label | ||
453 | 59 | color: UbuntuColors.darkGrey | ||
454 | 60 | fontSize: "xx-small" | ||
455 | 61 | opacity: headerButton.enabled ? 1.0 : 0.3 | ||
456 | 62 | anchors.horizontalCenter: _icon.horizontalCenter | ||
457 | 63 | } | ||
458 | 64 | } | ||
459 | 65 | } | ||
460 | 66 | 0 | ||
461 | === removed file 'app/upstreamcomponents/MultipleSelectionListView.qml' | |||
462 | --- app/upstreamcomponents/MultipleSelectionListView.qml 2015-05-27 16:03:23 +0000 | |||
463 | +++ app/upstreamcomponents/MultipleSelectionListView.qml 1970-01-01 00:00:00 +0000 | |||
464 | @@ -1,199 +0,0 @@ | |||
465 | 1 | /* | ||
466 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
467 | 3 | * | ||
468 | 4 | * This program is free software; you can redistribute it and/or modify | ||
469 | 5 | * it under the terms of the GNU General Public License as published by | ||
470 | 6 | * the Free Software Foundation; version 3. | ||
471 | 7 | * | ||
472 | 8 | * This program is distributed in the hope that it will be useful, | ||
473 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
474 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
475 | 11 | * GNU General Public License for more details. | ||
476 | 12 | * | ||
477 | 13 | * You should have received a copy of the GNU General Public License | ||
478 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
479 | 15 | */ | ||
480 | 16 | |||
481 | 17 | import QtQuick 2.4 | ||
482 | 18 | import Ubuntu.Components 1.2 | ||
483 | 19 | import Ubuntu.Components.Popups 1.0 as Popups | ||
484 | 20 | |||
485 | 21 | /*! | ||
486 | 22 | \qmltype ContactSimpleListView | ||
487 | 23 | \inqmlmodule Ubuntu.Contacts 0.1 | ||
488 | 24 | \ingroup ubuntu | ||
489 | 25 | \brief The MultipleSelectionListView provides a ListView with support to multiple selection | ||
490 | 26 | |||
491 | 27 | The MultipleSelectionListViewprovides a ListView with support to multiple selection which can be used by any | ||
492 | 28 | application. | ||
493 | 29 | |||
494 | 30 | Example: | ||
495 | 31 | \qml | ||
496 | 32 | import Ubuntu.Contacts 0.1 | ||
497 | 33 | |||
498 | 34 | MultipleSelectionListView { | ||
499 | 35 | id: view | ||
500 | 36 | anchors.fill: paret | ||
501 | 37 | model: 100 | ||
502 | 38 | delegate: Rectangle { | ||
503 | 39 | width: parent.width | ||
504 | 40 | height: 100 | ||
505 | 41 | color: view.selectedItems.indexOf(index) == -1 ? "white" : "blue" | ||
506 | 42 | |||
507 | 43 | MouseArea { | ||
508 | 44 | anchors.fill: parent | ||
509 | 45 | onClicked: { | ||
510 | 46 | if (view.isInSelectionModel) { | ||
511 | 47 | view.selectItem(index) | ||
512 | 48 | } | ||
513 | 49 | } | ||
514 | 50 | onPressAndHold: view.startSelection() | ||
515 | 51 | } | ||
516 | 52 | } | ||
517 | 53 | onSelectionDone: console.debug("Selected items:" + view.selectedItems) | ||
518 | 54 | } | ||
519 | 55 | \endqml | ||
520 | 56 | */ | ||
521 | 57 | |||
522 | 58 | ListView { | ||
523 | 59 | id: listView | ||
524 | 60 | |||
525 | 61 | /*! | ||
526 | 62 | \qmlproperty model selectedItems | ||
527 | 63 | |||
528 | 64 | This property holds the list of selected items | ||
529 | 65 | */ | ||
530 | 66 | readonly property alias selectedItems: visualModel.selectedItems | ||
531 | 67 | /*! | ||
532 | 68 | \qmlproperty bool multipleSelection | ||
533 | 69 | |||
534 | 70 | This property holds if the selection will accept multiple items or single items | ||
535 | 71 | */ | ||
536 | 72 | property bool multipleSelection: true | ||
537 | 73 | |||
538 | 74 | /*! | ||
539 | 75 | \qmlproperty model listModel | ||
540 | 76 | |||
541 | 77 | This property holds the model providing data for the list. | ||
542 | 78 | */ | ||
543 | 79 | property alias listModel: visualModel.model | ||
544 | 80 | /*! | ||
545 | 81 | \qmlproperty Component listDelegate | ||
546 | 82 | |||
547 | 83 | The delegate provides a template defining each item instantiated by the view. | ||
548 | 84 | */ | ||
549 | 85 | property alias listDelegate: visualModel.delegate | ||
550 | 86 | |||
551 | 87 | /*! | ||
552 | 88 | \qmlproperty bool isInSelectionMode | ||
553 | 89 | |||
554 | 90 | This property holds a list with the index of selected items | ||
555 | 91 | */ | ||
556 | 92 | readonly property bool isInSelectionMode: state === "selection" | ||
557 | 93 | /*! | ||
558 | 94 | This handler is called when the selection mode is finished without be canceled | ||
559 | 95 | */ | ||
560 | 96 | signal selectionDone(var items) | ||
561 | 97 | /*! | ||
562 | 98 | This handler is called when the selection mode is canceled | ||
563 | 99 | */ | ||
564 | 100 | signal selectionCanceled() | ||
565 | 101 | |||
566 | 102 | /*! | ||
567 | 103 | Start the selection mode on the list view. | ||
568 | 104 | */ | ||
569 | 105 | function startSelection() | ||
570 | 106 | { | ||
571 | 107 | state = "selection" | ||
572 | 108 | } | ||
573 | 109 | /*! | ||
574 | 110 | Check if the item is selected | ||
575 | 111 | Returns true if the item was marked as selected or false if the item is unselected | ||
576 | 112 | */ | ||
577 | 113 | function isSelected(item) | ||
578 | 114 | { | ||
579 | 115 | if (item && item.VisualDataModel) { | ||
580 | 116 | return (item.VisualDataModel.inSelected === true) | ||
581 | 117 | } else { | ||
582 | 118 | return false | ||
583 | 119 | } | ||
584 | 120 | } | ||
585 | 121 | /*! | ||
586 | 122 | Mark the item as selected | ||
587 | 123 | Returns true if the item was marked as selected or false if the item is already selected | ||
588 | 124 | */ | ||
589 | 125 | function selectItem(item) | ||
590 | 126 | { | ||
591 | 127 | if (item.VisualDataModel.inSelected) { | ||
592 | 128 | return false | ||
593 | 129 | } else { | ||
594 | 130 | if (!multipleSelection) { | ||
595 | 131 | clearSelection() | ||
596 | 132 | } | ||
597 | 133 | item.VisualDataModel.inSelected = true | ||
598 | 134 | return true | ||
599 | 135 | } | ||
600 | 136 | } | ||
601 | 137 | /*! | ||
602 | 138 | Remove the index from the selected list | ||
603 | 139 | */ | ||
604 | 140 | function deselectItem(item) | ||
605 | 141 | { | ||
606 | 142 | var result = false | ||
607 | 143 | if (item.VisualDataModel.inSelected) { | ||
608 | 144 | item.VisualDataModel.inSelected = false | ||
609 | 145 | result = true | ||
610 | 146 | } | ||
611 | 147 | return result | ||
612 | 148 | } | ||
613 | 149 | /*! | ||
614 | 150 | Finish the selection mode with sucess | ||
615 | 151 | */ | ||
616 | 152 | function endSelection() | ||
617 | 153 | { | ||
618 | 154 | selectionDone(listView.selectedItems) | ||
619 | 155 | clearSelection() | ||
620 | 156 | state = "" | ||
621 | 157 | } | ||
622 | 158 | /*! | ||
623 | 159 | Cancel the selection | ||
624 | 160 | */ | ||
625 | 161 | function cancelSelection() | ||
626 | 162 | { | ||
627 | 163 | selectionCanceled() | ||
628 | 164 | clearSelection() | ||
629 | 165 | state = "" | ||
630 | 166 | } | ||
631 | 167 | /*! | ||
632 | 168 | Remove any selected item from the selection list | ||
633 | 169 | */ | ||
634 | 170 | function clearSelection() | ||
635 | 171 | { | ||
636 | 172 | if (selectedItems.count > 0) { | ||
637 | 173 | selectedItems.remove(0, selectedItems.count) | ||
638 | 174 | } | ||
639 | 175 | } | ||
640 | 176 | /*! | ||
641 | 177 | Select all items in the list | ||
642 | 178 | */ | ||
643 | 179 | function selectAll() | ||
644 | 180 | { | ||
645 | 181 | if (multipleSelection) { | ||
646 | 182 | visualModel.items.addGroups(0, visualModel.items.count, ["selected"] ) | ||
647 | 183 | } | ||
648 | 184 | } | ||
649 | 185 | |||
650 | 186 | model: visualModel | ||
651 | 187 | |||
652 | 188 | MultipleSelectionVisualModel { | ||
653 | 189 | id: visualModel | ||
654 | 190 | } | ||
655 | 191 | |||
656 | 192 | Component.onCompleted: { | ||
657 | 193 | // FIXME: workaround for qtubuntu not returning values depending on the grid unit definition | ||
658 | 194 | // for Flickable.maximumFlickVelocity and Flickable.flickDeceleration | ||
659 | 195 | var scaleFactor = units.gridUnit / 8; | ||
660 | 196 | maximumFlickVelocity = maximumFlickVelocity * scaleFactor; | ||
661 | 197 | flickDeceleration = flickDeceleration * scaleFactor; | ||
662 | 198 | } | ||
663 | 199 | } | ||
664 | 200 | 0 | ||
665 | === removed file 'app/upstreamcomponents/MultipleSelectionVisualModel.qml' | |||
666 | --- app/upstreamcomponents/MultipleSelectionVisualModel.qml 2015-05-27 16:03:23 +0000 | |||
667 | +++ app/upstreamcomponents/MultipleSelectionVisualModel.qml 1970-01-01 00:00:00 +0000 | |||
668 | @@ -1,31 +0,0 @@ | |||
669 | 1 | /* | ||
670 | 2 | * Copyright (C) 2012-2013 Canonical, Ltd. | ||
671 | 3 | * | ||
672 | 4 | * This program is free software; you can redistribute it and/or modify | ||
673 | 5 | * it under the terms of the GNU General Public License as published by | ||
674 | 6 | * the Free Software Foundation; version 3. | ||
675 | 7 | * | ||
676 | 8 | * This program is distributed in the hope that it will be useful, | ||
677 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
678 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
679 | 11 | * GNU General Public License for more details. | ||
680 | 12 | * | ||
681 | 13 | * You should have received a copy of the GNU General Public License | ||
682 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
683 | 15 | */ | ||
684 | 16 | |||
685 | 17 | import QtQuick 2.4 | ||
686 | 18 | |||
687 | 19 | VisualDataModel { | ||
688 | 20 | id: contactVisualModel | ||
689 | 21 | |||
690 | 22 | property alias selectedItems: selectedGroup | ||
691 | 23 | |||
692 | 24 | groups: [ | ||
693 | 25 | VisualDataGroup { | ||
694 | 26 | id: selectedGroup | ||
695 | 27 | |||
696 | 28 | name: "selected" | ||
697 | 29 | } | ||
698 | 30 | ] | ||
699 | 31 | } | ||
700 | 32 | 0 | ||
701 | === modified file 'po/com.ubuntu.clock.pot' | |||
702 | --- po/com.ubuntu.clock.pot 2015-07-24 13:32:56 +0000 | |||
703 | +++ po/com.ubuntu.clock.pot 2015-07-24 13:32:56 +0000 | |||
704 | @@ -23,38 +23,38 @@ | |||
705 | 23 | msgid "Label" | 23 | msgid "Label" |
706 | 24 | msgstr "" | 24 | msgstr "" |
707 | 25 | 25 | ||
709 | 26 | #: ../app/alarm/AlarmList.qml:78 ../app/alarm/AlarmPage.qml:125 | 26 | #: ../app/alarm/AlarmList.qml:45 ../app/alarm/AlarmPage.qml:99 |
710 | 27 | #: ../app/worldclock/UserWorldCityList.qml:101 | 27 | #: ../app/worldclock/UserWorldCityList.qml:101 |
711 | 28 | msgid "Delete" | 28 | msgid "Delete" |
712 | 29 | msgstr "" | 29 | msgstr "" |
713 | 30 | 30 | ||
715 | 31 | #: ../app/alarm/AlarmPage.qml:26 | 31 | #: ../app/alarm/AlarmPage.qml:25 |
716 | 32 | msgid "Alarms" | 32 | msgid "Alarms" |
717 | 33 | msgstr "" | 33 | msgstr "" |
718 | 34 | 34 | ||
720 | 35 | #: ../app/alarm/AlarmPage.qml:41 ../app/alarm/AlarmPage.qml:66 | 35 | #: ../app/alarm/AlarmPage.qml:39 ../app/alarm/AlarmPage.qml:64 |
721 | 36 | #: ../app/worldclock/WorldCityList.qml:79 | 36 | #: ../app/worldclock/WorldCityList.qml:79 |
722 | 37 | msgid "Back" | 37 | msgid "Back" |
723 | 38 | msgstr "" | 38 | msgstr "" |
724 | 39 | 39 | ||
726 | 40 | #: ../app/alarm/AlarmPage.qml:51 ../app/alarm/EditAlarmPage.qml:44 | 40 | #: ../app/alarm/AlarmPage.qml:49 ../app/alarm/EditAlarmPage.qml:44 |
727 | 41 | #: ../app/alarm/EditAlarmPage.qml:166 | 41 | #: ../app/alarm/EditAlarmPage.qml:166 |
728 | 42 | msgid "Alarm" | 42 | msgid "Alarm" |
729 | 43 | msgstr "" | 43 | msgstr "" |
730 | 44 | 44 | ||
732 | 45 | #: ../app/alarm/AlarmPage.qml:95 | 45 | #: ../app/alarm/AlarmPage.qml:74 |
733 | 46 | msgid "Select None" | 46 | msgid "Select None" |
734 | 47 | msgstr "" | 47 | msgstr "" |
735 | 48 | 48 | ||
737 | 49 | #: ../app/alarm/AlarmPage.qml:97 ../app/alarm/AlarmRepeat.qml:38 | 49 | #: ../app/alarm/AlarmPage.qml:76 ../app/alarm/AlarmRepeat.qml:38 |
738 | 50 | msgid "Select All" | 50 | msgid "Select All" |
739 | 51 | msgstr "" | 51 | msgstr "" |
740 | 52 | 52 | ||
742 | 53 | #: ../app/alarm/AlarmPage.qml:162 | 53 | #: ../app/alarm/AlarmPage.qml:137 |
743 | 54 | msgid "No saved alarms" | 54 | msgid "No saved alarms" |
744 | 55 | msgstr "" | 55 | msgstr "" |
745 | 56 | 56 | ||
747 | 57 | #: ../app/alarm/AlarmPage.qml:163 | 57 | #: ../app/alarm/AlarmPage.qml:138 |
748 | 58 | msgid "Tap the + icon to add an alarm" | 58 | msgid "Tap the + icon to add an alarm" |
749 | 59 | msgstr "" | 59 | msgstr "" |
750 | 60 | 60 |
FAILED: Continuous integration, rev:277 91.189. 93.70:8080/ job/ubuntu- clock-app- ci/683/ 91.189. 93.70:8080/ job/ubuntu- clock-app- vivid-amd64- ci/29/console
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- clock-app- ci/683/ rebuild
http://