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

Proposed by Renato Araujo Oliveira Filho on 2014-12-15
Status: Merged
Approved by: Bill Filler on 2015-01-09
Approved revision: 148
Merged at revision: 149
Proposed branch: lp:~renatofilho/address-book-service/fix-1367906
Merge into: lp:address-book-service
Diff against target: 38 lines (+21/-0)
1 file modified
lib/qindividual.cpp (+21/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-service/fix-1367906
Reviewer Review Type Date Requested Status
Bill Filler (community) 2014-12-15 Approve on 2015-01-09
PS Jenkins bot continuous-integration Needs Fixing on 2014-12-15
Review via email: mp+244786@code.launchpad.net

Commit message

Added a new field on contact object "X-NORMALIZED_FN" which contains the unaccented contact full name.

This field will be used on search.

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

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 2014-11-06 15:44:15 +0000
3+++ lib/qindividual.cpp 2014-12-15 19:47:37 +0000
4@@ -116,6 +116,22 @@
5 } \
6 }
7
8+static QString unaccent(const QString &value)
9+{
10+ QString s2 = value.normalized(QString::NormalizationForm_D);
11+ QString out;
12+
13+ for (int i=0, j=s2.length(); i<j; i++)
14+ {
15+ // strip diacritic marks
16+ if (s2.at(i).category() != QChar::Mark_NonSpacing &&
17+ s2.at(i).category() != QChar::Mark_SpacingCombining) {
18+ out.append(s2.at(i));
19+ }
20+ }
21+ return out;
22+}
23+
24 }
25
26 namespace galera
27@@ -906,6 +922,11 @@
28 tag.setTag(label);
29 }
30 contact->saveDetail(&tag);
31+
32+ QContactExtendedDetail normalizedLabel;
33+ normalizedLabel.setName("X-NORMALIZED_FN");
34+ normalizedLabel.setData(unaccent(dLabel.label()));
35+ contact->saveDetail(&normalizedLabel);
36 }
37
38 bool QIndividual::update(const QtContacts::QContact &newContact, QObject *object, const char *slot)

Subscribers

People subscribed via source and target branches