diff options
77 files changed, 933 insertions, 608 deletions
diff --git a/examples/declarative/mapviewer/common/Menu.qml b/examples/declarative/mapviewer/common/Menu.qml deleted file mode 100644 index 59e67145..00000000 --- a/examples/declarative/mapviewer/common/Menu.qml +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 Nokia Corporation 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: menu - property int gap: 0 - property int button: -1 - property alias orientation: menuView.orientation - property alias count: menuModel.count - property int itemHeight //to create menu just set menu item height and width, do not set menu's height and width explicitly - property int itemWidth - height: (menuView.orientation == ListView.Horizontal)? itemHeight : itemHeight * count - width: (menuView.orientation == ListView.Horizontal)? itemWidth * count : itemWidth - property bool keepPreviousValue: false - property string nestedMenuSign: "\u25c2" - property string nestedPressedMenuSign: "\u25c0" - - signal clicked - - function setModel(objects) - { - menuModel.clear() - for (var i=0; i< objects.length; i++){ - menuModel.append({"label": objects[i], "enabledItem" : true}) - } - menuView.positionViewAtIndex(0,ListView.Beginning) - } - - function disableItem(index){ - menuModel.set(index, {"enabledItem": false}) - } - - function enableItem(index){ - menuModel.set(index, {"enabledItem": true}) - } - - ListModel { - id: menuModel - } - - Component{ - id: menuItemDelegate - Item { - height: itemHeight - width: itemWidth - - BorderImage { - id: menuItemImage; - source: "../resources/menuItem.sci"; - height: parent.height + 14; - width: parent.width - y: -7 - } - - Text { - id: menuItemText - text: label; - elide: Text.ElideLeft - font.bold: true; - color: enabledItem ? ((index == menuView.currentIndex) ? "crimson" :"white") : "dimgrey" - style: Text.Raised; - styleColor:"dimgrey" - anchors.verticalCenter: parent.verticalCenter - Component.onCompleted: { - if (menuView.orientation == ListView.Horizontal){ - anchors.horizontalCenter = parent.horizontalCenter - } - else { - anchors.left = parent.left - anchors.leftMargin = 10 - } - } - } - MouseArea { - id: mouseRegion - anchors.fill: parent - hoverEnabled: true - enabled: enabledItem - onClicked: { - button = index - menu.clicked() - } - } - - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { target: menuItemImage; source: "../resources/menuItem_pressed.png"} - PropertyChanges { target: menuItemText; style: Text.Sunken } - }, - State { - name: "Hovered" - when: mouseRegion.containsMouse == true - PropertyChanges { target: menuItemImage; source: "../resources/menuItem_hovered.png"} - StateChangeScript { - name: "myScript" - script:{ - var str = menuItemText.text - if (str.charAt(0) == menu.nestedMenuSign ) menuItemText.text = menu.nestedPressedMenuSign + str.substring(1, str.length) - else if (str.charAt(str.length -1) == menu.nestedMenuSign ) menuItemText.text = str.substring(0, str.length-1) + menu.nestedPressedMenuSign - } - } - }, - State { - name: "Released" - when: mouseRegion.containsMouse == false - StateChangeScript { - name: "myScript" - script:{ - var str = menuItemText.text - if (str.charAt(0) == menu.nestedPressedMenuSign ) menuItemText.text = menu.nestedMenuSign + str.substring(1, str.length) - else if (str.charAt(str.length-1) == menu.nestedPressedMenuSign ) menuItemText.text = str.substring(0, str.length-1) + menu.nestedMenuSign - } - } - }, - State { - name: "Disabled" - when: mouseRegion.enabled == false - PropertyChanges { target: menuItemText; color: "grey"} - } - ] - } - } - - ListView { - id: menuView - anchors.fill: parent - model: menuModel - delegate: menuItemDelegate - spacing: gap - interactive: false - currentIndex: (menu.keepPreviousValue == false) ? -1 : menu.button - } -} diff --git a/examples/declarative/mapviewer/mapviewer.pro b/examples/declarative/mapviewer/mapviewer.pro index 5d931a8e..726c2b35 100644 --- a/examples/declarative/mapviewer/mapviewer.pro +++ b/examples/declarative/mapviewer/mapviewer.pro @@ -1,28 +1,3 @@ -TARGET = qml_location_mapviewer -TEMPLATE=app +TEMPLATE = subdirs +SUBDIRS += mapviewerwrapper -QT += declarative network -SOURCES += qmlmapviewer.cpp - -symbian { - TARGET.CAPABILITY = NetworkServices Location ReadUserData WriteUserData - TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 -} - -RESOURCES += \ - mapviewer.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/declarative/mapviewer -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.qml *.png *.sci -sources.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/declarative/mapviewer - -INSTALLS += target sources - -OTHER_FILES += \ - mapviewer.qml \ - Dialog.qml \ - MapComponent.qml \ - Marker.qml \ - Message.qml \ - RouteDialog.qml \ - TextWithLabel.qml diff --git a/examples/declarative/mapviewer/mapviewer.qrc b/examples/declarative/mapviewer/mapviewer.qrc deleted file mode 100644 index cc2c671b..00000000 --- a/examples/declarative/mapviewer/mapviewer.qrc +++ /dev/null @@ -1,42 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>mapviewer.qml</file> - <file>Dialog.qml</file> - <file>common/TitleBar.qml</file> - <file>common/Button.qml</file> - <file>common/Slider.qml</file> - <file>common/Menu.qml</file> - <file>resources/button.png</file> - <file>resources/button.sci</file> - <file>resources/quit.png</file> - <file>resources/titlebar.png</file> - <file>resources/titlebar.sci</file> - <file>resources/quit_pressed.png</file> - <file>resources/menuItem.png</file> - <file>resources/menuItem.sci</file> - <file>resources/menuItem_pressed.png</file> - <file>resources/quit_hovered.png</file> - <file>resources/menuItem_hovered.png</file> - <file>resources/button_pressed.png</file> - <file>resources/button_hovered.png</file> - <file>Message.qml</file> - <file>common/Fader.qml</file> - <file>RouteDialog.qml</file> - <file>TextWithLabel.qml</file> - <file>resources/option_button_selected.png</file> - <file>resources/option_button.png</file> - <file>MapComponent.qml</file> - <file>Marker.qml</file> - <file>resources/marker.png</file> - <file>resources/marker_selected.png</file> - <file>resources/marker_hovered.png</file> - <file>resources/node.png</file> - <file>resources/node_selected.png</file> - <file>resources/catch.png</file> - <file>resources/scale.png</file> - <file>resources/checkbox_selected.png</file> - <file>resources/checkbox.png</file> - <file>common/Checkbox.qml</file> - <file>common/Optionbutton.qml</file> - </qresource> -</RCC> diff --git a/examples/declarative/mapviewer/common/Button.qml b/examples/declarative/mapviewer/mapviewer/content/components/Button.qml index d34bec4a..552313c4 100644 --- a/examples/declarative/mapviewer/common/Button.qml +++ b/examples/declarative/mapviewer/mapviewer/content/components/Button.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import "style" Item { id: container @@ -47,6 +48,8 @@ Item { property alias text: buttonText.text property alias color: buttonText.color + property bool checked: false + property ButtonStyle style: ButtonStyle{} function disable() { container.state = "Disabled"; @@ -58,8 +61,8 @@ Item { BorderImage { id: buttonImage - source: "../resources/button.sci" - width: container.width; height: container.height + source: style.background + width: parent.width; height: parent.height + style.heightAdjustment; y: style.yAdjustment } MouseArea { @@ -70,26 +73,26 @@ Item { } Text { id: buttonText - color: "white" + color: checked ? "lawngreen" : "white" anchors.centerIn: buttonImage; font.bold: true - style: Text.Raised; styleColor: "black" + style: Text.Raised; styleColor: "darkblue" } states: [ State { name: "Pressed" when: mouseRegion.pressed == true - PropertyChanges { target: buttonImage; source: "../resources/button_pressed.png" } + PropertyChanges { target: buttonImage; source: style.pressedBackground } PropertyChanges { target: buttonText; style: Text.Sunken } }, State { name: "Hovered" when: mouseRegion.containsMouse - PropertyChanges{ target: buttonImage; source: "../resources/button_hovered.png" } + PropertyChanges{ target: buttonImage; source: style.disabledBackground } }, State { name: "Disabled" - PropertyChanges{ target: buttonText; color: "grey" } + PropertyChanges{ target: buttonText; color: "silver" } PropertyChanges{ target: mouseRegion; enabled: false } } ] diff --git a/examples/declarative/mapviewer/common/Checkbox.qml b/examples/declarative/mapviewer/mapviewer/content/components/Checkbox.qml index cd496478..99b719f7 100644 --- a/examples/declarative/mapviewer/common/Checkbox.qml +++ b/examples/declarative/mapviewer/mapviewer/content/components/Checkbox.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 1.1 +import QtQuick 2.0 Item { id: checkbox diff --git a/examples/declarative/mapviewer/common/Fader.qml b/examples/declarative/mapviewer/mapviewer/content/components/Fader.qml index 2e0dd4bd..2e0dd4bd 100644 --- a/examples/declarative/mapviewer/common/Fader.qml +++ b/examples/declarative/mapviewer/mapviewer/content/components/Fader.qml diff --git a/examples/declarative/mapviewer/mapviewer/content/components/Menu.qml b/examples/declarative/mapviewer/mapviewer/content/components/Menu.qml new file mode 100644 index 00000000..5f7e27bd --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/components/Menu.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 Nokia Corporation 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 + + 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 + opacity: 0.9 + rows: (horizontalOrientation) ? 1 : children.length + columns: (horizontalOrientation) ? children.length : 1 + signal clicked(string button) + + onChildrenChanged: { + if (horizontalOrientation) 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: parent.height; onClicked: {parent.itemClicked(text)} style: HMenuItemStyle {}}', menu) + else + button = Qt.createQmlObject ('import "style"; Button {height: 40; width: parent.width; onClicked: {parent.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 + } + + 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 = [] + } + + 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(){ + for (var i = 0; i<children.length; i++) + children[i].width = parent.width/children.length - spacing + } + + 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/declarative/mapviewer/common/Optionbutton.qml b/examples/declarative/mapviewer/mapviewer/content/components/Optionbutton.qml index c4135f56..489d124c 100644 --- a/examples/declarative/mapviewer/common/Optionbutton.qml +++ b/examples/declarative/mapviewer/mapviewer/content/components/Optionbutton.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 1.1 +import QtQuick 2.0 Item { id: optionbutton diff --git a/examples/declarative/mapviewer/common/Slider.qml b/examples/declarative/mapviewer/mapviewer/content/components/Slider.qml index 8e4675a9..03e87d52 100644 --- a/examples/declarative/mapviewer/common/Slider.qml +++ b/examples/declarative/mapviewer/mapviewer/content/components/Slider.qml @@ -42,54 +42,54 @@ import QtQuick 2.0 Item { id: slider; - height: 40 + height: 10 property int value // value is read/write. property real minimum: 0 property real maximum: 1 - property int xMin: 2 - property int xMax: width - handle.width-xMin + property int length: width - handle.width Rectangle { anchors.fill: parent - border.width: 0; + border.width: 1; + border.color: "dodgerblue" radius: 8 - color: "dimgrey" - opacity: 0.6 + color: "white" + opacity: 1 } Rectangle { id: handle; smooth: true - width: 30; - y: slider.xMin; - x: slider.xMin + (slider.value - slider.minimum) * slider.xMax / (slider.maximum - slider.minimum) + width: 20; + y: (slider.height - height)/2; + x: (slider.value - slider.minimum) * slider.length / (slider.maximum - slider.minimum) - height: slider.height-4; radius: 6 + height: width; radius: width/2 gradient: normalGradient Gradient { id: normalGradient - GradientStop { position: 0.0; color: "lightgrey" } - GradientStop { position: 1.0; color: "gray" } + GradientStop { position: 0.0; color: "dodgerblue" } + GradientStop { position: 1.0; color: "mediumblue" } } Gradient { id: pressedGradient - GradientStop { position: 0.0; color: "lightgray" } - GradientStop { position: 1.0; color: "black" } + GradientStop { position: 0.0; color: "dodgerblue" } + GradientStop { position: 1.0; color: "navy" } } Gradient { id: hoveredGradient - GradientStop { position: 0.0; color: "lightgrey" } - GradientStop { position: 1.0; color: "dimgrey" } + GradientStop { position: 0.0; color: "dodgerblue" } + GradientStop { position: 1.0; color: "midnightblue" } } MouseArea { id: mouseRegion hoverEnabled: true anchors.fill: parent; drag.target: parent - drag.axis: Drag.XAxis; drag.minimumX: slider.xMin; drag.maximumX: slider.xMax - onPositionChanged: { value = (maximum - minimum) * (handle.x-slider.xMin) / (slider.xMax - slider.xMin) + minimum; } + drag.axis: Drag.XAxis; drag.minimumX: 0; drag.maximumX: slider.length + onPositionChanged: { value = (maximum - minimum) * handle.x / slider.length + minimum; } } } diff --git a/examples/declarative/mapviewer/TextWithLabel.qml b/examples/declarative/mapviewer/mapviewer/content/components/TextWithLabel.qml index 0b419b9f..1ff4e3f7 100644 --- a/examples/declarative/mapviewer/TextWithLabel.qml +++ b/examples/declarative/mapviewer/mapviewer/content/components/TextWithLabel.qml @@ -50,7 +50,7 @@ Row { Text { id: label; - width:55; + width:65; enabled: textWithLabel.enabled color: enabled ? "black" : "grey" anchors { @@ -62,9 +62,10 @@ Row { Rectangle { id: inputRectangle width: textWithLabel.width - label.width; height: 30 - color: enabled ? "whitesmoke" : "gainsboro" + color: enabled ? "white" : "ghostwhite" + border.width: 1 - border.color: enabled ? "black" : "grey" + border.color: enabled ? "dodgerblue" : "grey" radius: 5 TextInput { id: inputField diff --git a/examples/declarative/mapviewer/common/TitleBar.qml b/examples/declarative/mapviewer/mapviewer/content/components/TitleBar.qml index c8bc60c1..c8bc60c1 100644 --- a/examples/declarative/mapviewer/common/TitleBar.qml +++ b/examples/declarative/mapviewer/mapviewer/content/components/TitleBar.qml diff --git a/examples/declarative/mapviewer/mapviewer/content/components/style/ButtonStyle.qml b/examples/declarative/mapviewer/mapviewer/content/components/style/ButtonStyle.qml new file mode 100644 index 00000000..aa73ef95 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/components/style/ButtonStyle.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 Nokia Corporation 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.sci" + property string pressedBackground: "../resources/button_pressed.png" + property string disabledBackground: "../resources/button_hovered.png" + property int heightAdjustment: 0 + property int yAdjustment: 0 +} diff --git a/examples/declarative/mapviewer/mapviewer/content/components/style/HMenuItemStyle.qml b/examples/declarative/mapviewer/mapviewer/content/components/style/HMenuItemStyle.qml new file mode 100644 index 00000000..7dca7b2f --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/components/style/HMenuItemStyle.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 Nokia Corporation 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.sci" + pressedBackground: "../resources/hmenuItem_pressed.png" + disabledBackground: "../resources/hmenuItem_hovered.png" + heightAdjustment: 14 + yAdjustment: -7 +} diff --git a/examples/declarative/mapviewer/mapviewer/content/components/style/VMenuItemStyle.qml b/examples/declarative/mapviewer/mapviewer/content/components/style/VMenuItemStyle.qml new file mode 100644 index 00000000..f88af099 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/components/style/VMenuItemStyle.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 Nokia Corporation 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.sci" +} diff --git a/examples/declarative/mapviewer/Dialog.qml b/examples/declarative/mapviewer/mapviewer/content/dialogs/Dialog.qml index 00f2d5e5..dd32e81a 100644 --- a/examples/declarative/mapviewer/Dialog.qml +++ b/examples/declarative/mapviewer/mapviewer/content/dialogs/Dialog.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 -import "common" as Common +import "../components" Item { id: dialog @@ -65,12 +65,12 @@ Item { } } - Common.Fader {} + Fader {} Rectangle { id: dialogRectangle - color: "lightsteelblue" + color: "white" opacity: parent.opacity width: parent.width - gap; height: listview.height + titleBar.height + buttons.height + gap*2 @@ -83,10 +83,10 @@ Item { } border.width: 1 - border.color: "darkblue" + border.color: "dodgerblue" radius: 5 - Common.TitleBar { + TitleBar { id: titleBar; width: parent.width; height: 40; anchors.top: parent.top; anchors.left: parent.left; @@ -107,8 +107,8 @@ Item { id: textWithLabel label: labelText text: inputText - width: dialogRectangle.width - gap - labelWidth: 75 + width: dataRect.width - gap + labelWidth: 95 onTextChanged: { @@ -118,13 +118,34 @@ Item { } } + Rectangle { + id: dataRect + color: "#C0DCFF" + border.width: 1 + border.color: "dodgerblue" + radius: 5 + width:dialogRectangle.width - gap + height: listview.height// + gap + anchors { + top: titleBar.bottom + topMargin: gap/2 + left: parent.left + leftMargin: gap/2 + } + ListView { id: listview - anchors { +/* anchors { top: titleBar.bottom topMargin: gap left: parent.left leftMargin: gap/2 + }*/ + anchors { + top: dataRect.top + topMargin: gap/2 + left: parent.left + leftMargin: gap/2 } model: dialogModel delegate: listDelegate @@ -134,14 +155,17 @@ Item { height = (listItemHeight + gap/2)*length + gap/2 } } + } Row { id: buttons - anchors.top: listview.bottom + anchors.top: dataRect.bottom +// anchors.top: listview.bottom + anchors.topMargin: gap/2 anchors.horizontalCenter: parent.horizontalCenter spacing: gap/3 height: 32 - Common.Button { + Button { id: buttonClearAll text: "Clear" width: 80; height: parent.height @@ -151,7 +175,7 @@ Item { } } } - Common.Button { + Button { id: buttonGo text: "Go!" width: 80; height: parent.height diff --git a/examples/declarative/mapviewer/Message.qml b/examples/declarative/mapviewer/mapviewer/content/dialogs/Message.qml index 5ca70c59..788e63d9 100644 --- a/examples/declarative/mapviewer/Message.qml +++ b/examples/declarative/mapviewer/mapviewer/content/dialogs/Message.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 -import "common" as Common +import "../components" Item { id: dialog @@ -54,12 +54,13 @@ Item { signal cancelButtonClicked opacity: 0 - Common.Fader {} + Fader {} Rectangle { id: dialogRectangle - color: "lightsteelblue" + color: "white" +// color: "lightsteelblue" width: parent.width - gap; height: titleBar.height + message.height + okButton.height + gap*3 anchors { @@ -70,10 +71,10 @@ Item { } border.width: 1 - border.color: "darkblue" + border.color: "dodgerblue" radius: 5 - Common.TitleBar { + TitleBar { id: titleBar; width: parent.width; height: 40; anchors.top: parent.top; anchors.left: parent.left; @@ -95,7 +96,7 @@ Item { } } - Common.Button { + Button { id: okButton text: "Ok" anchors.top: message.bottom diff --git a/examples/declarative/mapviewer/RouteDialog.qml b/examples/declarative/mapviewer/mapviewer/content/dialogs/RouteDialog.qml index fbd504d2..7bf00b75 100644 --- a/examples/declarative/mapviewer/RouteDialog.qml +++ b/examples/declarative/mapviewer/mapviewer/content/dialogs/RouteDialog.qml @@ -40,7 +40,7 @@ import QtQuick 2.0 import QtLocation 5.0 -import "common" as Common +import "../components" Item { id: dialog @@ -67,11 +67,11 @@ Item { property int routeOptimization: RouteQuery.FastestRoute // ShortestRoute, FastestRoute, MostEconomicRoute, MostScenicRoute property variant features: [] // NoFeature, TollFeature, HighwayFeature, PublicTransitFeature, FerryFeature, TunnelFeature, DirtRoadFeature, ParksFeature, MotorPoolLaneFeature - Common.Fader {} + Fader {} Rectangle { id: dialogRectangle - color: "lightsteelblue" + color: "white" opacity: 1 width: parent.width - gap*2; height: options.height + gap*4 + buttons.height + titleBar.height + routeOptions.height @@ -84,10 +84,10 @@ Item { } border.width: 1 - border.color: "darkblue" + border.color: "dodgerblue" radius: 5 - Common.TitleBar { + TitleBar { id: titleBar; width: parent.width; height: 40; anchors.top: parent.top; anchors.left: parent.left; @@ -124,7 +124,7 @@ Item { Image { id: optionButtonCoord anchors.verticalCenter:parent.verticalCenter - source: coord.enabled ? "resources/option_button_selected.png" : "resources/option_button.png" + source: coord.enabled ? "../resources/option_button_selected.png" : "../resources/option_button.png" MouseArea { anchors.fill: parent onClicked: { options.state = "" } @@ -133,9 +133,9 @@ Item { Rectangle { id: coord - color: dialogRectangle.color + color: enabled ? "#C0DCFF" : "gainsboro" border.width: 1 - border.color: enabled ? "black" : "grey" + border.color: enabled ? "dodgerblue" : "grey" radius: 5 width:options.width - optionButtonCoord.width - row1.spacing height: longTo.y + longTo.height + gap @@ -235,7 +235,7 @@ Item { Image { id: optionButtonAddress - source: address.enabled ? "resources/option_button_selected.png" : "resources/option_button.png" + source: address.enabled ? "../resources/option_button_selected.png" : "../resources/option_button.png" anchors.verticalCenter: parent.verticalCenter MouseArea { anchors.fill: parent @@ -245,9 +245,9 @@ Item { Rectangle { id: address - color: dialogRectangle.color + color: enabled ? "#C0DCFF" : "gainsboro" border.width: 1 - border.color: enabled ? "black" : "grey" + border.color: enabled ? "dodgerblue" : "grey" radius: 5 width:coord.width height: countryTo.y + countryTo.height + gap @@ -371,14 +371,14 @@ Item { anchors.topMargin: gap anchors.left: parent.left anchors.leftMargin: gap - width: parent.width - gap + width: parent.width - gap*2 height: checkboxToll.height*2 + gap - spacing: gap + spacing: 0 Column {//travel mode spacing: gap/3 height: parent.height - width: parent.width/3 - gap - Common.Optionbutton { + width: parent.width*0.3 + Optionbutton { id: optionbuttonVehicle width: parent.width text: "Vehicle" @@ -388,7 +388,7 @@ Item { optionbuttonPedestrian.selected = false } } - Common.Optionbutton { + Optionbutton { id: optionbuttonPedestrian width: parent.width text: "Pedestrian" @@ -402,8 +402,8 @@ Item { Column {//Optimization spacing: gap/3 height: parent.height - width: parent.width/3 - gap - Common.Optionbutton { + width: parent.width*0.3 + Optionbutton { id: optionbuttonFastest width: parent.width text: "Fastest" @@ -413,7 +413,7 @@ Item { optionbuttonShortest.selected = false } } - Common.Optionbutton { + Optionbutton { id: optionbuttonShortest width: parent.width text: "Shortest" @@ -428,15 +428,15 @@ Item { id: routeFeatures spacing: gap/3 height: parent.height - width: parent.width/3 - gap - Common.Checkbox { + width: parent.width*0.4 + Checkbox { id: checkboxToll width: parent.width text: "Avoid toll roads" onSelectedChanged: {routeFeatures.updateRouteFeatures()} } - Common.Checkbox { + Checkbox { id: checkboxHighways width: parent.width text: "Avoid highways" @@ -463,7 +463,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter spacing: gap/3 height: 32 - Common.Button { + Button { text: "Clear" width: 80; height: parent.height onClicked: { @@ -484,7 +484,7 @@ Item { } } - Common.Button { + Button { text: "Go!" width: 80; height: parent.height onClicked: { diff --git a/examples/declarative/mapviewer/MapComponent.qml b/examples/declarative/mapviewer/mapviewer/content/map/MapBaseComponent.qml index b9f7610d..6ea826e0 100644 --- a/examples/declarative/mapviewer/MapComponent.qml +++ b/examples/declarative/mapviewer/mapviewer/content/map/MapBaseComponent.qml @@ -37,24 +37,60 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - import QtQuick 2.0 import QtLocation 5.0 -import "common" as Common +import "../components" Map { id: map - plugin : defaultPlugin - zoomLevel: 9 - focus: true - width: parent.width - center: defaultCoordinates - property int longPressDuration: 1000 - - property list<Marker> markers + anchors.fill: parent + zoomLevel: (maximumZoomLevel - minimumZoomLevel)/2 + center: brisbaneCoordinate + + pinch.activeGestures: MapPinch.ZoomGesture | RotationGesture + pinch.enabled: true + + // Flicking + flick.enabled: true + flick.deceleration: 3000 +// property list<Marker> markers +// property list<MapItem> mapItems property int counter: 0 // counter for total amount of markers. Resets to 0 when number of markers = 0 - property Marker currentMarker + property int mapItemsCounter: 0 // counter for total amount of mapItems. Resets to 0 when number of markers = 0 +// property Marker currentMarker + signal mapPressed() // replace with + // signal mousePressed(MouseEvent mouse) + // when QTBUG-14550 is fixed + + property int lastX : -1 + property int lastY : -1 + + Coordinate { + id: brisbaneCoordinate + latitude: -27.5 + longitude: 153 + } + Slider { + id: zoomSlider; + parent: map.parent //todo: remove the line + minimum: map.minimumZoomLevel; + maximum: map.maximumZoomLevel; + opacity: 1 + visible: parent.visible + z: map.z + anchors { + bottom: parent.bottom; + bottomMargin: 50; rightMargin: 5; leftMargin: 5 + left: parent.left + } + width: parent.width - anchors.rightMargin - anchors.leftMargin + value: map.zoomLevel + onValueChanged: { + map.zoomLevel = value + } + } +/* property RouteQuery routeQuery: RouteQuery {} property RouteModel routeModel: RouteModel { plugin : map.plugin @@ -83,13 +119,7 @@ Map { if (count == 1) map.center = get(0).coordinate } } - property int lastX : -1 - property int lastY : -1 - signal mousePressed() // replace with - // signal mousePressed(MouseEvent mouse) - // when QTBUG-14550 is fixed - signal sliderUpdated() signal coordinatesCaptured(double latitude, double longitude) signal geocodeFinished() signal showGeocodeInfo() @@ -112,7 +142,7 @@ Map { hoverEnabled: true onPressed : { - routeTimer.start(); + routeTimer.start()markers; map.state = "" map.lastX = mouse.x map.lastY = mouse.y @@ -307,7 +337,7 @@ Map { visible: (routeInfoModel.count > 0) Image { id: catchImage - source: "resources/catch.png" + source: "../resources/catch.png" anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right MouseArea { @@ -328,7 +358,7 @@ Map { id: infoRect width: parent.width - catchImage.sourceSize.width height: parent.height - color: "grey" + color: "#3F95FF" opacity: 0.75 radius: 5 MouseArea { @@ -354,33 +384,14 @@ Map { } } } - - Common.Slider { - id: zoomSlider; - parent: map.parent //todo: remove the line - minimum: map.minimumZoomLevel; - maximum: map.maximumZoomLevel; - opacity: 1 - z: map.z - anchors { - bottom: parent.bottom; - bottomMargin: 50; rightMargin: 5; leftMargin: 5 - left: parent.left - } - width: parent.width - anchors.rightMargin - anchors.leftMargin - value: map.zoomLevel - onValueChanged: { - map.zoomLevel = value - map.sliderUpdated() - } - } +*/ Item {//scale id: scale parent: zoomSlider.parent + visible: scaleText.text != "0 m" z: map.z opacity: 0.6 - visible: map.zoomLevel == 0 ? false : true anchors { bottom: zoomSlider.top; bottomMargin: 8; @@ -389,19 +400,19 @@ Map { } Image { id: scaleImage - source: "resources/scale.png" + source: "../resources/scale.png" anchors.bottom: parent.bottom anchors.left: parent.left } Text { id: scaleText - color: "black" + color: "#004EAE" horizontalAlignment: Text.AlignHCenter width: scaleImage.sourceSize.width anchors.bottom: parent.bottom anchors.left: parent.left anchors.bottomMargin: 3 - Component.onCompleted: {text = calculateScale()} + text:calculateScale() } } @@ -409,182 +420,215 @@ Map { scaleText.text = calculateScale() } - Common.Menu { + onZoomLevelChanged:{ + scaleText.text = map.calculateScale() + } + + onWidthChanged:{ + scaleText.text = map.calculateScale() + } + + onHeightChanged:{ + scaleText.text = map.calculateScale() + } + + Menu { id: markerMenu - orientation: ListView.Vertical + horizontalOrientation: false z: map.z + 2 opacity: 0 - itemHeight: 30; - itemWidth: 150 + width: 150 x: 0 y: 0 onClicked: { map.state = "" - switch (button) { - case 0: {//remove marker +/* switch (button) { + case "Delete": {//remove marker map.removeMarker(currentMarker) break; } - case 1: {//move marker + case "Move to": {//move marker map.moveMarker() break; } - case 2: {//show marker's coordinates + case "Coordinates": {//show marker's coordinates map.coordinatesCaptured(currentMarker.coordinate.latitude, currentMarker.coordinate.longitude) break; } - case 3: {//calculate route + case "Route to next points"://calculate route + case "Route to next point": { map.calculateRoute(currentMarker) break; } - } + }*/ } } - Common.Menu { + Menu { id: popupMenu - orientation: ListView.Vertical - z: map.z +2 + horizontalOrientation: false + z: map.z + 2 opacity: 0 - itemHeight: 30; - itemWidth: 150 + width: 150 x: 0 y: 0 onClicked: { - switch (button) { - case 0: { //add Marker +/* switch (button) { + case "Set Marker": { addMarker() break; } - case 1: {//show coordinates + case "Coordinates": { map.coordinatesCaptured(mouseArea.lastCoordinate.latitude, mouseArea.lastCoordinate.longitude) break; } - case 2: { //delete all Markers - map.deleteAllMarkers() + case "Delete all objects": { + map.deleteAllObjects() break; } - } + }*/ map.state = "" } } - Common.Menu { + Menu { id: routeMenu - orientation: ListView.Vertical + horizontalOrientation: false z: map.z +2 opacity: 0 - itemHeight: 30; - itemWidth: 150 + width: 150 x: 0 y: 0 onClicked: { - switch (button) { - case 0: {//delete route +/* switch (button) { + case "Delete": {//delete route routeModel.clear() routeInfoModel.update() break; } - } + }*/ map.state = "" } Component.onCompleted: { - setModel(["Delete"]) + addItem("Delete") } } - Common.Menu { + Menu { id: pointMenu - orientation: ListView.Vertical + horizontalOrientation: false z: map.z +2 opacity: 0 - itemHeight: 30; - itemWidth: 150 + width: 150 x: 0 y: 0 onClicked: { - switch (button) { - case 0: {//point info +/* switch (button) { + case "Info": { map.showGeocodeInfo() break; } - case 1: {//delete point + case "Delete": { geocodeModel.clear() break; } - } + }*/ map.state = "" } Component.onCompleted: { - setModel(["Info", "Delete"]) + addItem("Info") + addItem("Delete") } } - onZoomLevelChanged:{ - zoomSlider.value = map.zoomLevel - scaleText.text = map.calculateScale() + 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 + 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 Coordinate lastCoordinate: Coordinate { latitude : 0; longitude : 0} + anchors.fill: parent onPressed : { - mapTimer.start() + mapPressed(); map.state = "" map.lastX = mouse.x map.lastY = mouse.y lastCoordinate = mouse.coordinate - map.mousePressed() - } - onReleased : { - if (mapTimer.running) {//SHORT PRESS - mapTimer.stop() - map.lastX = -1 - map.lastY = -1 - } +// if (mouse.button == Qt.MiddleButton) +// addMarker() } + onPositionChanged: { - if (mapTimer.running) mapTimer.stop() + map.state = "" if ((mouse.button == Qt.LeftButton) & (map.state == "")) { - if ((map.lastX != -1) && (map.lastY != -1)) { +/* 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 = mouse.coordinate if (mouse.button == Qt.LeftButton){ map.zoomLevel += 1 - } else if (mouse.button == Qt.RightButton){ - map.zoomLevel -= 1 - } + } else if (mouse.button == Qt.RightButton) map.zoomLevel -= 1 lastX = -1 lastY = -1 } - Timer { - id: mapTimer - interval: longPressDuration; running: false; repeat: false - onTriggered: { //LONG PRESS - if (map.markers.length != 0) popupMenu.setModel(["Set Marker","Coordinates","Delete all markers"]) - else popupMenu.setModel(["Set Marker","Coordinates"]) - map.state = "PopupMenu" - } + onPressAndHold:{ + popupMenu.clear() + popupMenu.addItem("Coordinates") + popupMenu.addItem("Marker") + popupMenu.addItem("Rectangle") + popupMenu.addItem("Circle") + popupMenu.addItem("Polyline") + popupMenu.addItem("Polygon") +/* if ((map.markers.length != 0) || (map.mapItems.length != 0)) popupMenu.addItem("Delete all objects") + map.state = "PopupMenu"*/ } } + Keys.onPressed: { if ((event.key == Qt.Key_Plus) || (event.key == Qt.Key_VolumeUp)) { map.zoomLevel += 1 @@ -595,24 +639,48 @@ Map { function calculateScale(){ var coord1, coord2, dist, text - if (map.zoomLevel == 0) { text=""} - else{ - 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)) - text = formatDistance(dist) - } + 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)) + text = formatDistance(dist) return text } - function deleteAllMarkers(){ +/* + function addMapItem(type){ + var item, myArray + if (map.itemMarkers.length < 2){ + console.log("less than 2 points marked") + } else { + console.log("adding " + type) + item = Qt.createQmlObject (type + ' {}', map) + map.addMapObject(item) + //update list of markers + var count = map.objects.length + mapItemsCounter++ + myArray = new Array() + for (var i = 0; i<count; i++){ + myArray.push(mapItems[i]) + } + myArray.push(item) + mapItems = myArray + } + } + + function deleteAllObjects(){ var count = map.markers.length for (var i = 0; i<count; i++){ map.removeMapObject(map.markers[i]) map.markers[i].destroy() } map.markers = [] - counter = 0 + var count = map.mapItems.length + for (var i = 0; i<count; i++){ + map.removeMapObject(map.mapItems[i]) + map.mapItems[i].destroy() + } + map.mapItems = [] + mapItemsCounter = 0 } function addMarker(){ @@ -650,14 +718,16 @@ Map { var array var count = map.markers.length - if (currentMarker == markers[count-1]) array = ["Delete", "Move to", "Coordinates"] - else if (count > 2){ - if (currentMarker == markers[count-2]) array = ["Delete", "Move to", "Coordinates", "Route to next point"] - else array = ["Delete", "Move to", "Coordinates", "Route to next points"] + markerMenu.clear() + markerMenu.addItem("Delete") + markerMenu.addItem("Move to") + markerMenu.addItem("Coordinates") + if ((currentMarker != markers[count-1]) && (count > 2)) + if (currentMarker == markers[count-2]) markerMenu.addItem("Route to next point") + else markerMenu.addItem("Route to next points") } - else array = ["Delete", "Move to", "Coordinates", "Route to next point"] + else markerMenu.addItem("Route to next point") - markerMenu.setModel(array) map.state = "MarkerPopupMenu" } @@ -681,7 +751,7 @@ Map { } routeModel.update(); } - +*/ function roundNumber(number, digits) { var multiple = Math.pow(10, digits); return Math.round(number * multiple) / multiple; @@ -747,4 +817,5 @@ Map { PropertyChanges { target: pointMenu; y: ((map.lastY + pointMenu.height > map.height) ? map.height - pointMenu.height : map.lastY)} } ] + } diff --git a/examples/declarative/mapviewer/mapviewer/content/map/MapComponent.qml b/examples/declarative/mapviewer/mapviewer/content/map/MapComponent.qml new file mode 100644 index 00000000..4cd95914 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/map/MapComponent.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 Nokia Corporation 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: map + property MapBaseComponent currentMap + property list<MapBaseComponent> maps + + Component.onCompleted:{ + var plugins = getPlugins() + var myArray = new Array() + var tempMap + + for (var i = 0; i<plugins.length; i++){ + tempMap = Qt.createQmlObject ('import QtLocation 5.0; MapBaseComponent{visible: plugin == parent.currentMap.plugin; z: visible ? (parent.z + 1) : parent.z; plugin: Plugin{ name:"' + plugins[i] + '"}}', map) + myArray.push(tempMap) + } + currentMap = myArray[0] + maps = myArray + } + + 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 && tempPlugin.supportsReverseGeocoding && tempPlugin.supportsRouting ) + myArray.push(tempPlugin.name) + } + return myArray + } +} diff --git a/examples/declarative/mapviewer/Marker.qml b/examples/declarative/mapviewer/mapviewer/content/map/Marker.qml index 063ab6d7..2385f4bb 100644 --- a/examples/declarative/mapviewer/Marker.qml +++ b/examples/declarative/mapviewer/mapviewer/content/map/Marker.qml @@ -40,7 +40,7 @@ import QtQuick 2.0; import QtLocation 5.0 -import "common" as Common +import "../components" MapGroup { //to be used inside MapComponent only id: marker diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/button.png b/examples/declarative/mapviewer/mapviewer/content/resources/button.png Binary files differnew file mode 100644 index 00000000..18d9a84d --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/button.png diff --git a/examples/declarative/mapviewer/resources/button.sci b/examples/declarative/mapviewer/mapviewer/content/resources/button.sci index a34a58b6..a34a58b6 100644 --- a/examples/declarative/mapviewer/resources/button.sci +++ b/examples/declarative/mapviewer/mapviewer/content/resources/button.sci diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/button_hovered.png b/examples/declarative/mapviewer/mapviewer/content/resources/button_hovered.png Binary files differnew file mode 100644 index 00000000..0f228f83 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/button_hovered.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/button_pressed.png b/examples/declarative/mapviewer/mapviewer/content/resources/button_pressed.png Binary files differnew file mode 100644 index 00000000..0a91912d --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/button_pressed.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/catch.png b/examples/declarative/mapviewer/mapviewer/content/resources/catch.png Binary files differnew file mode 100644 index 00000000..cce322cb --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/catch.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/checkbox.png b/examples/declarative/mapviewer/mapviewer/content/resources/checkbox.png Binary files differnew file mode 100644 index 00000000..b9aab540 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/checkbox.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/checkbox_selected.png b/examples/declarative/mapviewer/mapviewer/content/resources/checkbox_selected.png Binary files differnew file mode 100644 index 00000000..28af3751 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/checkbox_selected.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem.png b/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem.png Binary files differnew file mode 100644 index 00000000..42f565a2 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem.sci b/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem.sci new file mode 100644 index 00000000..477ada8e --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: hmenuItem.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem_hovered.png b/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem_hovered.png Binary files differnew file mode 100644 index 00000000..6a9a3a98 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem_hovered.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem_pressed.png b/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem_pressed.png Binary files differnew file mode 100644 index 00000000..f779baf6 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/hmenuItem_pressed.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/marker.png b/examples/declarative/mapviewer/mapviewer/content/resources/marker.png Binary files differnew file mode 100644 index 00000000..86ec960e --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/marker.png diff --git a/examples/declarative/mapviewer/resources/marker_hovered.png b/examples/declarative/mapviewer/mapviewer/content/resources/marker_hovered.png Binary files differindex 890b67cc..902ae591 100644 --- a/examples/declarative/mapviewer/resources/marker_hovered.png +++ b/examples/declarative/mapviewer/mapviewer/content/resources/marker_hovered.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/marker_selected.png b/examples/declarative/mapviewer/mapviewer/content/resources/marker_selected.png Binary files differnew file mode 100644 index 00000000..f4bf8921 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/marker_selected.png diff --git a/examples/declarative/mapviewer/resources/menuItem.png b/examples/declarative/mapviewer/mapviewer/content/resources/menuItem.png Binary files differindex 51c90082..51c90082 100644 --- a/examples/declarative/mapviewer/resources/menuItem.png +++ b/examples/declarative/mapviewer/mapviewer/content/resources/menuItem.png diff --git a/examples/declarative/mapviewer/resources/menuItem.sci b/examples/declarative/mapviewer/mapviewer/content/resources/menuItem.sci index 0418d94c..0418d94c 100644 --- a/examples/declarative/mapviewer/resources/menuItem.sci +++ b/examples/declarative/mapviewer/mapviewer/content/resources/menuItem.sci diff --git a/examples/declarative/mapviewer/resources/menuItem_hovered.png b/examples/declarative/mapviewer/mapviewer/content/resources/menuItem_hovered.png Binary files differindex 16c1a94e..16c1a94e 100644 --- a/examples/declarative/mapviewer/resources/menuItem_hovered.png +++ b/examples/declarative/mapviewer/mapviewer/content/resources/menuItem_hovered.png diff --git a/examples/declarative/mapviewer/resources/menuItem_pressed.png b/examples/declarative/mapviewer/mapviewer/content/resources/menuItem_pressed.png Binary files differindex 3ab14f1f..3ab14f1f 100644 --- a/examples/declarative/mapviewer/resources/menuItem_pressed.png +++ b/examples/declarative/mapviewer/mapviewer/content/resources/menuItem_pressed.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/node.png b/examples/declarative/mapviewer/mapviewer/content/resources/node.png Binary files differnew file mode 100644 index 00000000..46e85672 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/node.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/node_selected.png b/examples/declarative/mapviewer/mapviewer/content/resources/node_selected.png Binary files differnew file mode 100644 index 00000000..a967f3cf --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/node_selected.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/option_button.png b/examples/declarative/mapviewer/mapviewer/content/resources/option_button.png Binary files differnew file mode 100644 index 00000000..b6c1a777 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/option_button.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/option_button_selected.png b/examples/declarative/mapviewer/mapviewer/content/resources/option_button_selected.png Binary files differnew file mode 100644 index 00000000..129e21c0 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/option_button_selected.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/quit.png b/examples/declarative/mapviewer/mapviewer/content/resources/quit.png Binary files differnew file mode 100644 index 00000000..9a5cb8a2 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/quit.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/quit_hovered.png b/examples/declarative/mapviewer/mapviewer/content/resources/quit_hovered.png Binary files differnew file mode 100644 index 00000000..bea8f251 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/quit_hovered.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/quit_pressed.png b/examples/declarative/mapviewer/mapviewer/content/resources/quit_pressed.png Binary files differnew file mode 100644 index 00000000..e69aa111 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/quit_pressed.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/scale.png b/examples/declarative/mapviewer/mapviewer/content/resources/scale.png Binary files differnew file mode 100644 index 00000000..29baa8a4 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/scale.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/titlebar.png b/examples/declarative/mapviewer/mapviewer/content/resources/titlebar.png Binary files differnew file mode 100644 index 00000000..c4689844 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/titlebar.png diff --git a/examples/declarative/mapviewer/resources/titlebar.sci b/examples/declarative/mapviewer/mapviewer/content/resources/titlebar.sci index 0418d94c..0418d94c 100644 --- a/examples/declarative/mapviewer/resources/titlebar.sci +++ b/examples/declarative/mapviewer/mapviewer/content/resources/titlebar.sci diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/vmenuItem.png b/examples/declarative/mapviewer/mapviewer/content/resources/vmenuItem.png Binary files differnew file mode 100644 index 00000000..5d60f854 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/vmenuItem.png diff --git a/examples/declarative/mapviewer/mapviewer/content/resources/vmenuItem.sci b/examples/declarative/mapviewer/mapviewer/content/resources/vmenuItem.sci new file mode 100644 index 00000000..909567db --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/content/resources/vmenuItem.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: vmenuItem.png diff --git a/examples/declarative/mapviewer/mapviewer/icon.png b/examples/declarative/mapviewer/mapviewer/icon.png Binary files differnew file mode 100644 index 00000000..2b3bbe01 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/icon.png diff --git a/examples/declarative/mapviewer/mapviewer/info.json b/examples/declarative/mapviewer/mapviewer/info.json new file mode 100644 index 00000000..412dd0b0 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/info.json @@ -0,0 +1,14 @@ +{ + "info-version": "1.0", + "dict": { + "DisplayName": "Mapviewer", + "Identifier": "com.nokia.mt-qt5location-mapviewer", + "Runtime": "qml", + "MainQML": "mapviewer.qml", + "Version": "1.0.0", + "Category": "application", + "Subcategory": "utility", + "Summary": "Mapviewer example", + "Author": "Qt" + } +} diff --git a/examples/declarative/mapviewer/mapviewer/mapviewer.pro b/examples/declarative/mapviewer/mapviewer/mapviewer.pro new file mode 100644 index 00000000..6dc685b9 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/mapviewer.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS = qml.pro diff --git a/examples/declarative/mapviewer/mapviewer.qml b/examples/declarative/mapviewer/mapviewer/mapviewer.qml index 4bd20721..f36acf6f 100644 --- a/examples/declarative/mapviewer/mapviewer.qml +++ b/examples/declarative/mapviewer/mapviewer/mapviewer.qml @@ -40,72 +40,81 @@ import QtQuick 2.0 import QtLocation 5.0 -import "common" as Common +import "content/components" +import "content/map" +import "content/dialogs" Item { - anchors.fill: parent id: page + width: 360 + height: 640 Rectangle { id: backgroundRect anchors.fill: parent - color: "darkgrey" + color: "lightgrey" z:2 } - Common.TitleBar { + TitleBar { id: titleBar; z: mainMenu.z; width: parent.width; height: 40; opacity: 0.9; text: "QML mapviewer example" onClicked: { Qt.quit() } } -//=====================Menus===================== - Common.Menu { - id: mainMenu - itemHeight: 40 - itemWidth: page.width / count +//=====================Menu===================== + Menu { + id:mainMenu anchors.bottom: parent.bottom - orientation: ListView.Horizontal - z: map.z + 3 + z: backgroundRect.z + 2 + Component.onCompleted: { - setModel(["Options","Settings"]) + addItem("Options") + addItem("Map Type") + addItem("Provider") + disableItem("Map Type") } + onClicked: { switch (button) { - case 0: { + case "Options": { page.state = "Options" break; } - case 1: { - page.state = "Settings" + case "Map Type": { + page.state = "MapType" + break; + } + case "Provider": { + page.state = "Provider" break; } } } } - Common.Menu { + Menu { id: optionsMenu - orientation: ListView.Vertical - z: mainMenu.z - 1 + z: backgroundRect.z + 2 + y: page.height + horizontalOrientation: false + Component.onCompleted: { - setModel(["Reverse geocode", "Geocode", "Route"]) + addItem("Reverse geocode") + addItem("Geocode") + addItem("Route") } - itemHeight: 30; - itemWidth: mainMenu.itemWidth - anchors.left: mainMenu.left - y: page.height onClicked: { switch (button) { - case 0: { + case "Reverse geocode": { page.state = "RevGeocode" break; } - case 1: { + case "Geocode": { page.state = "Geocode" break; } - case 2: { + case "Route": { page.state = "Route" break; } @@ -113,127 +122,58 @@ Item { } } - Common.Menu { - id: settingsMenu - orientation: ListView.Vertical - z: mainMenu.z - 1 - Component.onCompleted: { - setModel([ settingsMenu.nestedMenuSign + " Map type", settingsMenu.nestedMenuSign + " Connectivity", " Provider"]) - } - - itemHeight: 30; - itemWidth: mainMenu.itemWidth - y: page.height - anchors.right: mainMenu.right - - onClicked: { - switch (button) { - case 0: { - page.state = "MapType" - break; - } - case 1: { - page.state = "Connectivity" - break; - } - case 2: { - messageDialog.state = "Provider" - page.state = "Message" - break; - } - } - } - } - - Common.Menu { + Menu { id: mapTypeMenu - orientation: ListView.Vertical - z: mainMenu.z - 1 - keepPreviousValue: true - opacity: 0 - - itemHeight: 30; - itemWidth: mainMenu.itemWidth*2/3 - anchors.bottom: mainMenu.top - anchors.right: settingsMenu.left + z: backgroundRect.z + 2 + y: page.height + horizontalOrientation: false + exclusive: true Component.onCompleted: { - setModel(["Street", "Satellite", "Satellite Night", "Terrain"]) - disableItem(2) // Nokia map engine supports only Street, Satellite and Terrain map types - button = 0 // Nokia plugin's default map type is Map.StreetMap +/* for (var i = 0; i<map.supportedMapTypes.length; i++) + addItem(map.supportedMapTypes[i].name) + if (map.supportedMapTypes.length > 0) + exclusiveButton = map.supportedMapTypes[0].name*/ } onClicked: { page.state = "" } - onButtonChanged: { - switch (button) { - case 0: { - map.mapType = Map.StreetMap - break; - } - case 1: { - map.mapType = Map.SatelliteMapDay - break; - } - case 2: { - map.mapType = Map.SatelliteMapNight - break; - } - case 3: { - map.mapType = Map.TerrainMap - break; - } - } + onExclusiveButtonChanged: { +// map.mapType = exclusiveButton } } - Common.Menu { - id: connectivityModeMenu - orientation: ListView.Vertical - z: mainMenu.z - 1 - keepPreviousValue: true - opacity: 0 - - itemHeight: 30; - itemWidth: mainMenu.itemWidth/2 - anchors.bottom: mainMenu.top - anchors.right: settingsMenu.left + Menu { + id: providerMenu + z: backgroundRect.z + 2 + y: page.height + horizontalOrientation: false + exclusive: true Component.onCompleted: { - setModel(["Offline", "Online", "Hybrid"]) - disableItem(0) // Nokia map engine supports online mode - disableItem(2) - button = 1 + var plugins = map.getPlugins() + for (var i = 0; i<plugins.length; i++) + addItem(plugins[i]) + if (plugins.length > 0) exclusiveButton = plugins[0] } onClicked: { page.state = "" } - onButtonChanged: { - switch (button) { - case 0: { - map.connectivityMode = Map.OfflineMode - break; - } - case 1: { - map.connectivityMode = Map.OnlineMode - break; - } - case 2: { - map.connectivityMode = Map.HybridMode - break; - } - } + onExclusiveButtonChanged: { + for (var i = 0; i<map.maps.length; i++) + if (map.maps[i].plugin.name == exclusiveButton) + map.currentMap = map.maps[i] } } //=====================Dialogs===================== Message { id: messageDialog - z: mainMenu.z + 1 + z: backgroundRect.z + 2 onOkButtonClicked: { page.state = "" } @@ -243,11 +183,6 @@ Item { states: [ State{ - name: "Provider" - PropertyChanges { target: messageDialog; title: "Provider" } - PropertyChanges { target: messageDialog; text: "Nokia OVI <a href=\http://doc.qt.nokia.com/qtmobility-1.2/location-overview.html#the-nokia-plugin\">map plugin</a>." } - }, - State{ name: "GeocodeError" PropertyChanges { target: messageDialog; title: "Geocode Error" } PropertyChanges { target: messageDialog; text: "Unable to find location for the given point" } @@ -282,14 +217,14 @@ Item { //Route Dialog RouteDialog { id: routeDialog - z: mainMenu.z + 1 + z: backgroundRect.z + 2 Coordinate { id: endCoordinate } Coordinate { id: startCoordinate } Address { id:startAddress } Address { id:endAddress } - GeocodeModel { +/* GeocodeModel { id: tempGeocodeModel plugin : map.plugin property int success: 0 @@ -329,9 +264,9 @@ Item { } } } - +*/ onGoButtonClicked: { - var status = true +/* var status = true messageDialog.state = "" if (routeDialog.byCoordinates) { @@ -352,8 +287,8 @@ Item { endAddress.city = routeDialog.endCity tempGeocodeModel.query = startAddress - tempGeocodeModel.update(); - } + tempGeocodeModel.update();k + }*/ page.state = "" } @@ -361,7 +296,7 @@ Item { page.state = "" } - function calculateRoute(){ +/* function calculateRoute(){ map.routeQuery.clearWaypoints(); map.center = startCoordinate map.routeQuery.addWaypoint(startCoordinate) @@ -378,14 +313,14 @@ Item { } map.routeModel.update(); - } + }*/ } //Geocode Dialog Dialog { id: geocodeDialog title: "Geocode" - z: mainMenu.z + 1 + z: backgroundRect.z + 2 Component.onCompleted: { var obj = [["Street", "Brandl St"],["District",""],["City", "Eight Mile Plains"], ["County", ""],["State", ""],["Country code",""],["Country","Australia"], ["Post code", ""]] @@ -398,7 +333,7 @@ Item { onGoButtonClicked: { page.state = "" - messageDialog.state = "" +/* messageDialog.state = "" geocodeAddress.street = dialogModel.get(0).inputText geocodeAddress.district = dialogModel.get(1).inputText geocodeAddress.city = dialogModel.get(2).inputText @@ -409,7 +344,7 @@ Item { geocodeAddress.postcode = dialogModel.get(7).inputText map.geocodeModel.clear() map.geocodeModel.query = geocodeAddress - map.geocodeModel.update(); + map.geocodeModel.update();*/ } onCancelButtonClicked: { page.state = "" @@ -420,7 +355,7 @@ Item { Dialog { id: reverseGeocodeDialog title: "Reverse Geocode" - z: mainMenu.z + 1 + z: backgroundRect.z + 2 Component.onCompleted: { var obj = [["Latitude","-27.575"],["Longitude", "153.088"]] @@ -435,11 +370,11 @@ Item { page.state = "" messageDialog.state = "" - reverseGeocodeCoordinate.latitude = dialogModel.get(0).inputText +/* reverseGeocodeCoordinate.latitude = dialogModel.get(0).inputText reverseGeocodeCoordinate.longitude = dialogModel.get(1).inputText map.geocodeModel.clear() map.geocodeModel.query = reverseGeocodeCoordinate - map.geocodeModel.update(); + map.geocodeModel.update();*/ } onCancelButtonClicked: { @@ -451,7 +386,7 @@ Item { Dialog { id: coordinatesDialog title: "New coordinates" - z: mainMenu.z + 1 + z: backgroundRect.z + 2 Component.onCompleted: { var obj = [["Latitude", ""],["Longitude", ""]] @@ -461,9 +396,9 @@ Item { onGoButtonClicked: { page.state = "" messageDialog.state = "" - map.currentMarker.coordinate.latitude = dialogModel.get(0).inputText +/* map.currentMarker.coordinate.latitude = dialogModel.get(0).inputText map.currentMarker.coordinate.longitude = dialogModel.get(1).inputText - map.center = map.currentMarker.coordinate + map.center = map.currentMarker.coordinate*/ } onCancelButtonClicked: { @@ -471,7 +406,7 @@ Item { } } - GeocodeModel { +/* GeocodeModel { id: geocodeModel plugin : Plugin { name : "nokia"} onLocationsChanged: { @@ -480,21 +415,22 @@ Item { map.center = geocodeModel.get(0).coordinate } } - } + }*/ //=====================Map===================== MapComponent{ id: map z : backgroundRect.z + 1 - size.width: parent.width - size.height: parent.height - mainMenu.height - - onMousePressed: { - page.state = "" + width: parent.width + height: parent.height + Connections { + target: map.currentMap + onMapPressed: { page.state = "" } } + } - MapObjectView { +/* MapObjectView { model: geocodeModel delegate: Component { MapCircle { @@ -541,10 +477,10 @@ Item { page.state = "Message" } } - +*/ function geocodeMessage(){ var street, district, city, county, state, countryCode, country, postcode, latitude, longitude, text - latitude = map.geocodeModel.get(0).coordinate.latitude +/* latitude = map.geocodeModel.get(0).coordinate.latitude longitude = map.geocodeModel.get(0).coordinate.longitude street = map.geocodeModel.get(0).address.street district = map.geocodeModel.get(0).address.district @@ -564,10 +500,9 @@ Item { 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 (postcode) text +="<b>Postcode: </b>"+ postcode + " <br/>" + if (postcode) text +="<b>Postcode: </b>"+ postcode + " <br/>"*/ return text } - //=====================States of page===================== states: [ State { @@ -599,18 +534,12 @@ Item { PropertyChanges { target: optionsMenu; y: page.height - optionsMenu.height - mainMenu.height } }, State { - name : "Settings" - PropertyChanges { target: settingsMenu; y: page.height - settingsMenu.height - mainMenu.height } + name : "Provider" + PropertyChanges { target: providerMenu; y: page.height - providerMenu.height - mainMenu.height } }, State { name : "MapType" - PropertyChanges { target: mapTypeMenu; opacity: 1} - PropertyChanges { target: settingsMenu; y: page.height - settingsMenu.height - mainMenu.height } - }, - State { - name : "Connectivity" - PropertyChanges { target: connectivityModeMenu; opacity: 1} - PropertyChanges { target: settingsMenu; y: page.height - settingsMenu.height - mainMenu.height } + PropertyChanges { target: mapTypeMenu; y: page.height - mapTypeMenu.height - mainMenu.height } } ] @@ -641,7 +570,11 @@ Item { NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } }, Transition { - to: "Settings" + to: "Provider" + NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } + }, + Transition { + to: "MapType" NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } }, Transition { @@ -649,4 +582,21 @@ Item { NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } } ] + + + +/* function getPlugins(){ + var plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin {}', page) + var tempPlugin + var myArray = new Array() + + console.log("getting plugins") + 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 && tempPlugin.supportsReverseGeocoding && tempPlugin.supportsRouting ) + myArray.push(tempPlugin.name) + } + + return myArray + }*/ } diff --git a/examples/declarative/mapviewer/mapviewer/notions.json b/examples/declarative/mapviewer/mapviewer/notions.json new file mode 100644 index 00000000..95d05191 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/notions.json @@ -0,0 +1,5 @@ +{ + "notion-file-version": 1, + "capabilities": [ + ] +} diff --git a/examples/declarative/mapviewer/mapviewer/qml.pro b/examples/declarative/mapviewer/mapviewer/qml.pro new file mode 100644 index 00000000..756b13d2 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/qml.pro @@ -0,0 +1,30 @@ +TEMPLATE = aux + +files.files = info.json notions.json settings.json icon.png +#files.files = info.json notions.json settings.json mapviewer.qml content/HomePage.qml icon.png +files.path = /opt/mt/applications/mt-qt5location-mapviewer +INSTALLS = files + +OTHER_FILES += \ + content/dialogs/Dialog.qml \ + content/dialogs/Message.qml \ + content/dialogs/RouteDialog.qml \ + content/map/MapComponent.qml \ + content/map/MapBaseComponent.qml \ + content/map/MosPlugin.qml \ + content/map/RestPlugin.qml \ + content/map/Marker.qml \ + content/components/TextWithLabel.qml \ + content/components/Button.qml \ + content/components/Checkbox.qml \ + content/components/Fader.qml \ + content/components/Optionbutton.qml \ + content/components/Slider.qml \ + content/components/TitleBar.qml \ + content/components/ButtonRow.qml \ + content/components/Menu.qml \ + content/components/style/Style.qml \ + content/components/style/ButtonStyle.qml \ + content/components/style/HMenuItemStyle.qml \ + content/components/style/VMenuItemStyle.qml + diff --git a/examples/declarative/mapviewer/mapviewer/settings.json b/examples/declarative/mapviewer/mapviewer/settings.json new file mode 100644 index 00000000..83ffad51 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewer/settings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0", + "identifier": "com.nokia.mt-qt5location-mapviewer", + "label": "Settings for Mapviewer", + "settings": [ + ] +} diff --git a/examples/declarative/mapviewer/mapviewerwrapper/mapviewerwrapper.pro b/examples/declarative/mapviewer/mapviewerwrapper/mapviewerwrapper.pro new file mode 100644 index 00000000..748ec9c5 --- /dev/null +++ b/examples/declarative/mapviewer/mapviewerwrapper/mapviewerwrapper.pro @@ -0,0 +1,32 @@ +TARGET = qml_location_mapviewer +TEMPLATE=app + +QT += declarative network +SOURCES += qmlmapviewerwrapper.cpp + +RESOURCES += \ + mapviewerwrapper.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/declarative/mapviewer + +INSTALLS += target + +OTHER_FILES += \ + ../mapviewer/mapviewer.qml \ + ../mapviewer/content/dialogs/Dialog.qml \ + ../mapviewer/content/dialogs/Message.qml \ + ../mapviewer/content/dialogs/RouteDialog.qml \ + ../mapviewer/content/map/MapComponent.qml \ + ../mapviewer/content/map/MapBaseComponent.qml \ + ../mapviewer/content/map/Marker.qml \ + ../mapviewer/content/components/TextWithLabel.qml \ + ../mapviewer/content/components/Button.qml \ + ../mapviewer/content/components/Checkbox.qml \ + ../mapviewer/content/components/Fader.qml \ + ../mapviewer/content/components/Optionbutton.qml \ + ../mapviewer/content/components/Slider.qml \ + ../mapviewer/content/components/TitleBar.qml \ + ../mapviewer/content/components/Menu.qml \ + ../mapviewer/content/components/style/ButtonStyle.qml \ + ../mapviewer/content/components/style/HMenuItemStyle.qml \ + ../mapviewer/content/components/style/VMenuItemStyle.qml diff --git a/examples/declarative/mapviewer/mapviewerwrapper/mapviewerwrapper.qrc b/examples/declarative/mapviewer/mapviewerwrapper/mapviewerwrapper.qrc new file mode 100644 index 00000000..1b074aea --- /dev/null +++ b/examples/declarative/mapviewer/mapviewerwrapper/mapviewerwrapper.qrc @@ -0,0 +1,58 @@ +<RCC> + <qresource prefix="/"> + <file alias="mapviewer.qml">../mapviewer/mapviewer.qml</file> + </qresource> + <qresource prefix="/content/components"> + <file alias="Button.qml">../mapviewer/content/components/Button.qml</file> + <file alias="Checkbox.qml">../mapviewer/content/components/Checkbox.qml</file> + <file alias="Fader.qml">../mapviewer/content/components/Fader.qml</file> + <file alias="Optionbutton.qml">../mapviewer/content/components/Optionbutton.qml</file> + <file alias="Slider.qml">../mapviewer/content/components/Slider.qml</file> + <file alias="TextWithLabel.qml">../mapviewer/content/components/TextWithLabel.qml</file> + <file alias="TitleBar.qml">../mapviewer/content/components/TitleBar.qml</file> + <file alias="Menu.qml">../mapviewer/content/components/Menu.qml</file> + </qresource> + <qresource prefix="/content/components/style"> + <file alias="ButtonStyle.qml">../mapviewer/content/components/style/ButtonStyle.qml</file> + <file alias="HMenuItemStyle.qml">../mapviewer/content/components/style/HMenuItemStyle.qml</file> + <file alias="VMenuItemStyle.qml">../mapviewer/content/components/style/VMenuItemStyle.qml</file> + </qresource> + <qresource prefix="/content/dialogs"> + <file alias="Dialog.qml">../mapviewer/content/dialogs/Dialog.qml</file> + <file alias="Message.qml">../mapviewer/content/dialogs/Message.qml</file> + <file alias="RouteDialog.qml">../mapviewer/content/dialogs/RouteDialog.qml</file> + </qresource> + <qresource prefix="/content/map"> + <file alias="MapBaseComponent.qml">../mapviewer/content/map/MapBaseComponent.qml</file> + <file alias="MapComponent.qml">../mapviewer/content/map/MapComponent.qml</file> + <file alias="Marker.qml">../mapviewer/content/map/Marker.qml</file> + </qresource> + <qresource prefix="/content/resources"> + <file alias="button_hovered.png">../mapviewer/content/resources/button_hovered.png</file> + <file alias="button_pressed.png">../mapviewer/content/resources/button_pressed.png</file> + <file alias="button.png">../mapviewer/content/resources/button.png</file> + <file alias="button.sci">../mapviewer/content/resources/button.sci</file> + <file alias="catch.png">../mapviewer/content/resources/catch.png</file> + <file alias="checkbox_selected.png">../mapviewer/content/resources/checkbox_selected.png</file> + <file alias="checkbox.png">../mapviewer/content/resources/checkbox.png</file> + <file alias="hmenuItem_hovered.png">../mapviewer/content/resources/hmenuItem_hovered.png</file> + <file alias="hmenuItem_pressed.png">../mapviewer/content/resources/hmenuItem_pressed.png</file> + <file alias="hmenuItem.png">../mapviewer/content/resources/hmenuItem.png</file> + <file alias="marker_hovered.png">../mapviewer/content/resources/marker_hovered.png</file> + <file alias="marker_selected.png">../mapviewer/content/resources/marker_selected.png</file> + <file alias="marker.png">../mapviewer/content/resources/marker.png</file> + <file alias="node_selected.png">../mapviewer/content/resources/node_selected.png</file> + <file alias="node.png">../mapviewer/content/resources/node.png</file> + <file alias="option_button_selected.png">../mapviewer/content/resources/option_button_selected.png</file> + <file alias="option_button.png">../mapviewer/content/resources/option_button.png</file> + <file alias="quit_hovered.png">../mapviewer/content/resources/quit_hovered.png</file> + <file alias="quit_pressed.png">../mapviewer/content/resources/quit_pressed.png</file> + <file alias="quit.png">../mapviewer/content/resources/quit.png</file> + <file alias="scale.png">../mapviewer/content/resources/scale.png</file> + <file alias="titlebar.png">../mapviewer/content/resources/titlebar.png</file> + <file alias="titlebar.sci">../mapviewer/content/resources/titlebar.sci</file> + <file alias="vmenuItem.png">../mapviewer/content/resources/vmenuItem.png</file> + <file alias="hmenuItem.sci">../mapviewer/content/resources/hmenuItem.sci</file> + <file alias="vmenuItem.sci">../mapviewer/content/resources/vmenuItem.sci</file> + </qresource> +</RCC> diff --git a/examples/declarative/mapviewer/qmlmapviewer.cpp b/examples/declarative/mapviewer/mapviewerwrapper/qmlmapviewerwrapper.cpp index 5d45cf2e..91765429 100644 --- a/examples/declarative/mapviewer/qmlmapviewer.cpp +++ b/examples/declarative/mapviewer/mapviewerwrapper/qmlmapviewerwrapper.cpp @@ -60,11 +60,7 @@ int main(int argc, char *argv[]) // Qt.quit() called in embedded .qml by default only emits // quit() signal, so do this (optionally use Qt.exit()). QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit())); -#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_6) - view.showFullScreen(); -#else view.setGeometry(QRect(100, 100, 360, 640)); view.show(); -#endif return application.exec(); } diff --git a/examples/declarative/mapviewer/resources/button.png b/examples/declarative/mapviewer/resources/button.png Binary files differdeleted file mode 100644 index 11310013..00000000 --- a/examples/declarative/mapviewer/resources/button.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/button_hovered.png b/examples/declarative/mapviewer/resources/button_hovered.png Binary files differdeleted file mode 100644 index 7c9b9b63..00000000 --- a/examples/declarative/mapviewer/resources/button_hovered.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/button_pressed.png b/examples/declarative/mapviewer/resources/button_pressed.png Binary files differdeleted file mode 100644 index b290b6b9..00000000 --- a/examples/declarative/mapviewer/resources/button_pressed.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/catch.png b/examples/declarative/mapviewer/resources/catch.png Binary files differdeleted file mode 100644 index a07dabed..00000000 --- a/examples/declarative/mapviewer/resources/catch.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/checkbox.png b/examples/declarative/mapviewer/resources/checkbox.png Binary files differdeleted file mode 100644 index 193eeb3d..00000000 --- a/examples/declarative/mapviewer/resources/checkbox.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/checkbox_selected.png b/examples/declarative/mapviewer/resources/checkbox_selected.png Binary files differdeleted file mode 100644 index fbbf544f..00000000 --- a/examples/declarative/mapviewer/resources/checkbox_selected.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/marker.png b/examples/declarative/mapviewer/resources/marker.png Binary files differdeleted file mode 100644 index a0d6b2df..00000000 --- a/examples/declarative/mapviewer/resources/marker.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/marker_selected.png b/examples/declarative/mapviewer/resources/marker_selected.png Binary files differdeleted file mode 100644 index 2f850ec4..00000000 --- a/examples/declarative/mapviewer/resources/marker_selected.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/node.png b/examples/declarative/mapviewer/resources/node.png Binary files differdeleted file mode 100644 index e51978f2..00000000 --- a/examples/declarative/mapviewer/resources/node.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/node_selected.png b/examples/declarative/mapviewer/resources/node_selected.png Binary files differdeleted file mode 100644 index d46347bf..00000000 --- a/examples/declarative/mapviewer/resources/node_selected.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/option_button.png b/examples/declarative/mapviewer/resources/option_button.png Binary files differdeleted file mode 100644 index cf8dcda7..00000000 --- a/examples/declarative/mapviewer/resources/option_button.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/option_button_selected.png b/examples/declarative/mapviewer/resources/option_button_selected.png Binary files differdeleted file mode 100644 index 4ebb1223..00000000 --- a/examples/declarative/mapviewer/resources/option_button_selected.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/quit.png b/examples/declarative/mapviewer/resources/quit.png Binary files differdeleted file mode 100644 index 5bda1b6e..00000000 --- a/examples/declarative/mapviewer/resources/quit.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/quit_hovered.png b/examples/declarative/mapviewer/resources/quit_hovered.png Binary files differdeleted file mode 100644 index d4b900cf..00000000 --- a/examples/declarative/mapviewer/resources/quit_hovered.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/quit_pressed.png b/examples/declarative/mapviewer/resources/quit_pressed.png Binary files differdeleted file mode 100644 index 05c4ef83..00000000 --- a/examples/declarative/mapviewer/resources/quit_pressed.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/scale.png b/examples/declarative/mapviewer/resources/scale.png Binary files differdeleted file mode 100644 index 3ceccc5e..00000000 --- a/examples/declarative/mapviewer/resources/scale.png +++ /dev/null diff --git a/examples/declarative/mapviewer/resources/titlebar.png b/examples/declarative/mapviewer/resources/titlebar.png Binary files differdeleted file mode 100644 index 51c90082..00000000 --- a/examples/declarative/mapviewer/resources/titlebar.png +++ /dev/null |