diff options
author | Natalia Shubina <natalia.shubina@nokia.com> | 2011-07-20 09:01:01 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-20 02:54:22 +0200 |
commit | 987252cc1892c84a5f95990890bd991c470dc55d (patch) | |
tree | 44a63c687e236151089c16c334956653db932434 | |
parent | 1fa46a4cc7180185de26e2634f0e7d15728c146f (diff) |
qml_mapviewer: markers are MapObjects now
Change-Id: I3cb89274c5b124c20c9a880433dc23c475e3ac93
Reviewed-on: http://codereview.qt.nokia.com/1852
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
-rw-r--r-- | examples/declarative/mapviewer/Dialog.qml | 2 | ||||
-rw-r--r-- | examples/declarative/mapviewer/MapComponent.qml | 15 | ||||
-rw-r--r-- | examples/declarative/mapviewer/Marker.qml | 60 | ||||
-rw-r--r-- | examples/declarative/mapviewer/Message.qml | 2 | ||||
-rw-r--r-- | examples/declarative/mapviewer/RouteDialog.qml | 2 | ||||
-rw-r--r-- | examples/declarative/mapviewer/TextWithLabel.qml | 2 | ||||
-rwxr-xr-x | examples/declarative/mapviewer/common/Button.qml | 2 | ||||
-rw-r--r-- | examples/declarative/mapviewer/common/Fader.qml | 2 | ||||
-rw-r--r-- | examples/declarative/mapviewer/common/Menu.qml | 2 | ||||
-rw-r--r-- | examples/declarative/mapviewer/common/Slider.qml | 2 | ||||
-rwxr-xr-x | examples/declarative/mapviewer/common/TitleBar.qml | 2 | ||||
-rw-r--r-- | examples/declarative/mapviewer/mapviewer.qml | 5 |
12 files changed, 38 insertions, 60 deletions
diff --git a/examples/declarative/mapviewer/Dialog.qml b/examples/declarative/mapviewer/Dialog.qml index 586cc24e..ccc3a55c 100644 --- a/examples/declarative/mapviewer/Dialog.qml +++ b/examples/declarative/mapviewer/Dialog.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 import "common" as Common Item { diff --git a/examples/declarative/mapviewer/MapComponent.qml b/examples/declarative/mapviewer/MapComponent.qml index 5ea33db5..81e28730 100644 --- a/examples/declarative/mapviewer/MapComponent.qml +++ b/examples/declarative/mapviewer/MapComponent.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 import Qt.location 5.0 import "common" as Common @@ -126,7 +126,7 @@ Map { id: pointDelegate MapCircle { radius: 1000 - color: circleMouseArea.containsMouse ? "lime" : "#80FF0000" + color: circleMouseArea.containsMouse ? "#8000FF00" : "#80FF0000" center: place.coordinate MapMouseArea { id: circleMouseArea @@ -306,12 +306,6 @@ Map { map.state = "MarkerPopupMenu" } - function updateMarkers(){ - for (var i = 0; i<map.numberOfMarkers; i++){ - map.markers[i].update() - } - } - function calculateRoute(marker){ routeQuery.clearWaypoints(); var startPointFound = false @@ -329,12 +323,7 @@ Map { routeModel.update(); } - onCenterChanged: { - map.updateMarkers() - } - onZoomLevelChanged:{ - map.updateMarkers() zoomSlider.value = map.zoomLevel } diff --git a/examples/declarative/mapviewer/Marker.qml b/examples/declarative/mapviewer/Marker.qml index bd68b77f..7522518f 100644 --- a/examples/declarative/mapviewer/Marker.qml +++ b/examples/declarative/mapviewer/Marker.qml @@ -38,20 +38,24 @@ ** ****************************************************************************/ -import Qt 4.7; +import QtQuick 1.1 import Qt.location 5.0 import "common" as Common - MapImage { //to be used inside MapComponent only - id: marker +MapGroup { //to be used inside MapComponent only + id: marker + property alias coordinate: markerImage.coordinate + property alias lastMouseX: markerMouseArea.lastX + property alias lastMouseY: markerMouseArea.lastY + property alias text: markerIndex.text + + MapImage { + id: markerImage source: markerMouseArea.pressed ? "resources/marker_selected.png" : "resources/marker.png" //TODO replace with following lane when QTBUG-20096 fixed // source: markerMouseArea.containsMouse ? (markerMouseArea.pressed ? "resources/marker_selected.png" :"resources/marker_hovered.png") : "resources/marker.png" coordinate: Coordinate { latitude : 0; longitude : 0 } offset.x: -13 offset.y: -32 - property alias lastMouseX: markerMouseArea.lastX - property alias lastMouseY: markerMouseArea.lastY - property alias text: markerIndex.text Component.onCompleted: { coordinate = mouseArea.lastCoordinate @@ -66,12 +70,12 @@ import "common" as Common property bool longPress: false hoverEnabled: true onPressed: { - marker.z++ + ++marker.z var newX, newY, oldX, oldY newX = map.toScreenPosition(mouse.coordinate).x newY = map.toScreenPosition(mouse.coordinate).y - oldX = map.toScreenPosition(marker.coordinate).x - oldY = map.toScreenPosition(marker.coordinate).y + oldX = map.toScreenPosition(markerImage.coordinate).x + oldY = map.toScreenPosition(markerImage.coordinate).y dX = oldX - newX dY = oldY - newY lastX = mouse.x @@ -95,15 +99,13 @@ import "common" as Common lastY = mouse.y newX = map.toScreenPosition(mouse.coordinate).x + dX newY = map.toScreenPosition(mouse.coordinate).y + dY - marker.coordinate = map.toCoordinate(Qt.point(newX,newY)) - textArea.x = map.toScreenPosition(marker.coordinate).x + offset.x - textArea.y = map.toScreenPosition(marker.coordinate).y + offset.y + markerImage.coordinate = map.toCoordinate(Qt.point(newX,newY)) } } Timer { id: markerTimer - interval: 1000 + interval: map.longPressDuration running: false repeat: false onTriggered: { @@ -112,28 +114,16 @@ import "common" as Common } } } + } - Item { - id: textArea - width: 26 - height: 32 - x: map.toScreenPosition(marker.coordinate).x + offset.x - y: map.toScreenPosition(marker.coordinate).y + offset.y - Text { - id: markerIndex - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - z: marker.z - color: "white" - font.bold: true - Component.onCompleted: { - text = map.counter - } - } - } - - function update(){ - textArea.x = map.toScreenPosition(marker.coordinate).x + marker.offset.x - textArea.y = map.toScreenPosition(marker.coordinate).y + marker.offset.y + MapText { + id: markerIndex + offset.y : -16 + coordinate: markerImage.coordinate + color: "white" + font.bold: true + Component.onCompleted: { + text = map.counter } } +} diff --git a/examples/declarative/mapviewer/Message.qml b/examples/declarative/mapviewer/Message.qml index c5531cba..d42e9c27 100644 --- a/examples/declarative/mapviewer/Message.qml +++ b/examples/declarative/mapviewer/Message.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 import "common" as Common Item { diff --git a/examples/declarative/mapviewer/RouteDialog.qml b/examples/declarative/mapviewer/RouteDialog.qml index 8ee2eab0..8901c203 100644 --- a/examples/declarative/mapviewer/RouteDialog.qml +++ b/examples/declarative/mapviewer/RouteDialog.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 import Qt.location 5.0 import "common" as Common diff --git a/examples/declarative/mapviewer/TextWithLabel.qml b/examples/declarative/mapviewer/TextWithLabel.qml index 40242bb4..cc842dad 100644 --- a/examples/declarative/mapviewer/TextWithLabel.qml +++ b/examples/declarative/mapviewer/TextWithLabel.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 Row { id: textWithLabel diff --git a/examples/declarative/mapviewer/common/Button.qml b/examples/declarative/mapviewer/common/Button.qml index 529ef147..3ac9e283 100755 --- a/examples/declarative/mapviewer/common/Button.qml +++ b/examples/declarative/mapviewer/common/Button.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 Item { id: container diff --git a/examples/declarative/mapviewer/common/Fader.qml b/examples/declarative/mapviewer/common/Fader.qml index c6a064fd..f9489306 100644 --- a/examples/declarative/mapviewer/common/Fader.qml +++ b/examples/declarative/mapviewer/common/Fader.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 Rectangle { id: fader diff --git a/examples/declarative/mapviewer/common/Menu.qml b/examples/declarative/mapviewer/common/Menu.qml index b246060d..7224152a 100644 --- a/examples/declarative/mapviewer/common/Menu.qml +++ b/examples/declarative/mapviewer/common/Menu.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 Item { id: menu diff --git a/examples/declarative/mapviewer/common/Slider.qml b/examples/declarative/mapviewer/common/Slider.qml index 2b7aeb5b..372541c4 100644 --- a/examples/declarative/mapviewer/common/Slider.qml +++ b/examples/declarative/mapviewer/common/Slider.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 Item { id: slider; diff --git a/examples/declarative/mapviewer/common/TitleBar.qml b/examples/declarative/mapviewer/common/TitleBar.qml index fcb58903..4aabe7cb 100755 --- a/examples/declarative/mapviewer/common/TitleBar.qml +++ b/examples/declarative/mapviewer/common/TitleBar.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 Item { id: titleBar diff --git a/examples/declarative/mapviewer/mapviewer.qml b/examples/declarative/mapviewer/mapviewer.qml index 30fb2e28..6a76ed8b 100644 --- a/examples/declarative/mapviewer/mapviewer.qml +++ b/examples/declarative/mapviewer/mapviewer.qml @@ -38,14 +38,13 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 1.1 import Qt.location 5.0 import "common" as Common -FocusScope { +Item { anchors.fill: parent id: page - focus: true Rectangle { id: backgroundRect |