Merge lp:~ubuntu-clock-dev/ubuntu-clock-app/4-migrate-alarm-listitems into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
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
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 MultipleSelectionListView, MultipleSelectionVisualMode and HeaderButton

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 MultipleSelectionListView, MultipleSelectionVisualMode and HeaderButton

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
278. By Nekhelesh Ramananthan

merged prerequisite

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

It is working perfectly for me

review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches

to all changes: