Merge lp:~renatofilho/address-book-service/fix-1548783 into lp:address-book-service

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Arthur Mello
Approved revision: no longer in the source branch.
Merged at revision: 204
Proposed branch: lp:~renatofilho/address-book-service/fix-1548783
Merge into: lp:address-book-service
Diff against target: 86 lines (+30/-14)
2 files modified
lib/qindividual.cpp (+18/-2)
tests/unittest/qcontacts-test.cpp (+12/-12)
To merge this branch: bzr merge lp:~renatofilho/address-book-service/fix-1548783
Reviewer Review Type Date Requested Status
Arthur Mello (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+293808@code.launchpad.net

Commit message

Use middle name value on display name.

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: Approve (continuous-integration)
Revision history for this message
Arthur Mello (artmello) wrote :

lgtm

review: Approve
204. By Renato Araujo Oliveira Filho

Use middle name value on display name. Fixes: #1375933, #1548783
Approved by: Arthur Mello, PS Jenkins bot

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/qindividual.cpp'
2--- lib/qindividual.cpp 2015-10-29 13:34:18 +0000
3+++ lib/qindividual.cpp 2016-05-04 21:28:44 +0000
4@@ -1705,8 +1705,24 @@
5 if (fallbackLabel.isEmpty()) {
6 QContactName name = contact.detail<QContactName>();
7 if (!name.isEmpty()) {
8- QString fullName = QString("%1 %2").arg(name.firstName()).arg(name.lastName());
9- fallbackLabel = fullName.trimmed();
10+ QStringList names;
11+ if (!name.prefix().isEmpty()) {
12+ names << name.prefix();
13+ }
14+ if (!name.firstName().isEmpty()) {
15+ names << name.firstName();
16+ }
17+ if (!name.middleName().isEmpty()) {
18+ names << name.middleName();
19+ }
20+ if (!name.lastName().isEmpty()) {
21+ names << name.lastName();
22+ }
23+ if (!name.suffix().isEmpty()) {
24+ names << name.suffix();
25+ }
26+
27+ fallbackLabel = names.join(" ").trimmed();
28 }
29 }
30
31
32=== modified file 'tests/unittest/qcontacts-test.cpp'
33--- tests/unittest/qcontacts-test.cpp 2015-10-27 15:15:33 +0000
34+++ tests/unittest/qcontacts-test.cpp 2016-05-04 21:28:44 +0000
35@@ -366,8 +366,8 @@
36 QList<QContact> contacts = m_manager->contacts(ids);
37
38 QCOMPARE(contacts[0].details<QContactTag>().size(), 1);
39- QCOMPARE(contacts[0].detail<QContactDisplayLabel>().label(), QStringLiteral("Fulano Tal"));
40- QCOMPARE(contacts[0].detail<QContactTag>().tag(), QStringLiteral("FULANO TAL"));
41+ QCOMPARE(contacts[0].detail<QContactDisplayLabel>().label(), QStringLiteral("Fulano de Tal"));
42+ QCOMPARE(contacts[0].detail<QContactTag>().tag(), QStringLiteral("FULANO DE TAL"));
43
44 // Change contact name
45 name = contact.detail<QContactName>();
46@@ -377,8 +377,8 @@
47
48 contacts = m_manager->contacts(ids);
49 QCOMPARE(contacts[0].details<QContactTag>().size(), 1);
50- QCOMPARE(contacts[0].detail<QContactDisplayLabel>().label(), QStringLiteral("xFulano Tal"));
51- QCOMPARE(contacts[0].detail<QContactTag>().tag(), QStringLiteral("XFULANO TAL"));
52+ QCOMPARE(contacts[0].detail<QContactDisplayLabel>().label(), QStringLiteral("xFulano de Tal"));
53+ QCOMPARE(contacts[0].detail<QContactTag>().tag(), QStringLiteral("XFULANO DE TAL"));
54 }
55
56 void testContactChangeOrder()
57@@ -427,10 +427,10 @@
58 QContactFilter filter;
59 QList<QContact> contacts = m_manager->contacts(filter);
60
61- QCOMPARE(contacts[0].detail<QContactDisplayLabel>().label(), QStringLiteral("A Tal"));
62- QCOMPARE(contacts[1].detail<QContactDisplayLabel>().label(), QStringLiteral("B Tal"));
63- QCOMPARE(contacts[2].detail<QContactDisplayLabel>().label(), QStringLiteral("C Tal"));
64- QCOMPARE(contacts[3].detail<QContactDisplayLabel>().label(), QStringLiteral("D Tal"));
65+ QCOMPARE(contacts[0].detail<QContactDisplayLabel>().label(), QStringLiteral("A de Tal"));
66+ QCOMPARE(contacts[1].detail<QContactDisplayLabel>().label(), QStringLiteral("B de Tal"));
67+ QCOMPARE(contacts[2].detail<QContactDisplayLabel>().label(), QStringLiteral("C de Tal"));
68+ QCOMPARE(contacts[3].detail<QContactDisplayLabel>().label(), QStringLiteral("D de Tal"));
69
70 // Update contact B name
71 contactB = contacts[1];
72@@ -443,10 +443,10 @@
73 contacts = m_manager->contacts(filter);
74
75 // check new order
76- QCOMPARE(contacts[0].detail<QContactDisplayLabel>().label(), QStringLiteral("A Tal"));
77- QCOMPARE(contacts[1].detail<QContactDisplayLabel>().label(), QStringLiteral("C Tal"));
78- QCOMPARE(contacts[2].detail<QContactDisplayLabel>().label(), QStringLiteral("D Tal"));
79- QCOMPARE(contacts[3].detail<QContactDisplayLabel>().label(), QStringLiteral("X Tal"));
80+ QCOMPARE(contacts[0].detail<QContactDisplayLabel>().label(), QStringLiteral("A de Tal"));
81+ QCOMPARE(contacts[1].detail<QContactDisplayLabel>().label(), QStringLiteral("C de Tal"));
82+ QCOMPARE(contacts[2].detail<QContactDisplayLabel>().label(), QStringLiteral("D de Tal"));
83+ QCOMPARE(contacts[3].detail<QContactDisplayLabel>().label(), QStringLiteral("X de Tal"));
84 }
85
86 /*

Subscribers

People subscribed via source and target branches