summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2018-07-06 13:58:43 +0200
committerRobert Griebl <robert.griebl@pelagicore.com>2018-07-27 10:55:27 +0000
commitb65016eddb57d3b2cd7aa86b1f1bd0ee46f4f976 (patch)
treecddab4e99edc903f5bd68d911f601f63e1b33b75 /examples
parent91f8dcefa6b42542d98dda9528dab308045988c9 (diff)
downloadqtivi-b65016eddb57d3b2cd7aa86b1f1bd0ee46f4f976.tar.gz
Add a addressbook example for models and custom simulation
Adds the addressbook example which is used to explain how the autogeneration of models works. Task-number: AUTOSUITE-422 Change-Id: I2a0c6cba81dfdcf072da9584b731f170cc927711 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/ivicore/ivicore.pro5
-rw-r--r--examples/ivicore/qface-ivi-addressbook/backend_simulator/backend_simulator.pro23
-rw-r--r--examples/ivicore/qface-ivi-addressbook/demo/demo.pro38
-rw-r--r--examples/ivicore/qface-ivi-addressbook/demo/main.cpp72
-rw-r--r--examples/ivicore/qface-ivi-addressbook/demo/main.qml96
-rw-r--r--examples/ivicore/qface-ivi-addressbook/demo/qml.qrc5
-rw-r--r--examples/ivicore/qface-ivi-addressbook/example-ivi-addressbook.qface16
-rw-r--r--examples/ivicore/qface-ivi-addressbook/example-ivi-addressbook.yaml3
-rw-r--r--examples/ivicore/qface-ivi-addressbook/frontend/frontend.pro14
-rw-r--r--examples/ivicore/qface-ivi-addressbook/qface-ivi-addressbook.pro13
10 files changed, 284 insertions, 1 deletions
diff --git a/examples/ivicore/ivicore.pro b/examples/ivicore/ivicore.pro
index 8e7798d..e5895e5 100644
--- a/examples/ivicore/ivicore.pro
+++ b/examples/ivicore/ivicore.pro
@@ -1,5 +1,8 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += ivicore
-qtConfig(ivigenerator): SUBDIRS += qface-ivi-climate
+qtConfig(ivigenerator) {
+ SUBDIRS += qface-ivi-climate \
+ qface-ivi-addressbook
+}
qtConfig(ivigenerator): qtConfig(remoteobjects): SUBDIRS += qface-ivi-remote
diff --git a/examples/ivicore/qface-ivi-addressbook/backend_simulator/backend_simulator.pro b/examples/ivicore/qface-ivi-addressbook/backend_simulator/backend_simulator.pro
new file mode 100644
index 0000000..14ed034
--- /dev/null
+++ b/examples/ivicore/qface-ivi-addressbook/backend_simulator/backend_simulator.pro
@@ -0,0 +1,23 @@
+TEMPLATE=lib
+TARGET = $$qtLibraryTarget(example_ivi_addressbook)
+macos: CONFIG += debug_and_release build_all
+
+QT_FOR_CONFIG += ivicore
+!qtConfig(ivigenerator): error("No ivigenerator available")
+
+LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviAdressBookExample)
+DESTDIR = ../qtivi
+CONFIG += warn_off
+INCLUDEPATH += $$OUT_PWD/../frontend
+QT += core ivicore
+CONFIG += ivigenerator plugin
+
+QFACE_FORMAT = backend_simulator
+QFACE_SOURCES = ../example-ivi-addressbook.qface
+PLUGIN_TYPE = qtivi
+PLUGIN_EXTENDS = qtivi
+PLUGIN_CLASS_NAME = AddressBookPlugin
+
+CONFIG += install_ok # Do not cargo-cult this!
+target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-ivi-addressbook/qtivi/
+INSTALLS += target
diff --git a/examples/ivicore/qface-ivi-addressbook/demo/demo.pro b/examples/ivicore/qface-ivi-addressbook/demo/demo.pro
new file mode 100644
index 0000000..7905c88
--- /dev/null
+++ b/examples/ivicore/qface-ivi-addressbook/demo/demo.pro
@@ -0,0 +1,38 @@
+TARGET = qface-ivi-addressbook
+QMAKE_PROJECT_NAME = $$TARGET
+TEMPLATE = app
+
+QT += qml quick quickcontrols2
+CONFIG += c++11
+CONFIG -= app_bundle
+DESTDIR = ../
+
+LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviAdressBookExample)
+INCLUDEPATH += $$OUT_PWD/../frontend
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc
+
+QMAKE_RPATHDIR += $ORIGIN
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+# Additional import path used to resolve QML modules just for Qt Quick Designer
+QML_DESIGNER_IMPORT_PATH =
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+CONFIG += install_ok # Do not cargo-cult this!
+target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-ivi-addressbook
+INSTALLS += target
diff --git a/examples/ivicore/qface-ivi-addressbook/demo/main.cpp b/examples/ivicore/qface-ivi-addressbook/demo/main.cpp
new file mode 100644
index 0000000..4e69799
--- /dev/null
+++ b/examples/ivicore/qface-ivi-addressbook/demo/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: BSD-3-Clause
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QQuickStyle>
+
+#include <addressbookmodule.h>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ AddressBookModule::registerTypes();
+ AddressBookModule::registerQmlTypes(QLatin1String("IviAddressBook"), 1, 0);
+
+ QQuickStyle::setStyle("Material");
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
diff --git a/examples/ivicore/qface-ivi-addressbook/demo/main.qml b/examples/ivicore/qface-ivi-addressbook/demo/main.qml
new file mode 100644
index 0000000..30a6824
--- /dev/null
+++ b/examples/ivicore/qface-ivi-addressbook/demo/main.qml
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: BSD-3-Clause
+**
+****************************************************************************/
+
+import QtQuick 2.11
+import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
+import QtQuick.Window 2.2
+import IviAddressBook 1.0
+
+Window {
+ id: root
+ visible: true
+ width: 640
+ height: 480
+ title: qsTr("QtIVI AddressBook")
+
+ UiAddressBook {
+ id: addressBook
+ }
+ GroupBox {
+ anchors.fill: parent
+ anchors.margins: 10
+ title: "Contacts"
+
+ ColumnLayout {
+ anchors.fill: parent
+ //! [0]
+ ListView {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ model: addressBook.contacts
+
+ delegate: ItemDelegate {
+ width: parent.width
+ height: 100
+ text: model.item.forename + " " + model.item.name
+ }
+ }
+ //! [0]
+ Button {
+ Layout.fillWidth: true
+ text: "New Contact"
+ onClicked: addressBook.insertContact(0, AddressBookModule.contact())
+ }
+ }
+ }
+}
diff --git a/examples/ivicore/qface-ivi-addressbook/demo/qml.qrc b/examples/ivicore/qface-ivi-addressbook/demo/qml.qrc
new file mode 100644
index 0000000..5f6483a
--- /dev/null
+++ b/examples/ivicore/qface-ivi-addressbook/demo/qml.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/ivicore/qface-ivi-addressbook/example-ivi-addressbook.qface b/examples/ivicore/qface-ivi-addressbook/example-ivi-addressbook.qface
new file mode 100644
index 0000000..5ef26d6
--- /dev/null
+++ b/examples/ivicore/qface-ivi-addressbook/example-ivi-addressbook.qface
@@ -0,0 +1,16 @@
+module Example.IVI.AddressBook 1.0;
+
+@config: { qml_type: "UiAddressBook" }
+//! [0]
+interface AddressBook {
+ model<Contact> contacts;
+
+ void insertContact(int index, Contact contact);
+}
+
+struct Contact {
+ string forename;
+ string name;
+ int phone;
+}
+//! [0]
diff --git a/examples/ivicore/qface-ivi-addressbook/example-ivi-addressbook.yaml b/examples/ivicore/qface-ivi-addressbook/example-ivi-addressbook.yaml
new file mode 100644
index 0000000..4762f2a
--- /dev/null
+++ b/examples/ivicore/qface-ivi-addressbook/example-ivi-addressbook.yaml
@@ -0,0 +1,3 @@
+Example.IVI.AddressBook.AddressBook#contacts:
+ config_simulator:
+ default: [[ "John", "Doe", "12345" ], [ "Jane", "Doe", "67890" ]]
diff --git a/examples/ivicore/qface-ivi-addressbook/frontend/frontend.pro b/examples/ivicore/qface-ivi-addressbook/frontend/frontend.pro
new file mode 100644
index 0000000..78ef584
--- /dev/null
+++ b/examples/ivicore/qface-ivi-addressbook/frontend/frontend.pro
@@ -0,0 +1,14 @@
+TARGET = $$qtLibraryTarget(QtIviAdressBookExample)
+TEMPLATE = lib
+DESTDIR = ..
+macos: CONFIG += debug_and_release build_all
+QT_FOR_CONFIG += ivicore
+!qtConfig(ivigenerator): error("No ivigenerator available")
+QT += ivicore ivicore-private qml quick
+
+DEFINES += QT_BUILD_ADDRESSBOOK_LIB
+CONFIG += ivigenerator
+QFACE_SOURCES = ../example-ivi-addressbook.qface
+CONFIG += install_ok # Do not cargo-cult this!
+target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-iviaddressbook
+INSTALLS += target
diff --git a/examples/ivicore/qface-ivi-addressbook/qface-ivi-addressbook.pro b/examples/ivicore/qface-ivi-addressbook/qface-ivi-addressbook.pro
new file mode 100644
index 0000000..1f03305
--- /dev/null
+++ b/examples/ivicore/qface-ivi-addressbook/qface-ivi-addressbook.pro
@@ -0,0 +1,13 @@
+TEMPLATE = subdirs
+
+SUBDIRS = frontend \
+ backend_simulator \
+ demo
+
+CONFIG += ordered
+
+OTHER_FILES +=
+
+DISTFILES += \
+ example-ivi-addressbook.qface \
+ example-ivi-addressbook.yaml