Merge lp:~renatofilho/messaging-app/fix-1367906 into lp:messaging-app

Proposed by Renato Araujo Oliveira Filho
Status: Needs review
Proposed branch: lp:~renatofilho/messaging-app/fix-1367906
Merge into: lp:messaging-app
Diff against target: 83 lines (+30/-8)
3 files modified
src/messagingapplication.cpp (+24/-0)
src/messagingapplication.h (+1/-0)
src/qml/ContactSearchList.qml (+5/-8)
To merge this branch: bzr merge lp:~renatofilho/messaging-app/fix-1367906
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+246004@code.launchpad.net

Commit message

Use unaccented string to highlight searched text.

To post a comment you must log in.
287. By Renato Araujo Oliveira Filho

Use unaccented string to highlight searched text.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

287. By Renato Araujo Oliveira Filho

Use unaccented string to highlight searched text.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/messagingapplication.cpp'
2--- src/messagingapplication.cpp 2014-10-17 18:15:29 +0000
3+++ src/messagingapplication.cpp 2015-01-09 19:12:59 +0000
4@@ -59,6 +59,22 @@
5 }
6 }
7
8+static QString unaccentString(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 MessagingApplication::MessagingApplication(int &argc, char **argv)
25 : QGuiApplication(argc, argv), m_view(0), m_applicationIsReady(false)
26 {
27@@ -270,3 +286,11 @@
28 return QString();
29 }
30
31+int MessagingApplication::indexOf(const QString &string, const QString &value)
32+{
33+ const QString normalizedString(unaccentString(string.toLower()));
34+ const QString normalizedValue(unaccentString(value.toLower()));
35+
36+ return normalizedString.indexOf(normalizedValue);
37+}
38+
39
40=== modified file 'src/messagingapplication.h'
41--- src/messagingapplication.h 2014-07-01 18:08:32 +0000
42+++ src/messagingapplication.h 2015-01-09 19:12:59 +0000
43@@ -39,6 +39,7 @@
44 QString readTextFile(const QString &fileName);
45 QString fileMimeType(const QString &fileName);
46 QString contactNameFromVCard(const QString &fileName);
47+ int indexOf(const QString &string, const QString &value);
48
49 private Q_SLOTS:
50 void onViewStatusChanged(QQuickView::Status status);
51
52=== modified file 'src/qml/ContactSearchList.qml'
53--- src/qml/ContactSearchList.qml 2014-08-15 19:56:15 +0000
54+++ src/qml/ContactSearchList.qml 2015-01-09 19:12:59 +0000
55@@ -27,7 +27,6 @@
56 id: root
57
58 property alias filterTerm: contactModel.filterTerm
59- onFilterTermChanged: console.debug("FILTER :" + filterTerm)
60
61 signal phonePicked(string phoneNumber)
62
63@@ -100,15 +99,13 @@
64 height: units.gu(2)
65 text: {
66 // this is necessary to keep the string in the original format
67- var originalText = contact.displayLabel.label
68- var lowerSearchText = filterTerm.toLowerCase()
69- var lowerText = originalText.toLowerCase()
70- var searchIndex = lowerText.indexOf(lowerSearchText)
71+ var contactName = contact.displayLabel.label
72+ var searchIndex = application.indexOf(contactName, filterTerm)
73 if (searchIndex !== -1) {
74- var piece = originalText.substr(searchIndex, lowerSearchText.length)
75- return originalText.replace(piece, "<b>" + piece + "</b>")
76+ var piece = contactName.substr(searchIndex, filterTerm.length)
77+ return contactName.replace(piece, "<b>" + piece + "</b>")
78 } else {
79- return originalText
80+ return contactName
81 }
82 }
83 fontSize: "medium"

Subscribers

People subscribed via source and target branches