summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--app/ContactsView.qml36
-rw-r--r--app/Dialer.qml3
-rw-r--r--app/app.pro2
-rw-r--r--app/main.cpp3
-rwxr-xr-xapp/models/ContactsModel.qml68
-rw-r--r--app/numbertype.h33
6 files changed, 110 insertions, 35 deletions
diff --git a/app/ContactsView.qml b/app/ContactsView.qml
index 2a00cf5..8d37590 100644
--- a/app/ContactsView.qml
+++ b/app/ContactsView.qml
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Qt Company Ltd.
+ * Copyright (C) 2018 Konsulko Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +16,27 @@
*/
import QtQuick 2.6
-import QtQuick.Layouts 1.1
+import QtQuick.Layouts 1.3
import QtQuick.Controls 2.0
import AGL.Demo.Controls 1.0
+import NumberType 1.0
import 'models'
Item {
id: root
+ function display_type(type) {
+ if (type == NumberType.Mobile) {
+ return "M"
+ } else if (type == NumberType.Work) {
+ return "W"
+ } else if (type == NumberType.Home) {
+ return "H"
+ } else {
+ return "O"
+ }
+ }
+
signal call(var contact)
signal cancel
@@ -47,11 +61,11 @@ Item {
model: ContactsModel {}
delegate: MouseArea {
width: ListView.view.width
- height: width / 5
+ height: width / 3
RowLayout {
anchors.fill: parent
anchors.leftMargin: 200
- spacing: 20
+ spacing: 100
Image {
source: './images/HMI_ContactScreen_ImageHolder-01.svg'
}
@@ -59,14 +73,18 @@ Item {
Label {
Layout.fillWidth: true
color: '#59FF7F'
- text: model.name
+ font.pixelSize: 50
+ text: name
}
- Label {
- Layout.fillWidth: true
- font.pixelSize: 30
- text: model.number
- }
+ Repeater {
+ model: numbers
+ delegate: Label {
+ Layout.fillWidth: true
+ font.pixelSize: 50
+ text: display_type(type) + ": " + number
+ }
+ }
}
}
onClicked: {
diff --git a/app/Dialer.qml b/app/Dialer.qml
index 0bf51cf..f9c3e27 100644
--- a/app/Dialer.qml
+++ b/app/Dialer.qml
@@ -59,7 +59,8 @@ Item {
signal showContacts
function call(contact) {
name.text = contact.name
- number.text = contact.number
+ var rawNumber = contact.numbers.get(0).number
+ number.text = rawNumber.replace(/-/g, '')
callButton.checked = true
}
diff --git a/app/app.pro b/app/app.pro
index 3bb385a..41b90da 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -2,7 +2,7 @@ TARGET = phone
QT = quickcontrols2 websockets multimedia
SOURCES = main.cpp phone.cpp
-HEADERS = phone.h
+HEADERS = phone.h numbertype.h
SUBDIRS = telephony-binding
diff --git a/app/main.cpp b/app/main.cpp
index 6fd0e9a..ea6c8b5 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -28,6 +28,7 @@
#include <telephony.h>
#include "phone.h"
+#include "numbertype.h"
int main(int argc, char *argv[])
{
@@ -98,6 +99,8 @@ int main(int argc, char *argv[])
}
});
+ qmlRegisterUncreatableType<NumberType>("NumberType", 1, 0, "NumberType", "Not creatable as it is an enum type");
+
engine.load(QUrl(QStringLiteral("qrc:/Phone.qml")));
QObject *root = engine.rootObjects().first();
QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
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}
+ ]
}
}
diff --git a/app/numbertype.h b/app/numbertype.h
new file mode 100644
index 0000000..3c7e787
--- /dev/null
+++ b/app/numbertype.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2018 Konsulko Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <QObject>
+
+class NumberType
+{
+ Q_GADGET
+ public:
+ enum Value {
+ Mobile,
+ Work,
+ Home,
+ Other,
+ };
+ Q_ENUM(Value)
+
+ private:
+ NumberType();
+};