diff options
author | Matt Porter <mporter@konsulko.com> | 2018-05-22 11:33:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@automotivelinux.org> | 2018-05-22 11:33:10 +0000 |
commit | 361f599d0786b0b2729350a622c2a32a6a4862b5 (patch) | |
tree | 3337212cb405995d5247aa03197be298576e896a /app | |
parent | 4555731ec96de6e2ff29105e3a50df51a8278d2a (diff) | |
parent | b00822fe8b233f33adca86f93e5c1b90050983aa (diff) |
Merge "contacts: handle multiple numbers and types"
Diffstat (limited to 'app')
-rw-r--r-- | app/ContactsView.qml | 36 | ||||
-rw-r--r-- | app/Dialer.qml | 3 | ||||
-rw-r--r-- | app/app.pro | 2 | ||||
-rw-r--r-- | app/main.cpp | 3 | ||||
-rwxr-xr-x | app/models/ContactsModel.qml | 68 | ||||
-rw-r--r-- | app/numbertype.h | 33 |
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(); +}; |