Merge lp:~renatofilho/address-book-app/fix-1421245 into lp:address-book-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Michael Sheldon
Approved revision: 452
Merged at revision: 452
Proposed branch: lp:~renatofilho/address-book-app/fix-1421245
Merge into: lp:address-book-app
Diff against target: 221 lines (+117/-5)
7 files modified
src/imports/Ubuntu/Contacts/ContactListModel.qml (+4/-4)
src/imports/Ubuntu/Contacts/contacts.cpp (+10/-0)
src/imports/Ubuntu/Contacts/contacts.h (+1/-0)
tests/data/tst_ContactListModel_data.vcf (+35/-0)
tests/qml/CMakeLists.txt (+2/-0)
tests/qml/tst_ContactListModel.qml (+19/-1)
tests/qml/tst_UbuntuContacts.qml (+46/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1421245
Reviewer Review Type Date Requested Status
Michael Sheldon (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+263254@code.launchpad.net

Commit message

Fixed search by non-latin names.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (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 LABEL CHANGE

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

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?

 * Yes

Did CI run pass? If not, please explain why.

 * Yes (tested with both LTR and RTL non-latin languages)

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?

 * Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/imports/Ubuntu/Contacts/ContactListModel.qml'
2--- src/imports/Ubuntu/Contacts/ContactListModel.qml 2015-05-07 17:27:16 +0000
3+++ src/imports/Ubuntu/Contacts/ContactListModel.qml 2015-06-29 15:36:05 +0000
4@@ -76,6 +76,7 @@
5
6 filters: [
7 DetailFilter {
8+ id: nameFilter
9 detail: (root.manager === "galera" ? ContactDetail.ExtendedDetail : ContactDetail.DisplayLabel)
10 field: (root.manager === "galera" ? ExtendedDetail.Data : DisplayLabel.Label)
11 value: (root.manager === "galera" ? Contacts.normalized(contactTermFilter.value) : contactTermFilter.value)
12@@ -84,12 +85,11 @@
13 ]
14
15 onValueChanged: {
16- var containsLetter = /^[a-zA-Z]/.test(value)
17-
18+ var containsLetter = Contacts.containsLetters(value)
19 if (containsLetter && (filters.length > 1)) {
20- filters = [filters[0]]
21+ filters = [nameFilter]
22 } else if (!containsLetter) {
23- filters = [filters[0], phoneNumberFilter]
24+ filters = [nameFilter, phoneNumberFilter]
25 }
26 }
27 },
28
29=== modified file 'src/imports/Ubuntu/Contacts/contacts.cpp'
30--- src/imports/Ubuntu/Contacts/contacts.cpp 2015-05-13 21:31:33 +0000
31+++ src/imports/Ubuntu/Contacts/contacts.cpp 2015-06-29 15:36:05 +0000
32@@ -88,6 +88,16 @@
33 return imgThread->outputFile();
34 }
35
36+bool UbuntuContacts::containsLetters(const QString &value)
37+{
38+ foreach (const QChar &c, value) {
39+ if (c.isLetter()) {
40+ return true;
41+ }
42+ }
43+ return false;
44+}
45+
46 bool UbuntuContacts::removeFile(const QUrl &file)
47 {
48 return QFile::remove(file.toLocalFile());
49
50=== modified file 'src/imports/Ubuntu/Contacts/contacts.h'
51--- src/imports/Ubuntu/Contacts/contacts.h 2015-04-30 21:17:11 +0000
52+++ src/imports/Ubuntu/Contacts/contacts.h 2015-06-29 15:36:05 +0000
53@@ -34,6 +34,7 @@
54 Q_INVOKABLE QString contactInitialsFromString(const QString &value);
55 Q_INVOKABLE QString normalized(const QString &value);
56 Q_INVOKABLE QUrl copyImage(QObject *contact, const QUrl &imageUrl);
57+ Q_INVOKABLE bool containsLetters(const QString &value);
58 Q_INVOKABLE bool removeFile(const QUrl &file);
59 };
60
61
62=== modified file 'tests/data/tst_ContactListModel_data.vcf'
63--- tests/data/tst_ContactListModel_data.vcf 2014-12-15 13:39:54 +0000
64+++ tests/data/tst_ContactListModel_data.vcf 2015-06-29 15:36:05 +0000
65@@ -25,6 +25,41 @@
66 N:Fulano;da;Silva1;;;
67 FN:Fulano da Silva1
68 X-QTPROJECT-FAVORITE:false;0
69+TEL:+55(81)8704-0000
70 TEL:555666
71 CATEGORIES:F
72 END:VCARD
73+BEGIN:VCARD
74+VERSION:3.0
75+UID:pas-id-5591505300000002
76+NICKNAME:
77+NOTE:
78+FN:Дмитрий Ященко
79+N:Ященко;Дмитрий;;;
80+EMAIL;X-EVOLUTION-UI-SLOT=1;TYPE=WORK:0987654321
81+REV:2015-06-29T14:04:03Z(2)
82+END:VCARD
83+BEGIN:VCARD
84+VERSION:3.0
85+UID:pas-id-5591504300000001
86+FN:Роман Щекин
87+N:Щекин;Роман;;;
88+EMAIL;X-EVOLUTION-UI-SLOT=1;TYPE=WORK:12345678
89+REV:2015-06-29T14:03:47Z(0)
90+END:VCARD
91+BEGIN:VCARD
92+VERSION:3.0
93+UID:pas-id-5591510B00000003
94+FN:亚历山德拉
95+N:;亚历山德拉;;;
96+EMAIL;X-EVOLUTION-UI-SLOT=1;TYPE=WORK:5678
97+REV:2015-06-29T14:07:07Z(4)
98+END:VCARD
99+BEGIN:VCARD
100+VERSION:3.0
101+UID:pas-id-5591511B00000004
102+FN:阿娜丝塔西亚
103+N:;阿娜丝塔西亚;;;
104+EMAIL;X-EVOLUTION-UI-SLOT=1;TYPE=WORK:123890
105+REV:2015-06-29T14:07:23Z(6)
106+END:VCARD
107
108=== modified file 'tests/qml/CMakeLists.txt'
109--- tests/qml/CMakeLists.txt 2015-05-14 21:23:43 +0000
110+++ tests/qml/CMakeLists.txt 2015-06-29 15:36:05 +0000
111@@ -29,6 +29,7 @@
112 declare_qml_test("list_with_actions" tst_ListWithActions.qml)
113 declare_qml_test("contact_preview_page" tst_ContactPreviewPage.qml)
114 declare_qml_test("vcard_parser" tst_VCardParser.qml)
115+ declare_qml_test("ubuntu_contact" tst_UbuntuContacts.qml)
116 else()
117 if (NOT QMLTESTRUNNER_BIN)
118 message(WARNING "Qml tests disabled: qmltestrunner not found")
119@@ -47,5 +48,6 @@
120 tst_ListWithActions.qml
121 tst_ContactPreviewPage.qml
122 tst_VCardParser.qml
123+ tst_UbuntuContacts.qml
124 )
125 add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})
126
127=== modified file 'tests/qml/tst_ContactListModel.qml'
128--- tests/qml/tst_ContactListModel.qml 2014-12-15 13:38:41 +0000
129+++ tests/qml/tst_ContactListModel.qml 2015-06-29 15:36:05 +0000
130@@ -61,7 +61,7 @@
131
132 function test_contactImport()
133 {
134- tryCompare(root.contactListModelObj, "contactCount", 3)
135+ tryCompare(root.contactListModelObj, "contactCount", 7)
136 }
137
138 function test_searchByPhoneNumber()
139@@ -74,6 +74,9 @@
140
141 root.contactListModelObj.filterTerm = "6"
142 tryCompare(root.contactListModelObj, "contactCount", 3)
143+
144+ root.contactListModelObj.filterTerm = "+55(81)8704-0000"
145+ tryCompare(root.contactListModelObj, "contactCount", 1)
146 }
147
148 function test_searchByContactName()
149@@ -101,6 +104,21 @@
150
151 root.contactListModelObj.filterTerm = "1"
152 tryCompare(root.contactListModelObj, "contactCount", 3)
153+
154+ root.contactListModelObj.filterTerm = "Renato555"
155+ tryCompare(root.contactListModelObj, "contactCount", 0)
156+ }
157+
158+ function test_searchByNonLatinNames()
159+ {
160+ root.contactListModelObj.filterTerm = "Роман Щекин"
161+ tryCompare(root.contactListModelObj, "contactCount", 1)
162+
163+ root.contactListModelObj.filterTerm = "亚"
164+ tryCompare(root.contactListModelObj, "contactCount", 2)
165+
166+ root.contactListModelObj.filterTerm = "阿娜丝塔西"
167+ tryCompare(root.contactListModelObj, "contactCount", 1)
168 }
169 }
170 }
171
172=== added file 'tests/qml/tst_UbuntuContacts.qml'
173--- tests/qml/tst_UbuntuContacts.qml 1970-01-01 00:00:00 +0000
174+++ tests/qml/tst_UbuntuContacts.qml 2015-06-29 15:36:05 +0000
175@@ -0,0 +1,46 @@
176+/*
177+ * Copyright (C) 2014 Canonical, Ltd.
178+ *
179+ * This program is free software; you can redistribute it and/or modify
180+ * it under the terms of the GNU General Public License as published by
181+ * the Free Software Foundation; version 3.
182+ *
183+ * This program is distributed in the hope that it will be useful,
184+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
185+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
186+ * GNU General Public License for more details.
187+ *
188+ * You should have received a copy of the GNU General Public License
189+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
190+ */
191+
192+import QtQuick 2.2
193+import QtTest 1.0
194+import Ubuntu.Contacts 0.1
195+
196+Item {
197+ id: root
198+
199+ TestCase {
200+ id: uContactsTest
201+ name: 'UBuntuContactTestCase'
202+
203+ function test_normalize_string()
204+ {
205+ compare(Contacts.normalized("não"), "nao")
206+ compare(Contacts.normalized("josé"), "jose")
207+ compare(Contacts.normalized("açaí"), "acai")
208+ compare(Contacts.normalized("Роман Щекин"), "Роман Щекин")
209+ compare(Contacts.normalized("阿娜丝塔西"), "阿娜丝塔西")
210+ }
211+
212+ function test_containsLetters()
213+ {
214+ compare(Contacts.containsLetters("123456"), false)
215+ compare(Contacts.containsLetters("(123)"), false)
216+ compare(Contacts.containsLetters("Щекин"), true)
217+ compare(Contacts.containsLetters("阿娜丝塔西"), true)
218+ compare(Contacts.containsLetters("阿娜23西"), true)
219+ }
220+ }
221+}

Subscribers

People subscribed via source and target branches