diff options
author | Natalia Shubina <natalia.shubina@nokia.com> | 2012-01-09 12:35:38 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-10 04:51:26 +0100 |
commit | afc3fa343dd3caf742f60156014b66281fb611df (patch) | |
tree | 1f2fc14e6d0ca449d95c601915300e5da3fc454e | |
parent | f6b30d05e17a30cbb9697092d25df495e26ad7f7 (diff) | |
download | qtlocation-afc3fa343dd3caf742f60156014b66281fb611df.tar.gz |
mapviewer: added minimap
added minimap
deleted titlebar
renamed "Options" menu to "Tools"
Change-Id: I54b45435f6ee40e25e5009d80ffa766603b1c7ee
Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
-rw-r--r-- | examples/declarative/mapviewer/content/map/MiniMap.qml | 79 | ||||
-rw-r--r-- | examples/declarative/mapviewer/mapviewer.pri | 3 | ||||
-rw-r--r-- | examples/declarative/mapviewer/mapviewer.qml | 38 | ||||
-rw-r--r-- | examples/declarative/mapviewer/mapviewerwrapper.qrc | 1 |
4 files changed, 104 insertions, 17 deletions
diff --git a/examples/declarative/mapviewer/content/map/MiniMap.qml b/examples/declarative/mapviewer/content/map/MiniMap.qml new file mode 100644 index 00000000..da2002b6 --- /dev/null +++ b/examples/declarative/mapviewer/content/map/MiniMap.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 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 + +Rectangle{ + id: miniMapRect + width: 152 + height: 152 + anchors.right: (parent) ? parent.right : undefined + anchors.rightMargin: 10 + anchors.top: (parent) ? parent.top : undefined + anchors.topMargin: page.mobileUi ? 35 : 10 + color: "darkblue" + Map { + id: miniMap + anchors.top: parent.top + anchors.topMargin: 1 + anchors.left: parent.left + anchors.leftMargin: 1 + width: 150 + height: 150 + plugin: Plugin {name: "nokia"} + zoomLevel: (map.zoomLevel > minimumZoomLevel + 2) ? minimumZoomLevel + 2 : minimumZoomLevel + center: map.center + + pinch.enabled: false + flick.enabled: false + MapMouseArea{ + anchors.fill: parent + } + + MapRectangle { + color: "#44ff0000" + border.width: 1 + border.color: "red" + topLeft: Coordinate{latitude: miniMap.center.latitude + 5; longitude: miniMap.center.longitude - 5} + bottomRight: Coordinate{latitude: miniMap.center.latitude - 5; longitude: miniMap.center.longitude + 5} + } + } +} diff --git a/examples/declarative/mapviewer/mapviewer.pri b/examples/declarative/mapviewer/mapviewer.pri index 5d8c39f9..2d6e74f4 100644 --- a/examples/declarative/mapviewer/mapviewer.pri +++ b/examples/declarative/mapviewer/mapviewer.pri @@ -12,7 +12,8 @@ qmlcontentmap.files += \ content/map/PolygonItem.qml \ content/map/ImageItem.qml \ content/map/VideoItem.qml \ - content/map/3dItem.qml + content/map/3dItem.qml \ + content/map/MiniMap.qml OTHER_FILES += $$qmlcontentmap.files qmlcontentdialogs.files += \ diff --git a/examples/declarative/mapviewer/mapviewer.qml b/examples/declarative/mapviewer/mapviewer.qml index 9fbbf266..ce5729ef 100644 --- a/examples/declarative/mapviewer/mapviewer.qml +++ b/examples/declarative/mapviewer/mapviewer.qml @@ -50,6 +50,7 @@ Item { height: parent ? parent.height : 640 property bool mobileUi: true property variant map + property variant minimap property list<PluginParameter> parameters Rectangle { @@ -58,14 +59,6 @@ Item { color: "lightgrey" z:2 } - TitleBar { - id: titleBar; z: mainMenu.z; width: parent.width; height: 40; opacity: 0.9; text: "QML mapviewer example"; visible: !page.mobileUi - onClicked: { - // FIXME: quitting with 3d item on screen segfaults - map.deleteMapItems() - Qt.quit() - } - } //=====================Menu===================== Menu { @@ -74,15 +67,15 @@ Item { z: backgroundRect.z + 2 Component.onCompleted: { - addItem("Options") + addItem("Tools") addItem("Map Type") addItem("Provider") } onClicked: { switch (button) { - case "Options": { - page.state = "Options" + case "Tools": { + page.state = "Tools" break; } case "Map Type": { @@ -98,7 +91,7 @@ Item { } Menu { - id: optionsMenu + id: toolsMenu z: backgroundRect.z + 2 y: page.height horizontalOrientation: false @@ -131,6 +124,17 @@ Item { page.state = "" break; } + case "Minimap": { + minimap = Qt.createQmlObject ('import "content/map"; MiniMap{}', map) + page.state = "" + break; + } + case "Hide minimap": { + if (minimap) minimap.destroy() + minimap = null + page.state = "" + break; + } } } function update(){ @@ -140,6 +144,8 @@ Item { addItem("Route") var item = addItem("Follow me") item.text = (function() { return map.followme ? "Stop following" : "Follow me" }); + item = addItem("Minimap") + item.text = (function() { return minimap ? "Hide minimap" : "Minimap" }); } } @@ -536,7 +542,7 @@ Item { width: page.width;\ height: page.height;\ onMapPressed:{page.state = ""}\ - onFollowmeChanged: {optionsMenu.update()}\ + onFollowmeChanged: {toolsMenu.update()}\ onSupportedMapTypesChanged: {mapTypeMenu.update()}\ onCoordinatesCaptured: {\ messageDialog.state = "Coordinates";\ @@ -625,8 +631,8 @@ Item { PropertyChanges { target: messageDialog; opacity: 1 } }, State { - name : "Options" - PropertyChanges { target: optionsMenu; y: page.height - optionsMenu.height - mainMenu.height } + name : "Tools" + PropertyChanges { target: toolsMenu; y: page.height - toolsMenu.height - mainMenu.height } }, State { name : "Provider" @@ -677,7 +683,7 @@ Item { NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } }, Transition { - to: "Options" + to: "Tools" NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } } ] diff --git a/examples/declarative/mapviewer/mapviewerwrapper.qrc b/examples/declarative/mapviewer/mapviewerwrapper.qrc index c3329897..fac5ac80 100644 --- a/examples/declarative/mapviewer/mapviewerwrapper.qrc +++ b/examples/declarative/mapviewer/mapviewerwrapper.qrc @@ -13,5 +13,6 @@ <file>content/map/ImageItem.qml</file> <file>content/map/VideoItem.qml</file> <file>content/map/3dItem.qml</file> + <file>content/map/MiniMap.qml</file> </qresource> </RCC> |