diff options
Diffstat (limited to 'app')
72 files changed, 884 insertions, 4113 deletions
diff --git a/app/api/GPS.qml b/app/api/GPS.qml deleted file mode 100644 index 679c66e..0000000 --- a/app/api/GPS.qml +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2016 The Qt Company Ltd. - * Copyright (C) 2017 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. - */ - -import QtQuick 2.6 -import QtPositioning 5.5 -import QtWebSockets 1.0 - -WebSocket { - id: root - active: true - url: bindingAddress - - property string statusString: "waiting..." - property string apiString: "gps" - property string payloadLength: "9999" - - property bool loop_state: false - property bool running: false - - readonly property var msgid: { - "call": 2, - "retok": 3, - "reterr": 4, - "event": 5 - } - - onTextMessageReceived: { - var json = JSON.parse(message) - //console.debug("Raw response: " + message) - var request = json[2].request - var response = json[2].response - //console.debug("response: " + JSON.stringify(response)) - switch (json[0]) { - case msgid.call: - break - case msgid.retok: - break - case msgid.reterr: - root.statusString = "Bad return value, binding probably not installed" - break - case msgid.event: - var payload = JSON.parse(JSON.stringify(json[2])) - var event = payload.event - if (event == "gps/location") { - var data = json[2].data - var latitude = data.latitude - var longitude = data.longitude - var location = QtPositioning.coordinate(latitude, longitude) - if (map.followme || !map.location) { - map.center = location - } - map.location = location - if (data.speed > 1) { - map.updateCompass(data.track) - } - } - break - } - } - - onStatusChanged: { - switch (status) { - case WebSocket.Open: - console.debug("onStatusChanged: Open") - sendSocketMessage("subscribe", { value: "location" }) - break - case WebSocket.Error: - root.statusString = "WebSocket error: " + root.errorString - break - } - } - - function sendSocketMessage(verb, parameter) { - var requestJson = [ msgid.call, payloadLength, apiString + '/' - + verb, parameter ] - console.debug("sendSocketMessage: " + JSON.stringify(requestJson)) - sendTextMessage(JSON.stringify(requestJson)) - } -} diff --git a/app/api/GeoClue.qml b/app/api/GeoClue.qml deleted file mode 100644 index 6c8b2f1..0000000 --- a/app/api/GeoClue.qml +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2016 The Qt Company Ltd. - * Copyright (C) 2017 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. - */ - -import QtQuick 2.6 -import QtPositioning 5.5 -import QtWebSockets 1.0 - -WebSocket { - id: root - active: true - url: bindingAddress - - property string statusString: "waiting..." - property string apiString: "geoclue" - property string payloadLength: "9999" - - property bool loop_state: false - property bool running: false - - readonly property var msgid: { - "call": 2, - "retok": 3, - "reterr": 4, - "event": 5 - } - - onTextMessageReceived: { - var json = JSON.parse(message) - console.debug("Raw response: " + message) - var request = json[2].request - var response = json[2].response - console.debug("response: " + JSON.stringify(response)) - switch (json[0]) { - case msgid.call: - break - case msgid.retok: - var latitude = response.latitude - var longitude = response.longitude - map.location = QtPositioning.coordinate(latitude, longitude) - map.center = map.location - break - case msgid.reterr: - root.statusString = "Bad return value, binding probably not installed" - break - case msgid.event: - break - } - } - - onStatusChanged: { - switch (status) { - case WebSocket.Open: - console.debug("onStatusChanged: Open") - sendSocketMessage("location", 'None') - break - case WebSocket.Error: - root.statusString = "WebSocket error: " + root.errorString - break - } - } - - function sendSocketMessage(verb, parameter) { - var requestJson = [ msgid.call, payloadLength, apiString + '/' - + verb, parameter ] - console.debug("sendSocketMessage: " + JSON.stringify(requestJson)) - sendTextMessage(JSON.stringify(requestJson)) - } -} diff --git a/app/api/GeoFence.qml b/app/api/GeoFence.qml deleted file mode 100644 index 7061984..0000000 --- a/app/api/GeoFence.qml +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2016 The Qt Company Ltd. - * Copyright (C) 2017 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. - */ - -import QtQuick 2.6 -import QtPositioning 5.5 -import QtWebSockets 1.0 - -WebSocket { - id: root - active: true - url: bindingAddress - - property string statusString: "waiting..." - property string apiString: "geofence" - property string payloadLength: "9999" - - property bool loop_state: false - property bool running: false - - readonly property var msgid: { - "call": 2, - "retok": 3, - "reterr": 4, - "event": 5 - } - - onTextMessageReceived: { - var json = JSON.parse(message) - console.debug("Raw response: " + message) - var request = json[2].request - var response = json[2].response - console.debug("response: " + JSON.stringify(response)) - switch (json[0]) { - case msgid.call: - break - case msgid.retok: - break - case msgid.reterr: - root.statusString = "Bad return value, binding probably not installed" - break - case msgid.event: - var payload = JSON.parse(JSON.stringify(json[2])) - var event = payload.event - if (event == "geofence/fence") { - var data = json[2].data - console.log("geofence event - name: " + data.name + " state: " + data.state) - } - break - } - } - - onStatusChanged: { - switch (status) { - case WebSocket.Open: - console.debug("onStatusChanged: Open") - //sendSocketMessage("add_fence", { name: "Stop Sign", - // bbox: { min_longitude: -122.499217, max_longitude: -122.498732, - // min_latitude: 45.600136, max_latitude: 45.600384 } - // }) - sendSocketMessage("subscribe", { value: "fence" }) - break - case WebSocket.Error: - root.statusString = "WebSocket error: " + root.errorString - break - } - } - - function sendSocketMessage(verb, parameter) { - var requestJson = [ msgid.call, payloadLength, apiString + '/' - + verb, parameter ] - console.debug("sendSocketMessage: " + JSON.stringify(requestJson)) - sendTextMessage(JSON.stringify(requestJson)) - } -} diff --git a/app/app.pri b/app/app.pri index c3b1fd1..a1f6562 100644 --- a/app/app.pri +++ b/app/app.pri @@ -1,13 +1,18 @@ -TEMPLATE = app -QMAKE_LFLAGS += "-Wl,--hash-style=gnu -Wl,--as-needed" - load(configure) + qtCompileTest(libhomescreen) +qtCompileTest(qlibwindowmanager) config_libhomescreen { CONFIG += link_pkgconfig - PKGCONFIG += homescreen + PKGCONFIG += libhomescreen DEFINES += HAVE_LIBHOMESCREEN } +config_qlibwindowmanager { + CONFIG += link_pkgconfig + PKGCONFIG += qlibwindowmanager + DEFINES += HAVE_QLIBWINDOWMANAGER +} + DESTDIR = $${OUT_PWD}/../package/root/bin diff --git a/app/app.pro b/app/app.pro index 4eef717..bedd56a 100644 --- a/app/app.pro +++ b/app/app.pro @@ -1,47 +1,30 @@ -TARGET = navigation +TARGET = tbtnavi +TEMPLATE = app -CONFIG += link_pkgconfig -PKGCONFIG += libhomescreen qlibwindowmanager +QT += qml network quick positioning location sql widgets -QT = qml network quick positioning location quickcontrols2 +CONFIG += c++14 -static { - QTPLUGIN += qtvirtualkeyboardplugin - QT += svg +include(app.pri) + +ios|android { + QT -= widgets } -SOURCES += main.cpp +SOURCES += \ + main.cpp \ + qcheapruler.cpp + +HEADERS += \ + qcheapruler.hpp + +INCLUDEPATH += \ + ../include + +OTHER_FILES += \ + qmapboxlgapp.qml RESOURCES += \ - mapviewer.qrc - -OTHER_FILES +=mapviewer.qml \ - helper.js \ - map/MapComponent.qml \ - map/Marker.qml \ - map/CircleItem.qml \ - map/RectangleItem.qml \ - map/PolylineItem.qml \ - map/PolygonItem.qml \ - map/ImageItem.qml \ - menus/ItemPopupMenu.qml \ - menus/MainMenu.qml \ - menus/MapPopupMenu.qml \ - menus/MarkerPopupMenu \ - forms/Geocode.qml \ - forms/GeocodeForm.ui.qml\ - forms/Message.qml \ - forms/MessageForm.ui.qml \ - forms/ReverseGeocode.qml \ - forms/ReverseGeocodeForm.ui.qml \ - forms/RouteCoordinate.qml \ - forms/Locale.qml \ - forms/LocaleForm.ui.qml \ - forms/RouteAddress.qml \ - forms/RouteAddressForm.ui.qml \ - forms/RouteCoordinateForm.ui.qml \ - forms/RouteList.qml \ - forms/RouteListDelegate.qml \ - forms/RouteListHeader.qml + images/images.qrc \ + app.qrc -include(app.pri) diff --git a/app/app.qrc b/app/app.qrc new file mode 100644 index 0000000..f91201a --- /dev/null +++ b/app/app.qrc @@ -0,0 +1,9 @@ +<RCC> + <qresource prefix="/"> + <file>qml/qmldir</file> + <file>qml/CustomLabel.qml</file> + <file>qml/DateAndTime.qml</file> + <file>qml/Main.qml</file> + <file>qml/MapWindow.qml</file> + </qresource> +</RCC> diff --git a/app/config.tests/libhomescreen/.qmake.stash b/app/config.tests/libhomescreen/.qmake.stash new file mode 100644 index 0000000..d0807e7 --- /dev/null +++ b/app/config.tests/libhomescreen/.qmake.stash @@ -0,0 +1,24 @@ +QMAKE_CXX.INCDIRS = \ + /usr/include/c++/5 \ + /usr/include/x86_64-linux-gnu/c++/5 \ + /usr/include/c++/5/backward \ + /usr/lib/gcc/x86_64-linux-gnu/5/include \ + /usr/local/include \ + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed \ + /usr/include/x86_64-linux-gnu \ + /usr/include +QMAKE_CXX.LIBDIRS = \ + /usr/lib/gcc/x86_64-linux-gnu/5 \ + /usr/lib/x86_64-linux-gnu \ + /usr/lib \ + /lib/x86_64-linux-gnu \ + /lib +QMAKE_CXX.QT_COMPILER_STDCXX = 199711L +QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 5 +QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 4 +QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 +QMAKE_CXX.COMPILER_MACROS = \ + QT_COMPILER_STDCXX \ + QMAKE_GCC_MAJOR_VERSION \ + QMAKE_GCC_MINOR_VERSION \ + QMAKE_GCC_PATCH_VERSION diff --git a/app/config.tests/libhomescreen/libhomescreen.cpp b/app/config.tests/libhomescreen/libhomescreen.cpp new file mode 100644 index 0000000..d698b05 --- /dev/null +++ b/app/config.tests/libhomescreen/libhomescreen.cpp @@ -0,0 +1,8 @@ +#include <libhomescreen.hpp> + +int main(int argc,char **argv) +{ + LibHomeScreen libHomeScreen; + return 0; +} + diff --git a/app/config.tests/libhomescreen/libhomescreen.pro b/app/config.tests/libhomescreen/libhomescreen.pro new file mode 100644 index 0000000..7d43112 --- /dev/null +++ b/app/config.tests/libhomescreen/libhomescreen.pro @@ -0,0 +1,5 @@ +SOURCES = libhomescreen.cpp + +CONFIG -= qt +CONFIG += link_pkgconfig +PKGCONFIG += libhomescreen diff --git a/app/config.tests/qlibwindowmanager/.qmake.stash b/app/config.tests/qlibwindowmanager/.qmake.stash new file mode 100644 index 0000000..d0807e7 --- /dev/null +++ b/app/config.tests/qlibwindowmanager/.qmake.stash @@ -0,0 +1,24 @@ +QMAKE_CXX.INCDIRS = \ + /usr/include/c++/5 \ + /usr/include/x86_64-linux-gnu/c++/5 \ + /usr/include/c++/5/backward \ + /usr/lib/gcc/x86_64-linux-gnu/5/include \ + /usr/local/include \ + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed \ + /usr/include/x86_64-linux-gnu \ + /usr/include +QMAKE_CXX.LIBDIRS = \ + /usr/lib/gcc/x86_64-linux-gnu/5 \ + /usr/lib/x86_64-linux-gnu \ + /usr/lib \ + /lib/x86_64-linux-gnu \ + /lib +QMAKE_CXX.QT_COMPILER_STDCXX = 199711L +QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 5 +QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 4 +QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 +QMAKE_CXX.COMPILER_MACROS = \ + QT_COMPILER_STDCXX \ + QMAKE_GCC_MAJOR_VERSION \ + QMAKE_GCC_MINOR_VERSION \ + QMAKE_GCC_PATCH_VERSION diff --git a/app/config.tests/qlibwindowmanager/qlibwindowmanager.cpp b/app/config.tests/qlibwindowmanager/qlibwindowmanager.cpp new file mode 100644 index 0000000..bb95c93 --- /dev/null +++ b/app/config.tests/qlibwindowmanager/qlibwindowmanager.cpp @@ -0,0 +1,8 @@ +#include <qlibwindowmanager.h> + +int main(int argc,char **argv) +{ + QLibWindowmanager qwm; + return 0; +} + diff --git a/app/config.tests/qlibwindowmanager/qlibwindowmanager.pro b/app/config.tests/qlibwindowmanager/qlibwindowmanager.pro new file mode 100644 index 0000000..cb51d98 --- /dev/null +++ b/app/config.tests/qlibwindowmanager/qlibwindowmanager.pro @@ -0,0 +1,5 @@ +SOURCES = qlibwindowmanager.cpp + +CONFIG += qt +CONFIG += link_pkgconfig +PKGCONFIG += qlibwindowmanager diff --git a/app/forms/Geocode.qml b/app/forms/Geocode.qml deleted file mode 100644 index 9e27325..0000000 --- a/app/forms/Geocode.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtPositioning 5.5 - -GeocodeForm { - - property variant address - signal showPlace(variant address) - signal closeForm() - - goButton.onClicked: { - // fill out the Address element - address.street = street.text - address.city = city.text - address.state = state.text - address.country = country.text - address.postalCode = postalCode.text - showPlace(address) - } - - clearButton.onClicked: { - street.text = "" - city.text = "" - state.text = "" - country.text = "" - postalCode.text = "" - } - - cancelButton.onClicked: { - closeForm() - } - - Component.onCompleted: { - street.text = address.street - city.text = address.city - state.text = address.state - country.text = address.country - postalCode.text = address.postalCode - } -} - - diff --git a/app/forms/GeocodeForm.ui.qml b/app/forms/GeocodeForm.ui.qml deleted file mode 100644 index 3ed715a..0000000 --- a/app/forms/GeocodeForm.ui.qml +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 - -Item { - property alias goButton: goButton - property alias clearButton: clearButton - property alias postalCode: postalCode - property alias street: street - property alias city: city - property alias state: state - property alias country: country - property alias cancelButton: cancelButton - Rectangle { - id: tabRectangle - y: 20 - height: tabTitle.height * 2 - color: "#46a2da" - anchors.rightMargin: 0 - anchors.leftMargin: 0 - anchors.left: parent.left - anchors.right: parent.right - - Label { - id: tabTitle - color: "#ffffff" - text: qsTr("Geocode") - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - } - - Item { - id: item2 - anchors.rightMargin: 20 - anchors.leftMargin: 20 - anchors.bottomMargin: 20 - anchors.topMargin: 20 - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.top: tabRectangle.bottom - - - GridLayout { - id: gridLayout3 - anchors.rightMargin: 0 - anchors.bottomMargin: 0 - anchors.leftMargin: 0 - anchors.topMargin: 0 - rowSpacing: 10 - rows: 1 - columns: 2 - anchors.fill: parent - - Label { - id: label2 - text: qsTr("Street") - } - - TextField { - id: street - Layout.fillWidth: true - } - - Label { - id: label3 - text: qsTr("City") - } - - TextField { - id: city - Layout.fillWidth: true - } - - Label { - id: label4 - text: qsTr("State") - } - - TextField { - id: state - Layout.fillWidth: true - } - - Label { - id: label5 - text: qsTr("Country") - } - - TextField { - id: country - Layout.fillWidth: true - } - - Label { - id: label6 - text: qsTr("Postal Code") - } - - TextField { - id: postalCode - Layout.fillWidth: true - } - - RowLayout { - id: rowLayout1 - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignRight - - Button { - id: goButton - text: qsTr("Proceed") - } - - Button { - id: clearButton - text: qsTr("Clear") - } - - Button { - id: cancelButton - text: qsTr("Cancel") - } - } - - Item { - Layout.fillHeight: true - Layout.columnSpan: 2 - } - } - } -} diff --git a/app/forms/Locale.qml b/app/forms/Locale.qml deleted file mode 100644 index 6e76c98..0000000 --- a/app/forms/Locale.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtPositioning 5.5 - -LocaleForm { - property string locale - signal selectLanguage(string language) - signal closeForm() - - goButton.onClicked: { - - if (!languageGroup.current) return - - if (otherRadioButton.checked) { - selectLanguage(language.text) - } else { - selectLanguage(languageGroup.current.text) - } - } - - clearButton.onClicked: { - language.text = "" - } - - cancelButton.onClicked: { - closeForm() - } - - Component.onCompleted: { - switch (locale) { - case "en": - enRadioButton.checked = true; - break - case "fr": - frRadioButton.checked = true; - break - default: - otherRadioButton.checked = true; - language.text = locale - break - } - } -} diff --git a/app/forms/LocaleForm.ui.qml b/app/forms/LocaleForm.ui.qml deleted file mode 100644 index 91a0847..0000000 --- a/app/forms/LocaleForm.ui.qml +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 - -Item { - property alias clearButton: clearButton - property alias goButton: goButton - property alias cancelButton: cancelButton - property alias tabTitle: tabTitle - property alias languageGroup: languageGroup - property alias enRadioButton: enRadioButton - property alias frRadioButton: frRadioButton - property alias otherRadioButton: otherRadioButton - property alias language: language - - Rectangle { - id: tabRectangle - y: 20 - height: tabTitle.height * 2 - color: "#46a2da" - anchors.rightMargin: 0 - anchors.leftMargin: 0 - anchors.left: parent.left - anchors.right: parent.right - - Label { - id: tabTitle - color: "#ffffff" - text: "Locale" - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - } - - Item { - id: item2 - anchors.rightMargin: 20 - anchors.leftMargin: 20 - anchors.bottomMargin: 20 - anchors.topMargin: 20 - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.top: tabRectangle.bottom - - GridLayout { - id: gridLayout3 - anchors.rightMargin: 0 - anchors.bottomMargin: 0 - anchors.leftMargin: 0 - anchors.topMargin: 0 - rowSpacing: 10 - rows: 1 - columns: 2 - anchors.fill: parent - - ExclusiveGroup { id: languageGroup } - RadioButton { - id: enRadioButton - text: qsTr("en") - exclusiveGroup: languageGroup - Layout.columnSpan: 2 - } - - RadioButton { - id: frRadioButton - text: qsTr("fr") - exclusiveGroup: languageGroup - Layout.columnSpan: 2 - } - - RadioButton { - id: otherRadioButton - text: qsTr("Other") - exclusiveGroup: languageGroup - } - - TextField { - id: language - Layout.fillWidth: true - placeholderText: qsTr("") - } - - RowLayout { - id: rowLayout1 - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignRight - - Button { - id: goButton - text: qsTr("Proceed") - } - - Button { - id: clearButton - text: qsTr("Clear") - } - - Button { - id: cancelButton - text: qsTr("Cancel") - } - } - - Item { - Layout.fillHeight: true - Layout.columnSpan: 2 - } - - - } - } -} diff --git a/app/forms/Message.qml b/app/forms/Message.qml deleted file mode 100644 index 5d12c1f..0000000 --- a/app/forms/Message.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 - -MessageForm { - property string title - property string message - property variant backPage - - signal closeForm(variant backPage) - - button.onClicked: { - closeForm(backPage) - } - - Component.onCompleted: { - messageText.text = message - messageTitle.text = title - } -} diff --git a/app/forms/MessageForm.ui.qml b/app/forms/MessageForm.ui.qml deleted file mode 100644 index a300841..0000000 --- a/app/forms/MessageForm.ui.qml +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 - -Item { - id: root - property alias messageText: messageText - property alias messageTitle: messageTitle - property alias button: button - - Rectangle { - id: tabRectangle - y: 20 - height: messageTitle.height * 2 - color: "#46a2da" - anchors.rightMargin: 0 - anchors.leftMargin: 0 - anchors.left: parent.left - anchors.right: parent.right - - Label { - id: messageTitle - color: "#ffffff" - text: qsTr("type") - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - } - - Item { - anchors.rightMargin: 20 - anchors.leftMargin: 20 - anchors.bottomMargin: 20 - anchors.topMargin: 20 - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.top: tabRectangle.bottom - - ColumnLayout { - id: columnLayout1 - spacing: 20 - anchors.fill: parent - - Label { - id: messageText - text: qsTr("message") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - wrapMode: Text.WordWrap - textFormat: Text.RichText - } - - Button { - id: button - text: qsTr("OK") - Layout.alignment: Qt.AlignHCenter - } - - Item { - Layout.fillHeight: true - } - } - } -} - diff --git a/app/forms/ReverseGeocode.qml b/app/forms/ReverseGeocode.qml deleted file mode 100644 index 9e3cd65..0000000 --- a/app/forms/ReverseGeocode.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtPositioning 5.5 - -//Reverse Geocode Dialog -ReverseGeocodeForm { - property string title; - property variant coordinate - signal showPlace(variant coordinate) - signal closeForm() - - goButton.onClicked: { - var coordinate = QtPositioning.coordinate(parseFloat(latitude.text), - parseFloat(longitude.text)); - if (coordinate.isValid) { - showPlace(coordinate) - } - } - - clearButton.onClicked: { - latitude.text = "" - longitude.text = "" - } - - cancelButton.onClicked: { - closeForm() - } - - Component.onCompleted: { - latitude.text = "" + coordinate.latitude - longitude.text = "" + coordinate.longitude - if (title.length != 0) { - tabTitle.text = title; - } - } -} diff --git a/app/forms/ReverseGeocodeForm.ui.qml b/app/forms/ReverseGeocodeForm.ui.qml deleted file mode 100644 index 29eaec9..0000000 --- a/app/forms/ReverseGeocodeForm.ui.qml +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 - -Item { - property alias clearButton: clearButton - property alias goButton: goButton - property alias longitude: longitude - property alias latitude: latitude - property alias cancelButton: cancelButton - property alias tabTitle: tabTitle - Rectangle { - id: tabRectangle - y: 20 - height: tabTitle.height * 2 - color: "#46a2da" - anchors.rightMargin: 0 - anchors.leftMargin: 0 - anchors.left: parent.left - anchors.right: parent.right - - Label { - id: tabTitle - color: "#ffffff" - text: qsTr("Reverse Geocode") - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - } - - Item { - id: item2 - anchors.rightMargin: 20 - anchors.leftMargin: 20 - anchors.bottomMargin: 20 - anchors.topMargin: 20 - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.top: tabRectangle.bottom - - GridLayout { - id: gridLayout3 - anchors.rightMargin: 0 - anchors.bottomMargin: 0 - anchors.leftMargin: 0 - anchors.topMargin: 0 - rowSpacing: 10 - rows: 1 - columns: 2 - anchors.fill: parent - - Label { - id: label2 - text: qsTr("Latitude") - } - - TextField { - id: latitude - Layout.fillWidth: true - } - - Label { - id: label3 - text: qsTr("Longitude") - } - - TextField { - id: longitude - Layout.fillWidth: true - placeholderText: qsTr("") - } - - RowLayout { - id: rowLayout1 - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignRight - - Button { - id: goButton - text: qsTr("Proceed") - } - - Button { - id: clearButton - text: qsTr("Clear") - } - - Button { - id: cancelButton - text: qsTr("Cancel") - } - } - Item { - Layout.fillHeight: true - Layout.columnSpan: 2 - } - } - } -} diff --git a/app/forms/RouteAddress.qml b/app/forms/RouteAddress.qml deleted file mode 100644 index b8b8897..0000000 --- a/app/forms/RouteAddress.qml +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtLocation 5.6 -import QtPositioning 5.5 - -RouteAddressForm { - property alias plugin : tempGeocodeModel.plugin; - property variant toAddress; - property variant fromCoordinate; - signal showMessage(string topic, string message) - signal showRoute(variant startCoordinate,variant endCoordinate) - signal closeForm() - - goButton.onClicked: { - tempGeocodeModel.reset() - toAddress.country = toCountry.text - toAddress.street = toStreet.text - toAddress.city = toCity.text - toAddress.state = toState.text - tempGeocodeModel.startCoordinate = fromCoordinate - tempGeocodeModel.endCoordinate = QtPositioning.coordinate() - tempGeocodeModel.query = fromCoordinate - tempGeocodeModel.update(); - goButton.enabled = false; - } - - clearButton.onClicked: { - toStreet.text = "" - toCity.text = "" - toState.text = "" - toCountry.text = "" - } - - cancelButton.onClicked: { - closeForm() - } - - Component.onCompleted: { - toStreet.text = toAddress.street - toCity.text = toAddress.city - toState.text = toAddress.state - toCountry.text = toAddress.country - } - - GeocodeModel { - id: tempGeocodeModel - - property int success: 0 - property variant startCoordinate - property variant endCoordinate - - onCountChanged: { - if (success == 1 && count == 1) { - query = toAddress - update(); - } - } - - onStatusChanged: { - if ((status == GeocodeModel.Ready) && count >= 1) { - success++ - if (success == 1) { - startCoordinate.latitude = get(0).coordinate.latitude - startCoordinate.longitude = get(0).coordinate.longitude - } - if (success == 2) { - endCoordinate.latitude = get(0).coordinate.latitude - endCoordinate.longitude = get(0).coordinate.longitude - success = 0 - if (startCoordinate.isValid && endCoordinate.isValid) - showRoute(startCoordinate,endCoordinate) - else - goButton.enabled = true - } - } else if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error)) { - var st = (success == 0 ) ? "start" : "end" - success = 0 - if ((status == GeocodeModel.Ready) && (count == 0 )) { - showMessage(qsTr("Geocode Error"),qsTr("Unsuccessful geocode")); - goButton.enabled = true; - } - else if (status == GeocodeModel.Error) { - showMessage(qsTr("Geocode Error"), - qsTr("Unable to find location for the") + " " + - st + " " +qsTr("point")) - goButton.enabled = true; - } - else if ((status == GeocodeModel.Ready) && (count > 1 )) { - showMessage(qsTr("Ambiguous geocode"), - count + " " + qsTr("results found for the") + - " " + st + " " +qsTr("point, please specify location")) - goButton.enabled = true; - } - } - } - } -} diff --git a/app/forms/RouteAddressForm.ui.qml b/app/forms/RouteAddressForm.ui.qml deleted file mode 100644 index a0ace76..0000000 --- a/app/forms/RouteAddressForm.ui.qml +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 - -Item { - property alias toStreet: toStreet - property alias toCity: toCity - property alias toState: toState - property alias toCountry: toCountry - property alias goButton: goButton - property alias clearButton: clearButton - property alias cancelButton: cancelButton - - Rectangle { - id: tabRectangle - y: 20 - height: tabTitle.height * 2 - color: "#46a2da" - anchors.rightMargin: 0 - anchors.leftMargin: 0 - anchors.left: parent.left - anchors.right: parent.right - - Label { - id: tabTitle - color: "#ffffff" - text: qsTr("Route Address") - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - } - - Item { - id: item2 - anchors.rightMargin: 20 - anchors.leftMargin: 20 - anchors.bottomMargin: 20 - anchors.topMargin: 20 - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.top: tabRectangle.bottom - - GridLayout { - id: gridLayout3 - rowSpacing: 10 - rows: 1 - columns: 2 - anchors.fill: parent - - Label { - id: label6 - text: qsTr("To") - font.bold: true - anchors.horizontalCenter: parent.horizontalCenter - Layout.columnSpan: 2 - } - - Label { - id: label4 - text: qsTr("Street") - } - - TextField { - id: toStreet - Layout.fillWidth: true - } - - Label { - id: label5 - text: qsTr("City") - } - - TextField { - id: toCity - Layout.fillWidth: true - } - - Label { - id: label9 - text: qsTr("State") - } - - TextField { - id: toState - Layout.fillWidth: true - } - - Label { - id: label8 - text: qsTr("Country") - } - - TextField { - id: toCountry - Layout.fillWidth: true - } - - RowLayout { - id: rowLayout1 - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignRight - - Button { - id: goButton - text: qsTr("Proceed") - } - - Button { - id: clearButton - text: qsTr("Clear") - } - - Button { - id: cancelButton - text: qsTr("Cancel") - } - } - - Item { - Layout.fillHeight: true - Layout.columnSpan: 2 - } - } - } -} diff --git a/app/forms/RouteCoordinate.qml b/app/forms/RouteCoordinate.qml deleted file mode 100644 index f195ac7..0000000 --- a/app/forms/RouteCoordinate.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtPositioning 5.5 - -RouteCoordinateForm { - property variant toCoordinate - property variant fromCoordinate - signal showRoute(variant startCoordinate,variant endCoordinate) - signal closeForm() - - goButton.onClicked: { - var startCoordinate = QtPositioning.coordinate(parseFloat(fromLatitude.text), - parseFloat(fromLongitude.text)); - var endCoordinate = QtPositioning.coordinate(parseFloat(toLatitude.text), - parseFloat(toLongitude.text)); - if (startCoordinate.isValid && endCoordinate.isValid) { - goButton.enabled = false; - showRoute(startCoordinate,endCoordinate) - } - } - - clearButton.onClicked: { - fromLatitude.text = "" - fromLongitude.text = "" - toLatitude.text = "" - toLongitude.text = "" - } - - cancelButton.onClicked: { - closeForm() - } - - Component.onCompleted: { - fromLatitude.text = "" + fromCoordinate.latitude - fromLongitude.text = "" + fromCoordinate.longitude - toLatitude.text = "" + toCoordinate.latitude - toLongitude.text = "" + toCoordinate.longitude - } -} - diff --git a/app/forms/RouteCoordinateForm.ui.qml b/app/forms/RouteCoordinateForm.ui.qml deleted file mode 100644 index bd492d3..0000000 --- a/app/forms/RouteCoordinateForm.ui.qml +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 - -Item { - property alias fromLatitude: fromLatitude - property alias fromLongitude: fromLongitude - property alias toLatitude: toLatitude - property alias toLongitude: toLongitude - property alias clearButton: clearButton - property alias goButton: goButton - property alias cancelButton: cancelButton - - Rectangle { - id: tabRectangle - y: 20 - height: tabTitle.height * 2 - color: "#46a2da" - anchors.rightMargin: 0 - anchors.leftMargin: 0 - anchors.left: parent.left - anchors.right: parent.right - - Label { - id: tabTitle - color: "#ffffff" - text: qsTr("Route Coordinates") - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - } - - Item { - id: item2 - anchors.rightMargin: 20 - anchors.leftMargin: 20 - anchors.bottomMargin: 20 - anchors.topMargin: 20 - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.top: tabRectangle.bottom - - GridLayout { - id: gridLayout3 - rowSpacing: 10 - rows: 1 - columns: 2 - anchors.fill: parent - - Label { - id: label1 - text: qsTr("From") - anchors.horizontalCenter: parent.horizontalCenter - font.bold: true - Layout.columnSpan : 2 - } - - Label { - id: label2 - text: qsTr("Latitude") - } - - TextField { - id: fromLatitude - Layout.fillWidth: true - } - - Label { - id: label3 - text: qsTr("Longitude") - } - - TextField { - id: fromLongitude - Layout.fillWidth: true - } - - Label { - id: label6 - text: qsTr("To") - anchors.horizontalCenter: parent.horizontalCenter - font.bold: true - Layout.columnSpan: 2 - } - - Label { - id: label4 - text: qsTr("Latitude") - } - - TextField { - id: toLatitude - Layout.fillWidth: true - } - - Label { - id: label5 - text: qsTr("Longitude") - } - - TextField { - id: toLongitude - Layout.fillWidth: true - } - - RowLayout { - id: rowLayout1 - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignRight - Button { - id: goButton - text: qsTr("Proceed") - } - - Button { - id: clearButton - text: qsTr("Clear") - } - - Button { - id: cancelButton - text: qsTr("Cancel") - } - } - Item { - Layout.fillHeight: true - Layout.columnSpan: 2 - } - } - } -} diff --git a/app/forms/RouteList.qml b/app/forms/RouteList.qml deleted file mode 100644 index 27fa572..0000000 --- a/app/forms/RouteList.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import "../helper.js" as Helper - -//! [routeinfomodel0] -ListView { -//! [routeinfomodel0] - property variant routeModel - property string totalTravelTime - property string totalDistance - signal closeForm() -//! [routeinfomodel1] - interactive: true - model: ListModel { id: routeInfoModel } - header: RouteListHeader {} - delegate: RouteListDelegate{ - routeIndex.text: index + 1 - routeInstruction.text: instruction - routeDistance.text: distance - } -//! [routeinfomodel1] - footer: Button { - anchors.horizontalCenter: parent.horizontalCenter - text: qsTr("Close") - onClicked: { - closeForm() - } - } - - Component.onCompleted: { - //! [routeinfomodel2] - routeInfoModel.clear() - if (routeModel.count > 0) { - for (var i = 0; i < routeModel.get(0).segments.length; i++) { - routeInfoModel.append({ - "instruction": routeModel.get(0).segments[i].maneuver.instructionText, - "distance": Helper.formatDistance(routeModel.get(0).segments[i].maneuver.distanceToNextInstruction) - }); - } - } - //! [routeinfomodel2] - totalTravelTime = routeModel.count == 0 ? "" : Helper.formatTime(routeModel.get(0).travelTime) - totalDistance = routeModel.count == 0 ? "" : Helper.formatDistance(routeModel.get(0).distance) - } -//! [routeinfomodel3] -} -//! [routeinfomodel3] diff --git a/app/forms/RouteListDelegate.qml b/app/forms/RouteListDelegate.qml deleted file mode 100644 index 2dc9981..0000000 --- a/app/forms/RouteListDelegate.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 - -Item { - id: root - property bool checked: false - property alias routeInstruction: instructionLabel - property alias routeDistance: distanceLabel - property alias routeIndex: indexLabel - - width: parent.width - height: indexLabel.height * 2 - - RowLayout { - spacing: 10 - anchors.left: parent.left - anchors.leftMargin: 30 - anchors.verticalCenter: parent.verticalCenter - Label { - id: indexLabel - } - Label { - id: instructionLabel - wrapMode: Text.Wrap - } - Label { - id: distanceLabel - } - } - - Rectangle { - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: 15 - height: 1 - color: "#46a2da" - } -} - - - diff --git a/app/forms/RouteListHeader.qml b/app/forms/RouteListHeader.qml deleted file mode 100644 index 383f892..0000000 --- a/app/forms/RouteListHeader.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -Item { - property alias travelTime: travelTimeLabel - property alias distance: distanceLabel - width: parent.width - height: tabTitle.height * 3.0 - - Rectangle { - id: tabRectangle - y: tabTitle.height - height: tabTitle.height * 2 - 1 - color: "#46a2da" - anchors.left: parent.left - anchors.right: parent.right - - Label { - id: tabTitle - color: "#ffffff" - text: qsTr("Route Information") - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } - - Label { - id: travelTimeLabel - text: totalTravelTime - color: "#ffffff" - font.bold: true - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - } - - Label { - id: distanceLabel - text: totalDistance - color: "#ffffff" - font.bold: true - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - } - } -} diff --git a/app/helper.js b/app/helper.js deleted file mode 100644 index 19201d0..0000000 --- a/app/helper.js +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -.pragma library - -function roundNumber(number, digits) -{ - var multiple = Math.pow(10, digits); - return Math.round(number * multiple) / multiple; -} - -function formatTime(sec) -{ - var value = sec - var seconds = value % 60 - value /= 60 - value = (value > 1) ? Math.round(value) : 0 - var minutes = value % 60 - value /= 60 - value = (value > 1) ? Math.round(value) : 0 - var hours = value - if (hours > 0) value = hours + "h:"+ minutes + "m" - else value = minutes + "min" - return value -} - -function formatDistance(meters) -{ - var dist = Math.round(meters) - if (dist > 1000 ){ - if (dist > 100000){ - dist = Math.round(dist / 1000) - } - else{ - dist = Math.round(dist / 100) - dist = dist / 10 - } - dist = dist + " km" - } - else{ - dist = dist + " m" - } - return dist -} diff --git a/app/images/Thumbs.db b/app/images/Thumbs.db Binary files differnew file mode 100644 index 0000000..3ac30c1 --- /dev/null +++ b/app/images/Thumbs.db diff --git a/app/images/arrow-0.png b/app/images/arrow-0.png Binary files differnew file mode 100644 index 0000000..50b07ad --- /dev/null +++ b/app/images/arrow-0.png diff --git a/app/images/arrow-l-180.png b/app/images/arrow-l-180.png Binary files differnew file mode 100644 index 0000000..5c9223d --- /dev/null +++ b/app/images/arrow-l-180.png diff --git a/app/images/arrow-l-30.png b/app/images/arrow-l-30.png Binary files differnew file mode 100644 index 0000000..3503b07 --- /dev/null +++ b/app/images/arrow-l-30.png diff --git a/app/images/arrow-l-45.png b/app/images/arrow-l-45.png Binary files differnew file mode 100644 index 0000000..a033731 --- /dev/null +++ b/app/images/arrow-l-45.png diff --git a/app/images/arrow-l-75.png b/app/images/arrow-l-75.png Binary files differnew file mode 100644 index 0000000..cdaffec --- /dev/null +++ b/app/images/arrow-l-75.png diff --git a/app/images/arrow-r-180.png b/app/images/arrow-r-180.png Binary files differnew file mode 100644 index 0000000..823046e --- /dev/null +++ b/app/images/arrow-r-180.png diff --git a/app/images/arrow-r-30.png b/app/images/arrow-r-30.png Binary files differnew file mode 100644 index 0000000..3abf7f0 --- /dev/null +++ b/app/images/arrow-r-30.png diff --git a/app/images/arrow-r-45.png b/app/images/arrow-r-45.png Binary files differnew file mode 100644 index 0000000..ae27ad4 --- /dev/null +++ b/app/images/arrow-r-45.png diff --git a/app/images/arrow-r-75.png b/app/images/arrow-r-75.png Binary files differnew file mode 100644 index 0000000..24b296b --- /dev/null +++ b/app/images/arrow-r-75.png diff --git a/app/images/car-focus.png b/app/images/car-focus.png Binary files differnew file mode 100644 index 0000000..0b2a167 --- /dev/null +++ b/app/images/car-focus.png diff --git a/app/images/car-marker.png b/app/images/car-marker.png Binary files differnew file mode 100755 index 0000000..9ca4d50 --- /dev/null +++ b/app/images/car-marker.png diff --git a/app/images/car-marker2.png b/app/images/car-marker2.png Binary files differnew file mode 100755 index 0000000..34bab94 --- /dev/null +++ b/app/images/car-marker2.png diff --git a/app/images/images.qrc b/app/images/images.qrc new file mode 100644 index 0000000..6e57d04 --- /dev/null +++ b/app/images/images.qrc @@ -0,0 +1,20 @@ +<RCC> + <qresource prefix="/"> + <file>car-focus.png</file> + <file>car-marker.png</file> + <file>car-marker2.png</file> + <file>marker-green.png</file> + <file>marker-red.png</file> + <file>marker-end.png</file> + <file>simple-bottom-background-white.png</file> + <file>arrow-0.png</file> + <file>arrow-l-30.png</file> + <file>arrow-l-45.png</file> + <file>arrow-l-75.png</file> + <file>arrow-l-180.png</file> + <file>arrow-r-30.png</file> + <file>arrow-r-45.png</file> + <file>arrow-r-75.png</file> + <file>arrow-r-180.png</file> + </qresource> +</RCC> diff --git a/app/images/marker-end.png b/app/images/marker-end.png Binary files differnew file mode 100755 index 0000000..2763c39 --- /dev/null +++ b/app/images/marker-end.png diff --git a/app/images/marker-green.png b/app/images/marker-green.png Binary files differnew file mode 100644 index 0000000..e2f2078 --- /dev/null +++ b/app/images/marker-green.png diff --git a/app/images/marker-red.png b/app/images/marker-red.png Binary files differnew file mode 100644 index 0000000..e2f2078 --- /dev/null +++ b/app/images/marker-red.png diff --git a/app/images/simple-bottom-background-white.png b/app/images/simple-bottom-background-white.png Binary files differnew file mode 100644 index 0000000..df9c2a0 --- /dev/null +++ b/app/images/simple-bottom-background-white.png diff --git a/app/main.cpp b/app/main.cpp index fb7dbed..202b25c 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -1,67 +1,45 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * 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 <QQmlApplicationEngine> +#include <QtCore/QDebug> #include <QtCore/QCommandLineParser> -#include <QtCore/QTextStream> -#include <QtGui/QGuiApplication> -#include <QtQml/QQmlApplicationEngine> -#include <QtQuick/QQuickItem> #include <QtCore/QUrlQuery> +#include <QtGui/QGuiApplication> #include <QtQml/QQmlContext> -#include <QtQml/qqml.h> -#include <QtQuickControls2/QQuickStyle> -#include <QQuickWindow> +#include <QtQuick/QQuickWindow> + +#include "qcheapruler.hpp" + +#ifdef HAVE_LIBHOMESCREEN #include <libhomescreen.hpp> +#endif +#ifdef HAVE_QLIBWINDOWMANAGER #include <qlibwindowmanager.h> +#endif int main(int argc, char *argv[]) { + QString myname = QString("navigation"); - QString myname = QString("Navigation"); - - qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); QGuiApplication app(argc, argv); - - QQuickStyle::setStyle("AGL"); - QQmlApplicationEngine engine; - QQmlContext *context = engine.rootContext(); + app.setApplicationName(myname); + app.setApplicationVersion(QStringLiteral("0.1.0")); + app.setOrganizationDomain(QStringLiteral("automotivelinux.org")); + app.setOrganizationName(QStringLiteral("AutomotiveGradeLinux")); QCommandLineParser parser; parser.addPositionalArgument("port", app.translate("main", "port for binding")); @@ -71,10 +49,14 @@ int main(int argc, char *argv[]) parser.process(app); QStringList positionalArguments = parser.positionalArguments(); + QQmlApplicationEngine engine; + QQmlContext *context = engine.rootContext(); + QUrl bindingAddress; + int port = 0; + QString secret; if (positionalArguments.length() == 2) { - int port = positionalArguments.takeFirst().toInt(); - QString secret = positionalArguments.takeFirst(); - QUrl bindingAddress; + port = positionalArguments.takeFirst().toInt(); + secret = positionalArguments.takeFirst(); bindingAddress.setScheme(QStringLiteral("ws")); bindingAddress.setHost(QStringLiteral("localhost")); bindingAddress.setPort(port); @@ -83,54 +65,64 @@ int main(int argc, char *argv[]) query.addQueryItem(QStringLiteral("token"), secret); bindingAddress.setQuery(query); context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); - std::string token = secret.toStdString(); - LibHomeScreen* hs = new LibHomeScreen(); - QLibWindowmanager* qwm = new QLibWindowmanager(); + } else { + context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); + } - // WindowManager - if(qwm->init(port,secret) != 0){ - exit(EXIT_FAILURE); - } - // Request a surface as described in layers.json windowmanager’s file - if (qwm->requestSurface(myname) != 0) { - exit(EXIT_FAILURE); - } - // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs - qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [qwm, myname](json_object *object) { - fprintf(stderr, "Surface got syncDraw!\n"); - qwm->endDraw(myname); - }); +#ifdef HAVE_QLIBWINDOWMANAGER + // WindowManager + QLibWindowmanager* qwm = new QLibWindowmanager(); + if(qwm->init(port,secret) != 0){ + exit(EXIT_FAILURE); + } + // Request a surface as described in layers.json windowmanager’s file + if(qwm->requestSurface(myname) != 0){ + exit(EXIT_FAILURE); + } + // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs + qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [qwm, myname](json_object *object) { + fprintf(stderr, "Surface got syncDraw!\n"); + qwm->endDraw(myname); + }); +#endif - // HomeScreen - hs->init(port, token.c_str()); - // Set the event handler for Event_TapShortcut which will activate the surface for windowmanager - hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [qwm, myname](json_object *object){ - json_object *appnameJ = nullptr; - if(json_object_object_get_ex(object, "application_name", &appnameJ)) +#ifdef HAVE_LIBHOMESCREEN + // HomeScreen + LibHomeScreen* hs = new LibHomeScreen(); + std::string token = secret.toStdString(); + hs->init(port, token.c_str()); + // Set the event handler for Event_TapShortcut which will activate the surface for windowmanager + hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [qwm, myname](json_object *object){ + + json_object *appnameJ = nullptr; + if(json_object_object_get_ex(object, "application_name", &appnameJ)) + { + const char *appname = json_object_get_string(appnameJ); + if(QString::compare(myname, appname, Qt::CaseInsensitive) == 0) { - const char *appname = json_object_get_string(appnameJ); - if(myname == appname) - { - qDebug("Surface %s got tapShortcut\n", appname); - qwm->activateSurface(myname); - } + qDebug("Surface %s got tapShortcut\n", appname); + json_object *para, *area; + json_object_object_get_ex(object, "parameter", ¶); + json_object_object_get_ex(para, "area", &area); + const char *displayArea = json_object_get_string(area); + qDebug("Surface %s got tapShortcut area\n", displayArea); + qwm->activateWindow(myname, QString(QLatin1String(displayArea))); } - }); - - QVariantMap parameters; - parameters[QStringLiteral("osm.useragent")] = QStringLiteral("Automotive Grade Linux Navigation"); - - engine.addImportPath(QStringLiteral(":/imports")); - engine.load(QUrl(QStringLiteral("qrc:/mapviewer.qml"))); - QObject::connect(&engine, SIGNAL(quit()), qApp, SLOT(quit())); + } + }); +#endif + qmlRegisterType<QCheapRuler>("com.mapbox.cheap_ruler", 1, 0, "CheapRuler"); - QObject *root = engine.rootObjects().first(); - QQuickWindow *window = qobject_cast<QQuickWindow *>(root); - QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface())); + engine.load(QUrl(QStringLiteral("qrc:qml/Main.qml"))); - QMetaObject::invokeMethod(root, "initializeProviders", - Q_ARG(QVariant, QVariant::fromValue(parameters))); - } + QObject *root = engine.rootObjects().first(); + QQuickWindow *window = qobject_cast<QQuickWindow *>(root); +#ifdef HAVE_QLIBWINDOWMANAGER + QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface())); +#else + window->resize(1024, 768); + window->setVisible(true); +#endif return app.exec(); } diff --git a/app/map/CircleItem.qml b/app/map/CircleItem.qml deleted file mode 100644 index 3b32ba5..0000000 --- a/app/map/CircleItem.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ -import QtQuick 2.5 -import QtLocation 5.6 - -//TODO: remove/refactor me when items are integrated - -MapCircle { - - color: "#46a2da" - border.color: "#190a33" - border.width: 2 - smooth: true - opacity: 0.25 - - function setGeometry(markers, index){ - center.latitude = markers[index].coordinate.latitude - center.longitude = markers[index].coordinate.longitude - radius= center.distanceTo(markers[index + 1].coordinate) - } -} diff --git a/app/map/ImageItem.qml b/app/map/ImageItem.qml deleted file mode 100644 index 3bf4dfe..0000000 --- a/app/map/ImageItem.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ -import QtQuick 2.5; -import QtLocation 5.6 - -MapQuickItem { //to be used inside MapComponent only - id: imageItem - - MouseArea { - anchors.fill: parent - drag.target: parent - } - - function setGeometry(markers, index) { - coordinate.latitude = markers[index].coordinate.latitude - coordinate.longitude = markers[index].coordinate.longitude - } - - sourceItem: Image { - id: testImage - source: "../resources/icon.png" - opacity: 0.7 - } -} diff --git a/app/map/MapComponent.qml b/app/map/MapComponent.qml deleted file mode 100644 index 161038c..0000000 --- a/app/map/MapComponent.qml +++ /dev/null @@ -1,693 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Layouts 1.3 -import QtQuick.Controls 1.4 -import QtQuick.Extras 1.4 -import QtLocation 5.6 -import QtPositioning 5.5 -import "../helper.js" as Helper - -//! [top] -Map { - id: map -//! [top] - property variant markers - property variant mapItems - property variant location - property int markerCounter: 0 // counter for total amount of markers. Resets to 0 when number of markers = 0 - property int currentMarker - property int lastX : -1 - property int lastY : -1 - property int pressX : -1 - property int pressY : -1 - property int jitterThreshold : 30 - property bool followme: true - property variant scaleLengths: [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000] - property alias routeQuery: routeQuery - property alias routeModel: routeModel - property alias geocodeModel: geocodeModel - - signal showGeocodeInfo() - signal geocodeFinished() - signal routeError() - signal coordinatesCaptured(double latitude, double longitude) - signal showMainMenu(variant coordinate) - signal showMarkerMenu(variant coordinate) - signal showRouteMenu(variant coordinate) - signal showPointMenu(variant coordinate) - signal showRouteList() - - - center { - // null island - latitude: 0 - longitude: 0 - } - - function geocodeMessage() - { - var street, district, city, county, state, countryCode, country, postalCode, latitude, longitude, text - latitude = Math.round(geocodeModel.get(0).coordinate.latitude * 10000) / 10000 - longitude =Math.round(geocodeModel.get(0).coordinate.longitude * 10000) / 10000 - street = geocodeModel.get(0).address.street - district = geocodeModel.get(0).address.district - city = geocodeModel.get(0).address.city - county = geocodeModel.get(0).address.county - state = geocodeModel.get(0).address.state - countryCode = geocodeModel.get(0).address.countryCode - country = geocodeModel.get(0).address.country - postalCode = geocodeModel.get(0).address.postalCode - - text = "<b>Latitude:</b> " + latitude + "<br/>" - text +="<b>Longitude:</b> " + longitude + "<br/>" + "<br/>" - if (street) text +="<b>Street: </b>"+ street + " <br/>" - if (district) text +="<b>District: </b>"+ district +" <br/>" - if (city) text +="<b>City: </b>"+ city + " <br/>" - if (county) text +="<b>County: </b>"+ county + " <br/>" - if (state) text +="<b>State: </b>"+ state + " <br/>" - if (countryCode) text +="<b>Country code: </b>"+ countryCode + " <br/>" - if (country) text +="<b>Country: </b>"+ country + " <br/>" - if (postalCode) text +="<b>PostalCode: </b>"+ postalCode + " <br/>" - return text - } - - function calculateScale() - { - var coord1, coord2, dist, text, f - f = 0 - coord1 = map.toCoordinate(Qt.point(0,scale.y)) - coord2 = map.toCoordinate(Qt.point(0+scaleImage.sourceSize.width,scale.y)) - dist = Math.round(coord1.distanceTo(coord2)) - - if (dist === 0) { - // not visible - } else { - for (var i = 0; i < scaleLengths.length-1; i++) { - if (dist < (scaleLengths[i] + scaleLengths[i+1]) / 2 ) { - f = scaleLengths[i] / dist - dist = scaleLengths[i] - break; - } - } - if (f === 0) { - f = dist / scaleLengths[i] - dist = scaleLengths[i] - } - } - - text = Helper.formatDistance(dist) - scaleImage.width = (scaleImage.sourceSize.width * f) - 2 * scaleImageLeft.sourceSize.width - scaleText.text = text - } - - function deleteMarkers() - { - var count = map.markers.length - for (var i = 0; i<count; i++){ - map.removeMapItem(map.markers[i]) - map.markers[i].destroy() - } - map.markers = [] - markerCounter = 0 - } - - function deleteMapItems() - { - var count = map.mapItems.length - for (var i = 0; i<count; i++){ - map.removeMapItem(map.mapItems[i]) - map.mapItems[i].destroy() - } - map.mapItems = [] - } - - function addMarker() - { - var count = map.markers.length - markerCounter++ - var marker = Qt.createQmlObject ('Marker {}', map) - map.addMapItem(marker) - marker.z = map.z+1 - marker.coordinate = mouseArea.lastCoordinate - - //update list of markers - var myArray = new Array() - for (var i = 0; i<count; i++){ - myArray.push(markers[i]) - } - myArray.push(marker) - markers = myArray - } - - function addGeoItem(item) - { - var count = map.mapItems.length - var co = Qt.createComponent(item+'.qml') - if (co.status == Component.Ready) { - var o = co.createObject(map) - o.setGeometry(map.markers, currentMarker) - map.addMapItem(o) - //update list of items - var myArray = new Array() - for (var i = 0; i<count; i++){ - myArray.push(mapItems[i]) - } - myArray.push(o) - mapItems = myArray - - } else { - console.log(item + " is not supported right now, please call us later.") - } - } - - function deleteMarker(index) - { - //update list of markers - var myArray = new Array() - var count = map.markers.length - for (var i = 0; i<count; i++){ - if (index != i) myArray.push(map.markers[i]) - } - - map.removeMapItem(map.markers[index]) - map.markers[index].destroy() - map.markers = myArray - if (markers.length == 0) markerCounter = 0 - } - - function calculateMarkerRoute() - { - routeQuery.clearWaypoints(); - for (var i = currentMarker; i< map.markers.length; i++){ - routeQuery.addWaypoint(markers[i].coordinate) - } - routeQuery.travelModes = RouteQuery.CarTravel - routeQuery.routeOptimizations = RouteQuery.ShortestRoute - routeQuery.setFeatureWeight(0, 0) - routeModel.update(); - } - - function calculateCoordinateRoute(startCoordinate, endCoordinate) - { - //! [routerequest0] - // clear away any old data in the query - routeQuery.clearWaypoints(); - - // add the start and end coords as waypoints on the route - routeQuery.addWaypoint(startCoordinate) - routeQuery.addWaypoint(endCoordinate) - routeQuery.travelModes = RouteQuery.CarTravel - routeQuery.routeOptimizations = RouteQuery.FastestRoute - - //! [routerequest0] - - //! [routerequest0 feature weight] - for (var i=0; i<9; i++) { - routeQuery.setFeatureWeight(i, 0) - } - //for (var i=0; i<routeDialog.features.length; i++) { - // map.routeQuery.setFeatureWeight(routeDialog.features[i], RouteQuery.AvoidFeatureWeight) - //} - //! [routerequest0 feature weight] - - //! [routerequest1] - routeModel.update(); - - //! [routerequest1] - //! [routerequest2] - // center the map on the start coord - map.center = startCoordinate; - //! [routerequest2] - } - - function geocode(fromAddress) - { - //! [geocode1] - // send the geocode request - geocodeModel.query = fromAddress - geocodeModel.update() - //! [geocode1] - } - - function updateCompass(heading) - { - compass.rotation = heading - 90 - } - -//! [coord] - zoomLevel: (maximumZoomLevel - minimumZoomLevel)/2 -//! [coord] - -//! [mapnavigation] - // Enable pan, flick, and pinch gestures to zoom in and out - gesture.acceptedGestures: MapGestureArea.PanGesture | MapGestureArea.FlickGesture | MapGestureArea.PinchGesture - gesture.flickDeceleration: 3000 - gesture.enabled: !map.followme -//! [mapnavigation] - focus: true - onCopyrightLinkActivated: Qt.openUrlExternally(link) - - onCenterChanged:{ - scaleTimer.restart() - } - - onZoomLevelChanged:{ - scaleTimer.restart() - } - - onWidthChanged:{ - scaleTimer.restart() - } - - onHeightChanged:{ - scaleTimer.restart() - } - - Component.onCompleted: { - markers = new Array(); - mapItems = new Array(); - } - - Keys.onPressed: { - if (event.key === Qt.Key_Plus) { - map.zoomLevel++; - } else if (event.key === Qt.Key_Minus) { - map.zoomLevel--; - } else if (event.key === Qt.Key_Left || event.key === Qt.Key_Right || - event.key === Qt.Key_Up || event.key === Qt.Key_Down) { - var dx = 0; - var dy = 0; - - switch (event.key) { - - case Qt.Key_Left: dx = map.width / 4; break; - case Qt.Key_Right: dx = -map.width / 4; break; - case Qt.Key_Up: dy = map.height / 4; break; - case Qt.Key_Down: dy = -map.height / 4; break; - - } - - var mapCenterPoint = Qt.point(map.width / 2.0 - dx, map.height / 2.0 - dy); - map.center = map.toCoordinate(mapCenterPoint); - } - } - - /* @todo - Binding { - target: map - property: 'center' - when: followme - }*/ - - MapQuickItem { - id: locationPoint - sourceItem: Image { - id: compass - width: 100 * (map.zoomLevel / map.maximumZoomLevel) - height: 50 * (map.zoomLevel / map.maximumZoomLevel) - source: "../resources/car.png" - } - coordinate: location - opacity: 1.0 - anchorPoint: Qt.point(sourceItem.width/2, sourceItem.height/2) - } - - Slider { - id: zoomSlider; - z: map.z + 3 - minimumValue: map.minimumZoomLevel; - maximumValue: map.maximumZoomLevel; - anchors.margins: 10 - anchors.bottom: scale.top - anchors.top: parent.top - anchors.right: parent.right - orientation : Qt.Vertical - value: map.zoomLevel - onValueChanged: { - if (value >= 0) - map.zoomLevel = value - } - } - - GridLayout { - z: map.z + 3 - columns: 1 - width: 300 - height: 300 - - ToggleButton { - id: followme - text: "GeoLocation Pan" - checked: map.followme - Layout.fillWidth: true - Layout.fillHeight: true - onClicked: { - map.followme = !map.followme - } - } - - Button { - text: "Lookup Route" - Layout.fillWidth: true - Layout.fillHeight: true - onClicked: { - stackView.pop({item:page, immediate: true}) - stackView.push(Qt.resolvedUrl("../forms/RouteAddress.qml"), - { "plugin": map.plugin, - "toAddress": toAddress, - "fromCoordinate": map.location}) - stackView.currentItem.showRoute.connect(map.calculateCoordinateRoute) - stackView.currentItem.showMessage.connect(stackView.showMessage) - stackView.currentItem.closeForm.connect(stackView.closeForm) - } - } - - Button { - text: "Reverse GeoCode" - Layout.fillWidth: true - Layout.fillHeight: true - onClicked: { - stackView.pop({item:page, immediate: true}) - stackView.push(Qt.resolvedUrl("../forms/ReverseGeocode.qml"), - { "coordinate": map.location}) - stackView.currentItem.showPlace.connect(map.geocode) - stackView.currentItem.closeForm.connect(stackView.closeForm) - } - } - - Button { - text: "Show Route List" - Layout.fillWidth: true - Layout.fillHeight: true - onClicked: { - stackView.showRouteListPage() - } - } - - Button { - text: "Clear Route" - Layout.fillWidth: true - Layout.fillHeight: true - enabled: map.routeModel.count - onClicked: { - map.routeModel.reset(); - map.zoomLevel = map.maximumZoomLevel - map.center = map.location - } - } - } - - Item { - id: scale - z: map.z + 3 - visible: scaleText.text != "0 m" - anchors.bottom: parent.bottom; - anchors.right: parent.right - anchors.margins: 20 - height: scaleText.height * 2 - width: scaleImage.width - - Image { - id: scaleImageLeft - source: "../resources/scale_end.png" - anchors.bottom: parent.bottom - anchors.right: scaleImage.left - } - Image { - id: scaleImage - source: "../resources/scale.png" - anchors.bottom: parent.bottom - anchors.right: scaleImageRight.left - } - Image { - id: scaleImageRight - source: "../resources/scale_end.png" - anchors.bottom: parent.bottom - anchors.right: parent.right - } - Label { - id: scaleText - color: "#004EAE" - anchors.centerIn: parent - text: "0 m" - } - Component.onCompleted: { - map.calculateScale(); - } - } - - //! [routemodel0] - RouteModel { - id: routeModel - plugin : map.plugin - query: RouteQuery { - id: routeQuery - } - onStatusChanged: { - if (status == RouteModel.Ready) { - switch (count) { - case 0: - // technically not an error - map.routeError() - break - case 1: - map.showRouteList() - break - } - } else if (status == RouteModel.Error) { - map.routeError() - } - } - } - //! [routemodel0] - - //! [routedelegate0] - Component { - id: routeDelegate - - MapRoute { - id: route - route: routeData - line.color: "#46a2da" - line.width: 5 - smooth: true - opacity: 0.8 - //! [routedelegate0] - MouseArea { - id: routeMouseArea - anchors.fill: parent - hoverEnabled: false - property variant lastCoordinate - - onPressed : { - map.lastX = mouse.x + parent.x - map.lastY = mouse.y + parent.y - map.pressX = mouse.x + parent.x - map.pressY = mouse.y + parent.y - lastCoordinate = map.toCoordinate(Qt.point(mouse.x, mouse.y)) - } - - onPositionChanged: { - if (mouse.button == Qt.LeftButton) { - map.lastX = mouse.x + parent.x - map.lastY = mouse.y + parent.y - } - } - - onPressAndHold:{ - if (Math.abs(map.pressX - parent.x- mouse.x ) < map.jitterThreshold - && Math.abs(map.pressY - parent.y - mouse.y ) < map.jitterThreshold) { - showRouteMenu(lastCoordinate); - } - } - - } - //! [routedelegate1] - } - } - //! [routedelegate1] - - //! [geocodemodel0] - GeocodeModel { - id: geocodeModel - plugin: map.plugin - onStatusChanged: { - if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error)) - map.geocodeFinished() - } - onLocationsChanged: - { - if (count == 1) { - map.center.latitude = get(0).coordinate.latitude - map.center.longitude = get(0).coordinate.longitude - } - } - } - //! [geocodemodel0] - - //! [pointdel0] - Component { - id: pointDelegate - - MapCircle { - id: point - color: "#46a2da" - border.color: "#190a33" - border.width: 2 - smooth: true - opacity: 0.25 - center: locationData.coordinate - //! [pointdel0] - MouseArea { - anchors.fill:parent - id: circleMouseArea - hoverEnabled: false - property variant lastCoordinate - - onPressed : { - map.lastX = mouse.x + parent.x - map.lastY = mouse.y + parent.y - map.pressX = mouse.x + parent.x - map.pressY = mouse.y + parent.y - lastCoordinate = map.toCoordinate(Qt.point(mouse.x, mouse.y)) - } - - onPositionChanged: { - if (Math.abs(map.pressX - parent.x- mouse.x ) > map.jitterThreshold || - Math.abs(map.pressY - parent.y -mouse.y ) > map.jitterThreshold) { - if (pressed) parent.radius = parent.center.distanceTo( - map.toCoordinate(Qt.point(mouse.x, mouse.y))) - } - if (mouse.button == Qt.LeftButton) { - map.lastX = mouse.x + parent.x - map.lastY = mouse.y + parent.y - } - } - - onPressAndHold:{ - if (Math.abs(map.pressX - parent.x- mouse.x ) < map.jitterThreshold - && Math.abs(map.pressY - parent.y - mouse.y ) < map.jitterThreshold) { - showPointMenu(lastCoordinate); - } - } - } - //! [pointdel1] - } - } - //! [pointdel1] - - //! [routeview0] - MapItemView { - model: routeModel - delegate: routeDelegate - //! [routeview0] - autoFitViewport: true - //! [routeview1] - } - //! [routeview1] - - //! [geocodeview] - MapItemView { - model: geocodeModel - delegate: pointDelegate - } - //! [geocodeview] - - Timer { - id: scaleTimer - interval: 100 - running: false - repeat: false - onTriggered: { - map.calculateScale() - } - } - - MouseArea { - id: mouseArea - property variant lastCoordinate - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - - onPressed : { - map.lastX = mouse.x - map.lastY = mouse.y - map.pressX = mouse.x - map.pressY = mouse.y - lastCoordinate = map.toCoordinate(Qt.point(mouse.x, mouse.y)) - } - - onPositionChanged: { - if (mouse.button == Qt.LeftButton) { - map.lastX = mouse.x - map.lastY = mouse.y - } - } - - onDoubleClicked: { - var mouseGeoPos = map.toCoordinate(Qt.point(mouse.x, mouse.y)); - var preZoomPoint = map.fromCoordinate(mouseGeoPos, false); - if (mouse.button === Qt.LeftButton) { - map.zoomLevel++; - } else if (mouse.button === Qt.RightButton) { - map.zoomLevel--; - } - var postZoomPoint = map.fromCoordinate(mouseGeoPos, false); - var dx = postZoomPoint.x - preZoomPoint.x; - var dy = postZoomPoint.y - preZoomPoint.y; - - var mapCenterPoint = Qt.point(map.width / 2.0 + dx, map.height / 2.0 + dy); - map.center = map.toCoordinate(mapCenterPoint); - - lastX = -1; - lastY = -1; - } - - onPressAndHold:{ - if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold - && Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) { - showMainMenu(lastCoordinate); - } - } - } -//! [end] -} -//! [end] diff --git a/app/map/Marker.qml b/app/map/Marker.qml deleted file mode 100644 index 3c0ed17..0000000 --- a/app/map/Marker.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5; -import QtLocation 5.6 - -//! [mqi-top] -MapQuickItem { - id: marker -//! [mqi-top] - property alias lastMouseX: markerMouseArea.lastX - property alias lastMouseY: markerMouseArea.lastY - -//! [mqi-anchor] - anchorPoint.x: image.width/4 - anchorPoint.y: image.height - - sourceItem: Image { - id: image -//! [mqi-anchor] - source: "../resources/marker.png" - opacity: markerMouseArea.pressed ? 0.6 : 1.0 - MouseArea { - id: markerMouseArea - property int pressX : -1 - property int pressY : -1 - property int jitterThreshold : 10 - property int lastX: -1 - property int lastY: -1 - anchors.fill: parent - hoverEnabled : false - drag.target: marker - preventStealing: true - - onPressed : { - map.pressX = mouse.x - map.pressY = mouse.y - map.currentMarker = -1 - for (var i = 0; i< map.markers.length; i++){ - if (marker == map.markers[i]){ - map.currentMarker = i - break - } - } - } - - onPressAndHold:{ - if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold - && Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) { - var p = map.fromCoordinate(marker.coordinate) - lastX = p.x - lastY = p.y - map.showMarkerMenu(marker.coordinate) - } - } - } - - Text{ - id: number - y: image.height/10 - width: image.width - color: "white" - font.bold: true - font.pixelSize: 14 - horizontalAlignment: Text.AlignHCenter - Component.onCompleted: { - text = map.markerCounter - } - } - -//! [mqi-closeimage] - } -//! [mqi-closeimage] - - Component.onCompleted: coordinate = map.toCoordinate(Qt.point(markerMouseArea.mouseX, - markerMouseArea.mouseY)); -//! [mqi-close] -} -//! [mqi-close] diff --git a/app/map/PolygonItem.qml b/app/map/PolygonItem.qml deleted file mode 100644 index cab4e6c..0000000 --- a/app/map/PolygonItem.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ -import QtQuick 2.5 -import QtLocation 5.6 - -//TODO: remove me when items are integrated - -MapPolygon { - - color: "#46a2da" - border.color: "#190a33" - border.width: 2 - smooth: true - opacity: 0.25 - - function setGeometry(markers, index){ - for (var i = index; i<markers.length; i++){ - addCoordinate(markers[i].coordinate) - } - } - MouseArea { - anchors.fill:parent - id: mousearea - drag.target: parent - } -} diff --git a/app/map/PolylineItem.qml b/app/map/PolylineItem.qml deleted file mode 100644 index c27d8b7..0000000 --- a/app/map/PolylineItem.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ -import QtQuick 2.5 -import QtLocation 5.6 - -//TODO: remove/refactor me when items are integrated - -MapPolyline { - - line.color: "#46a2da" - line.width: 4 - opacity: 0.25 - smooth: true - - function setGeometry(markers, index){ - for (var i = index; i<markers.length; i++){ - addCoordinate(markers[i].coordinate) - } - } -} diff --git a/app/map/RectangleItem.qml b/app/map/RectangleItem.qml deleted file mode 100644 index 8369c90..0000000 --- a/app/map/RectangleItem.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ -import QtQuick 2.5 -import QtLocation 5.6 - -MapRectangle { - id: mapRectangle - - color: "#46a2da" - border.color: "#190a33" - border.width: 2 - smooth: true - opacity: 0.25 - - function setGeometry(markers, index){ - topLeft.latitude = Math.max(markers[index].coordinate.latitude, markers[index + 1].coordinate.latitude) - topLeft.longitude = Math.min(markers[index].coordinate.longitude, markers[index + 1].coordinate.longitude) - bottomRight.latitude = Math.min(markers[index].coordinate.latitude, markers[index + 1].coordinate.latitude) - bottomRight.longitude = Math.max(markers[index].coordinate.longitude, markers[index + 1].coordinate.longitude) - } - -} diff --git a/app/mapviewer.qml b/app/mapviewer.qml deleted file mode 100644 index 6240600..0000000 --- a/app/mapviewer.qml +++ /dev/null @@ -1,486 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 2.0 -import QtQuick.VirtualKeyboard 2.1 -import QtLocation 5.6 -import QtPositioning 5.5 -import AGL.Demo.Controls 1.0 -import "map" -import "menus" -import "helper.js" as Helper -import "api" as API - -ApplicationWindow { - id: appWindow - property variant map - property variant parameters - - //defaults - //! [routecoordinate] - property variant fromCoordinate: QtPositioning.coordinate(59.9483, 10.7695) - property variant toCoordinate: QtPositioning.coordinate(59.9645, 10.671) - //! [routecoordinate] - - API.GPS { - id: gps - url: bindingAddress - } - - API.GeoClue { - id: geoclue - url: bindingAddress - } - - API.GeoFence { - id: geofence - url: bindingAddress - } - - function createMap(provider) - { - var plugin - - if (parameters && parameters.length>0) - plugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin{ name:"' + provider + '"; parameters: appWindow.parameters}', appWindow) - else - plugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin{ name:"' + provider + '"}', appWindow) - - var zoomLevel = null - var center = null - if (map) { - zoomLevel = map.zoomLevel - center = map.center - map.destroy() - } - - map = mapComponent.createObject(page); - map.plugin = plugin; - - if (zoomLevel != null) { - map.zoomLevel = zoomLevel - map.center = center - } else { - map.zoomLevel = map.maximumZoomLevel - } - - map.forceActiveFocus() - } - - function getPlugins() - { - var plugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin {}', appWindow) - var myArray = new Array() - for (var i = 0; i<plugin.availableServiceProviders.length; i++) { - var tempPlugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin {name: "' + plugin.availableServiceProviders[i]+ '"}', appWindow) - if (tempPlugin.supportsMapping()) - myArray.push(tempPlugin.name) - } - myArray.sort() - return myArray - } - - function initializeProviders(pluginParameters) - { - var parameters = new Array() - for (var prop in pluginParameters){ - var parameter = Qt.createQmlObject('import QtLocation 5.6; PluginParameter{ name: "'+ prop + '"; value: "' + pluginParameters[prop]+'"}',appWindow) - parameters.push(parameter) - } - appWindow.parameters = parameters - var plugins = getPlugins() - mainMenu.providerMenu.createMenu(plugins) - for (var i = 0; i<plugins.length; i++) { - if (plugins[i] === "osm") - mainMenu.selectProvider(plugins[i]) - } - } - - visible: true - //menuBar: mainMenu - - //! [geocode0] - Address { - id :fromAddress - } - //! [geocode0] - - Address { - id: toAddress - street: "Golden Gate Park" - city: "San Francisco" - state: "California" - country: "US" - } - - InputPanel { - id: inputPanel - visible: Qt.inputMethod.visible - y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height - anchors.left: parent.left - anchors.right: parent.right - } - - MainMenu { - id: mainMenu - - function setLanguage(lang) - { - map.plugin.locales = lang; - stackView.pop(page) - } - - onSelectProvider: { - stackView.pop() - for (var i = 0; i < providerMenu.items.length; i++) { - providerMenu.items[i].checked = providerMenu.items[i].text === providerName - } - - createMap(providerName) - if (map.error === Map.NoError) { - selectMapType(map.activeMapType) - toolsMenu.createMenu(map); - } else { - mapTypeMenu.clear(); - toolsMenu.clear(); - } - } - - onSelectMapType: { - stackView.pop(page) - for (var i = 0; i < mapTypeMenu.items.length; i++) { - mapTypeMenu.items[i].checked = mapTypeMenu.items[i].text === mapType.name - } - map.activeMapType = mapType - } - - - onSelectTool: { - switch (tool) { - case "AddressRoute": - stackView.pop({item:page, immediate: true}) - stackView.push(Qt.resolvedUrl("forms/RouteAddress.qml"), - { "plugin": map.plugin, - "toAddress": toAddress, - "fromAddress": fromAddress}) - stackView.currentItem.showRoute.connect(map.calculateCoordinateRoute) - stackView.currentItem.showMessage.connect(stackView.showMessage) - stackView.currentItem.closeForm.connect(stackView.closeForm) - break - case "CoordinateRoute": - stackView.pop({item:page, immediate: true}) - stackView.push(Qt.resolvedUrl("forms/RouteCoordinate.qml"), - { "toCoordinate": toCoordinate, - "fromCoordinate": fromCoordinate}) - stackView.currentItem.showRoute.connect(map.calculateCoordinateRoute) - stackView.currentItem.closeForm.connect(stackView.closeForm) - break - case "Geocode": - stackView.pop({item:page, immediate: true}) - stackView.push(Qt.resolvedUrl("forms/Geocode.qml"), - { "address": fromAddress}) - stackView.currentItem.showPlace.connect(map.geocode) - stackView.currentItem.closeForm.connect(stackView.closeForm) - break - case "RevGeocode": - stackView.pop({item:page, immediate: true}) - stackView.push(Qt.resolvedUrl("forms/ReverseGeocode.qml"), - { "coordinate": fromCoordinate}) - stackView.currentItem.showPlace.connect(map.geocode) - stackView.currentItem.closeForm.connect(stackView.closeForm) - break - case "Language": - stackView.pop({item:page, immediate: true}) - stackView.push(Qt.resolvedUrl("forms/Locale.qml"), - { "locale": map.plugin.locales[0]}) - stackView.currentItem.selectLanguage.connect(setLanguage) - stackView.currentItem.closeForm.connect(stackView.closeForm) - break - case "Clear": - map.clearData() - break - case "Prefetch": - map.prefetchData() - break - default: - console.log("Unsupported operation") - } - } - - onToggleMapState: { - stackView.pop(page) - switch (state) { - case "FollowMe": - map.followme = !map.followme - break - default: - console.log("Unsupported operation") - } - } - } - - MapPopupMenu { - id: mapPopupMenu - - function show(coordinate) - { - stackView.pop(page) - mapPopupMenu.coordinate = coordinate - mapPopupMenu.markersCount = map.markers.length - mapPopupMenu.mapItemsCount = map.mapItems.length - mapPopupMenu.update() - mapPopupMenu.popup() - } - - onItemClicked: { - stackView.pop(page) - switch (item) { - case "addMarker": - map.addMarker() - break - case "getCoordinate": - map.coordinatesCaptured(coordinate.latitude, coordinate.longitude) - break - case "fitViewport": - map.fitViewportToMapItems() - break - case "deleteMarkers": - map.deleteMarkers() - break - case "deleteItems": - map.deleteMapItems() - break - default: - console.log("Unsupported operation") - } - } - } - - MarkerPopupMenu { - id: markerPopupMenu - - function show(coordinate) - { - stackView.pop(page) - markerPopupMenu.markersCount = map.markers.length - markerPopupMenu.update() - markerPopupMenu.popup() - } - - function askForCoordinate() - { - stackView.push(Qt.resolvedUrl("forms/ReverseGeocode.qml"), - { "title": qsTr("New Coordinate"), - "coordinate": map.markers[map.currentMarker].coordinate}) - stackView.currentItem.showPlace.connect(moveMarker) - stackView.currentItem.closeForm.connect(stackView.closeForm) - } - - function moveMarker(coordinate) - { - map.markers[map.currentMarker].coordinate = coordinate; - map.center = coordinate; - stackView.pop(page) - } - - onItemClicked: { - stackView.pop(page) - switch (item) { - case "deleteMarker": - map.deleteMarker(map.currentMarker) - break; - case "getMarkerCoordinate": - map.coordinatesCaptured(map.markers[map.currentMarker].coordinate.latitude, map.markers[map.currentMarker].coordinate.longitude) - break; - case "moveMarkerTo": - askForCoordinate() - break; - case "routeToNextPoint": - case "routeToNextPoints": - map.calculateMarkerRoute() - break - case "distanceToNextPoint": - var coordinate1 = map.markers[currentMarker].coordinate; - var coordinate2 = map.markers[currentMarker+1].coordinate; - var distance = Helper.formatDistance(coordinate1.distanceTo(coordinate2)); - stackView.showMessage(qsTr("Distance"),"<b>" + qsTr("Distance:") + "</b> " + distance) - break - case "drawImage": - map.addGeoItem("ImageItem") - break - case "drawRectangle": - map.addGeoItem("RectangleItem") - break - case "drawCircle": - map.addGeoItem("CircleItem") - break; - case "drawPolyline": - map.addGeoItem("PolylineItem") - break; - case "drawPolygonMenu": - map.addGeoItem("PolygonItem") - break - default: - console.log("Unsupported operation") - } - } - } - - ItemPopupMenu { - id: itemPopupMenu - - function show(type,coordinate) - { - stackView.pop(page) - itemPopupMenu.type = type - itemPopupMenu.update() - itemPopupMenu.popup() - } - - onItemClicked: { - stackView.pop(page) - switch (item) { - case "showRouteInfo": - stackView.showRouteListPage() - break; - case "deleteRoute": - map.routeModel.reset(); - break; - case "showPointInfo": - map.showGeocodeInfo() - break; - case "deletePoint": - map.geocodeModel.reset() - break; - default: - console.log("Unsupported operation") - } - } - } - - StackView { - id: stackView - anchors.fill: parent - focus: true - initialItem: Item { - id: page - } - - function showMessage(title,message,backPage) - { - push(Qt.resolvedUrl("forms/Message.qml"), - { - "title" : title, - "message" : message, - "backPage" : backPage - }) - currentItem.closeForm.connect(closeMessage) - } - - function closeMessage(backPage) - { - pop(backPage) - } - - function closeForm() - { - pop(page) - } - - function showRouteListPage() - { - push(Qt.resolvedUrl("forms/RouteList.qml") , - { - "routeModel" : map.routeModel - }) - currentItem.closeForm.connect(closeForm) - } - } - - Component { - id: mapComponent - - MapComponent{ - width: page.width - height: page.height - onFollowmeChanged: mainMenu.isFollowMe = map.followme - onSupportedMapTypesChanged: mainMenu.mapTypeMenu.createMenu(map) - onCoordinatesCaptured: { - var text = "<b>" + qsTr("Latitude:") + "</b> " + Helper.roundNumber(latitude,4) + "<br/><b>" + qsTr("Longitude:") + "</b> " + Helper.roundNumber(longitude,4) - stackView.showMessage(qsTr("Coordinates"),text); - } - onGeocodeFinished:{ - if (map.geocodeModel.status == GeocodeModel.Ready) { - if (map.geocodeModel.count == 0) { - stackView.showMessage(qsTr("Geocode Error"),qsTr("Unsuccessful geocode")) - } else if (map.geocodeModel.count > 1) { - stackView.showMessage(qsTr("Ambiguous geocode"), map.geocodeModel.count + " " + - qsTr("results found for the given address, please specify location")) - } else { - stackView.showMessage(qsTr("Location"), geocodeMessage(),page) - } - } else if (map.geocodeModel.status == GeocodeModel.Error) { - stackView.showMessage(qsTr("Geocode Error"),qsTr("Unsuccessful geocode")) - } - } - onRouteError: stackView.showMessage(qsTr("Route Error"),qsTr("Unable to find a route for the given points"),page) - - onShowGeocodeInfo: stackView.showMessage(qsTr("Location"),geocodeMessage(),page) - - onErrorChanged: { - if (map.error != Map.NoError) { - var title = qsTr("ProviderError") - var message = map.errorString + "<br/><br/><b>" + qsTr("Try to select other provider") + "</b>" - if (map.error == Map.MissingRequiredParameterError) - message += "<br/>" + qsTr("or see") + " \'mapviewer --help\' " - + qsTr("how to pass plugin parameters.") - stackView.showMessage(title,message); - } - } - //onShowMainMenu: mapPopupMenu.show(coordinate) - onShowMarkerMenu: markerPopupMenu.show(coordinate) - onShowRouteMenu: itemPopupMenu.show("Route",coordinate) - onShowPointMenu: itemPopupMenu.show("Point",coordinate) - onShowRouteList: stackView.showRouteListPage() - } - } -} diff --git a/app/mapviewer.qrc b/app/mapviewer.qrc deleted file mode 100644 index c5dca44..0000000 --- a/app/mapviewer.qrc +++ /dev/null @@ -1,40 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>mapviewer.qml</file> - <file>api/GPS.qml</file> - <file>api/GeoClue.qml</file> - <file>api/GeoFence.qml</file> - <file>map/MapComponent.qml</file> - <file>map/Marker.qml</file> - <file>map/PolylineItem.qml</file> - <file>map/RectangleItem.qml</file> - <file>map/CircleItem.qml</file> - <file>map/PolygonItem.qml</file> - <file>map/ImageItem.qml</file> - <file>forms/Message.qml</file> - <file>forms/MessageForm.ui.qml</file> - <file>forms/Geocode.qml</file> - <file>forms/GeocodeForm.ui.qml</file> - <file>forms/ReverseGeocode.qml</file> - <file>forms/ReverseGeocodeForm.ui.qml</file> - <file>forms/RouteCoordinate.qml</file> - <file>forms/RouteCoordinateForm.ui.qml</file> - <file>forms/RouteAddress.qml</file> - <file>forms/RouteAddressForm.ui.qml</file> - <file>forms/Locale.qml</file> - <file>forms/LocaleForm.ui.qml</file> - <file>forms/RouteList.qml</file> - <file>forms/RouteListDelegate.qml</file> - <file>forms/RouteListHeader.qml</file> - <file>menus/MainMenu.qml</file> - <file>menus/MapPopupMenu.qml</file> - <file>menus/MarkerPopupMenu.qml</file> - <file>menus/ItemPopupMenu.qml</file> - <file>helper.js</file> - <file>resources/car.png</file> - <file>resources/scale_end.png</file> - <file>resources/scale.png</file> - <file>resources/marker.png</file> - <file>resources/icon.png</file> - </qresource> -</RCC> diff --git a/app/menus/ItemPopupMenu.qml b/app/menus/ItemPopupMenu.qml deleted file mode 100644 index 8d7e2f7..0000000 --- a/app/menus/ItemPopupMenu.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -Menu { - property variant type - signal itemClicked(string item) - - function update() { - clear() - addItem(qsTr("Info")).triggered.connect(function(){itemClicked("show" + type + "Info")}) - addItem(qsTr("Delete")).triggered.connect(function(){itemClicked("delete" + type )}) - } -} diff --git a/app/menus/MainMenu.qml b/app/menus/MainMenu.qml deleted file mode 100644 index fe2bfa1..0000000 --- a/app/menus/MainMenu.qml +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtLocation 5.6 - -MenuBar { - property variant providerMenu: providerMenu - property variant mapTypeMenu: mapTypeMenu - property variant toolsMenu: toolsMenu - property alias isFollowMe: toolsMenu.isFollowMe - - signal selectProvider(string providerName) - signal selectMapType(variant mapType) - signal selectTool(string tool); - signal toggleMapState(string state) - - Menu { - id: providerMenu - title: qsTr("Provider") - - function createMenu(plugins) - { - clear() - for (var i = 0; i < plugins.length; i++) { - createProviderMenuItem(plugins[i]); - } - } - - function createProviderMenuItem(provider) - { - var item = addItem(provider); - item.checkable = true; - item.triggered.connect(function(){selectProvider(provider)}) - } - } - - Menu { - id: mapTypeMenu - title: qsTr("MapType") - - function createMenu(map) - { - clear() - for (var i = 0; i<map.supportedMapTypes.length; i++) { - createMapTypeMenuItem(map.supportedMapTypes[i]).checked = - (map.activeMapType === map.supportedMapTypes[i]); - } - } - - function createMapTypeMenuItem(mapType) - { - var item = addItem(mapType.name); - item.checkable = true; - item.triggered.connect(function(){selectMapType(mapType)}) - return item; - } - } - - Menu { - id: toolsMenu - property bool isFollowMe: false; - title: qsTr("Tools") - - function createMenu(map) - { - clear() - if (map.plugin.supportsGeocoding(Plugin.ReverseGeocodingFeature)) { - addItem(qsTr("Reverse geocode")).triggered.connect(function(){selectTool("RevGeocode")}) - } - if (map.plugin.supportsGeocoding()) { - addItem(qsTr("Geocode")).triggered.connect(function(){selectTool("Geocode")}) - } - if (map.plugin.supportsRouting()) { - addItem(qsTr("Route with coordinates")).triggered.connect(function(){selectTool("CoordinateRoute")}) - addItem(qsTr("Route with address")).triggered.connect(function(){selectTool("AddressRoute")}) - } - - var item = addItem("") - item.text = Qt.binding(function() { return isFollowMe ? qsTr("Stop following") : qsTr("Follow me")}) - item.triggered.connect(function() {toggleMapState("FollowMe")}) - - addItem(qsTr("Language")).triggered.connect(function(){selectTool("Language")}) - addItem(qsTr("Prefetch Map Data")).triggered.connect(function(){selectTool("Prefetch")}) - addItem(qsTr("Clear Map Data")).triggered.connect(function(){selectTool("Clear")}) - } - } -} diff --git a/app/menus/MapPopupMenu.qml b/app/menus/MapPopupMenu.qml deleted file mode 100644 index b8cc841..0000000 --- a/app/menus/MapPopupMenu.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -Menu { - property variant coordinate - property int markersCount - property int mapItemsCount - signal itemClicked(string item) - - function update() { - clear() - addItem(qsTr("Add Marker")).triggered.connect(function(){itemClicked("addMarker")}) - addItem(qsTr("Get coordinate")).triggered.connect(function(){itemClicked("getCoordinate")}) - addItem(qsTr("Fit Viewport To Map Items")).triggered.connect(function(){itemClicked("fitViewport")}) - - if (markersCount > 0) { - addItem(qsTr("Delete all markers")).triggered.connect(function(){itemClicked("deleteMarkers")}) - } - - if (mapItemsCount > 0) { - addItem(qsTr("Delete all items")).triggered.connect(function(){itemClicked("deleteItems")}) - } - } -} diff --git a/app/menus/MarkerPopupMenu.qml b/app/menus/MarkerPopupMenu.qml deleted file mode 100644 index 61855ff..0000000 --- a/app/menus/MarkerPopupMenu.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -Menu { - property int currentMarker - property int markersCount - signal itemClicked(string item) - - function update() { - clear() - addItem(qsTr("Delete")).triggered.connect(function(){itemClicked("deleteMarker")}) - addItem(qsTr("Coordinates")).triggered.connect(function(){itemClicked("getMarkerCoordinate")}) - addItem(qsTr("Move to")).triggered.connect(function(){itemClicked("moveMarkerTo")}) - if (currentMarker == markersCount-2){ - addItem(qsTr("Route to next point")).triggered.connect(function(){itemClicked("routeToNextPoint")}); - addItem(qsTr("Distance to next point")).triggered.connect(function(){itemClicked("distanceToNextPoint")}); - } - if (currentMarker < markersCount-2){ - addItem(qsTr("Route to next points")).triggered.connect(function(){itemClicked("routeToNextPoints")}); - addItem(qsTr("Distance to next point")).triggered.connect(function(){itemClicked("distanceToNextPoint")}); - } - - var menu = addMenu(qsTr("Draw...")) - menu.addItem(qsTr("Image")).triggered.connect(function(){itemClicked("drawImage")}) - - if (currentMarker <= markersCount-2){ - menu.addItem(qsTr("Rectangle")).triggered.connect(function(){itemClicked("drawRectangle")}) - menu.addItem(qsTr("Circle")).triggered.connect(function(){itemClicked("drawCircle")}) - menu.addItem(qsTr("Polyline")).triggered.connect(function(){itemClicked("drawPolyline")}) - } - - if (currentMarker < markersCount-2){ - menu.addItem(qsTr("Polygon")).triggered.connect(function(){itemClicked("drawPolygonMenu")}) - } - } -} diff --git a/app/qcheapruler.cpp b/app/qcheapruler.cpp new file mode 100644 index 0000000..4e520d2 --- /dev/null +++ b/app/qcheapruler.cpp @@ -0,0 +1,99 @@ +#include "qcheapruler.hpp" + +#include <QString> + +double QCheapRuler::distance() const +{ + return m_distance; +} + +double QCheapRuler::currentDistance() const +{ + return m_currentDistance; +} + +void QCheapRuler::setCurrentDistance(double current) +{ + if (m_path.empty()) { + m_currentDistance = 0.; + m_currentPosition = QGeoCoordinate(0., 0.); + m_segmentIndex = 0; + + return; + } + + double currentDistance = qMin(qMax(0., current), distance()); + if (m_currentDistance != currentDistance) { + m_currentDistance = currentDistance; + emit currentDistanceChanged(); + } + + cr::point c = ruler().along(m_path, m_currentDistance); + if (m_currentPosition != QGeoCoordinate(c.y, c.x)) { + m_currentPosition = QGeoCoordinate(c.y, c.x); + emit currentPositionChanged(); + } + + unsigned segmentIndex = ruler().pointOnLine(m_path, c).second; + if (m_segmentIndex != segmentIndex) { + m_segmentIndex = segmentIndex; + emit segmentIndexChanged(); + } +} + +QGeoCoordinate QCheapRuler::currentPosition() const +{ + return m_currentPosition; +} + +unsigned QCheapRuler::segmentIndex() const +{ + return m_segmentIndex; +} + +QJSValue QCheapRuler::path() const +{ + // Should neveer be called. + return QJSValue(); +} + +void QCheapRuler::setPath(const QJSValue &value) +{ + if (!value.isArray()) + return; + + m_path.clear(); + quint32 length = value.property(QStringLiteral("length")).toUInt(); + + for (unsigned i = 0; i < length; ++i) { + auto property = value.property(i); + cr::point coordinate = { 0., 0. }; + + if (property.hasProperty(QStringLiteral("latitude"))) + coordinate.y = property.property(QStringLiteral("latitude")).toNumber(); + + if (property.hasProperty(QStringLiteral("longitude"))) + coordinate.x = property.property(QStringLiteral("longitude")).toNumber(); + + m_path.push_back(coordinate); + } + + double distance = ruler().lineDistance(m_path); + if (m_distance != distance) { + m_distance = distance; + emit distanceChanged(); + } + + setCurrentDistance(0.); + + emit pathChanged(); +} + +cr::CheapRuler QCheapRuler::ruler() const +{ + if (m_path.empty()) { + return cr::CheapRuler(0., cr::CheapRuler::Kilometers); + } else { + return cr::CheapRuler(m_currentPosition.latitude(), cr::CheapRuler::Kilometers); + } +} diff --git a/app/qcheapruler.hpp b/app/qcheapruler.hpp new file mode 100644 index 0000000..4510315 --- /dev/null +++ b/app/qcheapruler.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include <QGeoCoordinate> +#include <QJSValue> +#include <QObject> + +#include <mapbox/cheap_ruler.hpp> + +namespace cr = mapbox::cheap_ruler; + +class QCheapRuler : public QObject { + Q_OBJECT + Q_PROPERTY(double distance READ distance NOTIFY distanceChanged) + Q_PROPERTY(double currentDistance READ currentDistance WRITE setCurrentDistance NOTIFY currentDistanceChanged) + Q_PROPERTY(unsigned segmentIndex READ segmentIndex NOTIFY segmentIndexChanged) + Q_PROPERTY(QGeoCoordinate currentPosition READ currentPosition NOTIFY currentPositionChanged) + Q_PROPERTY(QJSValue path READ path WRITE setPath NOTIFY pathChanged) + +public: + QCheapRuler() = default; + + double distance() const; + + double currentDistance() const; + void setCurrentDistance(double); + + unsigned segmentIndex() const; + + QGeoCoordinate currentPosition() const; + + QJSValue path() const; + void setPath(const QJSValue &value); + +signals: + void distanceChanged(); + void currentDistanceChanged(); + void currentPositionChanged(); + void segmentIndexChanged(); + void pathChanged(); + +private: + cr::CheapRuler ruler() const; + + double m_distance = 0.; + double m_currentDistance = 0.; + QGeoCoordinate m_currentPosition = QGeoCoordinate(0., 0.); + unsigned m_segmentIndex = 0; + + cr::line_string m_path; +}; diff --git a/app/qml/CustomLabel.qml b/app/qml/CustomLabel.qml new file mode 100644 index 0000000..12387a1 --- /dev/null +++ b/app/qml/CustomLabel.qml @@ -0,0 +1,9 @@ +import QtQuick 2.1 + +Text { + verticalAlignment: Text.AlignVCenter + font.family: "Lato" + font.weight: Font.Light + color: "#000000" + font.pixelSize: 24 +} diff --git a/app/qml/DateAndTime.qml b/app/qml/DateAndTime.qml new file mode 100644 index 0000000..65afb0b --- /dev/null +++ b/app/qml/DateAndTime.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.0 + +Item { + id: dateAndTime + + width: 53 * hspan + height: 33 * vspan + + property int hspan: 4 + property int vspan: 1 + property var currentDate: new Date(); + + RowLayout { + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + spacing: 10 + + CustomLabel { + font.capitalization: Font.AllUppercase + text: Qt.formatDateTime(dateAndTime.currentDate, "HH:mm") + + color: "#000000" + } + } + + Timer { + interval: 60000 + running: true + repeat: true + + onTriggered: { + dateAndTime.currentDate = new Date(); + } + } +} diff --git a/app/qml/Main.qml b/app/qml/Main.qml new file mode 100644 index 0000000..a2861e5 --- /dev/null +++ b/app/qml/Main.qml @@ -0,0 +1,28 @@ +import QtGraphicalEffects 1.0 +import QtLocation 5.9 +import QtPositioning 5.0 +import QtQuick 2.0 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.0 + +import com.mapbox.cheap_ruler 1.0 +import "qrc:/qml" + +ApplicationWindow { + id: window + + title: "QT MapboxGL Turn By Turn Navigation Demo" + height: 768 + width: 1024 + visible: true + + Item { + anchors.centerIn: parent + width: parent.width + height: parent.height + + MapWindow { + anchors.fill: parent + } + } +} diff --git a/app/qml/MapWindow.qml b/app/qml/MapWindow.qml new file mode 100644 index 0000000..3772c31 --- /dev/null +++ b/app/qml/MapWindow.qml @@ -0,0 +1,434 @@ +import QtLocation 5.9 +import QtPositioning 5.0 +import QtQuick 2.0 + +import com.mapbox.cheap_ruler 1.0 + +Item { + id: mapWindow + + // Km/h + property int carSpeed: 180 + property bool navigating: false + + property real rotateAngle: 0 + property var startPoint: QtPositioning.coordinate(36.12549, -115.173498) + property var endPoint: QtPositioning.coordinate(36.0659063, -115.1800443) + + states: [ + State { + name: "" + PropertyChanges { target: map; tilt: 0; bearing: 0; zoomLevel: map.zoomLevel } + }, + State { + name: "navigating" + PropertyChanges { target: map; tilt: 60; zoomLevel: 20 } + } + ] + + transitions: [ + Transition { + to: "*" + RotationAnimation { target: map; property: "bearing"; duration: 100; direction: RotationAnimation.Shortest } + NumberAnimation { target: map; property: "zoomLevel"; duration: 100 } + NumberAnimation { target: map; property: "tilt"; duration: 100 } + } + ] + + state: navigating ? "navigating" : "" + + Image { + id: backgroud + anchors.left: parent.left + anchors.top: parent.top + width: parent.width + height: 100 + + source: "qrc:simple-bottom-background-white.png" + z: 1 + } + + Image { + id: carCurrent + anchors.left: parent.left + anchors.top: parent.top + z: 3 + + visible: !mapWindow.navigating + source: "qrc:car-focus.png" + + MouseArea { + id: area + + anchors.fill: parent + + onClicked: { + mapWindow.navigating = true + currentDistanceAnimation.start(); + } + } + + scale: area.pressed ? 0.85 : 1.0 + + Behavior on scale { + NumberAnimation {} + } + } + + Image { + id: turnDirection + anchors.left: carCurrent.right + anchors.top: parent.top + anchors.leftMargin: 20 + + z: 3 + } + + CustomLabel { + id: distance + anchors.left: carCurrent.right + anchors.bottom: backgroud.bottom + z: 3 + + font.pixelSize: 38 + } + + CustomLabel { + id: turnInstructions + anchors.left: turnDirection.right + anchors.top: parent.top + anchors.leftMargin: 30 + anchors.topMargin: (backgroud.height-turnInstructions.height)/2 + z: 3 + + font.pixelSize: 38 + } + + Map { + id: map + anchors.fill: parent + + plugin: Plugin { + name: "mapboxgl" + + PluginParameter { + name: "mapboxgl.mapping.items.insert_before" + value: "road-label-small" + } + + PluginParameter { + name: "mapboxgl.mapping.additional_style_urls" + value: "mapbox://styles/mapbox/streets-v9" + } + + PluginParameter { + name: "mapboxgl.access_token" + value: "pk.eyJ1IjoidG1wc2FudG9zIiwiYSI6ImNqMWVzZWthbDAwMGIyd3M3ZDR0aXl3cnkifQ.FNxMeWCZgmujeiHjl44G9Q" + } + + PluginParameter { + name: "mapboxgl.mapping.cache.directory" + value: "/home/0/app-data/navigation/" + } + } + + center: mapWindow.navigating ? ruler.currentPosition : startPoint + zoomLevel: 5 + minimumZoomLevel: 0 + maximumZoomLevel: 20 + tilt: 0 + + copyrightsVisible: false + + MouseArea { + anchors.fill: parent + + onWheel: { + mapWindow.navigating = false + wheel.accepted = false + } + } + gesture.onPanStarted: { + mapWindow.navigating = false + } + + gesture.onPinchStarted: { + mapWindow.navigating = false + } + + RotationAnimation on bearing { + id: bearingAnimation + + duration: 250 + alwaysRunToEnd: false + direction: RotationAnimation.Shortest + running: mapWindow.navigating + } + + Location { + id: previousLocation + coordinate: QtPositioning.coordinate(0, 0); + } + + onCenterChanged: { + if (previousLocation.coordinate === center || !mapWindow.navigating) + return; + + bearingAnimation.to = previousLocation.coordinate.azimuthTo(center); + bearingAnimation.start(); + + previousLocation.coordinate = center; + } + + function updateRoute() { + routeQuery.clearWaypoints(); + routeQuery.addWaypoint(startMarker.coordinate); + routeQuery.addWaypoint(endMarker.coordinate); + } + + MapQuickItem { + id: startMarker + + sourceItem: Image { + id: greenMarker + source: "qrc:///marker-green.png" + } + + coordinate : startPoint + anchorPoint.x: greenMarker.width / 2 + anchorPoint.y: greenMarker.height / 2 + + MouseArea { + drag.target: parent + anchors.fill: parent + + onReleased: { + map.updateRoute(); + } + } + } + + MapQuickItem { + id: endMarker + + sourceItem: Image { + id: redMarker + source: "qrc:///marker-end.png" + } + + coordinate : endPoint + anchorPoint.x: redMarker.width / 2 + anchorPoint.y: redMarker.height / 2 + + MouseArea { + drag.target: parent + anchors.fill: parent + + onReleased: { + map.updateRoute(); + } + } + } + + MapItemView { + model: routeModel + + delegate: MapRoute { + route: routeData + line.color: "#6b43a1" + line.width: map.zoomLevel - 5 + opacity: (index == 0) ? 1.0 : 0.3 + + onRouteChanged: { + ruler.path = routeData.path; + ruler.currentDistance = 0; + + currentDistanceAnimation.stop(); + currentDistanceAnimation.to = ruler.distance; + } + } + } + + MapQuickItem { + zoomLevel: map.zoomLevel + + sourceItem: Image { + id: carMarker + source: "qrc:///car-marker2.png" + transform: Rotation { + origin.x: carMarker.width / 2; + origin.y: carMarker.height / 2; + angle: rotateAngle + } + } + + coordinate: ruler.currentPosition + anchorPoint.x: carMarker.width / 2 + anchorPoint.y: carMarker.height / 2 + + Location { + id: previousCarLocation + coordinate: QtPositioning.coordinate(0, 0); + } + + onCoordinateChanged: { + if(coordinate === mapWindow.startPoint) + return; + rotateAngle = previousCarLocation.coordinate.azimuthTo(coordinate); + previousCarLocation.coordinate = coordinate; + } + } + + CheapRuler { + id: ruler + + PropertyAnimation on currentDistance { + id: currentDistanceAnimation + + duration: ruler.distance / mapWindow.carSpeed * 60 * 60 * 1000 + alwaysRunToEnd: false + } + + onCurrentDistanceChanged: { + var total = 0; + var total2 = 0; + var i = 0; + var j = 0; + var alltime = routeModel.get(0).travelTime; + var alldistance = routeModel.get(0).distance; + + // XXX: Use car speed in meters to pre-warn the turn instruction + while (total - mapWindow.carSpeed < ruler.currentDistance * 1000 && i < routeModel.get(0).segments.length) + { + total += routeModel.get(0).segments[i++].maneuver.distanceToNextInstruction; + } + + while (total2 < ruler.currentDistance * 1000 && j < routeModel.get(0).segments.length) + { + total2 += routeModel.get(0).segments[j++].maneuver.distanceToNextInstruction; + } + + var dis = (total2 - ruler.currentDistance * 1000).toFixed(1); + if(dis > 1000) + { + distance.text = (dis / 1000).toFixed(1) + " km"; + } + else + { + distance.text = dis + " m"; + } + + var travaltimesec=((1 - (ruler.currentDistance * 1000)/alldistance)*alltime).toFixed(0); + + if((travaltimesec/3600)>=1) + { + travaltime.text = (travaltimesec/3600).toFixed(0) + "h" + ((travaltimesec%3600)/60).toFixed(0) + "min"; + } + else + { + travaltime.text = (travaltimesec/60).toFixed(0) + "min"; + } + + turnInstructions.text = routeModel.get(0).segments[i - 1].maneuver.instructionText; + + if(routeModel.get(0).segments[i - 1].maneuver.direction === RouteManeuver.DirectionForward) + { + turnDirection.source = "qrc:arrow-0.png"; + } + else if(routeModel.get(0).segments[i - 1].maneuver.direction === RouteManeuver.DirectionLightRight) + { + turnDirection.source = "qrc:arrow-r-30.png"; + } + else if(routeModel.get(0).segments[i - 1].maneuver.direction === RouteManeuver.DirectionRight) + { + turnDirection.source = "qrc:arrow-r-45.png"; + } + else if(routeModel.get(0).segments[i - 1].maneuver.direction === RouteManeuver.DirectionHardRight) + { + turnDirection.source = "qrc:arrow-r-75.png"; + } + else if(routeModel.get(0).segments[i - 1].maneuver.direction === RouteManeuver.DirectionUTurnRight) + { + turnDirection.source = "qrc:arrow-r-180.png"; + } + else if(routeModel.get(0).segments[i - 1].maneuver.direction === RouteManeuver.DirectionLightLeft) + { + turnDirection.source = "qrc:arrow-l-30.png"; + } + else if(routeModel.get(0).segments[i - 1].maneuver.direction === RouteManeuver.DirectionLeft) + { + turnDirection.source = "qrc:arrow-l-45.png"; + } + else if(routeModel.get(0).segments[i - 1].maneuver.direction === RouteManeuver.DirectionHardLeft) + { + turnDirection.source = "qrc:arrow-l-75.png"; + } + else if(routeModel.get(0).segments[i - 1].maneuver.direction === RouteManeuver.DirectionUTurnLeft) + { + turnDirection.source = "qrc:arrow-l-180.png"; + } + else + { + turnDirection.source = "qrc:arrow-0.png"; + } + + } + } + } + + RouteModel { + id: routeModel + + autoUpdate: true + query: routeQuery + + plugin: Plugin { + name: "mapbox" + + // Development access token, do not use in production. + PluginParameter { + name: "mapbox.access_token" + value: "pk.eyJ1IjoicXRzZGsiLCJhIjoiY2l5azV5MHh5MDAwdTMybzBybjUzZnhxYSJ9.9rfbeqPjX2BusLRDXHCOBA" + } + } + + Component.onCompleted: { + if (map) { + map.updateRoute(); + } + } + } + + RouteQuery { + id: routeQuery + } + + Image { + id: bottombackgroud + anchors.left: parent.left + anchors.bottom: parent.bottom + width: parent.width + height: 100 + + source: "qrc:simple-bottom-background-white.png" + z: 1 + } + + CustomLabel { + id: travaltime + anchors.left: bottombackgroud.left + anchors.verticalCenter: bottombackgroud.verticalCenter + visible: mapWindow.navigating + z: 3 + font.pixelSize: 38 + } + + Row { + anchors.horizontalCenter: bottombackgroud.horizontalCenter + anchors.verticalCenter: bottombackgroud.verticalCenter + width: bottombackgroud.width / 4 + spacing: 10 + z:3 + DateAndTime {} + } +} diff --git a/app/qml/qmldir b/app/qml/qmldir new file mode 100644 index 0000000..c59f9cd --- /dev/null +++ b/app/qml/qmldir @@ -0,0 +1,3 @@ +CustomLabel 1.0 CustomLabel.qml +DateAndTime 1.0 DateAndTime.qml +MapWindow 1.0 MapWindow.qml diff --git a/app/resources/car.png b/app/resources/car.png Binary files differdeleted file mode 100644 index 0a8195e..0000000 --- a/app/resources/car.png +++ /dev/null diff --git a/app/resources/icon.png b/app/resources/icon.png Binary files differdeleted file mode 100644 index 973a500..0000000 --- a/app/resources/icon.png +++ /dev/null diff --git a/app/resources/marker.png b/app/resources/marker.png Binary files differdeleted file mode 100644 index 2116dfd..0000000 --- a/app/resources/marker.png +++ /dev/null diff --git a/app/resources/scale.png b/app/resources/scale.png Binary files differdeleted file mode 100644 index c4f0812..0000000 --- a/app/resources/scale.png +++ /dev/null diff --git a/app/resources/scale_end.png b/app/resources/scale_end.png Binary files differdeleted file mode 100644 index 94510b1..0000000 --- a/app/resources/scale_end.png +++ /dev/null |