diff options
Diffstat (limited to 'examples/location')
108 files changed, 8783 insertions, 0 deletions
diff --git a/examples/location/common/common.pri b/examples/location/common/common.pri new file mode 100644 index 00000000..30ede711 --- /dev/null +++ b/examples/location/common/common.pri @@ -0,0 +1,37 @@ + +QML_IMPORT_PATH += $$PWD/imports + +RESOURCES += \ + $$PWD/common.qrc + +commonresources.files += $$PWD/resources/* + +qmlcomponents.files += \ + $$PWD/imports/QtLocation/examples/components/TextWithLabel.qml \ + $$PWD/imports/QtLocation/examples/components/Button.qml \ + $$PWD/imports/QtLocation/examples/components/Checkbox.qml \ + $$PWD/imports/QtLocation/examples/components/Fader.qml \ + $$PWD/imports/QtLocation/examples/components/Optionbutton.qml \ + $$PWD/imports/QtLocation/examples/components/Slider.qml \ + $$PWD/imports/QtLocation/examples/components/TitleBar.qml \ + $$PWD/imports/QtLocation/examples/components/ButtonRow.qml \ + $$PWD/imports/QtLocation/examples/components/Menu.qml \ + $$PWD/imports/QtLocation/examples/components/IconButton.qml \ + $$PWD/imports/QtLocation/examples/components/BusyIndicator.qml +OTHER_FILES += $$qmlcomponents.files + +qmlcomponentsstyle.files += \ + $$PWD/imports/QtLocation/examples/components/style/Style.qml \ + $$PWD/imports/QtLocation/examples/components/style/ButtonStyle.qml \ + $$PWD/imports/QtLocation/examples/components/style/HMenuItemStyle.qml \ + $$PWD/imports/QtLocation/examples/components/style/VMenuItemStyle.qml +OTHER_FILES += $$qmlcomponentsstyle.files + +qmldialogs.files += \ + $$PWD/imports/QtLocation/examples/dialogs/Dialog.qml \ + $$PWD/imports/QtLocation/examples/dialogs/InputDialog.qml \ + $$PWD/imports/QtLocation/examples/dialogs/ErrorDialog.qml +OTHER_FILES += $$qmldialogs.files + +qmldir.files += $$PWD/imports/QtLocation/examples/qmldir +OTHER_FILES += $$qmldir.files diff --git a/examples/location/common/common.qrc b/examples/location/common/common.qrc new file mode 100644 index 00000000..bfd79b73 --- /dev/null +++ b/examples/location/common/common.qrc @@ -0,0 +1,59 @@ +<RCC> + <qresource prefix="/"> + <file>imports/QtLocation/examples/qmldir</file> + <file>imports/QtLocation/examples/components/style/ButtonStyle.qml</file> + <file>imports/QtLocation/examples/components/style/HMenuItemStyle.qml</file> + <file>imports/QtLocation/examples/components/style/VMenuItemStyle.qml</file> + <file>imports/QtLocation/examples/components/BusyIndicator.qml</file> + <file>imports/QtLocation/examples/components/Button.qml</file> + <file>imports/QtLocation/examples/components/Checkbox.qml</file> + <file>imports/QtLocation/examples/components/Fader.qml</file> + <file>imports/QtLocation/examples/components/IconButton.qml</file> + <file>imports/QtLocation/examples/components/Menu.qml</file> + <file>imports/QtLocation/examples/components/Optionbutton.qml</file> + <file>imports/QtLocation/examples/components/Slider.qml</file> + <file>imports/QtLocation/examples/components/TextWithLabel.qml</file> + <file>imports/QtLocation/examples/components/TitleBar.qml</file> + <file>imports/QtLocation/examples/dialogs/Dialog.qml</file> + <file>imports/QtLocation/examples/dialogs/InputDialog.qml</file> + <file>imports/QtLocation/examples/dialogs/ErrorDialog.qml</file> + <file>resources/busy.png</file> + <file>resources/button_pressed.png</file> + <file>resources/button.png</file> + <file>resources/catch.png</file> + <file>resources/categories_pressed.png</file> + <file>resources/categories.png</file> + <file>resources/checkbox_selected.png</file> + <file>resources/checkbox.png</file> + <file>resources/cross_hovered.png</file> + <file>resources/cross_pressed.png</file> + <file>resources/cross.png</file> + <file>resources/hmenuItem_pressed.png</file> + <file>resources/hmenuItem.png</file> + <file>resources/left_pressed.png</file> + <file>resources/left.png</file> + <file>resources/marker_hovered.png</file> + <file>resources/marker_selected.png</file> + <file>resources/marker.png</file> + <file>resources/node_selected.png</file> + <file>resources/node.png</file> + <file>resources/option_button_selected.png</file> + <file>resources/option_button.png</file> + <file>resources/pencil_hovered.png</file> + <file>resources/pencil_pressed.png</file> + <file>resources/pencil.png</file> + <file>resources/quit_hovered.png</file> + <file>resources/quit_pressed.png</file> + <file>resources/quit.png</file> + <file>resources/right_pressed.png</file> + <file>resources/right.png</file> + <file>resources/scale_end.png</file> + <file>resources/scale.png</file> + <file>resources/search_pressed.png</file> + <file>resources/search.png</file> + <file>resources/star.png</file> + <file>resources/titlebar.png</file> + <file>resources/titlebar.sci</file> + <file>resources/vmenuItem.png</file> + </qresource> +</RCC> diff --git a/examples/location/common/imports/QtLocation/examples/components/BusyIndicator.qml b/examples/location/common/imports/QtLocation/examples/components/BusyIndicator.qml new file mode 100644 index 00000000..188b3d18 --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/BusyIndicator.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Image { + id: root + + source: "../../../../resources/busy.png" + + RotationAnimation on rotation { + loops: Animation.Infinite + from: 0 + to: 360 + duration: 500 + running: root.visible + } +} diff --git a/examples/location/common/imports/QtLocation/examples/components/Button.qml b/examples/location/common/imports/QtLocation/examples/components/Button.qml new file mode 100644 index 00000000..e98f8651 --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/Button.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import "style" + +Item { + id: container + + signal clicked + + property alias text: buttonText.text + property alias color: buttonText.color + property alias paintedWidth: buttonText.paintedWidth + property alias paintedHeight: buttonText.paintedHeight + property bool checked: false + property bool enabled: true + property ButtonStyle style: ButtonStyle{} + + width: buttonText.width * 1.2 + height: buttonText.height * 1.2 + + function disable() { + enabled = false; + } + + function enable() { + enabled = true; + } + + BorderImage { + id: buttonImage + source: container.style.background + anchors.fill: parent + } + + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + hoverEnabled: false + onClicked: { container.clicked() } + } + Text { + id: buttonText + color: checked ? container.style.fontcolor_selected : container.style.fontcolor_normal + anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 14 + style: Text.Normal + anchors.baseline: parent.bottom + anchors.baselineOffset: -6 + } + + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: buttonImage; source: container.style.pressedBackground } + }, + State { + name: "Hovered" + when: mouseRegion.containsMouse + PropertyChanges{ target: buttonImage; source: container.style.disabledBackground } + }, + State { + name: "Disabled" + when: !enabled + PropertyChanges{ target: buttonText; color: "dimgray" } + PropertyChanges{ target: mouseRegion; enabled: false } + } + ] +} diff --git a/examples/location/common/imports/QtLocation/examples/components/Checkbox.qml b/examples/location/common/imports/QtLocation/examples/components/Checkbox.qml new file mode 100644 index 00000000..d0526797 --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/Checkbox.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Item { + id: checkbox + property bool selected: false + property alias text: checkboxText.text + height: checkboxText.height + + Row { + id: checkboxRow + spacing: 3 + anchors.fill: parent + Image { + source: checkbox.selected ? "../../../../resources/checkbox_selected.png" : "../../../../resources/checkbox.png" + } + Text { + id: checkboxText + font.pixelSize: 14 + color: "#242424" + } + } + MouseArea { + anchors.fill: parent + onClicked: { checkbox.selected = !checkbox.selected } + } +} diff --git a/examples/location/common/imports/QtLocation/examples/components/Fader.qml b/examples/location/common/imports/QtLocation/examples/components/Fader.qml new file mode 100644 index 00000000..482bc365 --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/Fader.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Rectangle { + id: fader + anchors.fill: parent + opacity: 0.7 + color: "darkgrey" + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: false + } + + Component.onCompleted: { + var globalXY + var root = parent + + if (root != null) { + while (root.parent) root = root.parent + width = root.width; height = root.height; + globalXY = mapFromItem(root, root.x, root.y); + } else { + globalXY = mapFromItem(null, 0, 0); + } + x = globalXY.x; + y = globalXY.y; + } +} diff --git a/examples/location/common/imports/QtLocation/examples/components/IconButton.qml b/examples/location/common/imports/QtLocation/examples/components/IconButton.qml new file mode 100644 index 00000000..d426203f --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/IconButton.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Item { + id: root + + property url source + property url hoveredSource: source + property url pressedSource: source + + signal clicked + + width: childrenRect.width + height: childrenRect.height + + Image { + id: image + + source: parent.source + height: sourceSize.height + + MouseArea { + id: mouseRegion + hoverEnabled: false + anchors.fill: parent + onClicked: root.clicked() + } + + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed + PropertyChanges { target: image; source: pressedSource } + }, + State { + name: "Hover" + when: mouseRegion.containsMouse + PropertyChanges { target: image; source: hoveredSource } + } + ] + } +} diff --git a/examples/location/common/imports/QtLocation/examples/components/Menu.qml b/examples/location/common/imports/QtLocation/examples/components/Menu.qml new file mode 100644 index 00000000..0fed3c4a --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/Menu.qml @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Grid { + id: menu + enabled: opacity > 0 ? true : false + + property bool horizontalOrientation: true + property list <Button> buttons + width: parent.width + height: horizontalOrientation ? 40 : ((children.length > 0) ? children[0].height * children.length : 0) + spacing: 0 + property string exclusiveButton: "" + property bool exclusive: false + property bool autoWidth: false + opacity: 1 + rows: (horizontalOrientation) ? 1 : children.length + columns: (horizontalOrientation) ? children.length : 1 + signal clicked(string button) + + onChildrenChanged: { + resizeItems() + } + + onExclusiveChanged: { + if (exclusive){ + if (children.length > 0) exclusiveButton = children[0].text + } + else + exclusiveButton = "" + } + + onExclusiveButtonChanged:{ + if (exclusive) { + for (var i = 0; i<children.length; i++){ + if (children[i].text == exclusiveButton){ + children[i].checked = true + break + } + } + } + } + + function addItem(caption) { + var button, myArray + if (horizontalOrientation) + button = Qt.createQmlObject ('import "style"; Button {height: menu.height; onClicked: {menu.itemClicked(text)} style: HMenuItemStyle {}}', menu) + else + button = Qt.createQmlObject ('import "style"; Button {height: 35; width: menu.width; onClicked: {menu.itemClicked(text)} style: VMenuItemStyle {}}', menu) + button.text = caption + + myArray = new Array() + for (var i = 0; i<children.length; i++){ + myArray.push(children[i]) + } + myArray.push(button) + children = myArray + + return button + } + + function deleteItem(caption){ + var myArray + + myArray = new Array() + for (var i = 0; i<children.length; i++){ + if (children[i].text != caption) + myArray.push(children[i]) + } + children = myArray + } + + function clear() { + children = [] + exclusiveButton = "" + } + + function disableItem(caption){ + for (var i = 0; i<children.length; i++){ + if (children[i].text == caption){ + children[i].disable() + break + } + } + } + + function enableItem(caption){ + for (var i = 0; i<children.length; i++){ + if (children[i].text == caption){ + children[i].enable() + break + } + } + } + + function resizeItems(){ + if (horizontalOrientation) { + for (var i = 0; i<children.length; i++) + children[i].width = parent.width/children.length - spacing + } else if (autoWidth) { + if (children.length > 0) { + var maxWidth = children[0].paintedWidth + for (var i = 1; i<children.length; i++){ + if (children[i].paintedWidth > maxWidth) { + maxWidth = children[i].paintedWidth + } + } + menu.width = maxWidth + 20 + } + for (var i = 0; i < children.length; i++) + children[i].width = menu.width; + } + } + + function itemClicked(text){ + if (exclusive && text != exclusiveButton) { + for (var i = 0; i<children.length; i++){ + if (children[i].text == exclusiveButton){ + children[i].checked = false + break + } + } + exclusiveButton = text + } + clicked(text) + } +} diff --git a/examples/location/common/imports/QtLocation/examples/components/Optionbutton.qml b/examples/location/common/imports/QtLocation/examples/components/Optionbutton.qml new file mode 100644 index 00000000..208301da --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/Optionbutton.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Item { + id: optionbutton + + signal clicked + + property bool selected: false + property alias text: optionbuttonText.text + property bool toggle: false + + height: optionbuttonText.height + + Row { + id: optionbuttonRow + spacing: 3 + anchors.fill: parent + Image { + source: optionbutton.selected ? "../../../../resources/option_button_selected.png" : "../../../../resources/option_button.png" + } + Text { + id: optionbuttonText + font.pixelSize: 14 + color: "#242424" + } + } + MouseArea { + anchors.fill: parent + onClicked: { + if (toggle) { + if (optionbutton.selected) + optionbutton.selected = false + else + optionbutton.selected = true + } else { + optionbutton.selected = true + } + optionbutton.clicked() + } + } +} diff --git a/examples/location/common/imports/QtLocation/examples/components/Slider.qml b/examples/location/common/imports/QtLocation/examples/components/Slider.qml new file mode 100644 index 00000000..1a337425 --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/Slider.qml @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Item { + id: slider; + height: 10 + property real value // value is read/write. + property real minimum: 0 + property real maximum: 1 + property int length: width - handle.width + + Rectangle { + anchors.fill: parent + border.width: 1; + border.color: "lightgrey" + radius: 8 + color: "white" + opacity: 1 + } + + Rectangle { + anchors.left: parent.left + anchors.leftMargin: 4 + anchors.top: parent.top + anchors.topMargin: (parent.height - height)/2 + height: 3 + width: handle.x - x + color: "#1c94fc" + } + + + Rectangle { + id: labelRect + width: label.width + height: label.height + 4 + radius: 4 + smooth: true + color: "white" + border.color: "lightgrey" + anchors.bottom: handle.top + anchors.bottomMargin: 4 + x: Math.max(Math.min(handle.x + (handle.width - width )/2, slider.width - width),0) + visible: mouseRegion.pressed + Text{ + id: label + color: "darkgrey" + text: slider.value.toFixed(2) + width: font.pointSize * 3.5 + anchors.horizontalCenter: labelRect.horizontalCenter + horizontalAlignment: Text.AlignHCenter + anchors.baseline: parent.bottom + anchors.baselineOffset: -6 + font.pixelSize: 14 + } + } + + Rectangle { + id: handle; + smooth: true + width: 26; + y: (slider.height - height)/2; + x: (slider.value - slider.minimum) * slider.length / (slider.maximum - slider.minimum) + + height: width; radius: width/2 + gradient: normalGradient + border.width: 2 + border.color: "white" + + Gradient { + id: normalGradient + GradientStop { position: 0.0; color: "#b0b0b0" } + GradientStop { position: 0.66; color: "#909090" } + GradientStop { position: 1.0; color: "#545454" } + } + + MouseArea { + id: mouseRegion + hoverEnabled: false + anchors.fill: parent; drag.target: parent + drag.axis: Drag.XAxis; drag.minimumX: 0; drag.maximumX: slider.length + onPositionChanged: { slider.value = (slider.maximum - slider.minimum) * handle.x / slider.length + slider.minimum; } + } + } +} diff --git a/examples/location/common/imports/QtLocation/examples/components/TextWithLabel.qml b/examples/location/common/imports/QtLocation/examples/components/TextWithLabel.qml new file mode 100644 index 00000000..7b4d9aba --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/TextWithLabel.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Row { + id: textWithLabel + height: inputRectangle.height + + property alias label: label.text + property alias text: inputField.text + property alias labelWidth: label.width + property alias font: inputField.font + property alias busy: busyIndicator.visible + + Text { + id: label; + width:65; + enabled: textWithLabel.enabled + color: enabled ? "#242424" : "lightgrey" + anchors.verticalCenter: parent.verticalCenter + + font.pixelSize: 14 + } + + Rectangle { + id: inputRectangle + width: textWithLabel.width - label.width; height: inputField.font.pixelSize * 1.5 + color: enabled ? "white" : "ghostwhite" + + radius: 5 + TextInput { + id: inputField + width: parent.width - anchors.leftMargin + enabled: textWithLabel.enabled + color: enabled ? "#242424" : "lightgrey" + horizontalAlignment: Text.AlignLeft + + anchors { + left: parent.left; + verticalCenter: parent.verticalCenter; + leftMargin: 5 + } + font.pixelSize: 14 + + BusyIndicator { + id: busyIndicator + height: parent.height * 0.8 + width: height + anchors.verticalCenter: parent.verticalCenter + anchors.rightMargin: parent.height * 0.1 + anchors.topMargin: parent.height * 0.1 + anchors.top: parent.top + anchors.right: parent.right + visible: false + } + } + } +} diff --git a/examples/location/common/imports/QtLocation/examples/components/TitleBar.qml b/examples/location/common/imports/QtLocation/examples/components/TitleBar.qml new file mode 100644 index 00000000..0e67fd9a --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/TitleBar.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Item { + id: titleBar + + property alias text:titleText.text + property alias hoverEnabled: mouseRegion.hoverEnabled + property alias font: titleText.font + signal clicked + + BorderImage { source: "../../../../resources/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Image { + id: quitButton + anchors.right: parent.right; anchors.rightMargin: 10 + anchors.verticalCenter: parent.verticalCenter + source: "../../../../resources/quit.png" + MouseArea { + id: mouseRegion + hoverEnabled: false + anchors.fill: parent + onClicked: { titleBar.clicked(); } + } + } + + Text { + id: titleText + anchors { + left: parent.left; leftMargin: 10; verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + font.bold: true; font.pixelSize: 14; color: "white"; style: Text.Raised; styleColor: "dimgrey" + } + + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed + PropertyChanges { target: quitButton; source: "../../../../resources/quit_pressed.png" } + }, + State { + name: "Hover" + when: mouseRegion.containsMouse + PropertyChanges { target: quitButton; source: "../../../../resources/quit_hovered.png" } + } + ] +} diff --git a/examples/location/common/imports/QtLocation/examples/components/style/ButtonStyle.qml b/examples/location/common/imports/QtLocation/examples/components/style/ButtonStyle.qml new file mode 100644 index 00000000..d93fee11 --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/style/ButtonStyle.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +QtObject { + id: buttonStyle + property string background: "../../../../resources/button.png" + property string pressedBackground: "../../../../resources/button_pressed.png" + property string disabledBackground: "../../../../resources/button.png" + property color fontcolor_normal: "white" + property color fontcolor_selected: "#1c94fc" +} diff --git a/examples/location/common/imports/QtLocation/examples/components/style/HMenuItemStyle.qml b/examples/location/common/imports/QtLocation/examples/components/style/HMenuItemStyle.qml new file mode 100644 index 00000000..588fdb39 --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/style/HMenuItemStyle.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +ButtonStyle { + background: "../../../../resources/hmenuItem.png" + pressedBackground: "../../../../resources/hmenuItem_pressed.png" + disabledBackground: "../../../../resources/hmenuItem.png" + fontcolor_normal: "#242424" + fontcolor_selected: "#1c94fc" +} diff --git a/examples/location/common/imports/QtLocation/examples/components/style/VMenuItemStyle.qml b/examples/location/common/imports/QtLocation/examples/components/style/VMenuItemStyle.qml new file mode 100644 index 00000000..be7c245d --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/components/style/VMenuItemStyle.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +HMenuItemStyle { + background: "../../../../resources/vmenuItem.png" +} diff --git a/examples/location/common/imports/QtLocation/examples/dialogs/Dialog.qml b/examples/location/common/imports/QtLocation/examples/dialogs/Dialog.qml new file mode 100644 index 00000000..5ed5cfca --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/dialogs/Dialog.qml @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import "../components" + +Item { + id: dialog + + signal goButtonClicked + signal cancelButtonClicked + signal clearButtonClicked + + property alias title: titleBar.text + + property int gap: 10 + property bool showButtons: true + property Item item + + opacity: 0 + anchors.fill: parent + enabled: opacity > 0 ? true : false + + Fader {} + + onItemChanged: { + if (item) + item.parent = dataRect; + } + + Rectangle { + id: dialogRectangle + + property int maximumDialogHeight: { + if (dialog.opacity === 0 || + (Qt.inputMethod.keyboardRectangle.width === 0 && Qt.inputMethod.keyboardRectangle.height === 0)) { + return dialog.height; + } else { + return dialog.mapFromItem(null, Qt.inputMethod.keyboardRectangle.x, Qt.inputMethod.keyboardRectangle.y).y + } + } + property int maximumContentHeight: maximumDialogHeight - titleBar.height - buttons.height - gap*1.5 + + color: "#ECECEC" + opacity: parent.opacity + + height: dataRect.height + titleBar.height + buttons.height + gap*1.5 + y: (maximumDialogHeight - height) / 2 + anchors.left: parent.left + anchors.leftMargin: gap/2 + anchors.right: parent.right + anchors.rightMargin: gap/2 + + radius: 5 + + TitleBar { + id: titleBar; + + height: 40 + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + + opacity: 0.9 + onClicked: { + Qt.inputMethod.hide(); + dialog.cancelButtonClicked(); + } + + } + + Rectangle { + id: dataRect + color: "#ECECEC" + radius: 5 + + anchors.top: titleBar.bottom + anchors.left: dialogRectangle.left + anchors.right: dialogRectangle.right + anchors.margins: gap/2 + height: Math.min(dialogRectangle.maximumContentHeight, item ? item.implicitHeight : 0) + + Binding { + target: item + property: "anchors.fill" + value: dataRect + } + Binding { + target: item + property: "anchors.margins" + value: gap/2 + } + } + + Row { + id: buttons + anchors.top: dataRect.bottom + anchors.topMargin: gap/2 + anchors.horizontalCenter: parent.horizontalCenter + spacing: gap/3 + height: 32 + visible: showButtons + Button { + id: buttonClearAll + text: "Clear" + width: 80 + height: parent.height + onClicked: dialog.clearButtonClicked() + } + Button { + id: buttonGo + text: "Go!" + width: 80 + height: parent.height + onClicked: dialog.goButtonClicked() + } + } + } +} diff --git a/examples/location/common/imports/QtLocation/examples/dialogs/ErrorDialog.qml b/examples/location/common/imports/QtLocation/examples/dialogs/ErrorDialog.qml new file mode 100644 index 00000000..f2fc5a25 --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/dialogs/ErrorDialog.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Dialog { + id: errorRoot + + property string text + opacity: 0 + showButtons:false + + item: Text { + id: errorText + text: errorRoot.text + } + + onCancelButtonClicked: { + opacity = 0; + } +} diff --git a/examples/location/common/imports/QtLocation/examples/dialogs/InputDialog.qml b/examples/location/common/imports/QtLocation/examples/dialogs/InputDialog.qml new file mode 100644 index 00000000..a905186e --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/dialogs/InputDialog.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import "../components" + +Dialog { + id: dialog + + property alias dialogModel: dialogModel + property alias length: dialogModel.count + + property int listItemHeight: 21 + + onClearButtonClicked: { + for (var i = 0; i < length; ++i) + dialogModel.set(i, { "inputText": "" }); + } + + item: ListView { + id: listview + + model: dialogModel + delegate: listDelegate + spacing: gap/2 + clip: true + snapMode: ListView.SnapToItem + implicitHeight: (listItemHeight + gap/2)*length + gap/2 + interactive: height < implicitHeight + width: parent.width + } + + function setModel(objects) { + dialogModel.clear(); + for (var i = 0; i < objects.length; ++i) { + dialogModel.append({ "labelText": objects[i][0], "inputText": objects[i][1] }); + } + } + + ListModel { + id: dialogModel + } + + Component { + id: listDelegate + + TextWithLabel { + id: textWithLabel + label: labelText + text: inputText + width: parent ? parent.width : 0 + labelWidth: 95 + + onTextChanged: dialogModel.set(index, {"inputText": text}) + } + } +} diff --git a/examples/location/common/imports/QtLocation/examples/qmldir b/examples/location/common/imports/QtLocation/examples/qmldir new file mode 100644 index 00000000..9089f6c0 --- /dev/null +++ b/examples/location/common/imports/QtLocation/examples/qmldir @@ -0,0 +1,13 @@ +BusyIndicator 5.0 components/BusyIndicator.qml +Button 5.0 components/Button.qml +Checkbox 5.0 components/Checkbox.qml +Fader 5.0 components/Fader.qml +IconButton 5.0 components/IconButton.qml +Menu 5.0 components/Menu.qml +Optionbutton 5.0 components/Optionbutton.qml +Slider 5.0 components/Slider.qml +TextWithLabel 5.0 components/TextWithLabel.qml +TitleBar 5.0 components/TitleBar.qml +Dialog 5.0 dialogs/Dialog.qml +ErrorDialog 5.0 dialogs/ErrorDialog.qml +InputDialog 5.0 dialogs/InputDialog.qml diff --git a/examples/location/common/resources/busy.png b/examples/location/common/resources/busy.png Binary files differnew file mode 100755 index 00000000..3cca7dab --- /dev/null +++ b/examples/location/common/resources/busy.png diff --git a/examples/location/common/resources/button.png b/examples/location/common/resources/button.png Binary files differnew file mode 100644 index 00000000..1e3e752c --- /dev/null +++ b/examples/location/common/resources/button.png diff --git a/examples/location/common/resources/button_pressed.png b/examples/location/common/resources/button_pressed.png Binary files differnew file mode 100644 index 00000000..21d9835f --- /dev/null +++ b/examples/location/common/resources/button_pressed.png diff --git a/examples/location/common/resources/catch.png b/examples/location/common/resources/catch.png Binary files differnew file mode 100644 index 00000000..c4fbba40 --- /dev/null +++ b/examples/location/common/resources/catch.png diff --git a/examples/location/common/resources/categories.png b/examples/location/common/resources/categories.png Binary files differnew file mode 100644 index 00000000..d1d82c2e --- /dev/null +++ b/examples/location/common/resources/categories.png diff --git a/examples/location/common/resources/categories_pressed.png b/examples/location/common/resources/categories_pressed.png Binary files differnew file mode 100644 index 00000000..965e0ad7 --- /dev/null +++ b/examples/location/common/resources/categories_pressed.png diff --git a/examples/location/common/resources/checkbox.png b/examples/location/common/resources/checkbox.png Binary files differnew file mode 100644 index 00000000..b9aab540 --- /dev/null +++ b/examples/location/common/resources/checkbox.png diff --git a/examples/location/common/resources/checkbox_selected.png b/examples/location/common/resources/checkbox_selected.png Binary files differnew file mode 100644 index 00000000..28b32f58 --- /dev/null +++ b/examples/location/common/resources/checkbox_selected.png diff --git a/examples/location/common/resources/cross.png b/examples/location/common/resources/cross.png Binary files differnew file mode 100644 index 00000000..835cd91a --- /dev/null +++ b/examples/location/common/resources/cross.png diff --git a/examples/location/common/resources/cross_hovered.png b/examples/location/common/resources/cross_hovered.png Binary files differnew file mode 100644 index 00000000..fdd23d79 --- /dev/null +++ b/examples/location/common/resources/cross_hovered.png diff --git a/examples/location/common/resources/cross_pressed.png b/examples/location/common/resources/cross_pressed.png Binary files differnew file mode 100644 index 00000000..c7a692af --- /dev/null +++ b/examples/location/common/resources/cross_pressed.png diff --git a/examples/location/common/resources/hmenuItem.png b/examples/location/common/resources/hmenuItem.png Binary files differnew file mode 100644 index 00000000..f2461f2d --- /dev/null +++ b/examples/location/common/resources/hmenuItem.png diff --git a/examples/location/common/resources/hmenuItem_pressed.png b/examples/location/common/resources/hmenuItem_pressed.png Binary files differnew file mode 100644 index 00000000..43336d1e --- /dev/null +++ b/examples/location/common/resources/hmenuItem_pressed.png diff --git a/examples/location/common/resources/left.png b/examples/location/common/resources/left.png Binary files differnew file mode 100644 index 00000000..c0efa646 --- /dev/null +++ b/examples/location/common/resources/left.png diff --git a/examples/location/common/resources/left_pressed.png b/examples/location/common/resources/left_pressed.png Binary files differnew file mode 100644 index 00000000..b4fee456 --- /dev/null +++ b/examples/location/common/resources/left_pressed.png diff --git a/examples/location/common/resources/marker.png b/examples/location/common/resources/marker.png Binary files differnew file mode 100644 index 00000000..86ec960e --- /dev/null +++ b/examples/location/common/resources/marker.png diff --git a/examples/location/common/resources/marker_hovered.png b/examples/location/common/resources/marker_hovered.png Binary files differnew file mode 100644 index 00000000..902ae591 --- /dev/null +++ b/examples/location/common/resources/marker_hovered.png diff --git a/examples/location/common/resources/marker_selected.png b/examples/location/common/resources/marker_selected.png Binary files differnew file mode 100644 index 00000000..f4bf8921 --- /dev/null +++ b/examples/location/common/resources/marker_selected.png diff --git a/examples/location/common/resources/node.png b/examples/location/common/resources/node.png Binary files differnew file mode 100644 index 00000000..46e85672 --- /dev/null +++ b/examples/location/common/resources/node.png diff --git a/examples/location/common/resources/node_selected.png b/examples/location/common/resources/node_selected.png Binary files differnew file mode 100644 index 00000000..a967f3cf --- /dev/null +++ b/examples/location/common/resources/node_selected.png diff --git a/examples/location/common/resources/option_button.png b/examples/location/common/resources/option_button.png Binary files differnew file mode 100644 index 00000000..90970424 --- /dev/null +++ b/examples/location/common/resources/option_button.png diff --git a/examples/location/common/resources/option_button_selected.png b/examples/location/common/resources/option_button_selected.png Binary files differnew file mode 100644 index 00000000..f1196286 --- /dev/null +++ b/examples/location/common/resources/option_button_selected.png diff --git a/examples/location/common/resources/pencil.png b/examples/location/common/resources/pencil.png Binary files differnew file mode 100644 index 00000000..a52cff02 --- /dev/null +++ b/examples/location/common/resources/pencil.png diff --git a/examples/location/common/resources/pencil_hovered.png b/examples/location/common/resources/pencil_hovered.png Binary files differnew file mode 100644 index 00000000..55053fc1 --- /dev/null +++ b/examples/location/common/resources/pencil_hovered.png diff --git a/examples/location/common/resources/pencil_pressed.png b/examples/location/common/resources/pencil_pressed.png Binary files differnew file mode 100644 index 00000000..f30f3703 --- /dev/null +++ b/examples/location/common/resources/pencil_pressed.png diff --git a/examples/location/common/resources/quit.png b/examples/location/common/resources/quit.png Binary files differnew file mode 100644 index 00000000..9a5cb8a2 --- /dev/null +++ b/examples/location/common/resources/quit.png diff --git a/examples/location/common/resources/quit_hovered.png b/examples/location/common/resources/quit_hovered.png Binary files differnew file mode 100644 index 00000000..bea8f251 --- /dev/null +++ b/examples/location/common/resources/quit_hovered.png diff --git a/examples/location/common/resources/quit_pressed.png b/examples/location/common/resources/quit_pressed.png Binary files differnew file mode 100644 index 00000000..e69aa111 --- /dev/null +++ b/examples/location/common/resources/quit_pressed.png diff --git a/examples/location/common/resources/right.png b/examples/location/common/resources/right.png Binary files differnew file mode 100644 index 00000000..db343b07 --- /dev/null +++ b/examples/location/common/resources/right.png diff --git a/examples/location/common/resources/right_pressed.png b/examples/location/common/resources/right_pressed.png Binary files differnew file mode 100644 index 00000000..111f386b --- /dev/null +++ b/examples/location/common/resources/right_pressed.png diff --git a/examples/location/common/resources/scale.png b/examples/location/common/resources/scale.png Binary files differnew file mode 100644 index 00000000..6e59ff08 --- /dev/null +++ b/examples/location/common/resources/scale.png diff --git a/examples/location/common/resources/scale_end.png b/examples/location/common/resources/scale_end.png Binary files differnew file mode 100644 index 00000000..5d3a471b --- /dev/null +++ b/examples/location/common/resources/scale_end.png diff --git a/examples/location/common/resources/search.png b/examples/location/common/resources/search.png Binary files differnew file mode 100644 index 00000000..6bad5bd7 --- /dev/null +++ b/examples/location/common/resources/search.png diff --git a/examples/location/common/resources/search_pressed.png b/examples/location/common/resources/search_pressed.png Binary files differnew file mode 100644 index 00000000..23c92fa3 --- /dev/null +++ b/examples/location/common/resources/search_pressed.png diff --git a/examples/location/common/resources/star.png b/examples/location/common/resources/star.png Binary files differnew file mode 100644 index 00000000..93451147 --- /dev/null +++ b/examples/location/common/resources/star.png diff --git a/examples/location/common/resources/titlebar.png b/examples/location/common/resources/titlebar.png Binary files differnew file mode 100644 index 00000000..5b1d09a1 --- /dev/null +++ b/examples/location/common/resources/titlebar.png diff --git a/examples/location/common/resources/titlebar.sci b/examples/location/common/resources/titlebar.sci new file mode 100644 index 00000000..0418d94c --- /dev/null +++ b/examples/location/common/resources/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/location/common/resources/vmenuItem.png b/examples/location/common/resources/vmenuItem.png Binary files differnew file mode 100644 index 00000000..9e4385e7 --- /dev/null +++ b/examples/location/common/resources/vmenuItem.png diff --git a/examples/location/location.pro b/examples/location/location.pro new file mode 100644 index 00000000..c186b7fc --- /dev/null +++ b/examples/location/location.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs + +qtHaveModule(quick) { + SUBDIRS += places \ + places_list \ + places_map + + qtHaveModule(multimedia): SUBDIRS += mapviewer +} diff --git a/examples/location/mapviewer/content/dialogs/Message.qml b/examples/location/mapviewer/content/dialogs/Message.qml new file mode 100644 index 00000000..7488eb83 --- /dev/null +++ b/examples/location/mapviewer/content/dialogs/Message.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation.examples 5.0 + +Item { + id: dialog + + anchors.fill: parent + + property alias title: titleBar.text + property alias text: message.text + property int gap: 10 + + signal okButtonClicked + signal cancelButtonClicked + opacity: 0 + enabled: opacity > 0 ? true : false + + Fader {} + + Rectangle { + id: dialogRectangle + + color: "#ECECEC" + width: parent.width - gap; + height: titleBar.height + message.height + okButton.height + gap*3 + anchors { + verticalCenter: parent.verticalCenter + left: parent.left + leftMargin: gap/2 + } + + radius: 5 + + TitleBar { + id: titleBar; + width: parent.width; height: 40; + anchors.top: parent.top; anchors.left: parent.left; + opacity: 0.9; + onClicked: { dialog.cancelButtonClicked() } + } + + Text { + id: message + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + anchors.top: titleBar.bottom + width: dialogRectangle.width - gap + anchors.topMargin: gap + textFormat: Text.RichText + wrapMode: Text.Wrap + onLinkActivated: { + Qt.openUrlExternally(link) + } + font.pixelSize: 14 + } + + Button { + id: okButton + text: "Ok" + anchors.top: message.bottom + anchors.topMargin: gap + width: 80; height: 32 + anchors.horizontalCenter: parent.horizontalCenter + onClicked: { + dialog.okButtonClicked () + } + } + } +} diff --git a/examples/location/mapviewer/content/dialogs/RouteDialog.qml b/examples/location/mapviewer/content/dialogs/RouteDialog.qml new file mode 100644 index 00000000..73e5f3d1 --- /dev/null +++ b/examples/location/mapviewer/content/dialogs/RouteDialog.qml @@ -0,0 +1,454 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtLocation.examples 5.0 + +Dialog { + id: dialog + + title: "Route" + gap: 6 + + property alias startLatitude: latFrom.text + property alias startLongitude: longFrom.text + property alias endLatitude: latTo.text + property alias endLongitude: longTo.text + property alias startStreet: streetFrom.text + property alias startCity: cityFrom.text + property alias startCountry: countryFrom.text + property alias endStreet: streetTo.text + property alias endCity: cityTo.text + property alias endCountry: countryTo.text + property alias byCoordinates: coord.enabled + + property int travelMode: RouteQuery.CarTravel // CarTravel, PedestrianTravel, BicycleTravel, PublicTransitTravel, TruckTravel + property int routeOptimization: RouteQuery.FastestRoute // ShortestRoute, FastestRoute, MostEconomicRoute, MostScenicRoute + property variant features: [] // NoFeature, TollFeature, HighwayFeature, PublicTransitFeature, FerryFeature, TunnelFeature, DirtRoadFeature, ParksFeature, MotorPoolLaneFeature + property color fontColorNormal: "#242424" + property color fontColorDisabled: "lightgrey" + property color backgroundColorNormal: "#ECECEC" + property color backgroundColorEnabled: "#98D0FC" + property color backgroundColorDisabled: "grey" + + item: Flickable { + id: f + + clip: true + interactive: height + gap < contentHeight + implicitHeight: contentItem.height + contentHeight: contentItem.height + contentWidth: contentItem.width + + Item { + id: contentItem + width: f.width + height: childrenRect.height + + Column { + id: options + spacing: gap + width: parent.width + + states: [ + State { + name: "Address" + PropertyChanges { target: coord; enabled: false } + PropertyChanges { target: address; enabled: true } + } + ] + + //by coordinates + Row { + id: row1 + spacing: gap + Image { + id: optionButtonCoord + anchors.verticalCenter:parent.verticalCenter + source: coord.enabled ? "../../resources/option_button_selected.png" : "../../resources/option_button.png" + MouseArea { + anchors.fill: parent + onClicked: { options.state = "" } + } + } + + Rectangle { + id: coord + color: enabled ? backgroundColorEnabled : backgroundColorDisabled + radius: 5 + width:options.width - optionButtonCoord.width - row1.spacing + height: longTo.y + longTo.height + gap + enabled: true + + //start point + Text { + id: fromLabel; + font.bold: true; + enabled: coord.enabled + anchors { + top: latFrom.top + topMargin:latFrom.height + gap/6 - fromLabel.height/2 + left: parent.left; + leftMargin: gap + } + text: "From" + color: enabled ? fontColorNormal : fontColorDisabled + font.pixelSize: 14 + } + + TextWithLabel { + id: latFrom + width: parent.width - fromLabel.width - gap*3 + text: "-27.575" + label: "latitude" + enabled: coord.enabled + anchors { + left: fromLabel.right + leftMargin: gap + top: parent.top + topMargin:gap + } + } + + TextWithLabel { + id: longFrom + width: latFrom.width + text: "153.088" + label: "longitude" + enabled: coord.enabled + anchors { + left: latFrom.left + top: latFrom.bottom + topMargin:gap/3 + } + } + + //end point + Text { + id: toLabel; + font.bold: true; + width: fromLabel.width + enabled: coord.enabled + anchors { + top: latTo.top + topMargin:latTo.height + gap/6 - toLabel.height/2 + left: parent.left; + leftMargin: gap; + } + text: "To" + color: enabled ? fontColorNormal : fontColorDisabled + font.pixelSize: 14 + } + + TextWithLabel { + id: latTo + width: latFrom.width + text: "-27.465" + label: "latitude" + enabled: coord.enabled + anchors { + left: toLabel.right + leftMargin: gap + top: longFrom.bottom + topMargin:gap + } + } + + TextWithLabel { + id: longTo + width: latTo.width + text: "153.023" + label: "longitude" + enabled: coord.enabled + anchors { + left: latTo.left + top: latTo.bottom + topMargin:gap/3 + } + } + } + } + + //by address + Row { + id: row2 + spacing: gap + + Image { + id: optionButtonAddress + source: address.enabled ? "../../resources/option_button_selected.png" : "../../resources/option_button.png" + anchors.verticalCenter: parent.verticalCenter + MouseArea { + anchors.fill: parent + onClicked: { options.state = "Address" } + } + } + + Rectangle { + id: address + color: enabled ? backgroundColorEnabled : backgroundColorDisabled + radius: 5 + width:coord.width + height: countryTo.y + countryTo.height + gap + enabled: false + + //start point + Text { + id: fromLabel2; + font.bold: true; + enabled: address.enabled + anchors { + top: cityFrom.top + left: parent.left; + leftMargin: gap + } + text: "From" + color: enabled ? fontColorNormal : fontColorDisabled + font.pixelSize: 14 + } + + TextWithLabel { + id: streetFrom + width: parent.width - fromLabel2.width - gap*3 + text: "Brandl st" + label: "street" + enabled: address.enabled + anchors { + left: fromLabel2.right + leftMargin: gap + top: parent.top + topMargin:gap + } + } + + TextWithLabel { + id: cityFrom + width: streetFrom.width + text: "Eight Mile Plains" + label: "city" + enabled: address.enabled + anchors { + left: streetFrom.left + top: streetFrom.bottom + topMargin:gap/3 + } + } + + TextWithLabel { + id: countryFrom + width: streetFrom.width + text: "Australia" + label: "country" + enabled: address.enabled + anchors { + left: streetFrom.left + top: cityFrom.bottom + topMargin:gap/3 + } + } + + //end point + Text { + id: toLabel2; + font.bold: true; + enabled: address.enabled + anchors { + top: cityTo.top + left: parent.left; + leftMargin: gap + } + text: "To" + color: enabled ? fontColorNormal : fontColorDisabled + font.pixelSize: 14 + } + + TextWithLabel { + id: streetTo + width: parent.width - fromLabel2.width - gap*3 + text: "Heal st" + label: "street" + enabled: address.enabled + anchors { + left: fromLabel2.right + leftMargin: gap + top: countryFrom.bottom + topMargin:gap + } + } + + TextWithLabel { + id: cityTo + width: streetTo.width + text: "New Farm" + label: "city" + enabled: address.enabled + anchors { + left: streetTo.left + top: streetTo.bottom + topMargin:gap/3 + } + } + + TextWithLabel { + id: countryTo + width: streetTo.width + text: "Australia" + label: "country" + enabled: address.enabled + anchors { + left: streetTo.left + top: cityTo.bottom + topMargin:gap/3 + } + } + } + } + } + + Row { + id: routeOptions + anchors.top: options.bottom + anchors.topMargin: gap + anchors.left: parent.left + anchors.leftMargin: gap + width: parent.width - gap*2 + height: checkboxToll.height*2 + gap + spacing: 0 + Column {//travel mode + spacing: gap/3 + height: parent.height + width: parent.width*0.325 + Optionbutton { + id: optionbuttonVehicle + width: parent.width + text: "Vehicle" + selected: true + onClicked: { + travelMode = RouteQuery.CarTravel + optionbuttonPedestrian.selected = false + } + } + Optionbutton { + id: optionbuttonPedestrian + width: parent.width + text: "Pedestrian" + onClicked: { + travelMode = RouteQuery.PedestrianTravel + optionbuttonVehicle.selected = false + } + } + } + + Column {//Optimization + spacing: gap/3 + height: parent.height + width: parent.width*0.275 + Optionbutton { + id: optionbuttonFastest + width: parent.width + text: "Fastest" + selected: true + onClicked: { + routeOptimization = RouteQuery.FastestRoute + optionbuttonShortest.selected = false + } + } + Optionbutton { + id: optionbuttonShortest + width: parent.width + text: "Shortest" + onClicked: { + routeOptimization = RouteQuery.ShortestRoute + optionbuttonFastest.selected = false + } + } + } + + Column {//Route features + id: routeFeatures + spacing: gap/3 + height: parent.height + width: parent.width*0.4 + Checkbox { + id: checkboxToll + width: parent.width + text: "Avoid toll roads" + onSelectedChanged: {routeFeatures.updateRouteFeatures()} + } + + Checkbox { + id: checkboxHighways + width: parent.width + text: "Avoid highways" + onSelectedChanged: {routeFeatures.updateRouteFeatures()} + } + + function updateRouteFeatures(){ + features = [] + var myArray = new Array + + if (checkboxToll.selected) myArray.push(RouteQuery.TollFeature) + if (checkboxHighways.selected) myArray.push(RouteQuery.HighwayFeature) + + features = myArray + } + } + } + } + } + + onClearButtonClicked: { + if (byCoordinates == true){ + latFrom.text = "" + longFrom.text = "" + latTo.text = "" + longTo.text = "" + } + else { + streetFrom.text = "" + cityFrom.text = "" + countryFrom.text = "" + streetTo.text = "" + cityTo.text = "" + countryTo.text = "" + } + } +} diff --git a/examples/location/mapviewer/content/map/3dItem.qml b/examples/location/mapviewer/content/map/3dItem.qml new file mode 100644 index 00000000..4c190429 --- /dev/null +++ b/examples/location/mapviewer/content/map/3dItem.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0; +import QtLocation 5.0 +import QtQuick 2.0 +import Qt3D 2.0 +import Qt3D.Shapes 2.0 + +// NOTE: If the creation of this compoment fails, make sure you have the latest +// qtquick3d (qml2 branch) and qtdeclarative installed. +// You can test your system with qtquick3d examples. +MapQuickItem { //to be used inside MapComponent only + id: mapItem + + // zoomLevel: 8 // set this if you want the item to follow zoom level changes + + function setGeometry(markers, index) { + coordinate.latitude = markers[index].coordinate.latitude + coordinate.longitude = markers[index].coordinate.longitude + } + + anchorPoint.x: testItem.width/2 + anchorPoint.y: testItem.height/2 + + sourceItem: Item { + id: testItem + width: 100 + height: 100 + Viewport { + width: parent.width; height: parent.height + renderMode: "BufferedRender" + navigation: false // set this true if you want to rotate/zoom with mouse + // but that interferes with map panning on 3d item area + Cube { + scale: 2 + transform: [ + Rotation3D { + angle: 45 + axis: Qt.vector3d(1, 0, 1) + }, + Rotation3D { + id: spin + angle: 0 + axis: Qt.vector3d(0, 1, 0) + }] + + NumberAnimation { + target: spin + property: "angle" + from: 0 + to: 360; duration: 5000; running: true + loops: NumberAnimation.Infinite } + + effect: Effect { + color: "#aaca00" + texture: "../../icon.png" + decal: true + } + } + } + } +} diff --git a/examples/location/mapviewer/content/map/CircleItem.qml b/examples/location/mapviewer/content/map/CircleItem.qml new file mode 100644 index 00000000..d7f03402 --- /dev/null +++ b/examples/location/mapviewer/content/map/CircleItem.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +//TODO: remove/refactor me when items are integrated + +MapCircle { + + color: "yellow" + border.color: "red" + border.width: 5 + smooth: true + opacity: 0.5 + + 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/examples/location/mapviewer/content/map/ImageItem.qml b/examples/location/mapviewer/content/map/ImageItem.qml new file mode 100644 index 00000000..a7146fbf --- /dev/null +++ b/examples/location/mapviewer/content/map/ImageItem.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0; +import QtLocation 5.0 + +MapQuickItem { //to be used inside MapComponent only + id: imageItem + + MapMouseArea { + 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: "../../icon.png" + opacity: 0.7 + } +} diff --git a/examples/location/mapviewer/content/map/MapComponent.qml b/examples/location/mapviewer/content/map/MapComponent.qml new file mode 100644 index 00000000..e51373a7 --- /dev/null +++ b/examples/location/mapviewer/content/map/MapComponent.qml @@ -0,0 +1,1157 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtPositioning 5.2 +import QtLocation.examples 5.0 + +//! [top] +Map { + id: map + zoomLevel: (maximumZoomLevel - minimumZoomLevel)/2 + + //! [coord] + center { + latitude: -27.5796 + longitude: 153.1003 + } + //! [coord] + + // Enable pinch gestures to zoom in and out + gesture.flickDeceleration: 3000 + gesture.enabled: true + +//! [top] + property variant markers + property variant mapItems + property int markerCounter: 0 // counter for total amount of markers. Resets to 0 when number of markers = 0 + property int currentMarker + signal resetState() + + property int lastX : -1 + property int lastY : -1 + property int pressX : -1 + property int pressY : -1 + property int jitterThreshold : 30 + property bool followme: false + property variant scaleLengths: [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000] + signal showDistance(string distance); + signal requestLocale() + + /* @todo + Binding { + target: map + property: 'center' + value: positionSource.position.coordinate + when: followme + }*/ + + PositionSource{ + id: positionSource + active: followme + + onPositionChanged: { + map.center = positionSource.position.coordinate + } + } + + MapCircle { + id: poiEightMilePlains + center { + latitude: -27.5758 + longitude: 153.0881 + } + + radius: 1800 + color: "green" + border.width: 2 + border.color: "#242424" + opacity: 0.7 + } + + MapQuickItem { + sourceItem: Text{ + text: "Eight Mile Plains" + color:"#242424" + font.bold: true + styleColor: "#ECECEC" + style: Text.Outline + } + coordinate { + latitude: -27.59 + longitude: 153.084 + } + anchorPoint.x: 0 + anchorPoint.y: 0 + } + + MapQuickItem { + id: poiNokia + sourceItem: Rectangle { width: 14; height: 14; color: "#1c94fc"; border.width: 2; border.color: "#242424"; smooth: true; radius: 7 } + coordinate { + latitude: -27.5796 + longitude: 153.1003 + } + opacity:0.7 + anchorPoint.x: sourceItem.width/2 + anchorPoint.y: sourceItem.height/2 + } + + MapQuickItem { + sourceItem: Text{ + text: "Nokia" + color:"#242424" + font.bold: true + styleColor: "#ECECEC" + style: Text.Outline + } + coordinate: poiNokia.coordinate + anchorPoint.x: -poiNokia.sourceItem.width * 0.5 + anchorPoint.y: poiNokia.sourceItem.height * 1.5 + } + + + Slider { + id: zoomSlider; + minimum: map.minimumZoomLevel; + maximum: map.maximumZoomLevel; + opacity: 1 + visible: parent.visible + z: map.z + 3 + anchors { + bottom: parent.bottom; + bottomMargin: 15; rightMargin: 10; leftMargin: 90 + left: parent.left + } + width: parent.width - anchors.rightMargin - anchors.leftMargin + + value: map.zoomLevel + + Binding { + target: zoomSlider; property: "value"; value: map.zoomLevel + } + + onValueChanged: { + map.zoomLevel = value + map.state="" + map.resetState() + } + } + + Button { + id: languageButton + text: "en" + width: 30 + height: 30 + z: map.z + 2 + anchors.bottom: zoomSlider.top + anchors.bottomMargin: 8 + anchors.right: zoomSlider.right + onClicked: { + map.state = "LanguageMenu" + } + } + + Menu { + id:languageMenu + horizontalOrientation: false + autoWidth: true + opacity: 0 + z: map.z + 4 + anchors.bottom: languageButton.top + anchors.right: languageButton.left + onClicked: { + switch (button) { + case "en": + case "fr": { + setLanguage(button); + break; + } + case "Other": { + map.requestLocale() + } + } + map.state = "" + } + Component.onCompleted: { + addItem("en") + addItem("fr") + addItem("Other") + } + } + +//! [routemodel0] + property RouteQuery routeQuery: RouteQuery {} + + property RouteModel routeModel: RouteModel { + plugin : map.plugin + query: routeQuery +//! [routemodel0] + +//! [routemodel1] + onStatusChanged: { + if (status == RouteModel.Ready) { + switch (count) { + case 0: + clearAll() // technically not an error + map.routeError() + break + case 1: + routeInfoModel.update() + break + } + } else if (status == RouteModel.Error) { + clearAll() + map.routeError() + } + } +//! [routemodel1] + +//! [routemodel2] + function clearAll() { + routeInfoModel.update() + } +//! [routemodel2] +//! [routemodel3] + } +//! [routemodel3] + +//! [geocodemodel0] + property GeocodeModel geocodeModel: GeocodeModel { +//! [geocodemodel0] +//! [geocodemodel0 body] + 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 body] +//! [geocodemodel1] + } +//! [geocodemodel1] + + signal showGeocodeInfo() + signal moveMarker() + + signal geocodeFinished() + signal routeError() + signal coordinatesCaptured(double latitude, double longitude) + + Component.onCompleted: { + markers = new Array(); + mapItems = new Array(); + } + +//! [routedelegate0] + Component { + id: routeDelegate + + MapRoute { + route: routeData + + line.color: routeMouseArea.containsMouse ? "lime" : "red" + line.width: 5 + smooth: true + opacity: 0.8 +//! [routedelegate0] + MapMouseArea { + id: routeMouseArea + anchors.fill: parent + hoverEnabled: false + + onPressed : { + map.resetState(); + map.state = "" + map.lastX = mouse.x + parent.x + map.lastY = mouse.y + parent.y + map.pressX = mouse.x + parent.x + map.pressY = mouse.y + parent.y + } + + onPositionChanged: { + if (map.state != "RoutePopupMenu" || + Math.abs(map.pressX - parent.x- mouse.x ) > map.jitterThreshold || + Math.abs(map.pressY - parent.y -mouse.y ) > map.jitterThreshold) { + map.state = "" + } + if ((mouse.button == Qt.LeftButton) & (map.state == "")) { + 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) { + map.state = "RoutePopupMenu" + } + } + } + } +//! [routedelegate1] + } +//! [routedelegate1] + +//! [pointdel0] + Component { + id: pointDelegate + + MapCircle { + radius: 1000 + color: circleMouseArea.containsMouse ? "lime" : "red" + opacity: 0.6 + center: locationData.coordinate +//! [pointdel0] + MapMouseArea { + anchors.fill:parent + id: circleMouseArea + hoverEnabled: false + + onPressed : { + map.resetState(); + map.state = "" + map.lastX = mouse.x + parent.x + map.lastY = mouse.y + parent.y + map.pressX = mouse.x + parent.x + map.pressY = mouse.y + parent.y + } + + onPositionChanged: { + if (map.state != "PointPopupMenu" || + Math.abs(map.pressX - parent.x- mouse.x ) > map.jitterThreshold || + Math.abs(map.pressY - parent.y -mouse.y ) > map.jitterThreshold) { + map.state = "" + if (pressed) parent.radius = parent.center.distanceTo(mouseToCoordinate(mouse)) + } + if ((mouse.button == Qt.LeftButton) & (map.state == "")) { + 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) { + map.state = "PointPopupMenu" + } + } + } +//! [pointdel1] + } + } +//! [pointdel1] + +//! [routeinfodel0] + Component { + id: routeInfoDelegate + Row { + spacing: 10 +//! [routeinfodel0] + Text { + id: indexText + text: index + 1 + color: "#242424" + font.bold: true + font.pixelSize: 14 + } +//! [routeinfodel1] + Text { + id: instructionText + text: instruction + color: "#242424" + wrapMode: Text.Wrap +//! [routeinfodel1] + width: textArea.width - indexText.width - distanceText.width - spacing*4 +//! [routeinfodel2] + font.pixelSize: 14 + } + Text { + id: distanceText + text: distance + color: "#242424" + font.bold: true + font.pixelSize: 14 + } + } + } +//! [routeinfodel2] + + Component{ + id: routeInfoHeader + Item { + width: textArea.width + height: travelTime.height + line.anchors.topMargin + line.height + Text { + id: travelTime + text: routeInfoModel.travelTime + color: "#242424" + font.bold: true + font.pixelSize: 14 + anchors.left: parent.left + } + Text { + id: distance + text: routeInfoModel.distance + color: "#242424" + font.bold: true + font.pixelSize: 14 + anchors.right: parent.right + } + Rectangle { + id: line + color: "#242424" + width: parent.width + height: 2 + anchors.left: parent.left + anchors.topMargin: 1 + anchors.top: distance.bottom + } + } + } + +//! [routeinfomodel] + ListModel { + id: routeInfoModel + + property string travelTime + property string distance + + function update() { + clear() + if (routeModel.count > 0) { + for (var i = 0; i < routeModel.get(0).segments.length; i++) { + append({ + "instruction": routeModel.get(0).segments[i].maneuver.instructionText, + "distance": formatDistance(routeModel.get(0).segments[i].maneuver.distanceToNextInstruction) + }); + } + } + travelTime = routeModel.count == 0 ? "" : formatTime(routeModel.get(0).travelTime) + distance = routeModel.count == 0 ? "" : formatDistance(routeModel.get(0).distance) + } + } +//! [routeinfomodel] + +//! [routeview] + MapItemView { + model: routeModel + delegate: routeDelegate + autoFitViewport: true + } +//! [routeview] + +//! [geocodeview] + MapItemView { + model: geocodeModel + delegate: pointDelegate + } +//! [geocodeview] + + Item { + id: infoTab + parent: scale.parent + z: map.z + 2 + height: parent.height - 180 + width: parent.width + x: -5 - infoRect.width + y: 60 + visible: (routeInfoModel.count > 0) + Image { + id: catchImage + source: "../../resources/catch.png" + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + MouseArea { + anchors.fill: parent + onClicked: { + if (infoTab.x == -5) infoTab.x -= infoRect.width + else infoTab.x = -5 + map.state = "" + } + } + } + + Behavior on x { + PropertyAnimation { properties: "x"; duration: 300; easing.type: Easing.InOutQuad } + } + + Rectangle { + id: infoRect + width: parent.width - catchImage.sourceSize.width + height: parent.height + color: "#ECECEC" + opacity: 1 + radius: 5 + MouseArea { + anchors.fill: parent + hoverEnabled: false + } + Item { + id: textArea + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.top: parent.top + anchors.topMargin: 10 + width: parent.width -15 + height: parent.height - 20 + ListView { + id: routeInfoView + model: routeInfoModel + delegate: routeInfoDelegate + header: routeInfoHeader + anchors.fill: parent + clip: true + } + } + } + } + + + Item {//scale + id: scale + parent: zoomSlider.parent + visible: scaleText.text != "0 m" + z: map.z + 2 + opacity: 0.6 + anchors { + bottom: zoomSlider.top; + bottomMargin: 8; + left: zoomSlider.left + } + Image { + id: scaleImageLeft + source: "../../resources/scale_end.png" + anchors.bottom: parent.bottom + anchors.left: parent.left + } + Image { + id: scaleImage + source: "../../resources/scale.png" + anchors.bottom: parent.bottom + anchors.left: scaleImageLeft.right + } + Image { + id: scaleImageRight + source: "../../resources/scale_end.png" + anchors.bottom: parent.bottom + anchors.left: scaleImage.right + } + Text { + id: scaleText + color: "#004EAE" + horizontalAlignment: Text.AlignHCenter + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.bottomMargin: 3 + text: "0 m" + font.pixelSize: 14 + } + Component.onCompleted: { + map.calculateScale(); + } + } + + Timer { + id: scaleTimer + interval: 100 + running: false + repeat: false + onTriggered: { + map.calculateScale() + } + } + + onCenterChanged:{ + scaleTimer.restart() + if (map.followme) + if (map.center != positionSource.position.coordinate) map.followme = false + } + + onZoomLevelChanged:{ + scaleTimer.restart() + if (map.followme) map.center = positionSource.position.coordinate + } + + onWidthChanged:{ + scaleTimer.restart() + } + + onHeightChanged:{ + scaleTimer.restart() + } + + Menu { + id: markerMenu + horizontalOrientation: false + autoWidth: true + z: map.z + 4 + opacity: 0 + + width: 150 + x: 0 + y: 0 + onClicked: { + map.state = "" + switch (button) { + case "Delete": {//remove marker + map.deleteMarker(currentMarker) + break; + } + case "Move to": {//move marker + map.moveMarker() + break; + } + case "Coordinates": {//show marker's coordinates + map.coordinatesCaptured(markers[currentMarker].coordinate.latitude, markers[currentMarker].coordinate.longitude) + break; + } + case "Distance to next point": { + showDistance(formatDistance(map.markers[currentMarker].coordinate.distanceTo(map.markers[currentMarker+1].coordinate))); + break; + } + case "Route to next points"://calculate route + case "Route to next point": { + map.calculateRoute() + break; + } + case "Draw...": { + map.drawItemPopup() + break; + } + } + } + } + + Menu { + id: drawMenu + horizontalOrientation: false + autoWidth: true + z: map.z + 4 + opacity: 0 + + width: 150 + x: 0 + y: 0 + onClicked: { + map.state = "" + switch (button) { + case "Polyline": { + addGeoItem("PolylineItem") + break; + } + + case "Rectangle": { + addGeoItem("RectangleItem") + break; + } + + case "Circle": { + addGeoItem("CircleItem") + break; + } + + case "Polygon": { + addGeoItem("PolygonItem") + break; + } + + case "Image": { + addGeoItem("ImageItem") + break; + } + + case "Video": { + addGeoItem("VideoItem") + break; + } + + case "3D QML Item": { + addGeoItem("3dItem") + break; + } + } + } + } + + Menu { + id: popupMenu + horizontalOrientation: false + autoWidth: true + z: map.z + 4 + opacity: 0 + + width: 150 + x: 0 + y: 0 + + onClicked: { + switch (button) { + case "Add Marker": { + addMarker() + break; + } + case "Get coordinate": { + map.coordinatesCaptured(mouseArea.lastCoordinate.latitude, mouseArea.lastCoordinate.longitude) + break; + } + case "Fit Viewport To Map Items": { + map.fitViewportToMapItems() + break; + } + + case "Delete all markers": { + deleteMarkers() + break; + } + + case "Delete all items": { + deleteMapItems() + break; + } + } + map.state = "" + } + } + + Menu { + id: routeMenu + horizontalOrientation: false + autoWidth: true + z: map.z + 4 + opacity: 0 + + width: 150 + x: 0 + y: 0 + + onClicked: { + switch (button) { + case "Delete": {//delete route + routeModel.reset() + routeInfoModel.update() + break; + } + } + map.state = "" + } + Component.onCompleted: { + addItem("Delete") + } + } + + Menu { + id: pointMenu + horizontalOrientation: false + autoWidth: true + z: map.z + 4 + opacity: 0 + + width: 150 + x: 0 + y: 0 + + onClicked: { + switch (button) { + case "Info": { + map.showGeocodeInfo() + break; + } + case "Delete": { + geocodeModel.reset() + break; + } + } + map.state = "" + } + Component.onCompleted: { + addItem("Info") + addItem("Delete") + } + } + + Rectangle { + id: infoLabel + width: backgroundRect.width + 10 + height: infoText.height + 5 + y: 440 + anchors.left: map.left + z: map.z + 1 + color: "dimgrey" + opacity: (infoText.text !="") ? 0.8 : 0 + + Behavior on opacity { + NumberAnimation { duration: 200 } + } + Text { + id: infoText + width: parent.width + elide: Text.ElideLeft + maximumLineCount: 4 + wrapMode: Text.Wrap + font.bold: true + font.pixelSize: 14 + style: Text.Raised; + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 5 + anchors.rightMargin: 5 + color: "white" + } + } + + MapMouseArea { + id: mouseArea + property variant lastCoordinate + anchors.fill: parent + + onPressed : { + map.resetState(); + map.state = "" + map.lastX = mouse.x + map.lastY = mouse.y + map.pressX = mouse.x + map.pressY = mouse.y + lastCoordinate = mouseArea.mouseToCoordinate(mouse) + // if (mouse.button == Qt.MiddleButton) + // addMarker() + } + + onPositionChanged: { + if (map.state != "PopupMenu" || + Math.abs(map.pressX - mouse.x ) > map.jitterThreshold || + Math.abs(map.pressY - mouse.y ) > map.jitterThreshold) { + map.state = "" + } + if ((mouse.button == Qt.LeftButton) & (map.state == "")) { + // if ((map.lastX != -1) && (map.lastY != -1)) { + // var dx = mouse.x - map.lastX + // var dy = mouse.y - map.lastY + // map.pan(-dx, -dy) + // } + map.lastX = mouse.x + map.lastY = mouse.y + } + } + + onDoubleClicked: { + map.center = mouseArea.mouseToCoordinate(mouse) + if (mouse.button == Qt.LeftButton){ + map.zoomLevel += 1 + } else if (mouse.button == Qt.RightButton) map.zoomLevel -= 1 + lastX = -1 + lastY = -1 + } + + onPressAndHold:{ + if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold + && Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) { + popupMenu.clear() + popupMenu.addItem("Add Marker") + popupMenu.addItem("Get coordinate") + popupMenu.addItem("Fit Viewport To Map Items") + + if (map.markers.length>0) { + popupMenu.addItem("Delete all markers") + } + + if (map.mapItems.length>0) { + popupMenu.addItem("Delete all items") + } + map.state = "PopupMenu" + } + } + } + + + Keys.onPressed: { + if ((event.key == Qt.Key_Plus) || (event.key == Qt.Key_VolumeUp)) { + map.zoomLevel += 1 + } else if ((event.key == Qt.Key_Minus) || (event.key == Qt.Key_VolumeDown)){ + map.zoomLevel -= 1 + } + } + + 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 = 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 + + //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 markerPopup(){ + var array + var length = map.markers.length + + markerMenu.clear() + markerMenu.addItem("Delete") + markerMenu.addItem("Coordinates") + markerMenu.addItem("Move to") + markerMenu.addItem("Draw...") + + + if (currentMarker == length-2){ + markerMenu.addItem("Route to next point") + markerMenu.addItem("Distance to next point") + + } + if (currentMarker < length-2){ + markerMenu.addItem("Route to next points") + markerMenu.addItem("Distance to next point") + } + map.state = "MarkerPopupMenu" + } + + + function drawItemPopup(){ + var array + var length = map.markers.length + + drawMenu.clear() + + drawMenu.addItem("Image") + drawMenu.addItem("Video") + drawMenu.addItem("3D QML Item") + + if (currentMarker <= length-2){ + drawMenu.addItem("Rectangle") + drawMenu.addItem("Circle") + drawMenu.addItem("Polyline") + } + if (currentMarker < length-2){ + drawMenu.addItem("Polygon") + } + map.state = "DrawItemMenu" + } + + function calculateRoute(){ + 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 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 + } + + function setLanguage(lang) { + map.plugin.locales = lang; + if (map.plugin.locales.length > 0) { + languageButton.text = map.plugin.locales[0]; + } + } + + // states of map + states: [ + State { + name: "PopupMenu" + PropertyChanges { target: popupMenu; opacity: 1} + PropertyChanges { target: popupMenu; x: ((map.lastX + popupMenu.width > map.width) ? map.width - popupMenu.width : map.lastX)} + PropertyChanges { target: popupMenu; y: ((map.lastY + popupMenu.height > map.height - 40) ? map.height - popupMenu.height - 40 : map.lastY)} + }, + State { + name: "MarkerPopupMenu" + PropertyChanges { target: markerMenu; opacity: 1} + PropertyChanges { target: markerMenu; x: ((markers[currentMarker].lastMouseX + markerMenu.width > map.width) ? map.width - markerMenu.width : markers[currentMarker].lastMouseX )} + PropertyChanges { target: markerMenu; y: ((markers[currentMarker].lastMouseY + markerMenu.height > map.height - 40) ? map.height - markerMenu.height - 40 : markers[currentMarker].lastMouseY)} + }, + State { + name: "DrawItemMenu" + PropertyChanges { target: drawMenu; opacity: 1} + PropertyChanges { target: drawMenu; x: ((markers[currentMarker].lastMouseX + drawMenu.width > map.width) ? map.width - drawMenu.width : markers[currentMarker].lastMouseX )} + PropertyChanges { target: drawMenu; y: ((markers[currentMarker].lastMouseY + drawMenu.height > map.height - 40) ? map.height - drawMenu.height - 40 : markers[currentMarker].lastMouseY)} + }, + State { + name: "RoutePopupMenu" + PropertyChanges { target: routeMenu; opacity: 1} + PropertyChanges { target: routeMenu; x: ((map.lastX + routeMenu.width > map.width) ? map.width - routeMenu.width : map.lastX)} + PropertyChanges { target: routeMenu; y: ((map.lastY + routeMenu.height > map.height - 40) ? map.height - routeMenu.height - 40 : map.lastY)} + }, + State { + name: "PointPopupMenu" + PropertyChanges { target: pointMenu; opacity: 1} + PropertyChanges { target: pointMenu; x: ((map.lastX + pointMenu.width > map.width) ? map.width - pointMenu.width : map.lastX)} + PropertyChanges { target: pointMenu; y: ((map.lastY + pointMenu.height > map.height - 40) ? map.height - pointMenu.height - 40 : map.lastY)} + }, + State { + name: "LanguageMenu" + PropertyChanges { target: languageMenu; opacity: 1} + } + ] +//! [end] +} +//! [end] diff --git a/examples/location/mapviewer/content/map/Marker.qml b/examples/location/mapviewer/content/map/Marker.qml new file mode 100644 index 00000000..d7a1e838 --- /dev/null +++ b/examples/location/mapviewer/content/map/Marker.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0; +import QtLocation 5.0 +import QtLocation.examples 5.0 + +//! [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: markerMouseArea.containsMouse ? (markerMouseArea.pressed ? "../../resources/marker_selected.png" :"../../resources/marker_hovered.png") : "../../resources/marker.png" + MapMouseArea { + 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 + + 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 + } + } + map.state = "" + } + + onPressAndHold:{ + if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold + && Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) { + lastX = map.toScreenPosition(marker.coordinate).x + lastY = map.toScreenPosition(marker.coordinate).y + map.markerPopup() + } + } + } + + Text{ + id: number + y: image.height/4 + color: "white" + font.bold: true + font.pixelSize: 14 + width:27 + horizontalAlignment: Text.AlignHCenter + Component.onCompleted: { + text = map.markerCounter + } + } + +//! [mqi-closeimage] + } +//! [mqi-closeimage] + + Component.onCompleted: coordinate = mouseArea.lastCoordinate +//! [mqi-close] +} +//! [mqi-close] diff --git a/examples/location/mapviewer/content/map/MiniMap.qml b/examples/location/mapviewer/content/map/MiniMap.qml new file mode 100644 index 00000000..e5d03e49 --- /dev/null +++ b/examples/location/mapviewer/content/map/MiniMap.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +Rectangle{ + id: miniMapRect + width: 152 + height: 152 + anchors.right: (parent) ? parent.right : undefined + anchors.rightMargin: 10 + anchors.top: (parent) ? parent.top : undefined + anchors.topMargin: 10 + color: "#242424" + Map { + id: miniMap + anchors.top: parent.top + anchors.topMargin: 1 + anchors.left: parent.left + anchors.leftMargin: 1 + width: 150 + height: 150 + zoomLevel: (map.zoomLevel > minimumZoomLevel + 3) ? minimumZoomLevel + 3 : 2.5 + center: map.center + plugin: map.plugin + gesture.enabled: false + MapMouseArea{ + anchors.fill: parent + } + + MapRectangle { + color: "#44ff0000" + border.width: 1 + border.color: "red" + topLeft { + latitude: miniMap.center.latitude + 5 + longitude: miniMap.center.longitude - 5 + } + bottomRight { + latitude: miniMap.center.latitude - 5 + longitude: miniMap.center.longitude + 5 + } + } + } +} diff --git a/examples/location/mapviewer/content/map/PolygonItem.qml b/examples/location/mapviewer/content/map/PolygonItem.qml new file mode 100644 index 00000000..b6e41ea6 --- /dev/null +++ b/examples/location/mapviewer/content/map/PolygonItem.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +//TODO: remove me when items are integrated + +MapPolygon { + + color: "green" + border.color: "darkgreen" + border.width: 4 + smooth: true + opacity: 0.5 + + function setGeometry(markers, index){ + for (var i = index; i<markers.length; i++){ + addCoordinate(markers[i].coordinate) + } + } + MapMouseArea { + anchors.fill:parent + id: mousearea + drag.target: parent + } +} diff --git a/examples/location/mapviewer/content/map/PolylineItem.qml b/examples/location/mapviewer/content/map/PolylineItem.qml new file mode 100644 index 00000000..f065142e --- /dev/null +++ b/examples/location/mapviewer/content/map/PolylineItem.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +//TODO: remove/refactor me when items are integrated + +MapPolyline { + line.color: "blue" + line.width: 4 + opacity: 0.7 + smooth: true + + function setGeometry(markers, index){ + for (var i = index; i<markers.length; i++){ + addCoordinate(markers[i].coordinate) + } + } +} diff --git a/examples/location/mapviewer/content/map/RectangleItem.qml b/examples/location/mapviewer/content/map/RectangleItem.qml new file mode 100644 index 00000000..97896883 --- /dev/null +++ b/examples/location/mapviewer/content/map/RectangleItem.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +MapRectangle { + id: mapRectangle + + color: mousearea.containsMouse ? "lime" : "red" + opacity: 0.5 + border.width: 2.0 + + 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) + } + + Binding { + target: mapRectangle + property: 'border.width' + value: 60 + + when: ((topLeft.latitude == -27.1144) && + (topLeft.longitude == 152.6594) && + (bottomRight.latitude == -27.7434) && + (bottomRight.longitude == 153.3021)) + } + + MapMouseArea { + anchors.fill:parent + id: mousearea + hoverEnabled: false + drag.target: parent + } +} diff --git a/examples/location/mapviewer/content/map/VideoItem.qml b/examples/location/mapviewer/content/map/VideoItem.qml new file mode 100644 index 00000000..a3df3c99 --- /dev/null +++ b/examples/location/mapviewer/content/map/VideoItem.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0; +import QtLocation 5.0 +import QtMultimedia 5.0 + +// NOTE: If the creation of this compoment fails, make sure you have the latest +// qtmultimedia and relevant gstreamer etc packages installed. +// You can test your system with qtmultimedia examples. +MapQuickItem { //to be used inside MapComponent only + id: testVideoItem + + // zoomLevel: 8 // set this if you want the video to follow zoom level changes + + function setGeometry(markers, index) { + coordinate.latitude = markers[index].coordinate.latitude + coordinate.longitude = markers[index].coordinate.longitude + } + + sourceItem: Rectangle { + id: testVideo + color: "black" + x: 0; + y: 0; + z: 500 + width: 176; + height: 144; + MediaPlayer { + id: player + source: "file://" + appDirPath + "/demo.ogv" + autoPlay: true + + onError: { + if (MediaPlayer.NoError != error) { + console.log(errorString) + } + } + } + VideoOutput { + id: videoItem + source: player + anchors.fill: parent + } + MouseArea{ + anchors.fill: parent + onClicked: { + if (player.playbackState == MediaPlayer.PlayingState) + player.stop() + else + player.play() + } + } + } +} diff --git a/examples/location/mapviewer/demo.ogv b/examples/location/mapviewer/demo.ogv Binary files differnew file mode 100644 index 00000000..1ed7e540 --- /dev/null +++ b/examples/location/mapviewer/demo.ogv diff --git a/examples/location/mapviewer/icon.png b/examples/location/mapviewer/icon.png Binary files differnew file mode 100644 index 00000000..0954baf0 --- /dev/null +++ b/examples/location/mapviewer/icon.png diff --git a/examples/location/mapviewer/mapviewer.pro b/examples/location/mapviewer/mapviewer.pro new file mode 100644 index 00000000..36fead08 --- /dev/null +++ b/examples/location/mapviewer/mapviewer.pro @@ -0,0 +1,49 @@ +TARGET = qml_location_mapviewer +TEMPLATE = app + +QT += qml network quick +SOURCES += qmlmapviewerwrapper.cpp + +RESOURCES += \ + mapviewerwrapper.qrc + +qmlcontent.files += \ + mapviewer.qml \ + demo.ogv +OTHER_FILES += $$qmlcontent.files + +qmlcontentmap.files += \ + content/map/MapComponent.qml \ + content/map/Marker.qml \ + content/map/CircleItem.qml \ + content/map/RectangleItem.qml \ + content/map/PolylineItem.qml \ + content/map/PolygonItem.qml \ + content/map/ImageItem.qml \ + content/map/VideoItem.qml \ + content/map/3dItem.qml \ + content/map/MiniMap.qml +OTHER_FILES += $$qmlcontentmap.files + +qmlcontentdialogs.files += \ + content/dialogs/Message.qml \ + content/dialogs/RouteDialog.qml +OTHER_FILES += $$qmlcontentdialogs.files + +include(../common/common.pri) + +target.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/mapviewer + +INSTALLS += target + +!equals($${_PRO_FILE_PWD_}, $${OUT_PWD}) { + MEDIAFILE = $${_PRO_FILE_PWD_}/demo.ogv + copy2build.input = MEDIAFILE + copy2build.output = $${OUT_PWD}/demo.ogv + !contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS + copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} + copy2build.name = COPY ${QMAKE_FILE_IN} + copy2build.CONFIG += no_link + copy2build.CONFIG += no_clean + QMAKE_EXTRA_COMPILERS += copy2build +} diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml new file mode 100644 index 00000000..59a5de5c --- /dev/null +++ b/examples/location/mapviewer/mapviewer.qml @@ -0,0 +1,722 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtPositioning 5.2 +import QtLocation.examples 5.0 +import "content/map" +import "content/dialogs" + +Item { + id: page + width: parent ? parent.width : 360 + height: parent ? parent.height : 640 + property variant map + property variant minimap + property variant parameters + + Rectangle { + id: backgroundRect + anchors.fill: parent + color: "lightgrey" + z:2 + } + + //=====================Menu===================== + Menu { + id:mainMenu + anchors.bottom: parent.bottom + z: backgroundRect.z + 3 + + Component.onCompleted: { + addItem("Tools") + addItem("Map Type") + addItem("Provider") + } + + onClicked: { + switch (button) { + case "Tools": { + page.state = "Tools" + break; + } + case "Map Type": { + page.state = "MapType" + break; + } + case "Provider": { + page.state = "Provider" + break; + } + } + } + } + + Menu { + id: toolsMenu + z: backgroundRect.z + 2 + y: page.height + horizontalOrientation: false + + onClicked: { + switch (button) { + case "Reverse geocode": { + page.state = "RevGeocode" + break; + } + case "Geocode": { + page.state = "Geocode" + break; + } + case "Route": { + page.state = "Route" + break; + } + case "Follow me": { + map.followme =true + page.state = "" + break; + } + case "Stop following": { + map.followme =false + page.state = "" + break; + } + case "Minimap": { + minimap = Qt.createQmlObject ('import "content/map"; MiniMap{ z: map.z + 2 }', map) + page.state = "" + break; + } + case "Hide minimap": { + if (minimap) minimap.destroy() + minimap = null + page.state = "" + break; + } + } + } + function update(){ + clear() + addItem("Reverse geocode") + addItem("Geocode") + addItem("Route") + var item = addItem("Follow me") + item.text = Qt.binding(function() { return map.followme ? "Stop following" : "Follow me" }); + item = addItem("Minimap") + item.text = Qt.binding(function() { return minimap ? "Hide minimap" : "Minimap" }); + } + } + + Menu { + id: mapTypeMenu + z: backgroundRect.z + 2 + y: page.height + horizontalOrientation: false + exclusive: true + + onClicked: { + page.state = "" + } + + onExclusiveButtonChanged: { + for (var i = 0; i<map.supportedMapTypes.length; i++){ + if (exclusiveButton == map.supportedMapTypes[i].name){ + map.activeMapType = map.supportedMapTypes[i] + break; + } + } + } + + function update(){ + clear() + for (var i = 0; i<map.supportedMapTypes.length; i++) + addItem(map.supportedMapTypes[i].name) + + if (map.supportedMapTypes.length > 0) + exclusiveButton = map.activeMapType.name + } + } + + Menu { + id: providerMenu + z: backgroundRect.z + 2 + y: page.height + horizontalOrientation: false + exclusive: true + + Component.onCompleted: { + var plugins = getPlugins() + for (var i = 0; i<plugins.length; i++) + addItem(plugins[i]) + } + + onClicked: { + page.state = "" + } + + onExclusiveButtonChanged: createMap(exclusiveButton) + } + + //=====================Dialogs===================== + Message { + id: messageDialog + z: backgroundRect.z + 2 + onOkButtonClicked: { + page.state = "" + } + onCancelButtonClicked: { + page.state = "" + } + + states: [ + State{ + name: "GeocodeError" + PropertyChanges { target: messageDialog; title: "Geocode Error" } + PropertyChanges { target: messageDialog; text: "No data available for the specified location" } + }, + State{ + name: "UnknownGeocodeError" + PropertyChanges { target: messageDialog; title: "Geocode Error" } + PropertyChanges { target: messageDialog; text: "Unsuccessful geocode" } + }, + State{ + name: "AmbiguousGeocode" + PropertyChanges { target: messageDialog; title: "Ambiguous geocode" } + PropertyChanges { target: messageDialog; text: map.geocodeModel.count + " results found for the given address, please specify location" } + }, + State{ + name: "RouteError" + PropertyChanges { target: messageDialog; title: "Route Error" } + PropertyChanges { target: messageDialog; text: "Unable to find a route for the given points"} + }, + State{ + name: "Coordinates" + PropertyChanges { target: messageDialog; title: "Coordinates" } + }, + State{ + name: "LocationInfo" + PropertyChanges { target: messageDialog; title: "Location" } + PropertyChanges { target: messageDialog; text: geocodeMessage() } + }, + State{ + name: "Distance" + PropertyChanges { target: messageDialog; title: "Distance" } + } + ] + } + + //Route Dialog +//! [routedialog0] + RouteDialog { + id: routeDialog + + property variant startCoordinate + property variant endCoordinate + +//! [routedialog0] + Address { id: startAddress } + Address { id: endAddress } + + z: backgroundRect.z + 2 + + GeocodeModel { + id: tempGeocodeModel + + property int success: 0 + + onCountChanged: { + if (success == 1 && count == 1) { + query = endAddress + 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 + routeDialog.calculateRoute() + } + } + else if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error)){ + var st = (success == 0 ) ? "start" : "end" + messageDialog.state = "" + if ((status == GeocodeModel.Ready) && (count == 0 )) messageDialog.state = "UnknownGeocodeError" + else if (status == GeocodeModel.Error) { + messageDialog.state = "GeocodeError" + messageDialog.text = "Unable to find location for the " + st + " point" + } + else if ((status == GeocodeModel.Ready) && (count > 1 )){ + messageDialog.state = "AmbiguousGeocode" + messageDialog.text = count + " results found for the " + st + " point, please specify location" + } + success = 0 + page.state = "Message" + map.routeModel.clearAll() + } + } + } + + onGoButtonClicked: { + tempGeocodeModel.reset() + messageDialog.state = "" + if (routeDialog.byCoordinates) { + startCoordinate = QtPositioning.coordinate(parseFloat(routeDialog.startLatitude), + parseFloat(routeDialog.startLongitude)); + endCoordinate = QtPositioning.coordinate(parseFloat(routeDialog.endLatitude), + parseFloat(routeDialog.endLongitude)); + + calculateRoute() + } + else { + startAddress.country = routeDialog.startCountry + startAddress.street = routeDialog.startStreet + startAddress.city = routeDialog.startCity + + endAddress.country = routeDialog.endCountry + endAddress.street = routeDialog.endStreet + endAddress.city = routeDialog.endCity + + tempGeocodeModel.query = startAddress + tempGeocodeModel.update(); + } + page.state = "" + } + + onCancelButtonClicked: { + page.state = "" + } + +//! [routerequest0] + function calculateRoute() { + // clear away any old data in the query + map.routeQuery.clearWaypoints(); + + // add the start and end coords as waypoints on the route + map.routeQuery.addWaypoint(startCoordinate) + map.routeQuery.addWaypoint(endCoordinate) + map.routeQuery.travelModes = routeDialog.travelMode + map.routeQuery.routeOptimizations = routeDialog.routeOptimization +//! [routerequest0] + +//! [routerequest0 feature weight] + for (var i=0; i<9; i++) { + map.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] + map.routeModel.update(); + + // center the map on the start coord + map.center = startCoordinate; +//! [routerequest1] + } +//! [routedialog1] + } +//! [routedialog1] + + //Geocode Dialog +//! [geocode0] + InputDialog { + id: geocodeDialog +//! [geocode0] + title: "Geocode" + z: backgroundRect.z + 2 + + Component.onCompleted: { + var obj = [["Street", "Brandl St"],["City", "Eight Mile Plains"],["State", ""],["Country","Australia"], ["Postal code", ""]] + setModel(obj) + } + +//! [geocode1] + Address { + id: geocodeAddress + } + + onGoButtonClicked: { + // manage the UI state transitions + page.state = "" + messageDialog.state = "" + + // fill out the Address element + geocodeAddress.street = dialogModel.get(0).inputText + geocodeAddress.city = dialogModel.get(1).inputText + geocodeAddress.state = dialogModel.get(2).inputText + geocodeAddress.country = dialogModel.get(3).inputText + geocodeAddress.postalCode = dialogModel.get(4).inputText + + // send the geocode request + map.geocodeModel.query = geocodeAddress + map.geocodeModel.update() + } +//! [geocode1] + + onCancelButtonClicked: { + page.state = "" + } +//! [geocode2] + } +//! [geocode2] + + //Reverse Geocode Dialog + InputDialog { + id: reverseGeocodeDialog + title: "Reverse Geocode" + z: backgroundRect.z + 2 + + Component.onCompleted: { + var obj = [["Latitude","-27.575"],["Longitude", "153.088"]] + setModel(obj) + } + + onGoButtonClicked: { + page.state = "" + messageDialog.state = "" + map.geocodeModel.query = QtPositioning.coordinate(parseFloat(dialogModel.get(0).inputText), + parseFloat(dialogModel.get(1).inputText)); + map.geocodeModel.update(); + } + + onCancelButtonClicked: { + page.state = "" + } + } + + //Get new coordinates for marker + InputDialog { + id: coordinatesDialog + title: "New coordinates" + z: backgroundRect.z + 2 + + Component.onCompleted: { + var obj = [["Latitude", ""],["Longitude", ""]] + setModel(obj) + } + + onGoButtonClicked: { + page.state = "" + messageDialog.state = "" + var newLat = parseFloat(dialogModel.get(0).inputText) + var newLong = parseFloat(dialogModel.get(1).inputText) + + if (newLat !== "NaN" && newLong !== "NaN") { + var c = QtPositioning.coordinate(newLat, newLong); + if (c.isValid) { + map.markers[map.currentMarker].coordinate = c; + map.center = c; + } + } + } + + onCancelButtonClicked: { + page.state = "" + } + } + + //Get new locale + InputDialog { + id: localeDialog + title: "New Locale" + z: backgroundRect.z + 2 + + Component.onCompleted: { + var obj = [["Language", ""]] + setModel(obj) + } + + onGoButtonClicked: { + page.state = "" + messageDialog.state = "" + map.setLanguage(dialogModel.get(0).inputText.split(Qt.locale().groupSeparator)); + } + + onCancelButtonClicked: { + page.state = "" + } + } + + + /* GeocodeModel { + id: geocodeModel + plugin : Plugin { name : "nokia"} + onLocationsChanged: { + if (geocodeModel.count > 0) { + console.log('setting the coordinate as locations changed in model.') + map.center = geocodeModel.get(0).coordinate + } + } + }*/ + + //=====================Map===================== + + /* MapObjectView { + model: geocodeModel + delegate: Component { + MapCircle { + radius: 10000 + color: "red" + center: location.coordinate + } + } + } + + + */ + +/* + + } +*/ + function geocodeMessage(){ + var street, district, city, county, state, countryCode, country, postalCode, latitude, longitude, text + latitude = Math.round(map.geocodeModel.get(0).coordinate.latitude * 10000) / 10000 + longitude =Math.round(map.geocodeModel.get(0).coordinate.longitude * 10000) / 10000 + street = map.geocodeModel.get(0).address.street + district = map.geocodeModel.get(0).address.district + city = map.geocodeModel.get(0).address.city + county = map.geocodeModel.get(0).address.county + state = map.geocodeModel.get(0).address.state + countryCode = map.geocodeModel.get(0).address.countryCode + country = map.geocodeModel.get(0).address.country + postalCode = map.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 createMap(provider){ + var plugin + if (parameters.length>0) + plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin{ name:"' + provider + '"; parameters: page.parameters}', page) + else + plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin{ name:"' + provider + '"}', page) + if (plugin.supportsMapping() + && plugin.supportsGeocoding(Plugin.ReverseGeocodingFeature) + && plugin.supportsRouting()) { + + if (map) { + map.destroy() + minimap = null + } + + map = Qt.createQmlObject ('import QtLocation 5.0;\ + import "content/map";\ + MapComponent{\ + z : backgroundRect.z + 1;\ + width: page.width;\ + height: page.height - mainMenu.height;\ + onFollowmeChanged: {toolsMenu.update()}\ + onSupportedMapTypesChanged: {mapTypeMenu.update()}\ + onCoordinatesCaptured: {\ + messageDialog.state = "Coordinates";\ + messageDialog.text = "<b>Latitude:</b> " + roundNumber(latitude,4) + "<br/><b>Longitude:</b> " + roundNumber(longitude,4);\ + page.state = "Message";\ + }\ + onGeocodeFinished:{\ + if (map.geocodeModel.status == GeocodeModel.Ready){\ + if (map.geocodeModel.count == 0) {messageDialog.state = "UnknownGeocodeError";}\ + else if (map.geocodeModel.count > 1) {messageDialog.state = "AmbiguousGeocode";}\ + else {messageDialog.state = "LocationInfo";}\ + }\ + else if (map.geocodeModel.status == GeocodeModel.Error) {messageDialog.state = "GeocodeError";}\ + page.state = "Message";\ + }\ + onShowDistance:{\ + messageDialog.state = "Distance";\ + messageDialog.text = "<b>Distance:</b> " + distance;\ + page.state = "Message";\ + }\ + onMoveMarker: {\ + page.state = "Coordinates";\ + }\ + onRouteError: {\ + messageDialog.state = "RouteError";\ + page.state = "Message";\ + }\ + onRequestLocale:{\ + page.state = "Locale";\ + }\ + onShowGeocodeInfo:{\ + messageDialog.state = "LocationInfo";\ + page.state = "Message";\ + }\ + onResetState: {\ + page.state = "";\ + }\ + }',page) + map.plugin = plugin; + tempGeocodeModel.plugin = plugin; + mapTypeMenu.update(); + toolsMenu.update(); + } + } + + function getPlugins(){ + var plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin {}', page) + var tempPlugin + var myArray = new Array() + for (var i = 0; i<plugin.availableServiceProviders.length; i++){ + tempPlugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin {name: "' + plugin.availableServiceProviders[i]+ '"}', page) + + if (tempPlugin.supportsMapping() + && tempPlugin.supportsGeocoding(Plugin.ReverseGeocodingFeature) + && tempPlugin.supportsRouting()) { + myArray.push(tempPlugin.name) + } + } + + return myArray + } + + function setPluginParameters(pluginParameters) { + var parameters = new Array() + for (var prop in pluginParameters){ + var parameter = Qt.createQmlObject('import QtLocation 5.0; PluginParameter{ name: "'+ prop + '"; value: "' + pluginParameters[prop]+'"}',page) + parameters.push(parameter) + } + page.parameters=parameters + if (providerMenu.exclusiveButton !== "") + createMap(providerMenu.exclusiveButton); + else if (providerMenu.children.length > 0) + createMap(providerMenu.children[0].text); + } + + //=====================States of page===================== + states: [ + State { + name: "RevGeocode" + PropertyChanges { target: reverseGeocodeDialog; opacity: 1 } + }, + State { + name: "Route" + PropertyChanges { target: routeDialog; opacity: 1 } + }, + State { + name: "Geocode" + PropertyChanges { target: geocodeDialog; opacity: 1 } + }, + State { + name: "Coordinates" + PropertyChanges { target: coordinatesDialog; opacity: 1 } + }, + State { + name: "Message" + PropertyChanges { target: messageDialog; opacity: 1 } + }, + State { + name : "Tools" + PropertyChanges { target: toolsMenu; y: page.height - toolsMenu.height - mainMenu.height } + }, + State { + name : "Provider" + PropertyChanges { target: providerMenu; y: page.height - providerMenu.height - mainMenu.height } + }, + State { + name : "MapType" + PropertyChanges { target: mapTypeMenu; y: page.height - mapTypeMenu.height - mainMenu.height } + }, + State { + name : "Locale" + PropertyChanges { target: localeDialog; opacity: 1 } + } + ] + + //=====================State-transition animations for page===================== + transitions: [ + Transition { + to: "RevGeocode" + NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } + }, + Transition { + to: "Route" + NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } + }, + Transition { + to: "Geocode" + NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } + }, + Transition { + to: "Coordinates" + NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } + }, + Transition { + to: "Message" + NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } + }, + Transition { + to: "" + NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } + }, + Transition { + to: "Provider" + NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } + }, + Transition { + to: "MapType" + NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } + }, + Transition { + to: "Tools" + NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } + } + ] +} diff --git a/examples/location/mapviewer/mapviewerwrapper.qrc b/examples/location/mapviewer/mapviewerwrapper.qrc new file mode 100644 index 00000000..854a6503 --- /dev/null +++ b/examples/location/mapviewer/mapviewerwrapper.qrc @@ -0,0 +1,19 @@ +<RCC> + <qresource prefix="/"> + <file>mapviewer.qml</file> + <file>icon.png</file> + <file>content/map/MapComponent.qml</file> + <file>content/map/Marker.qml</file> + <file>content/map/PolylineItem.qml</file> + <file>content/map/RectangleItem.qml</file> + <file>content/map/CircleItem.qml</file> + <file>content/map/PolygonItem.qml</file> + <file>content/dialogs/Message.qml</file> + <file>content/dialogs/RouteDialog.qml</file> + <file>content/map/ImageItem.qml</file> + <file>content/map/VideoItem.qml</file> + <file>content/map/3dItem.qml</file> + <file>content/map/MiniMap.qml</file> + <file>demo.ogv</file> + </qresource> +</RCC> diff --git a/examples/location/mapviewer/qmlmapviewerwrapper.cpp b/examples/location/mapviewer/qmlmapviewerwrapper.cpp new file mode 100644 index 00000000..5f5aee84 --- /dev/null +++ b/examples/location/mapviewer/qmlmapviewerwrapper.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + +#include <QtCore/QStringList> +#include <QtCore/QTextStream> +#include <QtGui/QGuiApplication> +#include <QtQml/QQmlEngine> +#include <QtQml/QQmlContext> +#include <QtQuick/QQuickView> +#include <QtQuick/QQuickItem> + +static bool parseArgs(QStringList& args, QVariantMap& parameters) +{ + + while (!args.isEmpty()) { + + QString param = args.takeFirst(); + + if (param.startsWith("--help")) { + QTextStream out(stdout); + out << "Usage: " << endl; + out << "--plugin.<parameter_name> <parameter_value> - Sets parameter = value for plugin" << endl; + out.flush(); + return true; + } + + if (param.startsWith("--plugin.")) { + + param.remove(0, 9); + + if (args.isEmpty() || args.first().startsWith("--")) { + parameters[param] = true; + } else { + + QString value = args.takeFirst(); + + if (value == "true" || value == "on" || value == "enabled") { + parameters[param] = true; + } else if (value == "false" || value == "off" + || value == "disable") { + parameters[param] = false; + } else { + parameters[param] = value; + } + } + } + } + return false; +} + +int main(int argc, char *argv[]) +{ + QGuiApplication application(argc, argv); + + QVariantMap parameters; + QStringList args(QCoreApplication::arguments()); + + if (parseArgs(args, parameters)) exit(0); + + const QString mainQmlApp = QLatin1String("qrc:///mapviewer.qml"); + QQuickView view; + + view.engine()->addImportPath(QLatin1String(":/imports")); + + view.rootContext()->setContextProperty("appDirPath", QCoreApplication::applicationDirPath()); + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + + QQuickItem *object = view.rootObject(); + QMetaObject::invokeMethod(object, "setPluginParameters", + Q_ARG(QVariant, QVariant::fromValue(parameters))); + + QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit())); + view.setGeometry(QRect(100, 100, 360, 640)); + view.show(); + return application.exec(); +} diff --git a/examples/location/places/content/places/CategoryDelegate.qml b/examples/location/places/content/places/CategoryDelegate.qml new file mode 100644 index 00000000..4bb2b8e0 --- /dev/null +++ b/examples/location/places/content/places/CategoryDelegate.qml @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtLocation.examples 5.0 + +Item { + id: root + + property bool showSave: true + property bool showRemove: true + property bool showChildren: true + + signal clicked + signal arrowClicked + signal crossClicked + signal editClicked + + width: parent.width + height: textItem.height + + Item { + id: textItem + anchors.left: parent.left + anchors.right: arrow.left + anchors.verticalCenter: parent.verticalCenter + + height: Math.max(icon.height, name.height) + + Image { + id: icon + + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + source: category.icon.url() + } + + //! [CategoryModel delegate text] + Text { + id: name + + anchors.left: icon.right + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + + verticalAlignment: Text.AlignVCenter + + text: category.name + elide: Text.ElideRight + } + + MouseArea { + anchors.fill: parent + onClicked: root.clicked() + } + //! [CategoryModel delegate text] + } + + //! [CategoryModel delegate icon] + IconButton { + id: edit + + anchors.right: cross.left + anchors.verticalCenter: parent.verticalCenter + + visible: (placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.SaveCategoryFeature) : false) + && showSave + + source: "../../resources/pencil.png" + hoveredSource: "../../resources/pencil_hovered.png" + pressedSource: "../../resources/pencil_pressed.png" + + onClicked: root.editClicked() + } + + IconButton { + id: cross + + anchors.right: arrow.left + anchors.verticalCenter: parent.verticalCenter + visible: (placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.RemoveCategoryFeature) : false) + && showRemove + + source: "../../resources/cross.png" + hoveredSource: "../../resources/cross_hovered.png" + pressedSource: "../../resources/cross_pressed.png" + + onClicked: root.crossClicked() + } + + IconButton { + id: arrow + + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + visible: model.hasModelChildren && showChildren + + source: "../../resources/right.png" + pressedSource: "../../resources/right_pressed.png" + + onClicked: root.arrowClicked() + } + //! [CategoryModel delegate icon] +} diff --git a/examples/location/places/content/places/CategoryDialog.qml b/examples/location/places/content/places/CategoryDialog.qml new file mode 100644 index 00000000..289d8501 --- /dev/null +++ b/examples/location/places/content/places/CategoryDialog.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtLocation.examples 5.0 + +InputDialog { + title: "Edit Category" + + property Category category + + Behavior on opacity { NumberAnimation { duration: 500 } } + + Component.onCompleted: prepareDialog() + onCategoryChanged: prepareDialog() + + function prepareDialog() { + setModel([ + ["Name", category ? category.name : ""] + ]); + } + + //! [Category save] + onGoButtonClicked: { + var modifiedCategory = category ? category : Qt.createQmlObject('import QtLocation 5.0; Category { }', page); + modifiedCategory.plugin = placesPlugin; + + modifiedCategory.name = dialogModel.get(0).inputText; + + category = modifiedCategory; + + category.save(); + } + //! [Category save] +} diff --git a/examples/location/places/content/places/CategoryView.qml b/examples/location/places/content/places/CategoryView.qml new file mode 100644 index 00000000..9b28e892 --- /dev/null +++ b/examples/location/places/content/places/CategoryView.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtLocation.examples 5.0 + + +//! [CategoryModel view 1] +ListView { + id: root + + property bool showSave: true + property bool showRemove: true + property bool showChildren: true + + signal categoryClicked(variant category) + signal editClicked(variant category) +//! [CategoryModel view 1] + + anchors.topMargin: 10 + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.right: parent.right + anchors.rightMargin: 10 + + clip: true + snapMode: ListView.SnapToItem + spacing: 5 + +//! [CategoryModel view 2] + header: IconButton { + source: "../../resources/left.png" + pressedSource: "../../resources/left_pressed.png" + onClicked: categoryListModel.rootIndex = categoryListModel.parentModelIndex() + } +//! [CategoryModel view 2] + +//! [CategoryModel view 3] + model: VisualDataModel { + id: categoryListModel + model: categoryModel + delegate: CategoryDelegate { + id: categoryDelegate + + showSave: root.showSave + showRemove: root.showRemove + showChildren: root.showChildren + + onClicked: root.categoryClicked(category); + onArrowClicked: categoryListModel.rootIndex = categoryListModel.modelIndex(index) + onCrossClicked: category.remove(); + onEditClicked: root.editClicked(category); + } + } +} +//! [CategoryModel view 3] diff --git a/examples/location/places/content/places/EditorialDelegate.qml b/examples/location/places/content/places/EditorialDelegate.qml new file mode 100644 index 00000000..fa33bcf0 --- /dev/null +++ b/examples/location/places/content/places/EditorialDelegate.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +Item { + id: root + + width: parent.width + height: icon.height + 8 + + Image { + id: icon + + width: 64 + height: 64 + + anchors.verticalCenter: root.verticalCenter + anchors.left: root.left + anchors.leftMargin: 4 + + source: supplier.icon.url(Qt.size(64, 64), Icon.List) + fillMode: Image.PreserveAspectFit + } + + Text { + anchors.top: icon.top + anchors.topMargin: 4 + anchors.left: icon.right + anchors.leftMargin: 4 + anchors.right: root.right + anchors.rightMargin: 4 + + text: model.title.length > 0 ? model.title : qsTr("Untitled editorial") + font.bold: true + font.pixelSize: 16 + + wrapMode: Text.WordWrap + elide: Text.ElideRight + maximumLineCount: 2 + } + + MouseArea { + anchors.fill: parent + onClicked: { + placeContent.source = ""; + placeContent.data = model; + placeContent.source = "EditorialPage.qml"; + } + } +} diff --git a/examples/location/places/content/places/EditorialPage.qml b/examples/location/places/content/places/EditorialPage.qml new file mode 100644 index 00000000..60f175d3 --- /dev/null +++ b/examples/location/places/content/places/EditorialPage.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +Item { + anchors.fill: parent + + property variant d: parent ? parent.data : null + + Flickable { + anchors.fill: parent + + contentHeight: c.height + contentWidth: width + + Column { + id: c + + width: parent.width + clip: true + + Text { + text: d ? d.title : "" + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 24 + } + + Text { + text: d ? d.text : "" + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 20 + } + + Row { + Image { + width: 16 + height: 16 + + source: d ? d.supplier.icon.url(Qt.size(width, height), Icon.List) : "" + } + Text { + text: d ? d.supplier.name : "" + font.pixelSize: 16 + } + } + Text { + text: d ? d.supplier.url : "" + font.pixelSize: 16 + } + } + } +} diff --git a/examples/location/places/content/places/Group.qml b/examples/location/places/content/places/Group.qml new file mode 100644 index 00000000..ac44d905 --- /dev/null +++ b/examples/location/places/content/places/Group.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Item { + id: item1 + width: parent.width + height: childrenRect.height + 3 + + property alias text: heading.text + + Text { + id: heading + text: '#heading#' + anchors.left: parent.left + } + + Rectangle { + id: rectangle1 + width: parent.width + height: 1 + radius: 1 + border.width: 1 + border.color: "#808080" + anchors.top: heading.bottom + anchors.topMargin: 3 + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/location/places/content/places/MapComponent.qml b/examples/location/places/content/places/MapComponent.qml new file mode 100644 index 00000000..00ba9b2e --- /dev/null +++ b/examples/location/places/content/places/MapComponent.qml @@ -0,0 +1,237 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtPositioning 5.2 +import QtLocation 5.0 +import QtLocation.examples 5.0 + +Map { + id: map + zoomLevel: (maximumZoomLevel - minimumZoomLevel)/2 + center { + // Brisbane + latitude: -27.5 + longitude: 153 + } + + gesture.flickDeceleration: 3000 + gesture.enabled: true + + property bool followme: false + property variant scaleLengths: [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000] + + PositionSource{ + id: positionSource + active: followme + + onPositionChanged: { + map.center = positionSource.position.coordinate + } + } + + Slider { + id: zoomSlider; + minimum: map.minimumZoomLevel; + maximum: map.maximumZoomLevel; + opacity: 1 + visible: parent.visible + z: map.z+1 + anchors { + bottom: parent.bottom; + bottomMargin: 15; rightMargin: 10; leftMargin: 90 + left: parent.left + } + width: parent.width - anchors.rightMargin - anchors.leftMargin + value: map.zoomLevel + onValueChanged: { + map.zoomLevel = value + } + } + + signal coordinatesCaptured(double latitude, double longitude) + + Item {//scale + id: scale + parent: zoomSlider.parent + visible: scaleText.text != "0 m" + z: map.z + opacity: 0.6 + anchors { + bottom: zoomSlider.top; + bottomMargin: 8; + left: zoomSlider.left + } + Image { + id: scaleImageLeft + source: "../../resources/scale_end.png" + anchors.bottom: parent.bottom + anchors.left: parent.left + } + Image { + id: scaleImage + source: "../../resources/scale.png" + anchors.bottom: parent.bottom + anchors.left: scaleImageLeft.right + } + Image { + id: scaleImageRight + source: "../../resources/scale_end.png" + anchors.bottom: parent.bottom + anchors.left: scaleImage.right + } + Text { + id: scaleText + color: "#004EAE" + horizontalAlignment: Text.AlignHCenter + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.bottomMargin: 3 + text: "0 m" + font.pixelSize: 14 + } + Component.onCompleted: { + map.calculateScale(); + } + } + + Timer { + id: scaleTimer + interval: 100 + running: false + repeat: false + onTriggered: { + map.calculateScale() + } + } + + onCenterChanged:{ + scaleTimer.restart() + if (map.followme) + if (map.center != positionSource.position.coordinate) map.followme = false + } + + onZoomLevelChanged:{ + scaleTimer.restart() + if (map.followme) map.center = positionSource.position.coordinate + } + + onWidthChanged:{ + scaleTimer.restart() + } + + onHeightChanged:{ + scaleTimer.restart() + } + + Keys.onPressed: { + if ((event.key == Qt.Key_Plus) || (event.key == Qt.Key_VolumeUp)) { + map.zoomLevel += 1 + } else if ((event.key == Qt.Key_Minus) || (event.key == Qt.Key_VolumeDown)){ + map.zoomLevel -= 1 + } + } + + 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 = formatDistance(dist) + scaleImage.width = (scaleImage.sourceSize.width * f) - 2 * scaleImageLeft.sourceSize.width + scaleText.text = text + } + + 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/examples/location/places/content/places/OptionsDialog.qml b/examples/location/places/content/places/OptionsDialog.qml new file mode 100644 index 00000000..7b7c9266 --- /dev/null +++ b/examples/location/places/content/places/OptionsDialog.qml @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtLocation.examples 5.0 + +Dialog { + id: dialog + + property alias isFavoritesEnabled: enableFavoritesButton.selected + property alias orderByDistance: orderByDistanceButton.selected + property alias orderByName: orderByNameButton.selected + property alias locales: localesInput.text + property int listItemHeight: 21 + + title: "Options" + + item: Column { + id: options + width: parent.width + spacing: gap + + TextWithLabel { + id: localesInput + + width: parent.width - gap + height: listItemHeight + label: "Locale(s)" + enabled: true + visible: placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.LocalizedPlacesFeature) : false; + } + + Optionbutton { + id: enableFavoritesButton + + function resetVisibility() { + //jsondb plug-in is no more but saving of places may come back + /*if (placesPlugin.name !== "places_jsondb") { + var pluginNames = placesPlugin.availableServiceProviders; + for (var i = 0; i < pluginNames.length; ++i) { + if (pluginNames[i] === "places_jsondb") { + enableFavoritesButton.visible = true; + return; + } + } + }*/ + enableFavoritesButton.visible = false; + } + + width: parent.width + text: "Enable favorites" + toggle: true + visible: false + + Component.onCompleted: { + resetVisibility(); + placesPlugin.nameChanged.connect(resetVisibility); + } + } + + Optionbutton { + id: orderByDistanceButton + width: parent.width + text: "Order by distance" + toggle: true + visible: true + onClicked: + if (selected) + orderByNameButton.selected = false; + } + Optionbutton { + id: orderByNameButton + width: parent.width + text: "Order by name" + toggle: true + visible: true + onClicked: + if (selected) + orderByDistanceButton.selected = false; + } + } +} diff --git a/examples/location/places/content/places/PlaceDelegate.qml b/examples/location/places/content/places/PlaceDelegate.qml new file mode 100644 index 00000000..90a2cceb --- /dev/null +++ b/examples/location/places/content/places/PlaceDelegate.qml @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtLocation.examples 5.0 +import "PlacesUtils.js" as PlacesUtils + +Item { + id: placeDelegate + + property Place place + property real distance + + signal searchForSimilar(variant place) + signal showReviews(variant place) + signal showEditorials(variant place) + signal showImages(variant place) + signal editPlace(variant place) + signal deletePlace(variant place) + + Flickable { + anchors.fill: parent + + contentHeight: c.height + contentWidth: width + + Column { + id: c + + width: parent.width + spacing: 2 + clip: true + + Row { + width: parent.width + + Image { + id: iconImage + width: 40 + height: 40 + source: place ? (place.favorite ? place.favorite.icon.url(Qt.size(40,40)) + : place.icon.url(Qt.size(40,40))) + : "" + visible: source != "" + } + + Text { + id: placeName + text: place ? (place.favorite ? place.favorite.name : place.name) : "" + font.pixelSize: 16 + font.bold: true + } + } + + RatingView { rating: (place && place.ratings) ? place.ratings.average : 0 } + + Group { text: qsTr("Address") } + Text { text: PlacesUtils.prettyDistance(distance) } + Text { + function placeAddress(place) { + if (!place) + return ""; + + if (place.location.address.text.length > 0) + return place.location.address.text; + + return place.location.address.street; + } + + text: placeAddress(place) + } + + Group { + text: qsTr("Categories") + visible: place && place.categories.length > 0 + } + Text { + function categoryNames(categories) { + var result = ""; + + for (var i = 0; i < categories.length; ++i) { + if (result == "") { + result = categories[i].name; + } else { + result = result + ", " + categories[i].name; + } + } + + return result; + } + + text: place ? categoryNames(place.categories) : "" + width: parent.width + wrapMode: Text.WordWrap + visible: place && place.categories.length > 0 + } + + Group { + text: qsTr("Contact details") + visible: phone.visible || fax.visible || email.visible || website.visible + } + Text { + id: phone + text: qsTr("Phone: ") + (place ? place.primaryPhone : "") + visible: place && place.primaryPhone.length > 0 + } + Text { + id: fax + text: qsTr("Fax: ") + (place ? place.primaryFax : "") + visible: place && place.primaryFax.length > 0 + } + Text { + id: email + text: place ? place.primaryEmail : "" + visible: place && place.primaryEmail.length > 0 + } + Text { + id: website + text: place ? '<a href=\"' + place.primaryWebsite + '\">' + place.primaryWebsite + '</a>' : "" + visible: place && String(place.primaryWebsite).length > 0 + onLinkActivated: Qt.openUrlExternally(place.primaryWebsite) + } + + Group { + text: qsTr("Additional information") + visible: extendedAttributes.count > 0 && extendedAttributes.height > 0 + } + + Repeater { + id: extendedAttributes + model: place ? place.extendedAttributes.keys() : null + delegate: Text { + text: place.extendedAttributes[modelData] ? + place.extendedAttributes[modelData].label + + place.extendedAttributes[modelData].text : "" + + visible: place.extendedAttributes[modelData] ? place.extendedAttributes[modelData].label.length > 0 : false + + width: c.width + wrapMode: Text.WordWrap + } + } + + Column { + id: buttons + + anchors.horizontalCenter: parent.horizontalCenter + + spacing: 5 + + Button { + text: qsTr("Editorials") + enabled: place && place.editorialModel.totalCount > 0 + onClicked: showEditorials(place) + } + Button { + text: qsTr("Reviews") + enabled: place && place.reviewModel.totalCount > 0 + onClicked: showReviews(place) + } + Button { + text: qsTr("Images") + enabled: place && place.imageModel.totalCount > 0 + onClicked: showImages(place) + } + Button { + text: qsTr("Find similar") + onClicked: searchForSimilar(place) + } + Button { + text: qsTr("Edit") + visible: placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.SavePlaceFeature) : false; + onClicked: editPlace(place) + } + + Button { + text: qsTr("Delete"); + visible: placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.RemovePlaceFeature) : false; + onClicked: deletePlace(place) + } + + Item { + width: parent.width + height: childrenRect.height + + Button { + id: saveButton; + function updateSaveStatus() { + if (updateSaveStatus.prevStatus === Place.Saving) { + switch (place.favorite.status) { + case Place.Ready: + break; + case Place.Error: + saveStatus.text = "Save Failed"; + saveStatus.visible = true; + console.log(place.favorite.errorString()); + break; + default: + } + } else if (updateSaveStatus.prevStatus == Place.Removing) { + place.favorite = null; + updateSaveStatus.prevStatus = Place.Ready + return; + + } + + updateSaveStatus.prevStatus = place.favorite.status; + } + + function reset() + { + saveButton.visible = (placeSearchModel.favoritesPlugin !== null); + saveStatus.visible = false; + } + + Component.onCompleted: { + reset(); + placeDelegate.placeChanged.connect(reset); + } + + text: (place && place.favorite !== null) ? qsTr("Remove Favorite") : qsTr("Save as Favorite") + onClicked: { + if (place.favorite === null) { + place.initializeFavorite(placeSearchModel.favoritesPlugin); + place.favorite.statusChanged.connect(updateSaveStatus); + place.favorite.save(); + } else { + place.favorite.statusChanged.connect(updateSaveStatus); + place.favorite.remove(); + } + } + } + + Text { + id: saveStatus + anchors.top: saveButton.bottom + visible: false + } + } + } + } + } +} diff --git a/examples/location/places/content/places/PlaceDialog.qml b/examples/location/places/content/places/PlaceDialog.qml new file mode 100644 index 00000000..ed08716d --- /dev/null +++ b/examples/location/places/content/places/PlaceDialog.qml @@ -0,0 +1,362 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtLocation.examples 5.0 + +Dialog { + id: root + property list<Category> __categories + property Place locationPlace + property bool __createdPlace: false + + signal completed; + + function prepareDialog(inputPlace) { + if (!inputPlace) { + locationPlace = Qt.createQmlObject('import QtLocation 5.0; Place { }', root); + __createdPlace = true; + } else { + locationPlace = inputPlace; + __createdPlace = false; + } + + setDataFields([ + ["Name", locationPlace ? locationPlace.name : ""], + ["Street", locationPlace ? locationPlace.location.address.street : ""], + ["District", locationPlace ? locationPlace.location.address.district : ""], + ["City", locationPlace ? locationPlace.location.address.city : ""], + ["County", locationPlace ? locationPlace.location.address.county : ""], + ["State", locationPlace ? locationPlace.location.address.state : ""], + ["Country code", locationPlace ? locationPlace.location.address.countryCode : ""], + ["Country", locationPlace ? locationPlace.location.address.country : ""], + ["Postal code", locationPlace ? locationPlace.location.address.postalCode : ""], + ["Latitude", locationPlace ? locationPlace.location.coordinate.latitude.toString() : ""], + ["Longitude", locationPlace ? locationPlace.location.coordinate.longitude.toString() : ""], + ["Phone", locationPlace ? locationPlace.primaryPhone : ""], + ["Fax", locationPlace ? locationPlace.primaryFax : ""], + ["Email", locationPlace ? locationPlace.primaryEmail : ""], + ["Website", locationPlace ? locationPlace.primaryWebsite.toString() : ""] + ]); + + __categories = locationPlace ? locationPlace.categories : new Array() + } + + function setDataFields(objects) + { + dataFieldsModel.clear(); + for (var i = 0; i < objects.length; i++) + dataFieldsModel.append({"labelText": objects[i][0], "inputText": objects[i][1]}) + } + + function processStatus() { + if (processStatus.prevStatus == Place.Saving) { + switch (locationPlace.status) { + case Place.Ready: + if (__createdPlace) { + locationPlace.destroy(); + __createdPlace = false; + processStatus.prevStatus = null; + } + completed(); + break; + case Place.Error: + console.log("Save failed:" + locationPlace.errorString()); + errorDialog.text = locationPlace.errorString(); + errorDialog.opacity = 1; + break; + } + } + + processStatus.prevStatus = locationPlace.status; + } + + Behavior on opacity { NumberAnimation { duration: 500 } } + + ErrorDialog { + id: errorDialog + title: "Save Place Failed" + } + + onGoButtonClicked: { + if (locationPlace.status == Place.Saving) + return; +//! [Place save] + locationPlace.plugin = placesPlugin; + + locationPlace.name = dataFieldsModel.get(0).inputText; + locationPlace.location.address.street = dataFieldsModel.get(1).inputText; + locationPlace.location.address.district = dataFieldsModel.get(2).inputText; + locationPlace.location.address.city = dataFieldsModel.get(3).inputText; + locationPlace.location.address.county = dataFieldsModel.get(4).inputText; + locationPlace.location.address.state = dataFieldsModel.get(5).inputText; + locationPlace.location.address.countryCode = dataFieldsModel.get(6).inputText; + locationPlace.location.address.country = dataFieldsModel.get(7).inputText; + locationPlace.location.address.postalCode = dataFieldsModel.get(8).inputText; + + var c = QtPositioning.coordinate(parseFloat(dataFieldsModel.get(9).inputText), + parseFloat(dataFieldsModel.get(10).inputText)); + locationPlace.location.coordinate = c; + var phone = Qt.createQmlObject('import QtLocation 5.0; ContactDetail { }', locationPlace); + phone.label = "Phone"; + phone.value = dataFieldsModel.get(11).inputText; + locationPlace.contactDetails.phone = phone; + + var fax = Qt.createQmlObject('import QtLocation 5.0; ContactDetail { }', locationPlace); + fax.label = "Fax"; + fax.value = dataFieldsModel.get(12).inputText; + locationPlace.contactDetails.fax = fax; + + var email = Qt.createQmlObject('import QtLocation 5.0; ContactDetail { }', locationPlace); + email.label = "Email"; + email.value = dataFieldsModel.get(13).inputText; + locationPlace.contactDetails.email = email; + + var website = Qt.createQmlObject('import QtLocation 5.0; ContactDetail { }', locationPlace); + website.label = "Website"; + website.value = dataFieldsModel.get(14).inputText; + locationPlace.contactDetails.website = website; + + locationPlace.categories = __categories; + locationPlace.statusChanged.connect(processStatus); + locationPlace.save(); +//! [Place save] + } + + onClearButtonClicked: { + for (var i = 0; i < dataFieldsModel.count; i++) + dataFieldsModel.set(i, {"inputText": ""}); + __categories = new Array(); + } + + onCancelButtonClicked: { + if (locationPlace && __createdPlace) + locationPlace.destroy(); + } + + onOpacityChanged: { + if (opacity == 0) + view.currentIndex = 0 + } + + ListModel { + id: dataFieldsModel + } + + item: ListView { + id: view + + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: 10 + + implicitHeight: flickable.contentHeight + + spacing: gap/2 + orientation: ListView.Horizontal + interactive: false + + model: VisualItemModel { + Item { + id: firstPage + width: view.width + height: view.height + + Flickable { + id: flickable + anchors.top: parent.top + anchors.topMargin: gap/2 + anchors.bottomMargin: gap/2 + height: parent.height + width: parent.width + interactive: height < contentHeight + contentWidth: parent.width + contentHeight:col.height + + clip: true + + Column { + id: col + anchors.top: parent.top + anchors.left: parent.left + width: parent.width - gap + spacing: gap/2 + + Repeater { + id: dataFields + model: dataFieldsModel + + TextWithLabel { + anchors.leftMargin: gap/2 + anchors.rightMargin: gap/2 + + width: parent ? parent.width : 0 + labelWidth: 95 + label: labelText + text: inputText + + onTextChanged: dataFieldsModel.set(index, {"inputText": text}) + } + } + + Group { + id: categoriesHeading + width: parent.width + anchors.topMargin: gap + + text: qsTr("Categories"); + } + + Repeater { + model: __categories + width: parent.width + + delegate: Item { + height: cross.height + width: parent.width + + Text { + id: categoryName + + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + text: model.modelData.name + } + + IconButton { + id: cross + + anchors.top: parent.top + anchors.right: parent.right + source: "../../resources/cross.png" + hoveredSource: "../../resources/cross_hovered.png" + pressedSource: "../../resources/cross_pressed.png" + + onClicked: { + var cats = new Array(); + for (var i =0; i < __categories.length; ++i) { + if (__categories[i].name != model.modelData.name) + cats.push(__categories[i]); + } + __categories = cats + } + } + } + } + + Button { + text: qsTr("Add Category") + onClicked: view.currentIndex = 1 + } + } + } + + Rectangle { + id: scrollbar + anchors.right: flickable.right + y: { + var yPosition = flickable.visibleArea.yPosition + if (yPosition < 0) + yPosition = 0 + if (yPosition > (1.0 - flickable.visibleArea.heightRatio)) + yPosition = (1.0 - flickable.visibleArea.heightRatio) + yPosition *flickable.height + } + + width: 10 + height: flickable.visibleArea.heightRatio * flickable.height + color: "gray" + radius: 5 + } + + } + + Item { + height:view.height + width: view.width + + Group { + id: chooseCategoryHeading + + anchors.top: parent.top + width: parent.width + text: qsTr("Choose Category"); + } + + CategoryView { + id: categoryView + + anchors.top: chooseCategoryHeading.bottom + anchors.bottom: categoryCancel.top + width: parent.width + + showSave: false + showRemove: false + showChildren: false + + onCategoryClicked: { + var categoriesList = new Array(); + var alreadyExists = false; + for (var i = 0; i < __categories.length; ++i) { + categoriesList.push(__categories[i]); + if (__categories[i].categoryId == category.categoryId) + alreadyExists = true; + } + + if (!alreadyExists) + categoriesList.push(category); + __categories = categoriesList + view.currentIndex = 0; + } + } + + Button { + id: categoryCancel + + anchors.bottom: parent.bottom + text: qsTr("Cancel ") + onClicked: view.currentIndex = 0 + } + } + } + } +} diff --git a/examples/location/places/content/places/PlaceEditorials.qml b/examples/location/places/content/places/PlaceEditorials.qml new file mode 100644 index 00000000..06cff09c --- /dev/null +++ b/examples/location/places/content/places/PlaceEditorials.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +Item { + anchors.fill: parent + + clip: true + + //! [PlaceEditorialModel view] + ListView { + anchors.fill: parent + + model: place.editorialModel + + delegate: EditorialDelegate { } + } + //! [PlaceEditorialModel view] +} diff --git a/examples/location/places/content/places/PlaceImages.qml b/examples/location/places/content/places/PlaceImages.qml new file mode 100644 index 00000000..be18a923 --- /dev/null +++ b/examples/location/places/content/places/PlaceImages.qml @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +Item { + id: root + + anchors.fill: parent + + clip: true + + GridView { + id: gridView + + anchors.fill: parent + + model: place.imageModel + + cellWidth: width / 3 + cellHeight: cellWidth + + delegate: Rectangle { + width: gridView.cellWidth + height: gridView.cellHeight + + color: "#30FFFFFF" + + Image { + anchors.fill: parent + anchors.margins: 5 + + source: url + + fillMode: Image.PreserveAspectFit + } + + MouseArea { + anchors.fill: parent + onClicked: { + listView.positionViewAtIndex(index, ListView.Contain); + root.state = "list"; + } + } + } + } + + ListView { + id: listView + + anchors.top: parent.top + anchors.bottom: position.top + width: parent.width + spacing: 10 + + model: place.imageModel + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + + visible: false + + delegate: Item { + width: listView.width + height: listView.height + + Image { + anchors.fill: parent + + source: url + + fillMode: Image.PreserveAspectFit + } + + Text { + text: supplier.name + "\n" + supplier.url + width: parent.width + anchors.bottom: parent.bottom + } + } + + MouseArea { + anchors.fill: parent + onClicked: root.state = "" + } + } + + Text { + id: position + + width: parent.width + anchors.bottom: parent.bottom + visible: listView.visible + + text: (listView.currentIndex + 1) + '/' + listView.model.totalCount + horizontalAlignment: Text.AlignRight + } + + states: [ + State { + name: "list" + PropertyChanges { + target: gridView + visible: false + } + PropertyChanges { + target: listView + visible: true + } + } + ] +} diff --git a/examples/location/places/content/places/PlaceReviews.qml b/examples/location/places/content/places/PlaceReviews.qml new file mode 100644 index 00000000..3d54c52c --- /dev/null +++ b/examples/location/places/content/places/PlaceReviews.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +Item { + anchors.fill: parent + + clip: true + +//! [ReviewModel delegate] + ListView { + anchors.fill: parent + + model: place.reviewModel + + delegate: ReviewDelegate { } + } +//! [ReviewModel delegate] +} diff --git a/examples/location/places/content/places/PlacesUtils.js b/examples/location/places/content/places/PlacesUtils.js new file mode 100644 index 00000000..756deb99 --- /dev/null +++ b/examples/location/places/content/places/PlacesUtils.js @@ -0,0 +1,12 @@ +.pragma library + +function prettyDistance(distance) { + if (distance < 1000) + return distance.toFixed(0) + "m"; + + var km = distance/1000; + if (km < 10) + return km.toFixed(1) + "km"; + + return km.toFixed(0) + "km"; +} diff --git a/examples/location/places/content/places/RatingView.qml b/examples/location/places/content/places/RatingView.qml new file mode 100644 index 00000000..255bb8b8 --- /dev/null +++ b/examples/location/places/content/places/RatingView.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 + +Row { + property real rating: 0 + property int size: 32 + + Repeater { + model: Math.ceil(rating) + Image { + source: "../../resources/star.png" + width: size + height: size + } + } +} diff --git a/examples/location/places/content/places/ReviewDelegate.qml b/examples/location/places/content/places/ReviewDelegate.qml new file mode 100644 index 00000000..50753e09 --- /dev/null +++ b/examples/location/places/content/places/ReviewDelegate.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +Item { + id: root + + width: parent.width + height: icon.height + 8 + + Image { + id: icon + + width: 64 + height: 64 + + anchors.verticalCenter: root.verticalCenter + anchors.left: root.left + anchors.leftMargin: 4 + + source: supplier.icon.url(Qt.size(64, 64), Icon.List) + fillMode: Image.PreserveAspectFit + } + + Text { + anchors.top: icon.top + anchors.topMargin: 4 + anchors.left: icon.right + anchors.leftMargin: 4 + anchors.right: root.right + anchors.rightMargin: 4 + + text: model.title + font.bold: true + font.pixelSize: 16 + + wrapMode: Text.WordWrap + elide: Text.ElideRight + maximumLineCount: 2 + } + + RatingView { + anchors.bottom: icon.bottom + anchors.bottomMargin: 4 + anchors.left: icon.right + anchors.leftMargin: 4 + anchors.right: root.right + anchors.rightMargin: 4 + + rating: model.rating + size: 16 + } + + MouseArea { + anchors.fill: parent + onClicked: { + placeContent.source = ""; + placeContent.data = model; + placeContent.source = "ReviewPage.qml"; + } + } +} diff --git a/examples/location/places/content/places/ReviewPage.qml b/examples/location/places/content/places/ReviewPage.qml new file mode 100644 index 00000000..c7287e19 --- /dev/null +++ b/examples/location/places/content/places/ReviewPage.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 + +Item { + anchors.fill: parent + + property variant d: parent ? parent.data : null + + Flickable { + anchors.fill: parent + + contentHeight: c.height + contentWidth: width + + Column { + id: c + + width: parent.width + clip: true + + Text { + text: d ? d.title : "" + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 24 + } + + Text { + text: d ? Qt.formatDateTime(d.dateTime) : "" + width: parent.width + font.pixelSize: 18 + } + + RatingView { + size: 16 + rating: d ? d.rating : 0.0 + } + + Text { + text: d ? d.text : "" + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 20 + } + + Row { + Image { + width: 16 + height: 16 + + source: d ? d.supplier.icon.url(Qt.size(width, height), Icon.List) : "" + } + Text { + text: d ? d.supplier.name : "" + font.pixelSize: 16 + } + } + Text { + text: d ? d.supplier.url : "" + font.pixelSize: 16 + } + } + } +} diff --git a/examples/location/places/content/places/SearchBox.qml b/examples/location/places/content/places/SearchBox.qml new file mode 100644 index 00000000..335af339 --- /dev/null +++ b/examples/location/places/content/places/SearchBox.qml @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtLocation.examples 5.0 + +Rectangle { + id: searchRectangle + + property bool suggestionsEnabled: true + property int expandedHeight: childrenRect.height + readonly property int baseHeight: searchBox.height + 20 + + color: "#ECECEC" + + height: baseHeight + Behavior on height { + NumberAnimation { duration: 250 } + } + + clip: true + + TextWithLabel { + id: searchBox + label: "Search" + text: "sushi" + + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.right: row.left + anchors.rightMargin: 10 + anchors.top: parent.top + anchors.topMargin: 10 + + busy: placeSearchModel.status === PlaceSearchModel.Loading + + //! [PlaceSearchSuggestionModel search text changed] + onTextChanged: { + if (searchRectangle.suggestionsEnabled) { + if (text.length >= 3) { + if (suggestionModel != null) { + suggestionModel.searchTerm = text; + suggestionModel.update(); + } + } else { + searchRectangle.state = ""; + } + } + } + //! [PlaceSearchSuggestionModel search text changed] + } + + Row { + id: row + + anchors.right: parent.right + anchors.rightMargin: 10 + anchors.top: parent.top + anchors.topMargin: 10 + spacing: 10 + + IconButton { + id: searchButton + + anchors.verticalCenter: parent.verticalCenter + + source: "../../resources/search.png" + pressedSource: "../../resources/search_pressed.png" + + onClicked: { + placeSearchModel.searchForText(searchBox.text); + searchRectangle.state = ""; + } + } + + IconButton { + id: categoryButton + + source: "../../resources/categories.png" + pressedSource: "../../resources/categories_pressed.png" + + onClicked: { + if (searchRectangle.state !== "CategoriesShown") + searchRectangle.state = "CategoriesShown"; + else if (suggestionView.count > 0) + searchRectangle.state = "SuggestionsShown"; + else + searchRectangle.state = ""; + } + } + } + + CategoryView { + id: categoryView + + anchors.top: row.bottom + height: expandedHeight - y + visible: false + spacing: 5 + + onCategoryClicked: { + placeSearchModel.searchForCategory(category); + searchRectangle.state = ""; + } + + onEditClicked: { + editCategoryDialog.category = category; + page.state = "EditCategory"; + searchRectangle.state = ""; + } + } + + BusyIndicator { + id: busy + + visible: false + + anchors.centerIn: parent + } + + Text { + id: noCategories + + anchors.centerIn: parent + text: qsTr("No categories") + visible: false + } + + //! [PlaceSearchSuggestionModel view 1] + ListView { + id: suggestionView + //! [PlaceSearchSuggestionModel view 1] + + anchors.top: row.bottom + anchors.topMargin: 10 + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.right: parent.right + anchors.rightMargin: 10 + height: 450 + visible: false + + clip: true + snapMode: ListView.SnapToItem + + //! [PlaceSearchSuggestionModel view 2] + model: suggestionModel + delegate: Text { + text: suggestion + + width: parent.width + + MouseArea { + anchors.fill: parent + onClicked: { + suggestionsEnabled = false; + searchBox.text = suggestion; + suggestionsEnabled = true; + placeSearchModel.searchForText(suggestion); + searchRectangle.state = ""; + } + } + } + } + //! [PlaceSearchSuggestionModel view 2] + + //! [PlaceSearchSuggestionModel model] + PlaceSearchSuggestionModel { + id: suggestionModel + plugin: placesPlugin + searchArea: placeSearchModel.searchArea + + onStatusChanged: { + if (status == PlaceSearchSuggestionModel.Ready) + searchRectangle.state = "SuggestionsShown"; + } + } + //! [PlaceSearchSuggestionModel model] + + states: [ + State { + name: "CategoriesShown" + PropertyChanges { + target: searchRectangle + height: expandedHeight + } + PropertyChanges { + target: busy + visible: categoryModel.status === CategoryModel.Loading + } + PropertyChanges { + target: noCategories + visible: categoryView.count == 0 && !busy.visible + } + PropertyChanges { + target: categoryView + visible: true && !busy.visible + } + }, + State { + name: "SuggestionsShown" + PropertyChanges { + target: searchRectangle + height: childrenRect.height + 20 + } + PropertyChanges { + target: suggestionView + visible: true + } + } + ] +} diff --git a/examples/location/places/content/places/SearchResultDelegate.qml b/examples/location/places/content/places/SearchResultDelegate.qml new file mode 100644 index 00000000..76b64e83 --- /dev/null +++ b/examples/location/places/content/places/SearchResultDelegate.qml @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import "PlacesUtils.js" as PlacesUtils + +Item { + id: root + + signal displayPlaceDetails(variant data) + signal searchFor(string query) + + width: parent.width + height: childrenRect.height + 20 + + //! [PlaceSearchModel place delegate] + Component { + id: placeComponent + + Item { + id: placeRoot + + height: childrenRect.height + width: parent.width + + Rectangle { + anchors.fill: parent + color: "#dbffde" + visible: model.sponsored !== undefined ? model.sponsored : false + + Text { + text: qsTr("Sponsored result") + horizontalAlignment: Text.AlignRight + anchors.right: parent.right + anchors.bottom: parent.bottom + font.pixelSize: 8 + visible: model.sponsored !== undefined ? model.sponsored : false + } + } + + Row { + Image { + source: place.favorite ? "../../resources/star.png" : place.icon.url() + } + + Column { + anchors.verticalCenter: parent.verticalCenter + Text { + id: placeName + text: place.favorite ? place.favorite.name : place.name + } + + Text { + id: distanceText + font.italic: true + text: PlacesUtils.prettyDistance(distance) + } + } + } + + MouseArea { + anchors.fill: parent + + onPressed: placeRoot.state = "Pressed" + onReleased: placeRoot.state = "" + onCanceled: placeRoot.state = "" + + onClicked: { + if (model.type === undefined || type === PlaceSearchModel.PlaceResult) { + if (!place.detailsFetched) + place.getDetails(); + + root.displayPlaceDetails({ + distance: model.distance, + place: model.place, + }); + } + } + } + + states: [ + State { + name: "" + }, + State { + name: "Pressed" + PropertyChanges { target: placeName; color: "#1C94FC"} + PropertyChanges { target: distanceText; color: "#1C94FC"} + } + ] + } + } + //! [PlaceSearchModel place delegate] + + Component { + id: proposedSearchComponent + + Item { + id: proposedSearchRoot + + height: childrenRect.height + width: parent.width + + Row { + Image { + source: icon.url() + } + + Text { + id: proposedSearchTitle + anchors.verticalCenter: parent.verticalCenter + text: "Search for " + title + } + } + + MouseArea { + anchors.fill: parent + + onPressed: proposedSearchRoot.state = "Pressed" + onReleased: proposedSearchRoot.state = "" + onCanceled: proposedSearchRoot.state = "" + + onClicked: root.ListView.view.model.updateWith(index); + } + + states: [ + State { + name: "" + }, + State { + name: "Pressed" + PropertyChanges { target: proposedSearchTitle; color: "#1C94FC"} + } + ] + } + } + + Loader { + anchors.left: parent.left + anchors.right: parent.right + + sourceComponent: { + switch (model.type) { + case PlaceSearchModel.PlaceResult: + return placeComponent; + case PlaceSearchModel.ProposedSearchResult: + return proposedSearchComponent; + default: + //do nothing, don't assign component if result type not recognized + } + } + } +} diff --git a/examples/location/places/content/places/SearchResultView.qml b/examples/location/places/content/places/SearchResultView.qml new file mode 100644 index 00000000..b9d48776 --- /dev/null +++ b/examples/location/places/content/places/SearchResultView.qml @@ -0,0 +1,247 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtLocation 5.0 +import QtLocation.examples 5.0 + +Item { + id: root + + clip: true + + function showSearchResults() { + view.currentIndex = 0; + placeContentList.source = ""; + placeContentList.place = null; + } + + function showPlaceDetails(data) { + placeDetails.place = data.place; + placeDetails.distance = data.distance; + view.currentIndex = 1; + } + + ListView { + id: view + + orientation: ListView.Horizontal + interactive: false + anchors.fill: parent + snapMode: ListView.SnapOneItem + + model: VisualItemModel { + Item { + // search results (page 0) + + width: root.width + height: root.height + + Connections { + target: placeSearchModel + onStatusChanged: searchView.visible = true + } + + //! [PlaceSearchModel place list] + ListView { + id: searchView + + anchors.fill: parent + + model: placeSearchModel + delegate: SearchResultDelegate { + onDisplayPlaceDetails: showPlaceDetails(data) + onSearchFor: placeSearchModel.searchForText(query); + } + + footer: Item { + width: searchView.width + height: childrenRect.height + + Button { + text: qsTr("Previous") + onClicked: placeSearchModel.previousPage() + + anchors.left: parent.left + } + + Button { + text: qsTr("Clear") + onClicked: placeSearchModel.reset() + + anchors.horizontalCenter: parent.horizontalCenter + } + + Button { + text: qsTr("Next") + onClicked: placeSearchModel.nextPage() + + anchors.right: parent.right + } + } + } + //! [PlaceSearchModel place list] + } + Item { + // place details (page 1) + width: root.width + height: root.height + + IconButton { + id: placeBackButton + anchors.left: parent.left + + source: "../../resources/left.png" + pressedSource: "../../resources/left_pressed.png" + + onClicked: showSearchResults() + } + + PlaceDelegate { + id: placeDetails + + anchors.top: placeBackButton.bottom + anchors.bottom: parent.bottom + width: parent.width + anchors.margins: 10 + + onShowEditorials: { + placeContentList.source = ""; + placeContentList.place = place; + placeContentList.source = "PlaceEditorials.qml"; + view.currentIndex = 2; + } + + onShowReviews: { + placeContentList.source = ""; + placeContentList.place = place; + placeContentList.source = "PlaceReviews.qml"; + view.currentIndex = 2; + } + + onShowImages: { + placeContentList.source = ""; + placeContentList.place = place; + placeContentList.source = "PlaceImages.qml"; + view.currentIndex = 2; + } + + //! [PlaceRecommendationModel search] + onSearchForSimilar: { + placeContentList.source = ""; + placeSearchModel.searchForRecommendations(place.placeId); + } + //! [PlaceRecommendationModel search] + + onEditPlace: { + editPlaceDialog.prepareDialog(place); + page.state = "EditPlace" + } + + onDeletePlace: { + place.remove(); + showSearchResults(); + } + } + } + Item { + // content list (page 2) + width: root.width + height: root.height + + IconButton { + id: contentListBackButton + + source: "../../resources/left.png" + pressedSource: "../../resources/left_pressed.png" + + onClicked: view.currentIndex = 1 + } + + Loader { + id: placeContentList + + property Place place + + anchors.top: contentListBackButton.bottom + anchors.bottom: parent.bottom + width: parent.width + anchors.margins: 10 + + onStatusChanged: { + if (status === Loader.Null) + place = null; + } + } + } + Item { + // content (page 3) + width: root.width + height: root.height + + IconButton { + id: contentBackButton + + source: "../../resources/left.png" + pressedSource: "../../resources/left_pressed.png" + + onClicked: { + view.currentIndex = 2; + placeContent.source = ""; + placeContent.data = null; + } + } + + Loader { + id: placeContent + + anchors.top: contentBackButton.bottom + anchors.bottom: parent.bottom + width: parent.width + anchors.margins: 10 + + onLoaded: view.currentIndex = 3 + + property variant data + } + } + } + } +} diff --git a/examples/location/places/icon.png b/examples/location/places/icon.png Binary files differnew file mode 100644 index 00000000..0954baf0 --- /dev/null +++ b/examples/location/places/icon.png diff --git a/examples/location/places/places.pro b/examples/location/places/places.pro new file mode 100644 index 00000000..459a241e --- /dev/null +++ b/examples/location/places/places.pro @@ -0,0 +1,43 @@ +TARGET = qml_location_places +TEMPLATE = app + +QT += qml quick network +SOURCES += qmlplaceswrapper.cpp + +RESOURCES += \ + placeswrapper.qrc + +qmlcontent.files += \ + places.qml +OTHER_FILES += $$qmlcontent.files + +qmlcontentplaces.files += \ + content/places/PlacesUtils.js \ + content/places/Group.qml \ + content/places/SearchBox.qml \ + content/places/CategoryDelegate.qml \ + content/places/SearchResultDelegate.qml \ + content/places/PlaceDelegate.qml \ + content/places/RatingView.qml \ + content/places/SearchResultView.qml \ + content/places/PlaceDialog.qml \ + content/places/CategoryDialog.qml \ + content/places/PlaceEditorials.qml \ + content/places/EditorialDelegate.qml \ + content/places/EditorialPage.qml \ + content/places/PlaceReviews.qml \ + content/places/ReviewDelegate.qml \ + content/places/ReviewPage.qml \ + content/places/PlaceImages.qml \ + content/places/MapComponent.qml \ + content/places/OptionsDialog.qml \ + content/places/CategoryView.qml + +OTHER_FILES += $$qmlcontentplaces.files + +include(../common/common.pri) + +target.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/places + +INSTALLS += target + diff --git a/examples/location/places/places.qml b/examples/location/places/places.qml new file mode 100644 index 00000000..6b4b32dd --- /dev/null +++ b/examples/location/places/places.qml @@ -0,0 +1,660 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.0 +import QtPositioning 5.2 +import QtLocation 5.0 +import QtLocation.examples 5.0 +import "content/places" + +Item { + id: page + width: (parent && parent.width > 0) ? parent.width : 360 + height: (parent && parent.height > 0) ? parent.height : 640 + property variant map + property variant startLocation + property variant searchRegion: QtPositioning.circle(startLocation) + property variant searchRegionItem + property Plugin favoritesPlugin + + onMapChanged: editPlaceDialog.prepareDialog() + + Binding { + target: page + property: "startLocation" + value: map ? map.center : QtPositioning.coordinate() + } + + Rectangle { + id: backgroundRect + anchors.fill: parent + color: "lightgrey" + z: 2 + } + + //=====================Menu===================== + Menu { + id:mainMenu + anchors.bottom: parent.bottom + z: backgroundRect.z + 3 + + Component.onCompleted: { + addItem("Provider"); + addItem("New"); + addItem("Search"); + } + + onClicked: page.state = page.state == "" ? button : ""; + } + + Menu { + id: providerMenu + z: backgroundRect.z + 2 + y: page.height + horizontalOrientation: false + exclusive: true + + Component.onCompleted: { + var plugins = getPlacesPlugins() + for (var i = 0; i<plugins.length; i++) { + addItem(plugins[i]); + + // default to nokia plugin + if (plugins[i] === "nokia") + exclusiveButton = plugins[i]; + } + + // otherwise default to first + if (exclusiveButton === "") + exclusiveButton = plugins[0]; + } + + onClicked: page.state = "" + + onExclusiveButtonChanged: placesPlugin.name = exclusiveButton; + } + + Menu { + id: newMenu + z: backgroundRect.z + 2 + y: page.height + horizontalOrientation: false + + Component.onCompleted: { + var item = addItem("Place"); + item.enabled = Qt.binding(function() { return placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.SavePlaceFeature) : false }) + + item = addItem("Category"); + item.enabled = Qt.binding(function() { return placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.SaveCategoryFeature) : false }) + } + + onClicked: { + switch (button) { + case "Place": { + editPlaceDialog.prepareDialog(); + + page.state = "NewPlace"; + break; + } + case "Category": { + editCategoryDialog.category = null; + editCategoryDialog.prepareDialog(); + page.state = "NewCategory"; + break; + } + } + } + } + + Menu { + id: searchMenu + z: backgroundRect.z + 2 + y: page.height + horizontalOrientation: false + + Component.onCompleted: { + addItem("Search Center"); + addItem("Search Bounding Box"); + addItem("Search Bounding Circle"); + addItem("Search Options"); + } + + onClicked: page.state = button + } + + //=====================Dialogs===================== + PlaceDialog { + id: editPlaceDialog + z: backgroundRect.z + 4 + + onCancelButtonClicked: page.state = "" + onCompleted: page.state = ""; + } + + CategoryDialog { + id: editCategoryDialog + z: backgroundRect.z + 4 + + onCancelButtonClicked: page.state = "" + + Connections { + target: editCategoryDialog.category + onStatusChanged: { + switch (editCategoryDialog.category.status) { + case Category.Saving: { + break; + } + case Category.Ready: { + page.state = ""; + break; + } + case Category.Error: { + console.log("Error while saving!"); + break; + } + } + } + } + } + + InputDialog { + id: searchCenterDialog + z: backgroundRect.z + 4 + + title: "Search center" + + Behavior on opacity { NumberAnimation { duration: 500 } } + + Component.onCompleted: prepareDialog() + + function prepareDialog() { + setModel([ + ["Latitude", searchRegion.center ? String(searchRegion.center.latitude) : ""], + ["Longitude", searchRegion.center ? String(searchRegion.center.longitude) : ""] + ]); + } + + onCancelButtonClicked: page.state = "" + onGoButtonClicked: { + var c = QtPositioning.coordinate(parseFloat(dialogModel.get(0).inputText), + parseFloat(dialogModel.get(1).inputText)); + + map.center = c; + + searchRegion = Qt.binding(function() { return QtPositioning.circle(startLocation) }); + + if (searchRegionItem) { + map.removeMapItem(searchRegionItem); + searchRegionItem.destroy(); + } + + page.state = ""; + } + } + + InputDialog { + id: searchBoxDialog + z: backgroundRect.z + 4 + + title: "Search Bounding Box" + + Behavior on opacity { NumberAnimation { duration: 500 } } + + Component.onCompleted: prepareDialog() + + function prepareDialog() { + setModel([ + ["Latitude", searchRegion.center ? String(searchRegion.center.latitude) : ""], + ["Longitude", searchRegion.center ? String(searchRegion.center.longitude) : ""], + ["Width(deg)", searchRegion.width ? String(searchRegion.width) : "" ], + ["Height(deg)", searchRegion.height ? String(searchRegion.height) : "" ] + ]); + } + + onCancelButtonClicked: page.state = "" + onGoButtonClicked: { + var c = QtPositioning.coordinate(parseFloat(dialogModel.get(0).inputText), + parseFloat(dialogModel.get(1).inputText)); + var r = QtPositioning.rectangle(c, parseFloat(dialogModel.get(2).inputText), + parseFloat(dialogModel.get(3).inputText)); + + map.center = c; + + searchRegion = r; + + if (searchRegionItem) { + map.removeMapItem(searchRegionItem); + searchRegionItem.destroy(); + } + + searchRegionItem = Qt.createQmlObject('import QtLocation 5.0; MapRectangle { color: "red"; opacity: 0.4 }', page, "MapRectangle"); + searchRegionItem.topLeft = r.topLeft; + searchRegionItem.bottomRight = r.bottomRight; + map.addMapItem(searchRegionItem); + + page.state = ""; + } + } + + InputDialog { + id: searchCircleDialog + z: backgroundRect.z + 4 + + title: "Search Bounding Circle" + + Behavior on opacity { NumberAnimation { duration: 500 } } + + Component.onCompleted: prepareDialog() + + function prepareDialog() { + setModel([ + ["Latitude", searchRegion.center ? String(searchRegion.center.latitude) : ""], + ["Longitude", searchRegion.center ? String(searchRegion.center.longitude) : ""], + ["Radius(m)", searchRegion.radius ? String(searchRegion.radius) : "" ] + ]); + } + + onCancelButtonClicked: page.state = "" + onGoButtonClicked: { + var c = QtPositioning.coordinate(parseFloat(dialogModel.get(0).inputText), + parseFloat(dialogModel.get(1).inputText)); + var circle = QtPositioning.circle(c, parseFloat(dialogModel.get(2).inputText)); + + map.center = c; + + searchRegion = circle; + + if (searchRegionItem) { + map.removeMapItem(searchRegionItem); + searchRegionItem.destroy(); + } + + searchRegionItem = Qt.createQmlObject('import QtLocation 5.0; MapCircle { color: "red"; opacity: 0.4 }', page, "MapRectangle"); + searchRegionItem.center = circle.center; + searchRegionItem.radius = circle.radius; + map.addMapItem(searchRegionItem); + + page.state = ""; + } + } + + OptionsDialog { + id: optionsDialog + z: backgroundRect.z + 4 + + Behavior on opacity { NumberAnimation { duration: 500 } } + + Component.onCompleted: prepareDialog() + + function prepareDialog() { + if (placeSearchModel.favoritesPlugin !== null) + isFavoritesEnabled = true; + else + isFavoritesEnabled = false; + + locales = placesPlugin.locales.join(Qt.locale().groupSeparator); + } + + onCancelButtonClicked: page.state = "" + onGoButtonClicked: { + /*if (isFavoritesEnabled) { + if (favoritesPlugin == null) + favoritesPlugin = Qt.createQmlObject('import QtLocation 5.0; Plugin { name: "places_jsondb" }', page); + favoritesPlugin.parameters = pluginParametersFromMap(pluginParameters); + placeSearchModel.favoritesPlugin = favoritesPlugin; + } else { + placeSearchModel.favoritesPlugin = null; + }*/ + placeSearchModel.favoritesPlugin = null; + + placeSearchModel.relevanceHint = orderByDistance ? PlaceSearchModel.DistanceHint : + orderByName ? PlaceSearchModel.LexicalPlaceNameHint : + PlaceSearchModel.UnspecifiedHint; + placesPlugin.locales = locales.split(Qt.locale().groupSeparator); + categoryModel.update(); + page.state = ""; + } + } + + //! [PlaceSearchModel model] + PlaceSearchModel { + id: placeSearchModel + + plugin: placesPlugin + searchArea: searchRegion + + function searchForCategory(category) { + searchTerm = ""; + categories = category; + recommendationId = ""; + searchArea = searchRegion + limit = -1; + offset = 0; + update(); + } + + function searchForText(text) { + searchTerm = text; + categories = null; + recommendationId = ""; + searchArea = searchRegion + limit = -1; + offset = 0; + update(); + } + + function searchForRecommendations(placeId) { + searchTerm = ""; + categories = null; + recommendationId = placeId; + searchArea = null; + limit = -1; + offset = 0; + update(); + } + + function previousPage() { + if (limit === -1) + limit = count; + offset = Math.max(0, offset - limit); + update(); + } + + function nextPage() { + if (limit === -1) + limit = count; + offset += limit; + update(); + } + + onStatusChanged: { + switch (status) { + case PlaceSearchModel.Ready: + searchResultView.showSearchResults(); + break; + case PlaceSearchModel.Error: + console.log(errorString()); + } + } + } + //! [PlaceSearchModel model] + + //! [CategoryModel model] + CategoryModel { + id: categoryModel + plugin: placesPlugin + hierarchical: true + } + //! [CategoryModel model] + + SearchBox { + id: searchBox + + anchors.top: page.top + width: parent.width + expandedHeight: parent.height + z: backgroundRect.z + 3 + } + + Plugin { + id: placesPlugin + + parameters: pluginParametersFromMap(pluginParameters) + onNameChanged: { + createMap(placesPlugin); + categoryModel.update(); + } + } + + Item { + id: searchResultTab + + z: backgroundRect.z + 2 + height: parent.height - searchBox.baseHeight - mainMenu.height + width: parent.width + x: 0 + y: mainMenu.height - height + catchImage.width + + opacity: 0 + + property bool open: false + + Behavior on y { PropertyAnimation { duration: 300; easing.type: Easing.InOutQuad } } + Behavior on opacity { PropertyAnimation { duration: 300 } } + + Image { + id: catchImage + + source: "resources/catch.png" + rotation: 90 + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: (width - height) / 2 + + MouseArea { + anchors.fill: parent + onClicked: searchResultTab.open = !searchResultTab.open; + } + } + + Rectangle { + id: searchResultTabPage + + width: parent.width + height: parent.height - catchImage.width + color: "#ECECEC" + radius: 5 + + SearchResultView { + id: searchResultView + + anchors.fill: parent + anchors.margins: 10 + } + } + + states: [ + State { + name: "" + when: placeSearchModel.count == 0 + PropertyChanges { target: searchResultTab; open: false } + }, + State { + name: "Close" + when: (placeSearchModel.count > 0) && !searchResultTab.open + PropertyChanges { target: searchResultTab; opacity: 1 } + }, + State { + name: "Open" + when: (placeSearchModel.count > 0) && searchResultTab.open + PropertyChanges { target: searchResultTab; y: mainMenu.height; opacity: 1 } + } + ] + } + + Component { + id: mapComponent + + MapComponent { + z: backgroundRect.z + 1 + width: page.width + height: page.height - mainMenu.height + + MapItemView { + model: placeSearchModel + delegate: MapQuickItem { + coordinate: model.type === PlaceSearchModel.PlaceResult ? place.location.coordinate : QtPositioning.coordinate() + + visible: model.type === PlaceSearchModel.PlaceResult + + anchorPoint.x: image.width * 0.28 + anchorPoint.y: image.height + + sourceItem: Image { + id: image + + source: "resources/marker.png" + + MouseArea { + anchors.fill: parent + onClicked: { + searchResultView.showPlaceDetails({ + distance: model.distance, + place: model.place, + }); + searchResultTab.state = "Open"; + } + } + } + } + } + } + } + + function createMap(placesPlugin) { + var mapPlugin; + if (placesPlugin.supportsMapping()) { + mapPlugin = placesPlugin; + } else { + mapPlugin = Qt.createQmlObject('import QtLocation 5.0; Plugin { required.mapping: Plugin.AnyMappingFeatures;' + + 'parameters: pluginParametersFromMap(pluginParameters) }', page); + } + + if (map) + map.destroy(); + map = mapComponent.createObject(page); + map.plugin = mapPlugin; + } + + function getPlacesPlugins() { + var plugin = Qt.createQmlObject('import QtLocation 5.0; Plugin {}', page); + var myArray = new Array; + for (var i = 0; i < plugin.availableServiceProviders.length; i++) { + var tempPlugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin {name: "' + plugin.availableServiceProviders[i]+ '"}', page) + + if (tempPlugin.supportsPlaces()) + myArray.push(tempPlugin.name) + } + + return myArray; + } + + function pluginParametersFromMap(pluginParameters) { + var parameters = new Array() + for (var prop in pluginParameters){ + var parameter = Qt.createQmlObject('import QtLocation 5.0; PluginParameter{ name: "'+ prop + '"; value: "' + pluginParameters[prop]+'"}',page) + parameters.push(parameter) + } + return parameters + //createMap(placesPlugin) + } + + //=====================States of page===================== + states: [ + State { + name: "Provider" + PropertyChanges { target: providerMenu; y: page.height - providerMenu.height - mainMenu.height } + }, + State { + name: "New" + PropertyChanges { target: newMenu; y: page.height - newMenu.height - mainMenu.height } + }, + State { + name: "Search" + PropertyChanges { target: searchMenu; y: page.height - searchMenu.height - mainMenu.height } + }, + State { + name: "NewPlace" + PropertyChanges { target: editPlaceDialog; title: "New Place"; opacity: 1 } + }, + State { + name: "NewCategory" + PropertyChanges { target: editCategoryDialog; title: "New Category"; opacity: 1 } + }, + State { + name: "EditPlace" + PropertyChanges { target: editPlaceDialog; title: "Edit Place"; opacity: 1 } + }, + State { + name: "EditCategory" + PropertyChanges { target: editCategoryDialog; opacity: 1 } + }, + State { + name: "Search Center" + PropertyChanges { target: searchCenterDialog; opacity: 1 } + StateChangeScript { script: searchCenterDialog.prepareDialog() } + }, + State { + name: "Search Bounding Box" + PropertyChanges { target: searchBoxDialog; opacity: 1 } + StateChangeScript { script: searchBoxDialog.prepareDialog() } + }, + State { + name: "Search Bounding Circle" + PropertyChanges { target: searchCircleDialog; opacity: 1 } + StateChangeScript { script: searchCircleDialog.prepareDialog() } + }, + State { + name: "Search Options" + PropertyChanges { target: optionsDialog; opacity: 1 } + StateChangeScript { script: optionsDialog.prepareDialog() } + } + ] + + //=====================State-transition animations for page===================== + transitions: [ + Transition { + to: "" + NumberAnimation { properties: "opacity,y,x,rotation" ; duration: 500; easing.type: Easing.Linear } + }, + Transition { + to: "Provider" + NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } + }, + Transition { + to: "New" + NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } + }, + Transition { + to: "Search" + NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } + } + ] +} diff --git a/examples/location/places/placeswrapper.qrc b/examples/location/places/placeswrapper.qrc new file mode 100644 index 00000000..1e69207e --- /dev/null +++ b/examples/location/places/placeswrapper.qrc @@ -0,0 +1,25 @@ +<RCC> + <qresource prefix="/"> + <file>places.qml</file> + <file>content/places/CategoryDelegate.qml</file> + <file>content/places/CategoryDialog.qml</file> + <file>content/places/CategoryView.qml</file> + <file>content/places/EditorialDelegate.qml</file> + <file>content/places/EditorialPage.qml</file> + <file>content/places/Group.qml</file> + <file>content/places/MapComponent.qml</file> + <file>content/places/OptionsDialog.qml</file> + <file>content/places/PlaceDelegate.qml</file> + <file>content/places/PlaceDialog.qml</file> + <file>content/places/PlaceEditorials.qml</file> + <file>content/places/PlaceImages.qml</file> + <file>content/places/PlaceReviews.qml</file> + <file>content/places/RatingView.qml</file> + <file>content/places/ReviewDelegate.qml</file> + <file>content/places/ReviewPage.qml</file> + <file>content/places/SearchBox.qml</file> + <file>content/places/SearchResultDelegate.qml</file> + <file>content/places/SearchResultView.qml</file> + <file>content/places/PlacesUtils.js</file> + </qresource> +</RCC> diff --git a/examples/location/places/qmlplaceswrapper.cpp b/examples/location/places/qmlplaceswrapper.cpp new file mode 100644 index 00000000..5856d8c9 --- /dev/null +++ b/examples/location/places/qmlplaceswrapper.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + +#include <QtCore/QStringList> +#include <QtCore/QTextStream> +#include <QtGui/QGuiApplication> +#include <QtQml/QQmlEngine> +#include <QtQml/QQmlContext> +#include <QtQuick/QQuickView> +#include <QtQuick/QQuickItem> + +static bool parseArgs(QStringList& args, QVariantMap& parameters) +{ + + while (!args.isEmpty()) { + + QString param = args.takeFirst(); + + if (param.startsWith("--help")) { + QTextStream out(stdout); + out << "Usage: " << endl; + out << "--plugin.<parameter_name> <parameter_value> - Sets parameter = value for plugin" << endl; + out.flush(); + return true; + } + + if (param.startsWith("--plugin.")) { + + param.remove(0, 9); + + if (args.isEmpty() || args.first().startsWith("--")) { + parameters[param] = true; + } else { + + QString value = args.takeFirst(); + + if (value == "true" || value == "on" || value == "enabled") { + parameters[param] = true; + } else if (value == "false" || value == "off" + || value == "disable") { + parameters[param] = false; + } else { + parameters[param] = value; + } + } + } + } + return false; +} + +int main(int argc, char *argv[]) +{ + QGuiApplication application(argc, argv); + + QVariantMap parameters; + QStringList args(QCoreApplication::arguments()); + + if (parseArgs(args, parameters)) + return 0; + + const QString mainQmlApp = QLatin1String("qrc:///places.qml"); + QQuickView view; + + view.engine()->addImportPath(QLatin1String(":/imports")); + + view.rootContext()->setContextProperty(QLatin1String("pluginParameters"), parameters); + + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + + QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit())); + view.setGeometry(QRect(100, 100, 360, 640)); + view.show(); + return application.exec(); +} diff --git a/examples/location/places_list/main.cpp b/examples/location/places_list/main.cpp new file mode 100644 index 00000000..4ddb93ec --- /dev/null +++ b/examples/location/places_list/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQuickView> + +int main(int argc, char **argv) +{ + QGuiApplication app(argc,argv); + QQuickView view; + view.setSource(QUrl::fromLocalFile("places_list.qml")); + view.show(); + return app.exec(); +} diff --git a/examples/location/places_list/places_list.pro b/examples/location/places_list/places_list.pro new file mode 100644 index 00000000..2d4b29ab --- /dev/null +++ b/examples/location/places_list/places_list.pro @@ -0,0 +1,12 @@ +TARGET = places_list +TEMPLATE = app + +QT += quick qml network +SOURCES = main.cpp + +qmlcontent.files += $$files(*.qml) + +target.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/places_list +qmlcontent.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/places_list + +INSTALLS += target qmlcontent diff --git a/examples/location/places_list/places_list.qml b/examples/location/places_list/places_list.qml new file mode 100644 index 00000000..d3911d3c --- /dev/null +++ b/examples/location/places_list/places_list.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + +//! [Imports] +import QtQuick 2.0 +import QtPositioning 5.2 +import QtLocation 5.0 +//! [Imports] + +Rectangle { + width: 360 + height: 360 + property variant startCoordinate: QtPositioning.coordinate(-27.46778, 153.02778) + + //! [Initialize Plugin] + Plugin { + id: myPlugin + name: "nokia" + //specify plugin parameters as necessary + //PluginParameter {...} + //PluginParameter {...} + //... + } + //! [Initialize Plugin] + + //! [PlaceSearchModel] + PlaceSearchModel { + id: searchModel + + plugin: myPlugin + + searchTerm: "pizza" + searchArea: QtPositioning.circle(startCoordinate); + + Component.onCompleted: update() + + } + //! [PlaceSearchModel] + + //! [Places ListView] + ListView { + anchors.fill: parent + model: searchModel + delegate: Component { + Column { + Text { text: title } + Text { text: place.location.address.text } + } + } + spacing: 10 + } + //! [Places ListView] + + Connections { + target: searchModel + onStatusChanged: { + if (searchModel.status == PlaceSearchModel.Error) + console.log(searchModel.errorString()); + } + } +} diff --git a/examples/location/places_map/main.cpp b/examples/location/places_map/main.cpp new file mode 100644 index 00000000..b93cac43 --- /dev/null +++ b/examples/location/places_map/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQuickView> + +int main(int argc, char **argv) +{ + QGuiApplication app(argc,argv); + QQuickView view; + view.setSource(QUrl::fromLocalFile("places_map.qml")); + view.show(); + return app.exec(); +} diff --git a/examples/location/places_map/marker.png b/examples/location/places_map/marker.png Binary files differnew file mode 100644 index 00000000..86ec960e --- /dev/null +++ b/examples/location/places_map/marker.png diff --git a/examples/location/places_map/places_map.pro b/examples/location/places_map/places_map.pro new file mode 100644 index 00000000..5f7d3eaf --- /dev/null +++ b/examples/location/places_map/places_map.pro @@ -0,0 +1,13 @@ +TARGET = places_map +TEMPLATE = app + +QT += quick qml network +SOURCES = main.cpp + +qmlcontent.files += $$files(*.qml) \ + marker.png + +target.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/places_map +qmlcontent.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/places_map + +INSTALLS += target qmlcontent diff --git a/examples/location/places_map/places_map.qml b/examples/location/places_map/places_map.qml new file mode 100644 index 00000000..87a254a8 --- /dev/null +++ b/examples/location/places_map/places_map.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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$ +** +****************************************************************************/ + +//! [Imports] +import QtQuick 2.0 +import QtPositioning 5.2 +import QtLocation 5.0 +//! [Imports] + +Rectangle { + width: 360 + height: 360 + + //! [Initialize Plugin] + Plugin { + id: myPlugin + name: "nokia" + //specify plugin parameters if necessary + //PluginParameter {...} + //PluginParameter {...} + //... + } + //! [Initialize Plugin] + + //! [PlaceSearchModel] + PlaceSearchModel { + id: searchModel + + plugin: myPlugin + + searchTerm: "Pizza" + //Brisbane + searchArea: QtPositioning.circle(QtPositioning.coordinate(-27.46778, 153.02778)) + + Component.onCompleted: update() + } + //! [PlaceSearchModel] + + //! [Places MapItemView] + Map { + id: map + anchors.fill: parent + plugin: myPlugin; + center { + latitude: -27.47 + longitude: 153.025 + } + zoomLevel: 13 + + MapItemView { + model: searchModel + delegate: MapQuickItem { + coordinate: place.location.coordinate + + anchorPoint.x: image.width * 0.5 + anchorPoint.y: image.height + + sourceItem: Image { + id: image + source: "marker.png" + } + } + } + } + //! [Places MapItemView] + + Connections { + target: searchModel + onStatusChanged: { + if (searchModel.status == PlaceSearchModel.Error) + console.log(searchModel.errorString()); + } + } +} |