Merge lp:~renatofilho/address-book-app/fix-1419854-rtm into lp:address-book-app/rtm-14.09

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Bill Filler
Approved revision: 296
Merged at revision: 296
Proposed branch: lp:~renatofilho/address-book-app/fix-1419854-rtm
Merge into: lp:address-book-app/rtm-14.09
Diff against target: 167 lines (+46/-15)
2 files modified
src/imports/Common/ContactExporter.qml (+43/-12)
src/imports/ContactList/ContactListPage.qml (+3/-3)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1419854-rtm
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+249737@code.launchpad.net

Commit message

Show a dialog with a spinner while exporting contacts.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/imports/Common/ContactExporter.qml'
2--- src/imports/Common/ContactExporter.qml 2014-10-09 18:06:08 +0000
3+++ src/imports/Common/ContactExporter.qml 2015-02-13 23:38:59 +0000
4@@ -16,17 +16,20 @@
5
6 import QtQuick 2.2
7 import QtContacts 5.0
8+
9+import Ubuntu.Components 1.1
10 import Ubuntu.Content 1.1
11+import Ubuntu.Components.Popups 1.0
12
13 Item {
14 id: root
15
16 property var contactModel
17- property var outputFile
18+ property bool exportToDisk: true
19 property var activeTransfer: null
20
21 signal contactsFetched(var contacts)
22- signal done()
23+ signal done(string outputFile)
24
25 function start(contacts) {
26 if (!contactModel) {
27@@ -36,24 +39,38 @@
28
29 // skip if a query is running
30 if (priv.currentQueryId != -1) {
31- completed(0)
32+ console.error("Export already running")
33 return
34 }
35
36+ if (!priv.busyDialog) {
37+ priv.busyDialog = PopupUtils.open(busyDialogComponent, root)
38+ }
39+
40 var ids = []
41 for (var i=0; i < contacts.length; i++) {
42 ids.push(contacts[i].contactId)
43 }
44 if (ids.length == 0) {
45- completed(0)
46+ console.debug("The contact list is empty")
47+ done("")
48 } else {
49 priv.currentQueryId = contactModel.fetchContacts(ids)
50 }
51 }
52
53+ function dismissBusyDialog()
54+ {
55+ if (priv.busyDialog) {
56+ PopupUtils.close(priv.busyDialog)
57+ priv.busyDialog = null
58+ }
59+ }
60+
61 Item {
62 id: priv
63
64+ property var busyDialog: null
65 property int currentQueryId: -1
66 readonly property var detailsBlackList: [ ContactDetail.Favorite, ContactDetail.Tag ]
67
68@@ -83,8 +100,6 @@
69 target: root.contactModel
70
71 onExportCompleted: {
72- priv.currentQueryId = -1
73-
74 // send contacts back to source app (pick mode)
75 if (error === ContactModel.ExportNoError) {
76 var obj = Qt.createQmlObject("import Ubuntu.Content 1.1; ContentItem { url: '" + url + "' }", root)
77@@ -98,26 +113,27 @@
78 root.activeTransfer = ContentHub.ContentTransfer.Aborted
79 console.error("Fail to export contacts:" + error)
80 }
81- root.done()
82+ root.dismissBusyDialog()
83+ root.done(url)
84 }
85
86 onContactsFetched: {
87 // currentQueryId == -2 is used during a fetch using "memory" manager
88 if ((priv.currentQueryId == -2) || (requestId == priv.currentQueryId)) {
89- if (root.outputFile !== "") {
90+ if (root.exportToDisk) {
91 var contacts = []
92 // remove unnecessary info from contacts
93 for(var i=0; i < fetchedContacts.length; i++) {
94 contacts.push(priv.filterContactDetails(fetchedContacts[i]))
95 }
96 // update outputFile with a friendly name
97- root.outputFile = priv.generateOutputFileName(contacts)
98-
99- root.contactModel.exportContacts(root.outputFile,
100+ var outputFile = priv.generateOutputFileName(contacts)
101+ root.contactModel.exportContacts(outputFile,
102 [],
103 contacts)
104 }
105 root.contactsFetched(fetchedContacts)
106+ priv.currentQueryId = -1
107 }
108 }
109 }
110@@ -128,9 +144,24 @@
111 onStateChanged: {
112 if (root.activeTransfer.state === ContentTransfer.Aborted) {
113 root.activeTransfer = null
114- root.done()
115+ root.done("")
116 }
117 }
118 }
119 }
120+
121+ Component {
122+ id: busyDialogComponent
123+
124+ Dialog {
125+ title: i18n.tr("Exporting contacts...")
126+
127+ ActivityIndicator {
128+ id: activity
129+
130+ anchors.horizontalCenter: parent.horizontalCenter
131+ running: true
132+ }
133+ }
134+ }
135 }
136
137=== modified file 'src/imports/ContactList/ContactListPage.qml'
138--- src/imports/ContactList/ContactListPage.qml 2015-01-21 12:56:18 +0000
139+++ src/imports/ContactList/ContactListPage.qml 2015-02-13 23:38:59 +0000
140@@ -430,7 +430,6 @@
141 for (var i=0, iMax=items.count; i < iMax; i++) {
142 contacts.push(items.get(i).model.contact)
143 }
144-
145 contactExporter.start(contacts)
146 contactList.endSelection()
147 }
148@@ -569,16 +568,17 @@
149 id: contactExporter
150
151 contactModel: contactList.listModel
152- outputFile: mainPage.pickMode ? "file:///tmp/address_book_app_export.vcf" : ""
153+ exportToDisk: mainPage.pickMode
154 onDone: {
155 mainPage.pickMode = false
156 mainPage.state = "default"
157- application.returnVcard(contactExporter.outputFile)
158+ application.returnVcard(outputFile)
159 }
160
161 onContactsFetched: {
162 // Share contacts to an application chosen by the user
163 if (!mainPage.pickMode) {
164+ contactExporter.dismissBusyDialog()
165 pageStack.push(Qt.resolvedUrl("../ContactShare/ContactSharePage.qml"),
166 { contactModel: contactExporter.contactModel, contacts: contacts })
167 }

Subscribers

People subscribed via source and target branches