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

Proposed by Renato Araujo Oliveira Filho
Status: Superseded
Proposed branch: lp:~renatofilho/address-book-app/fix-1367906
Merge into: lp:address-book-app
Diff against target: 254 lines (+177/-10)
6 files modified
src/imports/Ubuntu/Contacts/ContactListModel.qml (+22/-10)
src/imports/Ubuntu/Contacts/contacts.cpp (+16/-0)
src/imports/Ubuntu/Contacts/contacts.h (+1/-0)
tests/data/tst_ContactListModel_data.vcf (+30/-0)
tests/qml/CMakeLists.txt (+2/-0)
tests/qml/tst_ContactListModel.qml (+106/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1367906
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+244787@code.launchpad.net

This proposal has been superseded by a proposal from 2014-12-15.

Commit message

Implemented search for unaccented contact names.

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

Fixed contact filter when using contact manager != "galera"

Unmerged revisions

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 2014-12-08 20:00:47 +0000
+++ src/imports/Ubuntu/Contacts/ContactListModel.qml 2014-12-15 19:48:22 +0000
@@ -16,6 +16,7 @@
1616
17import QtQuick 2.217import QtQuick 2.2
18import QtContacts 5.018import QtContacts 5.0
19import Ubuntu.Contacts 0.1
1920
20ContactModel {21ContactModel {
21 id: root22 id: root
@@ -66,19 +67,30 @@
66 id: contactTermFilter67 id: contactTermFilter
6768
68 property string value: ""69 property string value: ""
6970 property var phoneNumberFilter: DetailFilter {
70 DetailFilter {
71 detail: ContactDetail.DisplayLabel
72 field: DisplayLabel.Label
73 value: contactTermFilter.value
74 matchFlags: DetailFilter.MatchContains
75 }
76
77 DetailFilter {
78 detail: ContactDetail.PhoneNumber71 detail: ContactDetail.PhoneNumber
79 field: PhoneNumber.Number72 field: PhoneNumber.Number
80 value: contactTermFilter.value73 value: contactTermFilter.value
81 matchFlags: DetailFilter.MatchPhoneNumber | DetailFilter.MatchContains74 matchFlags: (DetailFilter.MatchPhoneNumber | DetailFilter.MatchContains)
75 }
76
77 filters: [
78 DetailFilter {
79 detail: ContactDetail.ExtendedDetail
80 field: root.manager === "galera" ? ExtendedDetail.Data : ContactDetail.DisplayLabel
81 value: root.manager === "galera" ? Contacts.normalized(contactTermFilter.value) : contactTermFilter.value
82 matchFlags: DetailFilter.MatchContains
83 }
84 ]
85
86 onValueChanged: {
87 var containsLetter = /^[a-zA-Z]/.test(value)
88
89 if (containsLetter && (filters.length > 1)) {
90 filters = [filters[0]]
91 } else if (!containsLetter) {
92 filters = [filters[0], phoneNumberFilter]
93 }
82 }94 }
83 },95 },
84 IntersectionFilter {96 IntersectionFilter {
8597
=== modified file 'src/imports/Ubuntu/Contacts/contacts.cpp'
--- src/imports/Ubuntu/Contacts/contacts.cpp 2014-07-05 22:00:02 +0000
+++ src/imports/Ubuntu/Contacts/contacts.cpp 2014-12-15 19:48:22 +0000
@@ -39,3 +39,19 @@
3939
40 return initials;40 return initials;
41}41}
42
43QString UbuntuContacts::normalized(const QString &value)
44{
45 QString s2 = value.normalized(QString::NormalizationForm_D);
46 QString out;
47
48 for (int i=0, j=s2.length(); i<j; i++)
49 {
50 // strip diacritic marks
51 if (s2.at(i).category() != QChar::Mark_NonSpacing &&
52 s2.at(i).category() != QChar::Mark_SpacingCombining) {
53 out.append(s2.at(i));
54 }
55 }
56 return out;
57}
4258
=== modified file 'src/imports/Ubuntu/Contacts/contacts.h'
--- src/imports/Ubuntu/Contacts/contacts.h 2014-07-05 22:00:02 +0000
+++ src/imports/Ubuntu/Contacts/contacts.h 2014-12-15 19:48:22 +0000
@@ -28,6 +28,7 @@
28 UbuntuContacts(QObject *parent = 0);28 UbuntuContacts(QObject *parent = 0);
2929
30 Q_INVOKABLE QString contactInitialsFromString(const QString &value);30 Q_INVOKABLE QString contactInitialsFromString(const QString &value);
31 Q_INVOKABLE QString normalized(const QString &value);
31};32};
3233
33#endif //_UBUNTU_CONTACTS_H_34#endif //_UBUNTU_CONTACTS_H_
3435
=== added file 'tests/data/tst_ContactListModel_data.vcf'
--- tests/data/tst_ContactListModel_data.vcf 1970-01-01 00:00:00 +0000
+++ tests/data/tst_ContactListModel_data.vcf 2014-12-15 19:48:22 +0000
@@ -0,0 +1,30 @@
1BEGIN:VCARD
2VERSION:3.0
3UID:47bbbfcab7c9b8ef0e7375074d22ff54905174bd
4X-QTPROJECT-EXTENDED-DETAIL:CLIENTPIDMAP;[\n "1"\n]\n
5N:First;Last;;;
6FN:First Last
7X-QTPROJECT-FAVORITE:false;0
8TEL:123456
9CATEGORIES:F
10END:VCARD
11BEGIN:VCARD
12VERSION:3.0
13UID:e5bb57fc852541dfc9ad29d583a36f1c353b65ed
14X-QTPROJECT-EXTENDED-DETAIL:CLIENTPIDMAP;[\n "1"\n]\n
15N:Fulano;de;tal6;;
16FN:Fulano de Tal6
17X-QTPROJECT-FAVORITE:false;0
18TEL:123678
19CATEGORIES:F
20END:VCARD
21BEGIN:VCARD
22VERSION:3.0
23UID:0d753ce1005dde92f69e4ddb62222240691693a0
24X-QTPROJECT-EXTENDED-DETAIL:CLIENTPIDMAP;[\n "1"\n]\n
25N:Fulano;da;Silva1;;;
26FN:Fulano da Silva1
27X-QTPROJECT-FAVORITE:false;0
28TEL:555666
29CATEGORIES:F
30END:VCARD
031
=== modified file 'tests/qml/CMakeLists.txt'
--- tests/qml/CMakeLists.txt 2014-11-10 20:14:36 +0000
+++ tests/qml/CMakeLists.txt 2014-12-15 19:48:22 +0000
@@ -22,6 +22,7 @@
2222
23if(QMLTESTRUNNER_BIN AND XVFB_RUN_BIN)23if(QMLTESTRUNNER_BIN AND XVFB_RUN_BIN)
24 declare_qml_test("contact_list" tst_ContactList.qml)24 declare_qml_test("contact_list" tst_ContactList.qml)
25 declare_qml_test("Contact_list_model" tst_ContactListModel.qml)
25 declare_qml_test("contact_editor" tst_ContactEditor.qml)26 declare_qml_test("contact_editor" tst_ContactEditor.qml)
26 declare_qml_test("contact_avatar" tst_ContactAvatar.qml)27 declare_qml_test("contact_avatar" tst_ContactAvatar.qml)
27 declare_qml_test("list_with_actions" tst_ListWithActions.qml)28 declare_qml_test("list_with_actions" tst_ListWithActions.qml)
@@ -40,6 +41,7 @@
40 tst_ContactEditor.qml41 tst_ContactEditor.qml
41 tst_ContactAvatar.qml42 tst_ContactAvatar.qml
42 tst_ContactList.qml43 tst_ContactList.qml
44 tst_ContactListModel.qml
43 tst_ListWithActions.qml45 tst_ListWithActions.qml
44 tst_ContactPreviewPage.qml46 tst_ContactPreviewPage.qml
45 tst_VCardParser.qml47 tst_VCardParser.qml
4648
=== added file 'tests/qml/tst_ContactListModel.qml'
--- tests/qml/tst_ContactListModel.qml 1970-01-01 00:00:00 +0000
+++ tests/qml/tst_ContactListModel.qml 2014-12-15 19:48:22 +0000
@@ -0,0 +1,106 @@
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.Components 1.1
20import Ubuntu.Test 0.1
21import Ubuntu.Contacts 0.1
22
23Item {
24 id: root
25
26 property var application
27 property var contactListModelObj
28
29 width: units.gu(40)
30 height: units.gu(80)
31
32 Component {
33 id: contactListModelCmp
34
35 ContactListModel {
36 id: contactListModel
37
38 property int contactCount: contacts ? contacts.length : 0
39
40 manager: "memory"
41 Component.onCompleted: importContacts(Qt.resolvedUrl("../data/tst_ContactListModel_data.vcf"))
42 }
43 }
44
45 UbuntuTestCase {
46 id: contactListModelTestCase
47 name: 'contactListModelTestCase'
48
49 when: windowShown
50
51 function init()
52 {
53 root.contactListModelObj = contactListModelCmp.createObject(root)
54 //waitForRendering(root.contactListModelObj)
55 }
56
57 function cleanup()
58 {
59 root.contactListModelObj.destroy()
60 }
61
62 function test_contactImport()
63 {
64 tryCompare(root.contactListModelObj, "contactCount", 3)
65 }
66
67 function test_searchByPhoneNumber()
68 {
69 root.contactListModelObj.filterTerm = "555"
70 tryCompare(root.contactListModelObj, "contactCount", 1)
71
72 root.contactListModelObj.filterTerm = "5"
73 tryCompare(root.contactListModelObj, "contactCount", 2)
74
75 root.contactListModelObj.filterTerm = "6"
76 tryCompare(root.contactListModelObj, "contactCount", 3)
77 }
78
79 function test_searchByContactName()
80 {
81 root.contactListModelObj.filterTerm = "First"
82 tryCompare(root.contactListModelObj, "contactCount", 1)
83
84 root.contactListModelObj.filterTerm = "Fulano"
85 tryCompare(root.contactListModelObj, "contactCount", 2)
86
87 root.contactListModelObj.filterTerm = "F"
88 tryCompare(root.contactListModelObj, "contactCount", 3)
89
90 root.contactListModelObj.filterTerm = "tal6"
91 tryCompare(root.contactListModelObj, "contactCount", 1)
92 }
93
94 function test_searchByNameAndNumber()
95 {
96 root.contactListModelObj.filterTerm = "First"
97 tryCompare(root.contactListModelObj, "contactCount", 1)
98
99 root.contactListModelObj.filterTerm = "555"
100 tryCompare(root.contactListModelObj, "contactCount", 1)
101
102 root.contactListModelObj.filterTerm = "1"
103 tryCompare(root.contactListModelObj, "contactCount", 3)
104 }
105 }
106}

Subscribers

People subscribed via source and target branches