Merge lp:~renatofilho/address-book-app/fix-1367417 into lp:~phablet-team/address-book-app/staging

Proposed by Renato Araujo Oliveira Filho
Status: Work in progress
Proposed branch: lp:~renatofilho/address-book-app/fix-1367417
Merge into: lp:~phablet-team/address-book-app/staging
Prerequisite: lp:~renatofilho/address-book-app/release-18-09-2014
Diff against target: 108 lines (+41/-20)
2 files modified
src/imports/ContactEdit/ContactDetailSyncTargetEditor.qml (+30/-19)
src/imports/ContactView/ContactView.qml (+11/-1)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1367417
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+235648@code.launchpad.net

This proposal supersedes a proposal from 2014-09-23.

Commit message

Avoid load contacts sync target if the contact edit page is not active.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
312. By Renato Araujo Oliveira Filho

Only load contacts model when page is active in edit mode.

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

Unmerged revisions

312. By Renato Araujo Oliveira Filho

Only load contacts model when page is active in edit mode.

311. By Renato Araujo Oliveira Filho

Avoid load contacts sync target if the contact edit page is not active.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/imports/ContactEdit/ContactDetailSyncTargetEditor.qml'
2--- src/imports/ContactEdit/ContactDetailSyncTargetEditor.qml 2014-09-03 19:21:20 +0000
3+++ src/imports/ContactEdit/ContactDetailSyncTargetEditor.qml 2014-09-25 20:40:09 +0000
4@@ -24,7 +24,7 @@
5 ContactDetailBase {
6 id: root
7
8- property alias active: sourceModel.autoUpdate
9+ property bool active: false
10
11 function save() {
12 // only changes the target sync for new contacts
13@@ -57,17 +57,35 @@
14 detail: root.contact ? contact.detail(ContactDetail.SyncTarget) : null
15 implicitHeight: root.isNewContact && sources.model && (sources.model.contacts.length > 1) ? myHeight : 0
16
17- ContactModel {
18- id: sourceModel
19-
20- manager: (typeof(QTCONTACTS_MANAGER_OVERRIDE) !== "undefined") && (QTCONTACTS_MANAGER_OVERRIDE != "") ? QTCONTACTS_MANAGER_OVERRIDE : "galera"
21- filter: DetailFilter {
22- detail: ContactDetail.Type
23- field: Type.TypeField
24- value: Type.Group
25- matchFlags: DetailFilter.MatchExactly
26- }
27- autoUpdate: false
28+
29+ Component {
30+ id: contactModelComponent
31+ ContactModel {
32+ id: sourceModel
33+
34+ manager: (typeof(QTCONTACTS_MANAGER_OVERRIDE) !== "undefined") && (QTCONTACTS_MANAGER_OVERRIDE != "") ? QTCONTACTS_MANAGER_OVERRIDE : "galera"
35+ filter: DetailFilter {
36+ detail: ContactDetail.Type
37+ field: Type.TypeField
38+ value: Type.Group
39+ matchFlags: DetailFilter.MatchExactly
40+ }
41+ autoUpdate: false
42+
43+ Component.onCompleted: update()
44+ }
45+ }
46+
47+ Loader {
48+ // does not create the model until the page became active
49+ sourceComponent: root.active ? contactModelComponent : null
50+ onStatusChanged: {
51+ if (status == Loader.Ready) {
52+ sources.model = item
53+ } else {
54+ sources.model = null
55+ }
56+ }
57 }
58
59 Label {
60@@ -92,7 +110,6 @@
61 OptionSelector {
62 id: sources
63
64- model: sourceModel
65 anchors {
66 left: parent.left
67 leftMargin: units.gu(2)
68@@ -111,11 +128,5 @@
69
70 containerHeight: sources.model && sources.model.contacts.length > 4 ? itemHeight * 4 : sources.model ? itemHeight * sources.model.contacts.length : 0
71 }
72-
73- onActiveChanged: {
74- if (active) {
75- sourceModel.update()
76- }
77- }
78 }
79
80
81=== modified file 'src/imports/ContactView/ContactView.qml'
82--- src/imports/ContactView/ContactView.qml 2014-09-17 18:36:48 +0000
83+++ src/imports/ContactView/ContactView.qml 2014-09-25 20:40:09 +0000
84@@ -35,13 +35,23 @@
85 }
86 }
87
88- // Page page if the contact get removed
89+ // Pop page if the contact get removed
90 onContactChanged: {
91 if (!contact) {
92 pageStack.pop()
93 }
94 }
95
96+ // Pop page if model reset
97+ Connections {
98+ target: root.model
99+ onContactsChanged: {
100+ if (root.model.contacts.length === 0) {
101+ pageStack.pop()
102+ }
103+ }
104+ }
105+
106 extensions: ContactDetailSyncTargetView {
107 contact: root.contact
108 anchors {

Subscribers

People subscribed via source and target branches