summaryrefslogtreecommitdiffstats
path: root/app/models/ContactsModel.qml
diff options
context:
space:
mode:
authorMatt Porter <mporter@konsulko.com>2018-05-18 14:42:52 -0400
committerMatt Porter <mporter@konsulko.com>2018-05-21 11:20:36 -0400
commitb00822fe8b233f33adca86f93e5c1b90050983aa (patch)
tree50d78108535f2659e398d198564b28fd6462b8a0 /app/models/ContactsModel.qml
parent4e454de545544526cbea9d787df9ba76cb99d889 (diff)
contacts: handle multiple numbers and types
The current contact model has a few fixed fields for phone numbers and only one is displayed and able to be dialed from the contacts view. Update the model to support an array of tuples indicating each phone number and type of phone number (mobile, home, work, other) associated with a contact entry. Also, update the ContactsView so we see all phone numbers for a given contact. Bug-AGL: SPEC-1435 Change-Id: Ie883d3f06c0e4102e79546395dbb1712741bac8b Signed-off-by: Matt Porter <mporter@konsulko.com>
Diffstat (limited to 'app/models/ContactsModel.qml')
-rwxr-xr-xapp/models/ContactsModel.qml68
1 files changed, 44 insertions, 24 deletions
diff --git a/app/models/ContactsModel.qml b/app/models/ContactsModel.qml
index f8419ee..f53d2c8 100755
--- a/app/models/ContactsModel.qml
+++ b/app/models/ContactsModel.qml
@@ -1,68 +1,88 @@
/* Copyright (C) 2015, Jaguar Land Rover. All Rights Reserved.
* Copyright (C) 2015, The Qt Company. All Rights Reserved.
+ * Copyright (C) 2018, Konsulko Group
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import QtQml.Models 2.2
+import NumberType 1.0
ListModel {
function findName(number) {
for (var i = 0; i < count; i++) {
- var o = get(i)
- if (o.phone === number || o.mobile === number || o.work === number)
- return o.name
+ var entry = get(i)
+ for (var j = 0; j < entry.numbers.length; j++) {
+ if (entry.numbers[j].number) {
+ return entry.name
+ }
+ }
}
return "Unknown number"
}
ListElement {
name: "Art McGee"
- number: "503-616-4940"
- mobile: "503-715-6618"
- work: "972-256-9732"
+ numbers: [
+ ListElement {number: "503-715-6618"; type: NumberType.Mobile},
+ ListElement {number: "972-256-9732"; type: NumberType.Work},
+ ListElement {number: "503-616-4940"; type: NumberType.Home}
+ ]
}
ListElement {
name: "Dana Jonty"
- number: "503-000-0000"
- mobile: "503-209-3254"
- work: "972-000-0000"
+ numbers: [
+ ListElement {number: "503-209-3254"; type: NumberType.Mobile},
+ ListElement {number: "972-000-0000"; type: NumberType.Work},
+ ListElement {number: "503-000-0000"; type: NumberType.Other}
+ ]
}
ListElement {
name: "Jojo Derick"
- number: "503-000-0000"
- mobile: "503-209-3254"
- work: "972-000-0000"
+ numbers: [
+ ListElement {number: "503-209-3254"; type: NumberType.Mobile},
+ ListElement {number: "972-000-0000"; type: NumberType.Work},
+ ListElement {number: "503-000-0000"; type: NumberType.Other}
+ ]
}
ListElement {
name: "Kelly Johnson"
- number: "503-000-0000"
- mobile: "503-000-0000"
- work: "972-000-0000"
+ numbers: [
+ ListElement {number: "503-000-0000"; type: NumberType.Mobile},
+ ListElement {number: "972-000-0000"; type: NumberType.Work},
+ ListElement {number: "503-000-0000"; type: NumberType.Home}
+ ]
}
ListElement {
name: "Marco Morales"
- number: "503-000-0000"
- mobile: "503-209-3254"
- work: "972-000-0000"
+ numbers: [
+ ListElement {number: "503-209-3254"; type: NumberType.Mobile},
+ ListElement {number: "972-000-0000"; type: NumberType.Work},
+ ListElement {number: "503-000-0000"; type: NumberType.Home}
+ ]
}
ListElement {
name: "Rob Brad"
- number: "503-000-0000"
- mobile: "503-209-3254"
- work: "972-000-0000"
+ numbers: [
+ ListElement {number: "503-209-3254"; type: NumberType.Mobile},
+ ListElement {number: "972-000-0000"; type: NumberType.Work},
+ ListElement {number: "503-000-0000"; type: NumberType.Other}
+ ]
}
ListElement {
name: "Ted Gilbert"
- number: "503-000-0000"
- mobile: "503-209-3254"
- work: "972-000-0000"
+ numbers: [
+ ListElement {number: "503-209-3254"; type: NumberType.Mobile},
+ ListElement {number: "972-000-0000"; type: NumberType.Work},
+ ListElement {number: "503-101-1001"; type: NumberType.Home},
+ ListElement {number: "503-000-0000"; type: NumberType.Other}
+ ]
}
}