Merge lp:~renatofilho/address-book-app/release-06-10-2014 into lp:address-book-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Bill Filler
Approved revision: 321
Merged at revision: 324
Proposed branch: lp:~renatofilho/address-book-app/release-06-10-2014
Merge into: lp:address-book-app
Diff against target: 848 lines (+289/-207)
17 files modified
data/address-book-app.desktop.in.in (+0/-1)
debian/control (+1/-0)
src/imports/Common/CMakeLists.txt (+1/-0)
src/imports/Common/ContactExporter.qml (+72/-10)
src/imports/ContactList/CMakeLists.txt (+0/-1)
src/imports/ContactList/ContactListPage.qml (+43/-86)
src/imports/ContactList/OnlineAccountsMessage.qml (+74/-30)
src/imports/ContactShare/ContactSharePage.qml (+15/-21)
src/imports/ContentHubProxy.qml (+3/-2)
src/imports/MainWindow.qml (+12/-2)
src/imports/Ubuntu/Contacts/ContactAvatar.qml (+2/-2)
src/imports/Ubuntu/Contacts/ContactDelegate.qml (+3/-5)
src/imports/Ubuntu/Contacts/ContactListView.qml (+0/-14)
src/imports/Ubuntu/Contacts/ContactPreviewPage.qml (+7/-13)
src/imports/Ubuntu/Contacts/ContactSimpleListView.qml (+1/-17)
src/imports/Ubuntu/Contacts/Contacts.js (+55/-1)
src/imports/Ubuntu/Contacts/MostCalledModel.qml (+0/-2)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/release-06-10-2014
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+237277@code.launchpad.net

Commit message

Fetch the full contact before export it on contact list.
Removed "_X-Ubuntu-Splash-Title" key from desktop file.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

tested, works

review: Approve
Revision history for this message
Bill Filler (bfiller) wrote :

Actually found an issue. Import of contacts doesn't work anymore. The way to test is send a vcard to your gmail account, then click on it from gmail and select Address Book from picker. Get this error:

file:///usr/share/address-book-app/imports/ContentHubProxy.qml:36: TypeError: Property 'importvcards' of object PageStack_QMLTYPE_22_QML_51(0x142b300) is not a function

review: Needs Fixing
318. By Renato Araujo Oliveira Filho

Fix import vcard.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
319. By Renato Araujo Oliveira Filho

Disabled "tst_VCardParser" until the new SDK get released.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
320. By Renato Araujo Oliveira Filho

Revert changes on tests.
Added thumbnailer-service as build-dep to avoid problems with unit test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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 STRING CHANGE

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

321. By Renato Araujo Oliveira Filho <renato@renato-ubuntu>

Update online account check
Format contact preview page title based on designer spec

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

approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/address-book-app.desktop.in.in'
2--- data/address-book-app.desktop.in.in 2014-09-29 15:10:16 +0000
3+++ data/address-book-app.desktop.in.in 2014-10-23 15:17:29 +0000
4@@ -14,5 +14,4 @@
5 X-Ubuntu-StageHint=SideStage
6 X-Ubuntu-Single-Instance=true
7 X-Ubuntu-Splash-Show-Header=true
8-_X-Ubuntu-Splash-Title=Contacts
9 @XSCREENSHOT@
10
11=== modified file 'debian/control'
12--- debian/control 2014-08-19 14:40:54 +0000
13+++ debian/control 2014-10-23 15:17:29 +0000
14@@ -20,6 +20,7 @@
15 qtbase5-dev,
16 qtdeclarative5-dev,
17 qtpim5-dev,
18+ thumbnailer-service,
19 xvfb [i386 amd64 armhf],
20 Standards-Version: 3.9.5
21 Homepage: https://launchpad.net/address-book-app
22
23=== modified file 'src/imports/Common/CMakeLists.txt'
24--- src/imports/Common/CMakeLists.txt 2014-08-13 20:52:57 +0000
25+++ src/imports/Common/CMakeLists.txt 2014-10-23 15:17:29 +0000
26@@ -1,5 +1,6 @@
27 set(CONTACT_COMMON_QMLS
28 ContactDetailItem.qml
29+ ContactExporter.qml
30 KeyboardRectangle.qml
31 RemoveContactsDialog.qml
32 StandardAnimation.qml
33
34=== renamed file 'src/imports/ContactList/ContactExporter.qml' => 'src/imports/Common/ContactExporter.qml'
35--- src/imports/ContactList/ContactExporter.qml 2014-05-06 13:18:07 +0000
36+++ src/imports/Common/ContactExporter.qml 2014-10-23 15:17:29 +0000
37@@ -16,19 +16,21 @@
38
39 import QtQuick 2.2
40 import QtContacts 5.0
41+import Ubuntu.Content 1.1
42
43 Item {
44 id: root
45
46- property var contacts: []
47 property var contactModel
48 property var outputFile
49-
50- signal completed(int error)
51-
52- function start() {
53+ property var activeTransfer: null
54+
55+ signal contactsFetched(var contacts)
56+ signal done()
57+
58+ function start(contacts) {
59 if (!contactModel) {
60- console.log("No contact model defined")
61+ console.error("No contact model defined")
62 return
63 }
64
65@@ -48,25 +50,85 @@
66 priv.currentQueryId = contactModel.fetchContacts(ids)
67 }
68 }
69+
70 Item {
71 id: priv
72
73 property int currentQueryId: -1
74+ readonly property var detailsBlackList: [ ContactDetail.Favorite, ContactDetail.Tag ]
75+
76+ function filterContactDetails(contact)
77+ {
78+ var newContact = Qt.createQmlObject("import QtContacts 5.0; Contact { }", root)
79+ var allDetails = contact.contactDetails
80+ for(var i=0; i < allDetails.length; i++) {
81+ var det = allDetails[i]
82+ if (detailsBlackList.indexOf(det.type) == -1) {
83+ newContact.addDetail(det)
84+ }
85+ }
86+ return newContact
87+ }
88+
89+ function generateOutputFileName(contacts)
90+ {
91+ if (contacts.length === 1) {
92+ return "file:///tmp/%1.vcf".arg(contacts[0].displayLabel.label.replace(/\s/g, ''))
93+ } else {
94+ return "file:///tmp/ubuntu_contacts.vcf";
95+ }
96+ }
97
98 Connections {
99 target: root.contactModel
100
101 onExportCompleted: {
102 priv.currentQueryId = -1
103- root.completed(error)
104+
105+ // send contacts back to source app (pick mode)
106+ if (error === ContactModel.ExportNoError) {
107+ var obj = Qt.createQmlObject("import Ubuntu.Content 1.1; ContentItem { url: '" + url + "' }", root)
108+ if (root.activeTransfer) {
109+ root.activeTransfer.items = [obj]
110+ root.activeTransfer.state = ContentTransfer.Charged
111+ } else {
112+ console.error("No active transfer")
113+ }
114+ } else {
115+ root.activeTransfer = ContentHub.ContentTransfer.Aborted
116+ console.error("Fail to export contacts:" + error)
117+ }
118+ root.done()
119 }
120
121 onContactsFetched: {
122 // currentQueryId == -2 is used during a fetch using "memory" manager
123 if ((priv.currentQueryId == -2) || (requestId == priv.currentQueryId)) {
124- root.contactModel.exportContacts(root.outputFile,
125- [],
126- fetchedContacts)
127+ if (root.outputFile !== "") {
128+ var contacts = []
129+ // remove unnecessary info from contacts
130+ for(var i=0; i < fetchedContacts.length; i++) {
131+ contacts.push(priv.filterContactDetails(fetchedContacts[i]))
132+ }
133+ // update outputFile with a friendly name
134+ root.outputFile = priv.generateOutputFileName(contacts)
135+
136+ root.contactModel.exportContacts(root.outputFile,
137+ [],
138+ contacts)
139+ }
140+ root.contactsFetched(fetchedContacts)
141+ }
142+ }
143+ }
144+
145+ Connections {
146+ target: root.activeTransfer
147+
148+ onStateChanged: {
149+ if (root.activeTransfer.state === ContentTransfer.Aborted) {
150+ root.activeTransfer = null
151+ root.done()
152 }
153 }
154 }
155
156=== modified file 'src/imports/ContactList/CMakeLists.txt'
157--- src/imports/ContactList/CMakeLists.txt 2014-07-25 08:30:04 +0000
158+++ src/imports/ContactList/CMakeLists.txt 2014-10-23 15:17:29 +0000
159@@ -1,6 +1,5 @@
160 set(CONTACT_LIST_QMLS
161 ContactListPage.qml
162- ContactExporter.qml
163 OnlineAccountsMessage.qml
164 VCardImportDialog.qml
165 )
166
167=== modified file 'src/imports/ContactList/ContactListPage.qml'
168--- src/imports/ContactList/ContactListPage.qml 2014-09-18 23:08:25 +0000
169+++ src/imports/ContactList/ContactListPage.qml 2014-10-23 15:17:29 +0000
170@@ -21,7 +21,7 @@
171 import Ubuntu.Components.ListItems 1.0 as ListItem
172 import Ubuntu.Components.Popups 1.0 as Popups
173 import Ubuntu.Contacts 0.1 as ContactsUI
174-import Ubuntu.Content 0.1 as ContentHub
175+import Ubuntu.Content 1.1 as ContentHub
176
177 import "../Common"
178
179@@ -32,7 +32,6 @@
180 property bool pickMode: false
181 property alias contentHubTransfer: contactExporter.activeTransfer
182 property bool pickMultipleContacts: false
183- property var onlineAccountsMessageDialog: null
184 property QtObject contactIndex: null
185 property bool contactsLoaded: false
186 property string newPhoneToAdd: ""
187@@ -147,42 +146,6 @@
188 bottomEdgeTitle: "+"
189 bottomEdgeEnabled: !contactList.isInSelectionMode
190
191- Component {
192- id: onlineAccountsDialog
193-
194- OnlineAccountsMessage {
195- id: onlineAccountsMessage
196- onCanceled: {
197- mainPage.onlineAccountsMessageDialog = null
198- PopupUtils.close(onlineAccountsMessage)
199- application.unsetFirstRun()
200- }
201- onAccepted: {
202- Qt.openUrlExternally("settings:///system/online-accounts")
203- mainPage.onlineAccountsMessageDialog = null
204- PopupUtils.close(onlineAccountsMessage)
205- application.unsetFirstRun()
206- }
207- }
208- }
209-
210- Component {
211- id: removeContactDialog
212-
213- RemoveContactsDialog {
214- id: removeContactsDialogMessage
215-
216- onCanceled: {
217- PopupUtils.close(removeContactsDialogMessage)
218- }
219-
220- onAccepted: {
221- removeContacts(contactList.listModel)
222- PopupUtils.close(removeContactsDialogMessage)
223- }
224- }
225- }
226-
227 flickable: null
228 ContactsUI.ContactListView {
229 id: contactList
230@@ -258,9 +221,7 @@
231 filterTerm: searchField.text
232 detailToPick: ContactDetail.PhoneNumber
233 multiSelectionEnabled: true
234- multipleSelection: !pickMode ||
235- mainPage.pickMultipleContacts ||
236- (contactExporter.active && contactExporter.isMultiple)
237+ multipleSelection: (mainPage.pickMode && mainPage.pickMultipleContacts) || !mainPage.pickMode
238
239 leftSideAction: Action {
240 iconName: "delete"
241@@ -305,7 +266,6 @@
242 }
243
244 onAddDetailClicked: mainPage.addPhoneToContact(contact.contactId, " ")
245-
246 onIsInSelectionModeChanged: mainPage.state = isInSelectionMode ? "selection" : "default"
247 onSelectionCanceled: {
248 if (pickMode) {
249@@ -463,7 +423,7 @@
250 contactList.selectAll()
251 }
252 }
253- visible: contactList.isInSelectionMode
254+ visible: contactList.multipleSelection
255 },
256 Action {
257 objectName: "share"
258@@ -478,13 +438,7 @@
259 contacts.push(items.get(i).model.contact)
260 }
261
262- if (mainPage.pickMode) {
263- contactExporter.exportContacts(contacts)
264- mainPage.pickMode = false
265- } else {
266- pageStack.push(Qt.resolvedUrl("../ContactShare/ContactSharePage.qml"),
267- { contactModel: contactList.listModel, contacts: contacts })
268- }
269+ contactExporter.start(contacts)
270 contactList.endSelection()
271 }
272 },
273@@ -628,49 +582,52 @@
274 }
275 }
276
277- QtObject {
278+ ContactExporter {
279 id: contactExporter
280
281- property var activeTransfer: null
282- readonly property bool active: activeTransfer && (activeTransfer.state === ContentHub.ContentTransfer.InProgress && activeTransfer.direction === ContentHub.ContentTransfer.Import)
283- readonly property bool isMultiple: activeTransfer && (activeTransfer.selectionType === ContentHub.ContentTransfer.Multiple)
284-
285- function exportContacts(contacts)
286- {
287- if (activeTransfer) {
288- var exportUrl = "file:///tmp/address_book_app_export.vcf"
289- mainPage.contactModel.exportCompleted.connect(contactExporter.onExportCompleted)
290- mainPage.contactModel.exportContacts(exportUrl, [], contacts)
291- } else {
292- console.error("Export requested with noo active transfer")
293- }
294- }
295-
296- function onExportCompleted(error, url)
297- {
298- mainPage.contactModel.exportCompleted.disconnect(contactExporter.onExportCompleted)
299- if (error === ContactModel.ExportNoError) {
300- var obj = Qt.createQmlObject("import Ubuntu.Content 0.1; ContentItem { url: '" + url + "' }", contactExporter)
301- activeTransfer.items = [obj]
302- activeTransfer.state = ContentHub.ContentTransfer.Charged
303- } else {
304- console.error("Fail to export contacts:" + error)
305- }
306- activeTransfer = null
307- pickMode = false
308- mainPage.state = "defautl"
309- application.returnVcard(url)
310+ contactModel: contactList.listModel
311+ outputFile: mainPage.pickMode ? "file:///tmp/address_book_app_export.vcf" : ""
312+ onDone: {
313+ mainPage.pickMode = false
314+ mainPage.state = "default"
315+ application.returnVcard(contactExporter.outputFile)
316+ }
317+
318+ onContactsFetched: {
319+ // Share contacts to an application chosen by the user
320+ if (!mainPage.pickMode) {
321+ pageStack.push(Qt.resolvedUrl("../ContactShare/ContactSharePage.qml"),
322+ { contactModel: contactExporter.contactModel, contacts: contacts })
323+ }
324+ }
325+ }
326+
327+ Loader {
328+ id: onlineAccount
329+ source: (contactList.count === 0) &&
330+ application.firstRun ? Qt.resolvedUrl("./OnlineAccountsMessage.qml") : ""
331+ }
332+
333+
334+ Component {
335+ id: removeContactDialog
336+
337+ RemoveContactsDialog {
338+ id: removeContactsDialogMessage
339+
340+ onCanceled: {
341+ PopupUtils.close(removeContactsDialogMessage)
342+ }
343+
344+ onAccepted: {
345+ removeContacts(contactList.listModel)
346+ PopupUtils.close(removeContactsDialogMessage)
347+ }
348 }
349 }
350
351 Component.onCompleted: {
352 application.elapsed()
353- if ((contactList.count === 0) &&
354- application.firstRun &&
355- !mainPage.syncEnabled) {
356- mainPage.onlineAccountsMessageDialog = PopupUtils.open(onlineAccountsDialog, null)
357- }
358-
359 if (TEST_DATA !== "") {
360 contactList.listModel.importContacts("file://" + TEST_DATA)
361 }
362
363=== modified file 'src/imports/ContactList/OnlineAccountsMessage.qml'
364--- src/imports/ContactList/OnlineAccountsMessage.qml 2014-07-20 20:23:20 +0000
365+++ src/imports/ContactList/OnlineAccountsMessage.qml 2014-10-23 15:17:29 +0000
366@@ -17,35 +17,79 @@
367 import QtQuick 2.2
368 import Ubuntu.Components 1.1
369 import Ubuntu.Components.Popups 1.0 as Popups
370-
371-Popups.Dialog {
372- width: units.gu(40)
373- height: units.gu(71)
374-
375- signal canceled()
376- signal accepted()
377- title: i18n.tr("You have no contacts.")
378- text: i18n.tr("Would you like to sync contacts\nfrom online accounts now?")
379- Button {
380- objectName: "onlineAccountsDialog.yesButton"
381- anchors {
382- left: parent.left
383- right: parent.right
384- margins: units.gu(1)
385- }
386- text: i18n.tr("Yes")
387- onClicked: accepted()
388- }
389-
390- Button {
391- objectName: "onlineAccountsDialog.noButton"
392- anchors {
393- left: parent.left
394- right: parent.right
395- margins: units.gu(1)
396- }
397- gradient: UbuntuColors.greyGradient
398- text: i18n.tr("No")
399- onClicked: canceled()
400+import Ubuntu.OnlineAccounts 0.1
401+import Ubuntu.OnlineAccounts.Client 0.1
402+
403+Item {
404+ id: root
405+
406+ property var onlineAccountsMessageDialog: null
407+
408+ function closeDialog()
409+ {
410+ if (onlineAccountsMessageDialog) {
411+ PopupUtils.close(onlineAccountsMessageDialog)
412+ onlineAccountsMessageDialog = null
413+ }
414+ application.unsetFirstRun()
415+ }
416+
417+ AccountServiceModel {
418+ id: accounts
419+ applicationId: "contacts-sync"
420+ onCountChanged: {
421+ if (count > 0) {
422+ root.closeDialog()
423+ }
424+ }
425+ }
426+
427+ Setup {
428+ id: setup
429+ applicationId: "contacts-sync"
430+ providerId: "google"
431+ }
432+
433+ Component {
434+ id: noAccountDialog
435+
436+ Popups.Dialog {
437+ width: units.gu(40)
438+ height: units.gu(71)
439+
440+ title: i18n.tr("You have no contacts.")
441+ text: i18n.tr("Would you like to sync contacts from your google online accounts now?")
442+ Button {
443+ objectName: "onlineAccountsDialog.yesButton"
444+ anchors {
445+ left: parent.left
446+ right: parent.right
447+ margins: units.gu(1)
448+ }
449+ text: i18n.tr("Yes")
450+ onClicked: {
451+ root.closeDialog()
452+ setup.exec()
453+ }
454+ }
455+
456+ Button {
457+ objectName: "onlineAccountsDialog.noButton"
458+ anchors {
459+ left: parent.left
460+ right: parent.right
461+ margins: units.gu(1)
462+ }
463+ gradient: UbuntuColors.greyGradient
464+ text: i18n.tr("No")
465+ onClicked: closeDialog()
466+ }
467+ }
468+ }
469+
470+ Component.onCompleted: {
471+ if (accounts.count === 0) {
472+ root.onlineAccountsMessageDialog = PopupUtils.open(noAccountDialog, null)
473+ }
474 }
475 }
476
477=== modified file 'src/imports/ContactShare/ContactSharePage.qml'
478--- src/imports/ContactShare/ContactSharePage.qml 2014-07-24 12:22:13 +0000
479+++ src/imports/ContactShare/ContactSharePage.qml 2014-10-23 15:17:29 +0000
480@@ -17,12 +17,13 @@
481 import QtQuick 2.2
482 import QtContacts 5.0
483 import Ubuntu.Components 1.1
484-import Ubuntu.Content 0.1 as ContentHub
485+import Ubuntu.Content 1.1 as ContentHub
486+import "../Common"
487
488 Page {
489 id: picker
490
491- property var contactModel
492+ property alias contactModel: exporter.contactModel
493 property var contacts
494 property var curTransfer
495
496@@ -33,30 +34,23 @@
497 handler: ContentHub.ContentHandler.Share
498
499 onPeerSelected: {
500- picker.curTransfer = peer.request();
501- if (picker.curTransfer.state === ContentHub.ContentTransfer.InProgress) {
502- var vCardUrl = "file:///tmp/vcard_" + encodeURIComponent(contact.contactId) + ".vcf"
503- picker.contactModel.exportContacts(vCardUrl, [], picker.contacts)
504+ exporter.activeTransfer = peer.request();
505+ if (exporter.activeTransfer.state === ContentHub.ContentTransfer.InProgress) {
506+ exporter.start(picker.contacts)
507 }
508 }
509
510- onCancelPressed: pageStack.pop()
511- }
512-
513- Connections {
514- target: picker.contactModel
515- onExportCompleted: {
516- if (picker.curTransfer && (picker.curTransfer.state === ContentHub.ContentTransfer.InProgress)) {
517- if (error === ContactModel.ExportNoError) {
518- var obj = Qt.createQmlObject("import Ubuntu.Content 0.1; ContentItem { url: '" + url + "' }", picker)
519- picker.curTransfer.items = [ obj ]
520- picker.curTransfer.state = ContentHub.ContentTransfer.Charged
521- } else {
522- picker.curTransfer = ContentHub.ContentTransfer.Aborted
523- console.error("Fail to export contact:" + error)
524- }
525+ onCancelPressed: {
526+ if (exporter.activeTransfer) {
527+ exporter.activeTransfer.state = ContentHub.ContentTransfer.Aborted
528 }
529 pageStack.pop()
530 }
531 }
532+
533+ ContactExporter {
534+ id: exporter
535+
536+ onDone: pageStack.pop()
537+ }
538 }
539
540=== modified file 'src/imports/ContentHubProxy.qml'
541--- src/imports/ContentHubProxy.qml 2014-07-28 23:12:24 +0000
542+++ src/imports/ContentHubProxy.qml 2014-10-23 15:17:29 +0000
543@@ -24,7 +24,8 @@
544 target: ContentHub.ContentHub
545 onExportRequested: {
546 // enter in pick mode
547- pageStack.contactListPage.startPickMode(false, transfer)
548+ mainWindow.pickWithTransfer((transfer.selectionType === ContentHub.ContentTransfer.Single),
549+ transfer)
550 }
551 onImportRequested: {
552 if (transfer.state === ContentHub.ContentTransfer.Charged) {
553@@ -32,7 +33,7 @@
554 for(var i=0; i < transfer.items.length; i++) {
555 urls.push(transfer.items[i].url)
556 }
557- pageStack.contactListPage.importContact(urls)
558+ mainWindow.importvcards(urls)
559 }
560 }
561 }
562
563=== modified file 'src/imports/MainWindow.qml'
564--- src/imports/MainWindow.qml 2014-08-14 20:26:22 +0000
565+++ src/imports/MainWindow.qml 2014-10-23 15:17:29 +0000
566@@ -54,17 +54,27 @@
567
568 function pick(single)
569 {
570+ pickWithTransfer(single, null)
571+ }
572+
573+ function pickWithTransfer(single, activeTransfer)
574+ {
575 mainStack.resetStack()
576 if (mainStack.contactListPage) {
577- mainStack.contactListPage.startPickMode(single == "true", null)
578+ mainStack.contactListPage.startPickMode(single == "true", activeTransfer)
579 }
580 }
581
582 function importvcard(_url)
583 {
584+ importvcards([_url])
585+ }
586+
587+ function importvcards(_urls)
588+ {
589 mainStack.resetStack()
590 if (mainStack.contactListPage) {
591- mainStack.contactListPage.importContactRequested([_url])
592+ mainStack.contactListPage.importContact(_urls)
593 }
594 }
595
596
597=== modified file 'src/imports/Ubuntu/Contacts/ContactAvatar.qml'
598--- src/imports/Ubuntu/Contacts/ContactAvatar.qml 2014-08-21 00:45:37 +0000
599+++ src/imports/Ubuntu/Contacts/ContactAvatar.qml 2014-10-23 15:17:29 +0000
600@@ -37,7 +37,7 @@
601 function reload()
602 {
603 img.avatarUrl = Qt.binding(function() { return ContactsJS.getAvatar(contactElement, fallbackAvatarUrl) })
604- initialsLabel.contactDisplayName = Qt.binding(function() { return ContactsJS.formatToDisplay(contactElement, ContactDetail.Name, [Name.FirstName, Name.LastName], fallbackDisplayName) })
605+ initialsLabel.contactDisplayName = Qt.binding(function() { return ContactsJS.formatToDisplayWithDetails(contactElement, ContactDetail.Name, [Name.FirstName, Name.LastName], fallbackDisplayName) })
606 }
607
608 radius: "medium"
609@@ -47,7 +47,7 @@
610 id: initialsLabel
611 objectName: "avatarInitials"
612
613- property string contactDisplayName: ContactsJS.formatToDisplay(contactElement, ContactDetail.Name, [Name.FirstName, Name.LastName], fallbackDisplayName)
614+ property string contactDisplayName: ContactsJS.formatToDisplayWithDetails(contactElement, ContactDetail.Name, [Name.FirstName, Name.LastName], fallbackDisplayName)
615
616 anchors.centerIn: parent
617 text: Contacts.contactInitialsFromString(contactDisplayName)
618
619=== modified file 'src/imports/Ubuntu/Contacts/ContactDelegate.qml'
620--- src/imports/Ubuntu/Contacts/ContactDelegate.qml 2014-09-02 19:23:05 +0000
621+++ src/imports/Ubuntu/Contacts/ContactDelegate.qml 2014-10-23 15:17:29 +0000
622@@ -26,12 +26,10 @@
623 property bool showAvatar: true
624 property bool isCurrentItem: false
625 property string defaultAvatarUrl: ""
626- property string defaultTitle: ""
627- property int titleDetail: ContactDetail.Name
628- property variant titleFields: [ Name.FirstName, Name.LastName ]
629 property bool detailsShown: false
630 property int loaderOpacity: 0.0
631 property bool flicking: false
632+ readonly property string displayLabel: contact ? ContactsJS.formatToDisplay(contact, "") : ""
633
634 signal clicked(int index, QtObject contact)
635 signal pressAndHold(int index, QtObject contact)
636@@ -84,7 +82,7 @@
637 id: avatar
638
639 contactElement: contact
640- fallbackDisplayName: name.text
641+ fallbackDisplayName: root.displayLabel
642 anchors {
643 left: parent.left
644 top: parent.top
645@@ -107,7 +105,7 @@
646
647 }
648 color: UbuntuColors.lightAubergine
649- text: contact ? ContactsJS.formatToDisplay(contact, root.titleDetail, root.titleFields, "") : root.defaultTitle
650+ text: root.displayLabel != "" ? root.displayLabel : i18n.dtr("address-book-app", "No name")
651 elide: Text.ElideRight
652 }
653
654
655=== modified file 'src/imports/Ubuntu/Contacts/ContactListView.qml'
656--- src/imports/Ubuntu/Contacts/ContactListView.qml 2014-08-27 22:40:35 +0000
657+++ src/imports/Ubuntu/Contacts/ContactListView.qml 2014-10-23 15:17:29 +0000
658@@ -69,20 +69,6 @@
659 */
660 property alias showAvatar: view.showAvatar
661 /*!
662- \qmlproperty int titleDetail
663-
664- This property holds the contact detail which will be used to display the contact title in the delegate
665- By default this is set to ContactDetail.Name.
666- */
667- property alias titleDetail: view.titleDetail
668- /*!
669- \qmlproperty list<int> titleFields
670-
671- This property holds the list of all fields which will be used to display the contact title in the delegate
672- By default this is set to [ Name.FirstName, Name.LastName ]
673- */
674- property alias titleFields: view.titleFields
675- /*!
676 \qmlproperty list<SortOrder> sortOrders
677
678 This property holds a list of sort orders used by the contacts model.
679
680=== modified file 'src/imports/Ubuntu/Contacts/ContactPreviewPage.qml'
681--- src/imports/Ubuntu/Contacts/ContactPreviewPage.qml 2014-09-17 18:36:48 +0000
682+++ src/imports/Ubuntu/Contacts/ContactPreviewPage.qml 2014-10-23 15:17:29 +0000
683@@ -20,6 +20,7 @@
684 import Ubuntu.Components.ListItems 1.0 as ListItem
685 import Ubuntu.Contacts 0.1 as ContactsUI
686 import Ubuntu.Components.Popups 1.0 as Popups
687+import "Contacts.js" as ContactsJS
688
689 Page {
690 id: root
691@@ -27,22 +28,15 @@
692 property QtObject contact: null
693 property alias extensions: extensionsContents.children
694
695- function formatNameToDisplay(contact) {
696- if (!contact) {
697- return ""
698- }
699- if (contact.name) {
700- var detail = contact.name
701- return (detail.firstName + " " + detail.lastName).trim()
702- } else if (contact.displayLabel && contact.displayLabel.label && contact.displayLabel.label !== "") {
703- return contact.displayLabel.label
704- } else {
705- return ""
706+ title: ContactsJS.formatToDisplay(contact, i18n.dtr("address-book-app", "No name"))
707+
708+ Connections {
709+ target: contact
710+ onContactChanged: {
711+ root.title = ContactsJS.formatToDisplay(contact, i18n.dtr("address-book-app", "No name"))
712 }
713 }
714
715- title: formatNameToDisplay(contact)
716-
717 Flickable {
718 id: flickable
719
720
721=== modified file 'src/imports/Ubuntu/Contacts/ContactSimpleListView.qml'
722--- src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2014-09-04 18:21:29 +0000
723+++ src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2014-10-23 15:17:29 +0000
724@@ -54,20 +54,6 @@
725 property bool showAvatar: true
726
727 /*!
728- \qmlproperty int titleDetail
729-
730- This property holds the contact detail which will be used to display the contact title in the delegate
731- By default this is set to ContactDetail.Name.
732- */
733- property int titleDetail: ContactDetail.DisplayLabel
734- /*!
735- \qmlproperty list<int> titleFields
736-
737- This property holds the list of all fields which will be used to display the contact title in the delegate
738- By default this is set to [ Name.FirstName, Name.LastName ]
739- */
740- property variant titleFields: [ DisplayLabel.Label ]
741- /*!
742 \qmlproperty list<SortOrder> sortOrders
743
744 This property holds a list of sort orders used by the contacts model.
745@@ -101,7 +87,7 @@
746 detailTypesHint: {
747 var hints = [ ContactDetail.Tag, // sections
748 ContactDetail.PhoneNumber, // expansion
749- contactListView.titleDetail ]
750+ ContactDetail.DisplayLabel ]
751
752 if (contactListView.showAvatar) {
753 hints.push(ContactDetail.Avatar)
754@@ -292,8 +278,6 @@
755 selected: contactListView.multiSelectionEnabled && contactListView.isSelected(contactDelegate)
756 selectionMode: contactListView.isInSelectionMode
757 defaultAvatarUrl: contactListView.defaultAvatarImageUrl
758- titleDetail: contactListView.titleDetail
759- titleFields: contactListView.titleFields
760 isCurrentItem: ListView.isCurrentItem
761
762 // actions
763
764=== modified file 'src/imports/Ubuntu/Contacts/Contacts.js'
765--- src/imports/Ubuntu/Contacts/Contacts.js 2014-07-05 22:00:02 +0000
766+++ src/imports/Ubuntu/Contacts/Contacts.js 2014-10-23 15:17:29 +0000
767@@ -2,7 +2,8 @@
768 var phoneTypeModel = null
769
770 // Format contact name to be displayed
771-function formatToDisplay(contact, contactDetail, detailFields, defaultTitle) {
772+function formatToDisplayWithDetails(contact, contactDetail, detailFields, defaultTitle)
773+{
774 if (!contact) {
775 return defaultTitle
776 }
777@@ -28,6 +29,59 @@
778 return values
779 }
780
781+function formatToDisplay(contact, defaultTitle)
782+{
783+ if (!contact) {
784+ return defaultTitle
785+ }
786+
787+ var detail = contact.detail(ContactDetail.DisplayLabel)
788+ if (detail && (detail.label.length > 0)) {
789+ return detail.label
790+ }
791+
792+ detail = contact.detail(ContactDetail.Name)
793+ if (detail) {
794+ var fullName = (detail.firstName + " " + detail.lastName).trim()
795+ if (fullName.length > 0) {
796+ return fullName
797+ }
798+ }
799+
800+ detail = contact.detail(ContactDetail.Organization)
801+ if (detail) {
802+ if (detail.name && (detail.name.length > 0)) {
803+ return detail.name
804+ }
805+ }
806+
807+ var details = contact.details(ContactDetail.PhoneNumber)
808+ if (details.length > 0) {
809+ detail = details[0]
810+ if (detail.number && detail.number.length > 0) {
811+ return detail.number
812+ }
813+ }
814+
815+ details = contact.details(ContactDetail.Email)
816+ if (details.length > 0) {
817+ detail = details[0]
818+ if (detail.emailAddress && detail.emailAddress.length > 0) {
819+ return detail.emailAddress
820+ }
821+ }
822+
823+ details = contact.details(ContactDetail.OnlineAccount)
824+ if (details.length > 0) {
825+ detail = details[0]
826+ if (detail.accountUri && detail.accountUri.length > 0) {
827+ return detail.accountUri
828+ }
829+ }
830+
831+ return defaultTitle
832+}
833+
834 function getAvatar(contact, defaultValue)
835 {
836 // use this verbose mode to avoid problems with binding loops
837
838=== modified file 'src/imports/Ubuntu/Contacts/MostCalledModel.qml'
839--- src/imports/Ubuntu/Contacts/MostCalledModel.qml 2014-09-04 20:34:55 +0000
840+++ src/imports/Ubuntu/Contacts/MostCalledModel.qml 2014-10-23 15:17:29 +0000
841@@ -75,8 +75,6 @@
842
843 defaultAvatarUrl: "image://theme/contacts"
844 width: parent ? parent.width : 0
845- titleDetail: ContactDetail.DisplayLabel
846- titleFields: [ DisplayLabel.Label ]
847 isCurrentItem: root.currentIndex === index
848 locked: true
849

Subscribers

People subscribed via source and target branches