Merge lp:~renatofilho/address-book-app/split-contactlist into lp:~phablet-team/address-book-app/staging

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 245
Merged at revision: 282
Proposed branch: lp:~renatofilho/address-book-app/split-contactlist
Merge into: lp:~phablet-team/address-book-app/staging
Diff against target: 392 lines (+178/-137)
4 files modified
src/imports/Ubuntu/Contacts/CMakeLists.txt (+1/-0)
src/imports/Ubuntu/Contacts/ContactListModel.qml (+171/-0)
src/imports/Ubuntu/Contacts/ContactListView.qml (+5/-137)
src/imports/Ubuntu/Contacts/qmldir (+1/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/split-contactlist
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+230992@code.launchpad.net

Commit message

[Contacts] Split ContactListView in two components (ContactListView and ContactListModel)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:244
http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-ci/285/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/3613
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2829
    SUCCESS: http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-utopic-amd64-ci/285
    SUCCESS: http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-utopic-armhf-ci/285
        deb: http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-utopic-armhf-ci/285/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-utopic-i386-ci/285
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/3498
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4860
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4860/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/11560
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/2294
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3113
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3113/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/phablet-team-address-book-app-staging-ci/285/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:245
http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-ci/286/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/3621/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/2832
    SUCCESS: http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-utopic-amd64-ci/286
    SUCCESS: http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-utopic-armhf-ci/286
        deb: http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-utopic-armhf-ci/286/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/phablet-team-address-book-app-staging-utopic-i386-ci/286
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/3509/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4868
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/4868/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/11575
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/2297
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3116
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/3116/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/phablet-team-address-book-app-staging-ci/286/rebuild

review: Needs Fixing (continuous-integration)
244. By Renato Araujo Oliveira Filho

[Contacts] Split ContactListView in two components (ContactListView and ContactListModel)

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

Are there any related MPs required for this MP to build/function as expected? NO

Is your branch in sync with latest trunk? YES
Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator? YES

Did you successfully run all tests found in your component's Test Plan on device or emulator? YES

If you changed the UI, was the change specified/approved by design? NO UI CHANGE

If you changed UI labels, did you update the pot file? NO NECESSARY

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP? NO PACKAGE CHANGE

245. By Renato Araujo Oliveira Filho

Merged parent branch.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

Looks good. Works as expected.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/imports/Ubuntu/Contacts/CMakeLists.txt'
2--- src/imports/Ubuntu/Contacts/CMakeLists.txt 2014-08-13 20:52:57 +0000
3+++ src/imports/Ubuntu/Contacts/CMakeLists.txt 2014-08-18 18:28:33 +0000
4@@ -22,6 +22,7 @@
5 ContactDetailWithTypeView.qml
6 ContactFetch.qml
7 ContactList.js
8+ ContactListModel.qml
9 ContactListView.qml
10 ContactPreviewPage.qml
11 ContactSimpleListView.qml
12
13=== added file 'src/imports/Ubuntu/Contacts/ContactListModel.qml'
14--- src/imports/Ubuntu/Contacts/ContactListModel.qml 1970-01-01 00:00:00 +0000
15+++ src/imports/Ubuntu/Contacts/ContactListModel.qml 2014-08-18 18:28:33 +0000
16@@ -0,0 +1,171 @@
17+ /*
18+ * Copyright (C) 2012-2013 Canonical, Ltd.
19+ *
20+ * This program is free software; you can redistribute it and/or modify
21+ * it under the terms of the GNU General Public License as published by
22+ * the Free Software Foundation; version 3.
23+ *
24+ * This program is distributed in the hope that it will be useful,
25+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
26+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+ * GNU General Public License for more details.
28+ *
29+ * You should have received a copy of the GNU General Public License
30+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
31+ */
32+
33+import QtQuick 2.2
34+import QtContacts 5.0
35+
36+ContactModel {
37+ id: root
38+
39+ property var externalFilter: null
40+ property string filterTerm: ""
41+ property bool onlyFavorites: false
42+ property var view: null
43+
44+ /* internal */
45+ property bool _clearModel: false
46+ property list<QtObject> _extraFilters
47+ property QtObject _timeout
48+
49+
50+ function changeFilter(newFilter)
51+ {
52+ if (root.contacts.length > 0) {
53+ root._clearModel = true
54+ }
55+ root.externalFilter = newFilter
56+ }
57+
58+
59+ filter: {
60+ if (root._clearModel) {
61+ return invalidFilter
62+ } else if (contactsFilter.active) {
63+ return contactsFilter
64+ } else {
65+ return null
66+ }
67+ }
68+
69+ _extraFilters: [
70+ InvalidFilter {
71+ id: invalidFilter
72+ },
73+ DetailFilter {
74+ id: favouritesFilter
75+
76+ detail: ContactDetail.Favorite
77+ field: Favorite.Favorite
78+ value: true
79+ matchFlags: DetailFilter.MatchExactly
80+ },
81+ UnionFilter {
82+ id: contactTermFilter
83+
84+ property string value: ""
85+
86+ DetailFilter {
87+ detail: ContactDetail.DisplayLabel
88+ field: DisplayLabel.Label
89+ value: contactTermFilter.value
90+ matchFlags: DetailFilter.MatchContains
91+ }
92+
93+ DetailFilter {
94+ detail: ContactDetail.PhoneNumber
95+ field: PhoneNumber.Number
96+ value: contactTermFilter.value
97+ matchFlags: DetailFilter.MatchPhoneNumber
98+ }
99+
100+ DetailFilter {
101+ detail: ContactDetail.PhoneNumber
102+ field: PhoneNumber.Number
103+ value: contactTermFilter.value
104+ matchFlags: DetailFilter.MatchContains
105+ }
106+ },
107+ IntersectionFilter {
108+ id: contactsFilter
109+
110+ // avoid runtime warning "depends on non-NOTIFYable properties"
111+ readonly property alias filtersProxy: contactsFilter.filters
112+
113+ property bool active: {
114+ var filters_ = []
115+ if (contactTermFilter.value.length > 0) {
116+ filters_.push(contactTermFilter)
117+ } else if (root.onlyFavorites) {
118+ filters_.push(favouritesFilter)
119+ }
120+
121+ if (root.externalFilter) {
122+ filters_.push(root.externalFilter)
123+ }
124+
125+ // check if the filter has changed
126+ var oldFilters = filtersProxy
127+ if (oldFilters.length !== filters_.length) {
128+ contactsFilter.filters = filters_
129+ } else {
130+ for(var i=0; i < oldFilters.length; i++) {
131+ if (filters_.indexOf(oldFilters[i]) === -1) {
132+ contactsFilter.filters = filters_
133+ }
134+ }
135+ }
136+
137+ return (filters_.length > 0)
138+ }
139+ }
140+ ]
141+
142+ _timeout: Timer {
143+ id: contactSearchTimeout
144+
145+ running: false
146+ repeat: false
147+ interval: 300
148+ onTriggered: {
149+ if (root.view) {
150+ view.positionViewAtBeginning()
151+ }
152+
153+ root.changeFilter(root.externalFilter)
154+ contactTermFilter.value = root.filterTerm
155+
156+ // manually update if autoUpdate is disabled
157+ if (!root.autoUpdate) {
158+ root.update()
159+ }
160+ }
161+ }
162+
163+ onFilterTermChanged: contactSearchTimeout.restart()
164+
165+ onErrorChanged: {
166+ if (error) {
167+ console.error("Contact List error:" + error)
168+ }
169+ }
170+
171+ onContactsChanged: {
172+ //WORKAROUND: clear the model before start populate it with the new contacts
173+ //otherwise the model will wait for all contacts before show any new contact
174+
175+ //after all contacts get removed we can populate the model again, this will show
176+ //new contacts as soon as it arrives in the model
177+ if (root._clearModel && contacts.length === 0) {
178+ root._clearModel = false
179+ // do a new update if autoUpdate is false
180+ if (!root.autoUpdate) {
181+ root.update()
182+ }
183+
184+ }
185+ }
186+}
187+
188
189=== modified file 'src/imports/Ubuntu/Contacts/ContactListView.qml'
190--- src/imports/Ubuntu/Contacts/ContactListView.qml 2014-08-12 23:51:38 +0000
191+++ src/imports/Ubuntu/Contacts/ContactListView.qml 2014-08-18 18:28:33 +0000
192@@ -52,7 +52,7 @@
193 This property holds a string that will be used to filter contacts on the list
194 By default this is set to empty
195 */
196- property string filterTerm: ""
197+ property alias filterTerm: contactsModel.filterTerm
198 /*!
199 \qmlproperty Filter filter
200
201@@ -60,7 +60,7 @@
202
203 \sa Filter
204 */
205- property var filter: null
206+ property alias filter: contactsModel.externalFilter
207 /*!
208 \qmlproperty bool showAvatar
209
210@@ -285,10 +285,7 @@
211 }
212 function changeFilter(newFilter)
213 {
214- if (root.count > 0) {
215- contactsModel._clearModel = true
216- }
217- root.filter = newFilter
218+ contactsModel.changeFilter(newFilter)
219 }
220 function reset()
221 {
222@@ -324,8 +321,6 @@
223 contactsModel.update()
224 }
225
226- onFilterTermChanged: contactSearchTimeout.restart()
227-
228 // colapse contacts if the keyboard appears
229 Connections {
230 target: Qt.inputMethod
231@@ -341,7 +336,7 @@
232 id: view
233
234 property bool showFavourites: true
235- property bool favouritesIsSelected: false
236+ property alias favouritesIsSelected: contactsModel.onlyFavorites
237
238 function getSectionText(index) {
239 var tag = listModel.contacts[index].tag.tag
240@@ -488,139 +483,12 @@
241 onContactDisappeared: root.contactDisappeared(contact)
242 clip: true
243
244- InvalidFilter {
245- id: invalidFilter
246- }
247-
248- DetailFilter {
249- id: favouritesFilter
250-
251- detail: ContactDetail.Favorite
252- field: Favorite.Favorite
253- value: true
254- matchFlags: DetailFilter.MatchExactly
255- }
256-
257- UnionFilter {
258- id: contactTermFilter
259-
260- property string value: ""
261-
262- DetailFilter {
263- detail: ContactDetail.DisplayLabel
264- field: DisplayLabel.Label
265- value: contactTermFilter.value
266- matchFlags: DetailFilter.MatchContains
267- }
268-
269- DetailFilter {
270- detail: ContactDetail.PhoneNumber
271- field: PhoneNumber.Number
272- value: contactTermFilter.value
273- matchFlags: DetailFilter.MatchPhoneNumber
274- }
275-
276- DetailFilter {
277- detail: ContactDetail.PhoneNumber
278- field: PhoneNumber.Number
279- value: contactTermFilter.value
280- matchFlags: DetailFilter.MatchContains
281- }
282- }
283-
284-
285- IntersectionFilter {
286- id: contactsFilter
287-
288- // avoid runtime warning "depends on non-NOTIFYable properties"
289- readonly property alias filtersProxy: contactsFilter.filters
290-
291- property bool active: {
292- var filters_ = []
293- if (contactTermFilter.value.length > 0) {
294- filters_.push(contactTermFilter)
295- } else if (view.favouritesIsSelected) {
296- filters_.push(favouritesFilter)
297- }
298-
299- if (root.filter) {
300- filters_.push(root.filter)
301- }
302-
303- // check if the filter has changed
304- var oldFilters = filtersProxy
305- if (oldFilters.length !== filters_.length) {
306- contactsFilter.filters = filters_
307- } else {
308- for(var i=0; i < oldFilters.length; i++) {
309- if (filters_.indexOf(oldFilters[i]) === -1) {
310- contactsFilter.filters = filters_
311- }
312- }
313- }
314-
315- return (filters_.length > 0)
316- }
317- }
318-
319- Timer {
320- id: contactSearchTimeout
321-
322- running: false
323- repeat: false
324- interval: 300
325- onTriggered: {
326- view.positionViewAtBeginning()
327-
328- root.changeFilter(root.filter)
329- contactTermFilter.value = root.filterTerm
330-
331- // manually update if autoUpdate is disabled
332- if (!root.autoUpdate) {
333- contactsModel.update()
334- }
335- }
336- }
337-
338- listModel: ContactModel {
339+ listModel: ContactListModel {
340 id: contactsModel
341
342- property bool _clearModel: false
343-
344 manager: root.manager
345 sortOrders: root.sortOrders
346 fetchHint: root.fetchHint
347- filter: {
348- if (contactsModel._clearModel) {
349- return invalidFilter
350- } else if (contactsFilter.active) {
351- return contactsFilter
352- } else {
353- return null
354- }
355- }
356-
357- onErrorChanged: {
358- if (error) {
359- console.error("Contact List error:" + error)
360- }
361- }
362-
363- onContactsChanged: {
364- //WORKAROUND: clear the model before start populate it with the new contacts
365- //otherwise the model will wait for all contacts before show any new contact
366-
367- //after all contacts get removed we can populate the model again, this will show
368- //new contacts as soon as it arrives in the model
369- if (contactsModel._clearModel && contacts.length === 0) {
370- contactsModel._clearModel = false
371- // do a new update if autoUpdate is false
372- if (!contactsModel.autoUpdate) {
373- contactsModel.update()
374- }
375-
376- }
377- }
378 }
379 }
380
381
382=== modified file 'src/imports/Ubuntu/Contacts/qmldir'
383--- src/imports/Ubuntu/Contacts/qmldir 2014-08-13 20:52:57 +0000
384+++ src/imports/Ubuntu/Contacts/qmldir 2014-08-18 18:28:33 +0000
385@@ -6,6 +6,7 @@
386 ContactDetailOnlineAccountTypeModel 0.1 ContactDetailOnlineAccountTypeModel.qml
387 ContactDetailPhoneNumberTypeModel 0.1 ContactDetailPhoneNumberTypeModel.qml
388 ContactFetch 0.1 ContactFetch.qml
389+ContactListModel 0.1 ContactListModel.qml
390 ContactListView 0.1 ContactListView.qml
391 ContactPreviewPage 0.1 ContactPreviewPage.qml
392 ListItemWithActions 0.1 ListItemWithActions.qml

Subscribers

People subscribed via source and target branches