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
=== modified file 'src/imports/Ubuntu/Contacts/ContactListModel.qml'
--- src/imports/Ubuntu/Contacts/ContactListModel.qml 2015-05-07 17:27:16 +0000
+++ src/imports/Ubuntu/Contacts/ContactListModel.qml 2015-06-29 15:36:05 +0000
@@ -76,6 +76,7 @@
7676
77 filters: [77 filters: [
78 DetailFilter {78 DetailFilter {
79 id: nameFilter
79 detail: (root.manager === "galera" ? ContactDetail.ExtendedDetail : ContactDetail.DisplayLabel)80 detail: (root.manager === "galera" ? ContactDetail.ExtendedDetail : ContactDetail.DisplayLabel)
80 field: (root.manager === "galera" ? ExtendedDetail.Data : DisplayLabel.Label)81 field: (root.manager === "galera" ? ExtendedDetail.Data : DisplayLabel.Label)
81 value: (root.manager === "galera" ? Contacts.normalized(contactTermFilter.value) : contactTermFilter.value)82 value: (root.manager === "galera" ? Contacts.normalized(contactTermFilter.value) : contactTermFilter.value)
@@ -84,12 +85,11 @@
84 ]85 ]
8586
86 onValueChanged: {87 onValueChanged: {
87 var containsLetter = /^[a-zA-Z]/.test(value)88 var containsLetter = Contacts.containsLetters(value)
88
89 if (containsLetter && (filters.length > 1)) {89 if (containsLetter && (filters.length > 1)) {
90 filters = [filters[0]]90 filters = [nameFilter]
91 } else if (!containsLetter) {91 } else if (!containsLetter) {
92 filters = [filters[0], phoneNumberFilter]92 filters = [nameFilter, phoneNumberFilter]
93 }93 }
94 }94 }
95 },95 },
9696
=== modified file 'src/imports/Ubuntu/Contacts/contacts.cpp'
--- src/imports/Ubuntu/Contacts/contacts.cpp 2015-05-13 21:31:33 +0000
+++ src/imports/Ubuntu/Contacts/contacts.cpp 2015-06-29 15:36:05 +0000
@@ -88,6 +88,16 @@
88 return imgThread->outputFile();88 return imgThread->outputFile();
89}89}
9090
91bool UbuntuContacts::containsLetters(const QString &value)
92{
93 foreach (const QChar &c, value) {
94 if (c.isLetter()) {
95 return true;
96 }
97 }
98 return false;
99}
100
91bool UbuntuContacts::removeFile(const QUrl &file)101bool UbuntuContacts::removeFile(const QUrl &file)
92{102{
93 return QFile::remove(file.toLocalFile());103 return QFile::remove(file.toLocalFile());
94104
=== modified file 'src/imports/Ubuntu/Contacts/contacts.h'
--- src/imports/Ubuntu/Contacts/contacts.h 2015-04-30 21:17:11 +0000
+++ src/imports/Ubuntu/Contacts/contacts.h 2015-06-29 15:36:05 +0000
@@ -34,6 +34,7 @@
34 Q_INVOKABLE QString contactInitialsFromString(const QString &value);34 Q_INVOKABLE QString contactInitialsFromString(const QString &value);
35 Q_INVOKABLE QString normalized(const QString &value);35 Q_INVOKABLE QString normalized(const QString &value);
36 Q_INVOKABLE QUrl copyImage(QObject *contact, const QUrl &imageUrl);36 Q_INVOKABLE QUrl copyImage(QObject *contact, const QUrl &imageUrl);
37 Q_INVOKABLE bool containsLetters(const QString &value);
37 Q_INVOKABLE bool removeFile(const QUrl &file);38 Q_INVOKABLE bool removeFile(const QUrl &file);
38};39};
3940
4041
=== modified file 'tests/data/tst_ContactListModel_data.vcf'
--- tests/data/tst_ContactListModel_data.vcf 2014-12-15 13:39:54 +0000
+++ tests/data/tst_ContactListModel_data.vcf 2015-06-29 15:36:05 +0000
@@ -25,6 +25,41 @@
25N:Fulano;da;Silva1;;;25N:Fulano;da;Silva1;;;
26FN:Fulano da Silva126FN:Fulano da Silva1
27X-QTPROJECT-FAVORITE:false;027X-QTPROJECT-FAVORITE:false;0
28TEL:+55(81)8704-0000
28TEL:55566629TEL:555666
29CATEGORIES:F30CATEGORIES:F
30END:VCARD31END:VCARD
32BEGIN:VCARD
33VERSION:3.0
34UID:pas-id-5591505300000002
35NICKNAME:
36NOTE:
37FN:Дмитрий Ященко
38N:Ященко;Дмитрий;;;
39EMAIL;X-EVOLUTION-UI-SLOT=1;TYPE=WORK:0987654321
40REV:2015-06-29T14:04:03Z(2)
41END:VCARD
42BEGIN:VCARD
43VERSION:3.0
44UID:pas-id-5591504300000001
45FN:Роман Щекин
46N:Щекин;Роман;;;
47EMAIL;X-EVOLUTION-UI-SLOT=1;TYPE=WORK:12345678
48REV:2015-06-29T14:03:47Z(0)
49END:VCARD
50BEGIN:VCARD
51VERSION:3.0
52UID:pas-id-5591510B00000003
53FN:亚历山德拉
54N:;亚历山德拉;;;
55EMAIL;X-EVOLUTION-UI-SLOT=1;TYPE=WORK:5678
56REV:2015-06-29T14:07:07Z(4)
57END:VCARD
58BEGIN:VCARD
59VERSION:3.0
60UID:pas-id-5591511B00000004
61FN:阿娜丝塔西亚
62N:;阿娜丝塔西亚;;;
63EMAIL;X-EVOLUTION-UI-SLOT=1;TYPE=WORK:123890
64REV:2015-06-29T14:07:23Z(6)
65END:VCARD
3166
=== modified file 'tests/qml/CMakeLists.txt'
--- tests/qml/CMakeLists.txt 2015-05-14 21:23:43 +0000
+++ tests/qml/CMakeLists.txt 2015-06-29 15:36:05 +0000
@@ -29,6 +29,7 @@
29 declare_qml_test("list_with_actions" tst_ListWithActions.qml)29 declare_qml_test("list_with_actions" tst_ListWithActions.qml)
30 declare_qml_test("contact_preview_page" tst_ContactPreviewPage.qml)30 declare_qml_test("contact_preview_page" tst_ContactPreviewPage.qml)
31 declare_qml_test("vcard_parser" tst_VCardParser.qml)31 declare_qml_test("vcard_parser" tst_VCardParser.qml)
32 declare_qml_test("ubuntu_contact" tst_UbuntuContacts.qml)
32else()33else()
33 if (NOT QMLTESTRUNNER_BIN)34 if (NOT QMLTESTRUNNER_BIN)
34 message(WARNING "Qml tests disabled: qmltestrunner not found")35 message(WARNING "Qml tests disabled: qmltestrunner not found")
@@ -47,5 +48,6 @@
47 tst_ListWithActions.qml48 tst_ListWithActions.qml
48 tst_ContactPreviewPage.qml49 tst_ContactPreviewPage.qml
49 tst_VCardParser.qml50 tst_VCardParser.qml
51 tst_UbuntuContacts.qml
50)52)
51add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})53add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})
5254
=== modified file 'tests/qml/tst_ContactListModel.qml'
--- tests/qml/tst_ContactListModel.qml 2014-12-15 13:38:41 +0000
+++ tests/qml/tst_ContactListModel.qml 2015-06-29 15:36:05 +0000
@@ -61,7 +61,7 @@
6161
62 function test_contactImport()62 function test_contactImport()
63 {63 {
64 tryCompare(root.contactListModelObj, "contactCount", 3)64 tryCompare(root.contactListModelObj, "contactCount", 7)
65 }65 }
6666
67 function test_searchByPhoneNumber()67 function test_searchByPhoneNumber()
@@ -74,6 +74,9 @@
7474
75 root.contactListModelObj.filterTerm = "6"75 root.contactListModelObj.filterTerm = "6"
76 tryCompare(root.contactListModelObj, "contactCount", 3)76 tryCompare(root.contactListModelObj, "contactCount", 3)
77
78 root.contactListModelObj.filterTerm = "+55(81)8704-0000"
79 tryCompare(root.contactListModelObj, "contactCount", 1)
77 }80 }
7881
79 function test_searchByContactName()82 function test_searchByContactName()
@@ -101,6 +104,21 @@
101104
102 root.contactListModelObj.filterTerm = "1"105 root.contactListModelObj.filterTerm = "1"
103 tryCompare(root.contactListModelObj, "contactCount", 3)106 tryCompare(root.contactListModelObj, "contactCount", 3)
107
108 root.contactListModelObj.filterTerm = "Renato555"
109 tryCompare(root.contactListModelObj, "contactCount", 0)
110 }
111
112 function test_searchByNonLatinNames()
113 {
114 root.contactListModelObj.filterTerm = "Роман Щекин"
115 tryCompare(root.contactListModelObj, "contactCount", 1)
116
117 root.contactListModelObj.filterTerm = "亚"
118 tryCompare(root.contactListModelObj, "contactCount", 2)
119
120 root.contactListModelObj.filterTerm = "阿娜丝塔西"
121 tryCompare(root.contactListModelObj, "contactCount", 1)
104 }122 }
105 }123 }
106}124}
107125
=== added file 'tests/qml/tst_UbuntuContacts.qml'
--- tests/qml/tst_UbuntuContacts.qml 1970-01-01 00:00:00 +0000
+++ tests/qml/tst_UbuntuContacts.qml 2015-06-29 15:36:05 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18import QtTest 1.0
19import Ubuntu.Contacts 0.1
20
21Item {
22 id: root
23
24 TestCase {
25 id: uContactsTest
26 name: 'UBuntuContactTestCase'
27
28 function test_normalize_string()
29 {
30 compare(Contacts.normalized("não"), "nao")
31 compare(Contacts.normalized("josé"), "jose")
32 compare(Contacts.normalized("açaí"), "acai")
33 compare(Contacts.normalized("Роман Щекин"), "Роман Щекин")
34 compare(Contacts.normalized("阿娜丝塔西"), "阿娜丝塔西")
35 }
36
37 function test_containsLetters()
38 {
39 compare(Contacts.containsLetters("123456"), false)
40 compare(Contacts.containsLetters("(123)"), false)
41 compare(Contacts.containsLetters("Щекин"), true)
42 compare(Contacts.containsLetters("阿娜丝塔西"), true)
43 compare(Contacts.containsLetters("阿娜23西"), true)
44 }
45 }
46}

Subscribers

People subscribed via source and target branches