summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatalia Shubina <natalia.shubina@nokia.com>2011-06-27 10:09:39 +1000
committerNatalia Shubina <natalia.shubina@nokia.com>2011-06-27 10:09:39 +1000
commit3ac02ff60ed3cb08f17071bc06722496f47f8370 (patch)
tree77c48e4d4a6593ab74b65440210df92136c09396
parentc207c21271263ffa0427c45aae718718e3ba90f9 (diff)
MOBILITY-2891: route dialog, map component
-rw-r--r--examples/declarative/mapviewer/Dialog.qml55
-rw-r--r--examples/declarative/mapviewer/MapComponent.qml260
-rw-r--r--examples/declarative/mapviewer/Message.qml6
-rw-r--r--examples/declarative/mapviewer/RouteDialog.qml381
-rw-r--r--examples/declarative/mapviewer/TextWithLabel.qml84
-rwxr-xr-xexamples/declarative/mapviewer/common/Button.qml2
-rw-r--r--examples/declarative/mapviewer/common/Fader.qml41
-rw-r--r--examples/declarative/mapviewer/common/Menu.qml62
-rw-r--r--examples/declarative/mapviewer/common/Slider.qml7
-rwxr-xr-xexamples/declarative/mapviewer/common/TitleBar.qml2
-rw-r--r--examples/declarative/mapviewer/mapviewer.qml481
-rw-r--r--examples/declarative/mapviewer/mapviewer.qrc5
-rw-r--r--examples/declarative/mapviewer/qmlmapviewer.cpp2
-rwxr-xr-xexamples/declarative/mapviewer/resources/option_button.pngbin0 -> 408 bytes
-rwxr-xr-xexamples/declarative/mapviewer/resources/option_button_selected.pngbin0 -> 469 bytes
15 files changed, 1152 insertions, 236 deletions
diff --git a/examples/declarative/mapviewer/Dialog.qml b/examples/declarative/mapviewer/Dialog.qml
index 504ca1d9..2bee59e6 100644
--- a/examples/declarative/mapviewer/Dialog.qml
+++ b/examples/declarative/mapviewer/Dialog.qml
@@ -52,14 +52,16 @@ Item {
property alias dialogModel: dialogModel
property alias length: dialogModel.count
property int gap: 20
- property int listItemHeight: 54
+ property int listItemHeight: 30
+
+ opacity: 0
function setModel(objects)
{
dialogModel.clear()
for (var i=0; i< objects.length; i++){
- dialogModel.append({"label": objects[i][0], "inputText": objects[i][1]})
+ dialogModel.append({"labelText": objects[i][0], "inputText": objects[i][1]})
}
}
@@ -69,7 +71,7 @@ Item {
id: dialogRectangle
color: "lightsteelblue"
- opacity: 1
+ opacity: parent.opacity
width: parent.width - gap;
height: listview.height + titleBar.height + buttonGo.height + gap*2
@@ -101,43 +103,21 @@ Item {
Column {
id: column1
height: listItemHeight
- Text { id: fieldTitle; text: label; height: 24;}
- Rectangle {
- id: inputRectangle
- width: dialogRectangle.width - gap; height: 30
- color: "whitesmoke"
- border.width: 1
- radius: 5
- TextInput {
- id: inputField
- focus: true
- width: parent.width - anchors.leftMargin
-
- anchors {
- left: parent.left;
- verticalCenter: parent.verticalCenter;
- leftMargin: 5
- }
-
- Component.onCompleted: {
- text = inputText
- }
-
- onTextChanged:
- {
- dialogModel.set(index, {"inputText": text})
- }
- }
- MouseArea {
- anchors.fill: parent
- onClicked: inputField.forceActiveFocus();
+ TextWithLabel {
+ id: textWithLabel
+ label: labelText
+ text: inputText
+ width: dialogRectangle.width - gap
+ labelWidth: 75
+
+ onTextChanged:
+ {
+ dialogModel.set(index, {"inputText": text})
}
}
}
}
-
-
ListView {
id: listview
anchors {
@@ -148,10 +128,10 @@ Item {
}
model: dialogModel
delegate: listDelegate
- spacing: gap
+ spacing: gap/2
interactive: false
Component.onCompleted: {
- height = (listItemHeight + gap)*length
+ height = (listItemHeight + gap/2)*length + gap/2
}
}
@@ -167,4 +147,3 @@ Item {
}
}
}
-
diff --git a/examples/declarative/mapviewer/MapComponent.qml b/examples/declarative/mapviewer/MapComponent.qml
new file mode 100644
index 00000000..2751fbfc
--- /dev/null
+++ b/examples/declarative/mapviewer/MapComponent.qml
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** 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 Mobility Components.
+**
+** $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 Qt 4.7
+import Qt.location 5.0
+import "common" as Common
+
+Map {
+ id: map
+ plugin : defaultPlugin
+ zoomLevel: 9
+ focus: true
+ width: parent.width
+ center: defaultCoordinates
+ property int longPressDuration: 1000
+
+ property RouteQuery routeQuery: RouteQuery {}
+ property RouteModel routeModel: RouteModel {
+ plugin : map.plugin;
+ query: routeQuery
+ onStatusChanged:{
+ if (status == RouteModel.Ready){
+ if (count == 1) showRouteInfo()
+ }
+ }
+ }
+ property GeocodeModel geocodeModel: GeocodeModel {
+ plugin : map.plugin;
+ onStatusChanged:{
+ if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error)) map.geocodeFinished()
+ }
+ }
+
+ signal mousePressed() // replace with
+ // signal mousePressed(MouseEvent mouse)
+ // when QTBUG-14550 is fixed
+ signal sliderUpdated()
+ signal coordinatesCaptured(double latitude, double longitude)
+ signal showRouteInfo()
+ signal geocodeFinished()
+ signal showGeocodeInfo()
+
+ Component {
+ id: routeDelegate
+ MapRoute {
+ route: path
+ color: routeMouseArea.containsMouse ? "lime" :"red"
+ MapMouseArea {
+ id: routeMouseArea
+ hoverEnabled: true
+ onPressed : {routeTimer.start()}
+ onReleased : { if (routeTimer.running) routeTimer.stop() }//SHORT PRESS
+ onPositionChanged: { if (routeTimer.running) routeTimer.stop()}
+
+ Timer {
+ id: routeTimer
+ interval: longPressDuration; running: false; repeat: false
+ onTriggered: { //LONG PRESS
+ map.showRouteInfo()
+ }
+ }
+ }
+ }
+ }
+
+ Component {
+ id: pointDelegate
+ MapCircle {
+ radius: 1000
+ color: circleMouseArea.containsMouse ? "lime" : "#80FF0000"
+ center: place.coordinate
+ MapMouseArea {
+ id: circleMouseArea
+ hoverEnabled: true
+ onPressed : { circleTimer.start()}
+ onReleased : { if (circleTimer.running) circleTimer.stop() }//SHORT PRESS
+ onPositionChanged: {
+ if (circleTimer.running) circleTimer.stop()
+ if (mouse.button == Qt.LeftButton) radius = center.distanceTo(mouse.coordinate)
+ }
+
+ Timer {
+ id: circleTimer
+ interval: longPressDuration; running: false; repeat: false
+ onTriggered: { //LONG PRESS
+ map.geocodeFinished()
+ }
+ }
+ }
+ }
+ }
+
+ MapObjectView {
+ model: routeModel
+ delegate: routeDelegate
+ }
+
+ MapObjectView {
+ model: geocodeModel
+ delegate: pointDelegate
+ }
+
+ Plugin {
+ id: defaultPlugin
+ name : "nokia"
+ }
+
+ Coordinate {
+ id: defaultCoordinates
+ latitude : -27.575
+ longitude : 153.088
+ }
+
+ Common.Slider {
+ id: zoomSlider;
+ parent: map.parent //todo: remove the line
+ minimum: map.minimumZoomLevel;
+ maximum: map.maximumZoomLevel;
+ opacity: 1
+ z: map.z + 1
+ 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()
+ }
+ }
+
+ Common.Menu {
+ id: popupMenu
+ orientation: ListView.Vertical
+ z: map.z + 1
+ opacity: 0
+
+ itemHeight: 30;
+ itemWidth: 150
+ x: 0
+ y: 0
+
+ Component.onCompleted: {
+ setModel(["Capture"])
+ }
+ onClicked: {
+ map.coordinatesCaptured(mouseArea.lastCoordinate.latitude, mouseArea.lastCoordinate.longitude)
+ map.state = ""
+ }
+ }
+
+ MapMouseArea {
+ id: mouseArea
+ property int lastX : -1
+ property int lastY : -1
+ property Coordinate lastCoordinate: Coordinate { latitude : 0; longitude : 0}
+
+ onPressed : {
+ mapTimer.start()
+ map.state = ""
+ lastX = mouse.x
+ lastY = mouse.y
+ lastCoordinate = mouse.coordinate
+ map.mousePressed()
+ }
+ onReleased : {
+ if (mapTimer.running) { //SHORT PRESS
+ mapTimer.stop()
+ lastX = -1
+ lastY = -1
+ }
+ }
+ onPositionChanged: {
+ if (mapTimer.running) mapTimer.stop()
+ if ((mouse.button == Qt.LeftButton) & (map.state == "")) {
+ if ((lastX != -1) && (lastY != -1)) {
+ var dx = mouse.x - lastX
+ var dy = mouse.y - lastY
+ map.pan(-dx, -dy)
+ }
+ lastX = mouse.x
+ 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
+ }
+ lastX = -1
+ lastY = -1
+ }
+ Timer {
+ id: mapTimer
+ interval: longPressDuration; running: false; repeat: false
+ onTriggered: { //LONG PRESS
+ map.state = "PopupMenu"
+ }
+ }
+ }
+
+ Keys.onPressed: {
+ if ((event.key == Qt.Key_Plus) || (event.key == Qt.Key_VolumeUp)) {
+ map.zoomLevel += 1
+ } else if ((event.key == Qt.Key_Minus) || (event.key == Qt.Key_VolumeDown)){
+ map.zoomLevel -= 1
+ }
+ }
+
+ // states of map
+ states: [
+ State {
+ name: "PopupMenu"
+ PropertyChanges { target: popupMenu; opacity: 1}
+ PropertyChanges { target: popupMenu; x: ((mouseArea.lastX + popupMenu.width > map.width) ? map.width - popupMenu.width : mouseArea.lastX)}
+ PropertyChanges { target: popupMenu; y: ((mouseArea.lastY + popupMenu.height > map.height) ? map.height - popupMenu.height : mouseArea.lastY)}
+ }
+ ]
+}
diff --git a/examples/declarative/mapviewer/Message.qml b/examples/declarative/mapviewer/Message.qml
index eafa5f1b..c5531cba 100644
--- a/examples/declarative/mapviewer/Message.qml
+++ b/examples/declarative/mapviewer/Message.qml
@@ -52,6 +52,7 @@ Item {
signal okButtonClicked
signal cancelButtonClicked
+ opacity: 0
Common.Fader {}
@@ -59,10 +60,8 @@ Item {
id: dialogRectangle
color: "lightsteelblue"
- opacity: 1
width: parent.width - gap;
height: titleBar.height + message.height + okButton.height + gap*3
-
anchors {
top: parent.top
topMargin: 50
@@ -90,7 +89,7 @@ Item {
width: dialogRectangle.width - gap
anchors.topMargin: gap
textFormat: Text.RichText
- wrapMode: Text.WrapAnywhere
+ wrapMode: Text.Wrap
onLinkActivated: {
Qt.openUrlExternally(link)
}
@@ -109,4 +108,3 @@ Item {
}
}
}
-
diff --git a/examples/declarative/mapviewer/RouteDialog.qml b/examples/declarative/mapviewer/RouteDialog.qml
new file mode 100644
index 00000000..a8cdf3b5
--- /dev/null
+++ b/examples/declarative/mapviewer/RouteDialog.qml
@@ -0,0 +1,381 @@
+/****************************************************************************
+**
+** 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 Mobility Components.
+**
+** $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 Qt 4.7
+import Qt.location 5.0
+import "common" as Common
+
+Item {
+ id: dialog
+ signal goButtonClicked
+ signal cancelButtonClicked
+
+ anchors.fill: parent
+ property int gap: 10
+ opacity: 0
+
+ property alias title: titleBar.text
+ property alias startLatitude: latFrom.text
+ property alias startLongitude: longFrom.text
+ property alias endLatitude: latTo.text
+ property alias endLongitude: longTo.text
+ property alias startStreet: streetFrom.text
+ property alias startCity: cityFrom.text
+ property alias startCountry: countryFrom.text
+ property alias endStreet: streetTo.text
+ property alias endCity: cityTo.text
+ property alias endCountry: countryTo.text
+ property alias byCoordinates: coord.enabled
+ property int travelMode: RouteQuery.CarTravel // CarTravel, PedestrianTravel, BicycleTravel, PublicTransitTravel, TruckTravel
+ property int routeOptimization: RouteQuery.ShortestRoute // ShortestRoute, FastestRoute, MostEconomicRoute, MostScenicRoute
+ // TODO NoFeature, TollFeature, HighwayFeature, PublicTransitFeature, FerryFeature, TunnelFeature, DirtRoadFeature, ParksFeature, MotorPoolLaneFeature
+
+ Common.Fader {}
+
+ Rectangle {
+ id: dialogRectangle
+ color: "lightsteelblue"
+ opacity: 1
+ width: parent.width - gap*2;
+ height: options.height + gap*3 + buttonGo.height + titleBar.height
+
+ anchors {
+ top: parent.top
+ topMargin: 50
+ left: parent.left
+ leftMargin: gap
+ }
+
+ border.width: 1
+ border.color: "darkblue"
+ radius: 5
+
+ Common.TitleBar {
+ id: titleBar;
+ width: parent.width; height: 40;
+ anchors.top: parent.top; anchors.left: parent.left;
+ opacity: 0.9
+ text: "Route"
+ onClicked: { dialog.cancelButtonClicked() }
+ }
+
+ Column {
+ id: options
+ spacing: gap
+ width: dialogRectangle.width - gap*2
+
+ anchors {
+ top: titleBar.bottom
+ topMargin: gap
+ left: dialogRectangle.left
+ leftMargin: gap
+ }
+
+ states: [
+ State {
+ name: "Address"
+ PropertyChanges { target: coord; enabled: false }
+ PropertyChanges { target: address; enabled: true }
+ }
+ ]
+
+
+//by coordinates
+ Row {
+ id: row1
+ spacing: gap
+ Image {
+ id: optionButtonCoord
+ anchors.verticalCenter:parent.verticalCenter
+ source: coord.enabled ? "resources/option_button_selected.png" : "resources/option_button.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { options.state = "" }
+ }
+ }
+
+ Rectangle {
+ id: coord
+ color: dialogRectangle.color
+ border.width: 1
+ border.color: enabled ? "black" : "grey"
+ radius: 5
+ width:options.width - optionButtonCoord.width - row1.spacing
+ height: longTo.y + longTo.height + gap
+ enabled: true
+
+//start point
+ Text {
+ id: fromLabel;
+ font.bold: true;
+ enabled: coord.enabled
+ anchors {
+ top: latFrom.top
+ topMargin:latFrom.height + gap/6 - fromLabel.height/2
+ left: parent.left;
+ leftMargin: gap
+ }
+ text: "From"
+ color: enabled ? "black" : "grey"
+ }
+
+ TextWithLabel {
+ id: latFrom
+ width: parent.width - fromLabel.width - gap*3
+ text: "-27.575"
+ label: "latitude"
+ enabled: coord.enabled
+ anchors {
+ left: fromLabel.right
+ leftMargin: gap
+ top: parent.top
+ topMargin:gap
+ }
+ }
+
+ TextWithLabel {
+ id: longFrom
+ width: latFrom.width
+ text: "153.088"
+ label: "longitude"
+ enabled: coord.enabled
+ anchors {
+ left: latFrom.left
+ top: latFrom.bottom
+ topMargin:gap/3
+ }
+ }
+
+//end point
+ Text {
+ id: toLabel;
+ font.bold: true;
+ width: fromLabel.width
+ enabled: coord.enabled
+ anchors {
+ top: latTo.top
+ topMargin:latTo.height + gap/6 - toLabel.height/2
+ left: parent.left;
+ leftMargin: gap;
+ }
+ text: "To"
+ color: enabled ? "black" : "grey"
+ }
+
+ TextWithLabel {
+ id: latTo
+ width: latFrom.width
+ text: "-27.465"
+ label: "latitude"
+ enabled: coord.enabled
+ anchors {
+ left: toLabel.right
+ leftMargin: gap
+ top: longFrom.bottom
+ topMargin:gap
+ }
+ }
+
+ TextWithLabel {
+ id: longTo
+ width: latTo.width
+ text: "153.023"
+ label: "longitude"
+ enabled: coord.enabled
+ anchors {
+ left: latTo.left
+ top: latTo.bottom
+ topMargin:gap/3
+ }
+ }
+ }
+ }
+
+//by address
+ Row {
+ id: row2
+ spacing: gap
+
+ Image {
+ id: optionButtonAddress
+ source: address.enabled ? "resources/option_button_selected.png" : "resources/option_button.png"
+ anchors.verticalCenter: parent.verticalCenter
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { options.state = "Address" }
+ }
+ }
+
+ Rectangle {
+ id: address
+ color: dialogRectangle.color
+ border.width: 1
+ border.color: enabled ? "black" : "grey"
+ radius: 5
+ width:coord.width
+ height: countryTo.y + countryTo.height + gap
+ enabled: false
+
+//start point
+ Text {
+ id: fromLabel2;
+ font.bold: true;
+ enabled: address.enabled
+ anchors {
+ top: cityFrom.top
+ left: parent.left;
+ leftMargin: gap
+ }
+ text: "From"
+ color: enabled ? "black" : "grey"
+ }
+
+ TextWithLabel {
+ id: streetFrom
+ width: parent.width - fromLabel2.width - gap*3
+ text: "Brandl st"
+ label: "street"
+ enabled: address.enabled
+ anchors {
+ left: fromLabel2.right
+ leftMargin: gap
+ top: parent.top
+ topMargin:gap
+ }
+ }
+
+ TextWithLabel {
+ id: cityFrom
+ width: streetFrom.width
+ text: "Eight Mile Plains"
+ label: "city"
+ enabled: address.enabled
+ anchors {
+ left: streetFrom.left
+ top: streetFrom.bottom
+ topMargin:gap/3
+ }
+ }
+
+ TextWithLabel {
+ id: countryFrom
+ width: streetFrom.width
+ text: "Australia"
+ label: "country"
+ enabled: address.enabled
+ anchors {
+ left: streetFrom.left
+ top: cityFrom.bottom
+ topMargin:gap/3
+ }
+ }
+
+
+//end point
+ Text {
+ id: toLabel2;
+ font.bold: true;
+ enabled: address.enabled
+ anchors {
+ top: cityTo.top
+ left: parent.left;
+ leftMargin: gap
+ }
+ text: "To"
+ color: enabled ? "black" : "grey"
+ }
+
+ TextWithLabel {
+ id: streetTo
+ width: parent.width - fromLabel2.width - gap*3
+ text: "Ann st"
+ label: "street"
+ enabled: address.enabled
+ anchors {
+ left: fromLabel2.right
+ leftMargin: gap
+ top: countryFrom.bottom
+ topMargin:gap
+ }
+ }
+
+ TextWithLabel {
+ id: cityTo
+ width: streetTo.width
+ text: "Brisbane"
+ label: "city"
+ enabled: address.enabled
+ anchors {
+ left: streetTo.left
+ top: streetTo.bottom
+ topMargin:gap/3
+ }
+ }
+
+ TextWithLabel {
+ id: countryTo
+ width: streetTo.width
+ text: "Australia"
+ label: "country"
+ enabled: address.enabled
+ anchors {
+ left: streetTo.left
+ top: cityTo.bottom
+ topMargin:gap/3
+ }
+ }
+
+ }
+ }
+ }
+
+ Common.Button {
+ id: buttonGo
+ text: "Go!"
+ anchors.top: options.bottom
+ anchors.topMargin: gap
+ width: 80; height: 32
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ dialog.goButtonClicked ()
+ }
+ }
+ }
+}
diff --git a/examples/declarative/mapviewer/TextWithLabel.qml b/examples/declarative/mapviewer/TextWithLabel.qml
new file mode 100644
index 00000000..40242bb4
--- /dev/null
+++ b/examples/declarative/mapviewer/TextWithLabel.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** 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 Mobility Components.
+**
+** $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 Qt 4.7
+
+Row {
+ id: textWithLabel
+ height: inputRectangle.height
+
+ property alias label: label.text
+ property alias text: inputField.text
+ property alias labelWidth: label.width
+
+ Text {
+ id: label;
+ width:55;
+ enabled: textWithLabel.enabled
+ color: enabled ? "black" : "grey"
+ anchors {
+ top: parent.top;
+ topMargin: (inputRectangle.height-height)/2
+ }
+ }
+
+ Rectangle {
+ id: inputRectangle
+ width: textWithLabel.width - label.width; height: 30
+ color: enabled ? "whitesmoke" : "gainsboro"
+ border.width: 1
+ border.color: enabled ? "black" : "grey"
+ radius: 5
+ TextInput {
+ id: inputField
+ focus: true
+ width: parent.width - anchors.leftMargin
+ enabled: textWithLabel.enabled
+ color: enabled ? "black" : "grey"
+ horizontalAlignment: Text.AlignLeft
+
+ anchors {
+ left: parent.left;
+ verticalCenter: parent.verticalCenter;
+ leftMargin: 5
+ }
+ }
+ }
+}
diff --git a/examples/declarative/mapviewer/common/Button.qml b/examples/declarative/mapviewer/common/Button.qml
index dc643d53..529ef147 100755
--- a/examples/declarative/mapviewer/common/Button.qml
+++ b/examples/declarative/mapviewer/common/Button.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/declarative/mapviewer/common/Fader.qml b/examples/declarative/mapviewer/common/Fader.qml
index e94b30ba..c6a064fd 100644
--- a/examples/declarative/mapviewer/common/Fader.qml
+++ b/examples/declarative/mapviewer/common/Fader.qml
@@ -1,3 +1,43 @@
+/****************************************************************************
+**
+** 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 Mobility Components.
+**
+** $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 Qt 4.7
Rectangle {
@@ -8,6 +48,7 @@ Rectangle {
MouseArea {
id: mouseArea
anchors.fill: parent
+ hoverEnabled: true
}
Component.onCompleted: {
diff --git a/examples/declarative/mapviewer/common/Menu.qml b/examples/declarative/mapviewer/common/Menu.qml
index 221765f6..05dc17e4 100644
--- a/examples/declarative/mapviewer/common/Menu.qml
+++ b/examples/declarative/mapviewer/common/Menu.qml
@@ -1,3 +1,43 @@
+/****************************************************************************
+**
+** 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 Mobility Components.
+**
+** $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 Qt 4.7
Item {
@@ -11,6 +51,8 @@ Item {
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
@@ -90,6 +132,26 @@ Item {
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"
diff --git a/examples/declarative/mapviewer/common/Slider.qml b/examples/declarative/mapviewer/common/Slider.qml
index 129df855..2b7aeb5b 100644
--- a/examples/declarative/mapviewer/common/Slider.qml
+++ b/examples/declarative/mapviewer/common/Slider.qml
@@ -1,6 +1,6 @@
-/*/****************************************************************************
+/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -43,8 +43,7 @@ import Qt 4.7
Item {
id: slider;
height: 40
- // value is read/write.
- property int value
+ property int value // value is read/write.
property real minimum: 0
property real maximum: 1
property int xMin: 2
diff --git a/examples/declarative/mapviewer/common/TitleBar.qml b/examples/declarative/mapviewer/common/TitleBar.qml
index ed175f50..fcb58903 100755
--- a/examples/declarative/mapviewer/common/TitleBar.qml
+++ b/examples/declarative/mapviewer/common/TitleBar.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/declarative/mapviewer/mapviewer.qml b/examples/declarative/mapviewer/mapviewer.qml
index 6e0cfa91..116f5ef7 100644
--- a/examples/declarative/mapviewer/mapviewer.qml
+++ b/examples/declarative/mapviewer/mapviewer.qml
@@ -45,8 +45,10 @@ import "common" as Common
FocusScope {
anchors.fill: parent
id: page
+ focus: true
Rectangle {
+ id: backgroundRect
anchors.fill: parent
color: "darkgrey"
z:2
@@ -54,36 +56,18 @@ FocusScope {
Common.TitleBar {
- id: titleBar; z: 4; width: parent.width; height: 40; opacity: 0.9; text: "QML mapviewer example"
+ id: titleBar; z: mainMenu.z; width: parent.width; height: 40; opacity: 0.9; text: "QML mapviewer example"
onClicked: { Qt.quit() }
}
- Common.Slider {
- id: zoomSlider;
- minimum: map.minimumZoomLevel;
- maximum: map.maximumZoomLevel;
- opacity: 1
- z: 4
- anchors {
- bottom: mainMenu.top;
- bottomMargin: 5; rightMargin: 5; leftMargin: 5
- left: parent.left
- }
- width: parent.width - anchors.rightMargin - anchors.leftMargin
- value: map.zoomLevel
- onValueChanged: {
- map.zoomLevel = value
- }
- }
-
- // Menus
+//=====================Menus=====================
Common.Menu {
id: mainMenu
itemHeight: 40
itemWidth: page.width / count
anchors.bottom: parent.bottom
orientation: ListView.Horizontal
- z: 5
+ z: map.z + 3
Component.onCompleted: {
setModel(["Options","Settings"])
}
@@ -141,7 +125,7 @@ FocusScope {
orientation: ListView.Vertical
z: mainMenu.z - 1
Component.onCompleted: {
- setModel(["Map type", "Connectivity", "Provider"])
+ setModel([ settingsMenu.nestedMenuSign + " Map type", settingsMenu.nestedMenuSign + " Connectivity", " Provider"])
}
itemHeight: 30;
@@ -160,7 +144,8 @@ FocusScope {
break;
}
case 2: {
- page.state = "ProviderInfo"
+ messageDialog.state = "Provider"
+ page.state = "Message"
break;
}
}
@@ -253,54 +238,167 @@ FocusScope {
}
- // Dialogs
-
+//=====================Dialogs=====================
Message {
- id: providerInfoDialog
- title: "Provider"
- text: "Nokia OVI <a href=\http://doc.qt.nokia.com/qtmobility-1.2/location-overview.html#the-nokia-plugin\">map plugin</a>."
- z: 5
- opacity: 0
+ id: messageDialog
+ z: mainMenu.z + 1
onOkButtonClicked: {
page.state = ""
}
onCancelButtonClicked: {
page.state = ""
}
+
+ 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 address." }
+ },
+ State{
+ name: "UnknownGeocodeError"
+ PropertyChanges { target: messageDialog; title: "Geocode Error" }
+ PropertyChanges { target: messageDialog; text: "Unknown geocode error. Try again" }
+ },
+ State{
+ name: "AmbiguousGeocode"
+ PropertyChanges { target: messageDialog; title: "Ambiguous geocode" }
+ PropertyChanges { target: messageDialog; text: "Several results found for the given address, please specify location" }
+ },
+ State{
+ name: "Coordinates"
+ PropertyChanges { target: messageDialog; title: "Coordinates" }
+ PropertyChanges { target: messageDialog; text: "Several results found for the given address, please specify location" }
+ },
+ State{
+ name: "LatitudeNotANumber"
+ PropertyChanges { target: messageDialog; title: "Input Error" }
+ PropertyChanges { target: messageDialog; text: "Latitude is not a number" }
+ },
+ State{
+ name: "LatitudeOutOfScope"
+ PropertyChanges { target: messageDialog; title: "Input Error" }
+ PropertyChanges { target: messageDialog; text: "Latitude should be in a range (-90,90)" }
+ },
+ State{
+ name: "LongitudeNotANumber"
+ PropertyChanges { target: messageDialog; title: "Input Error" }
+ PropertyChanges { target: messageDialog; text: "Longitude is not a number" }
+ },
+ State{
+ name: "LongitudeOutOfScope"
+ PropertyChanges { target: messageDialog; title: "Input Error" }
+ PropertyChanges { target: messageDialog; text: "Longitude should be in a range (-180,180)" }
+ },
+ State{
+ name: "NoAddress"
+ PropertyChanges { target: messageDialog; title: "Address" }
+ PropertyChanges { target: messageDialog; text: "Current location doesn't have address" }
+ },
+ State{
+ name: "LocationInfo"
+ PropertyChanges { target: messageDialog; title: "Location" }
+ PropertyChanges { target: messageDialog; text: geocodeMessage() }
+ }
+ ]
}
- Dialog {
+//Route Dialog
+ RouteDialog {
id: routeDialog
- title: "Routing from map center to"
- z: 5
- opacity: 0
-
- Component.onCompleted: {
- var obj = [["latitude:", "51.2207"],["and longitude:", "0.1"]]
- setModel(obj)
- }
- Coordinate {
- id: endCoordinate
+ z: mainMenu.z + 1
+
+ Coordinate { id: endCoordinate }
+ Coordinate { id: startCoordinate }
+ Address { id:startAddress }
+ Address { id:endAddress }
+
+ GeocodeModel {
+ id: tempGeocodeModel
+ plugin : map.plugin
+ property int successfulGeocodeCount: 0
+ onStatusChanged:{
+ if ((status == GeocodeModel.Ready) && (successfulGeocodeCount == 0)) {
+ ++successfulGeocodeCount
+ startCoordinate = tempGeocodeModel.get(0).coordinate
+
+ query = endAddress
+ update();
+ }
+ else if ((status == GeocodeModel.Ready) && (successfulGeocodeCount == 1)) {
+ ++successfulGeocodeCount
+ endCoordinate = tempGeocodeModel.get(0).coordinate
+
+ map.routeQuery.clearWaypoints();
+ map.center = startCoordinate
+ map.routeQuery.addWaypoint(startCoordinate)
+ map.routeQuery.addWaypoint(endCoordinate)
+ map.routeQuery.travelModes = routeDialog.travelMode
+ map.routeQuery.routeOptimizations = routeDialog.routeOptimization
+ map.routeModel.update();
+ }
+ else if ((status == GeocodeModel.Ready) && (count == 0 )){
+ messageDialog.state = "GeocodeError"
+ page.state = "Message"
+ }
+ else if ((status == GeocodeModel.Ready) && (count > 1 )){
+ messageDialog.state = "AmbiguousGeocode"
+ page.state = "Message"
+ }
+ else if (status == GeocodeModel.Error) {
+ messageDialog.state = "UnknownGeocodeError"
+ page.state = "Message"
+ }
+ }
}
+
onGoButtonClicked: {
+ var status = true
+
+ if (routeDialog.byCoordinates) {
+ startCoordinate.latitude = routeDialog.startLatitude
+ startCoordinate.longitude = routeDialog.startLongitude
+ endCoordinate.latitude = routeDialog.endLatitude
+ endCoordinate.longitude = routeDialog.endLongitude
+
+ map.routeQuery.clearWaypoints();
+ map.center = startCoordinate
+ map.routeQuery.addWaypoint(startCoordinate)
+ map.routeQuery.addWaypoint(endCoordinate)
+ map.routeQuery.travelModes = routeDialog.travelMode
+ map.routeQuery.routeOptimizations = routeDialog.routeOptimization
+ map.routeModel.update();
+ }
+ else {
+ startAddress.country = routeDialog.startCountry
+ startAddress.street = routeDialog.startStreet
+ startAddress.district = routeDialog.startCity
+
+ endAddress.country = routeDialog.endCountry
+ endAddress.street = routeDialog.endStreet
+ endAddress.district = routeDialog.endCity
+
+ tempGeocodeModel.query = startAddress
+ tempGeocodeModel.update();
+ }
page.state = ""
- endCoordinate.latitude = dialogModel.get(0).inputText
- endCoordinate.longitude = dialogModel.get(1).inputText
- routeQuery.clearWaypoints();
- routeQuery.addWaypoint(map.center) // Starting coordinate
- routeQuery.addWaypoint(endCoordinate) // Ending coordinate
- routeModel.update();
}
+
onCancelButtonClicked: {
page.state = ""
}
}
+//Search Dialog
Dialog {
id: searchDialog
title: "Search"
- z: 5
- opacity: 0
+ z: mainMenu.z + 1
onGoButtonClicked: {
page.state = ""
@@ -316,206 +414,211 @@ FocusScope {
}
}
+//Geocode Dialog
Dialog {
id: geocodeDialog
title: "Geocode"
- z: 5
- opacity: 0
+ z: mainMenu.z + 1
Component.onCompleted: {
- var obj = [["Country:","Australia"],["Street:", "Brandl St 53"],["District:","Eight Mile Plains"]]
+ var obj = [["Street", "Brandl St"],["District",""],["City", "Eight Mile Plains"], ["County", ""],["State", ""],["Country code",""],["Country","Australia"]]
setModel(obj)
}
+
+ Address {
+ id: geocodeAddress
+ }
+
onGoButtonClicked: {
page.state = ""
- geocodeAddress.country = dialogModel.get(0).inputText
- geocodeAddress.street = dialogModel.get(1).inputText
- geocodeAddress.district = dialogModel.get(2).inputText
- geocodeModel.query = geocodeAddress
- geocodeModel.update();
+ geocodeAddress.street = dialogModel.get(0).inputText
+ geocodeAddress.district = dialogModel.get(1).inputText
+ geocodeAddress.city = dialogModel.get(2).inputText
+ geocodeAddress.county = dialogModel.get(3).inputText
+ geocodeAddress.state = dialogModel.get(4).inputText
+ geocodeAddress.countryCode = dialogModel.get(5).inputText
+ geocodeAddress.country = dialogModel.get(6).inputText
+ map.geocodeModel.query = geocodeAddress
+ map.geocodeModel.update();
}
onCancelButtonClicked: {
page.state = ""
}
}
+//Reverse Geocode Dialog
Dialog {
id: reverseGeocodeDialog
title: "Reverse Geocode"
- z: 5
- opacity: 0
+ z: mainMenu.z + 1
Component.onCompleted: {
- var obj = [["Latitude:","51"],["Longitude:", "0"]]
+ var obj = [["Latitude","-27.575"],["Longitude", "153.088"]]
setModel(obj)
}
+
+ Coordinate {
+ id: reverseGeocodeCoordinate
+ }
+
onGoButtonClicked: {
page.state = ""
- reverseGeocodeCoordinate.latitude = dialogModel.get(0).inputText
- reverseGeocodeCoordinate.longitude = dialogModel.get(1).inputText
- geocodeModel.query = reverseGeocodeCoordinate
- geocodeModel.update();
+ messageDialog.state = ""
+ var latitude = dialogModel.get(0).inputText
+ var longtitude = dialogModel.get(1).inputText
+
+ verifyLatitude(latitude)
+ verifyLongitude(longtitude)
+
+ if (messageDialog.state == "") {
+ reverseGeocodeCoordinate.latitude = latitude
+ reverseGeocodeCoordinate.longitude = longtitude
+ map.geocodeModel.query = reverseGeocodeCoordinate
+ map.geocodeModel.update();
+ }
}
+
onCancelButtonClicked: {
page.state = ""
}
}
- RouteModel {
- id : routeModel
- plugin : Plugin { name : "nokia"}
- query: RouteQuery {
- id: routeQuery
+
+//=====================Map=====================
+ MapComponent{
+ id: map
+ z : backgroundRect.z + 1
+ size.width: parent.width
+ size.height: parent.height - mainMenu.height
+
+ onMousePressed: {
+ page.state = ""
}
- }
- Address {
- id: geocodeAddress
- }
- Coordinate {
- id: reverseGeocodeCoordinate
- }
- GeocodeModel {
- id: geocodeModel
- plugin : Plugin { name : "nokia"}
- onPlacesChanged: {
- if (geocodeModel.count > 0) {
- console.log('setting the coordinate as places changed in model.')
- map.center = geocodeModel.get(0).coordinate
- }
+ onSliderUpdated: {
+ page.state = ""
}
- }
- Map {
- id: map
- z : 3
- plugin : Plugin {name : "nokia"}
- size.width: parent.width
- size.height: parent.height
- zoomLevel: 9
- focus : true
- center: Coordinate {
- latitude: 51.5
- longitude: -0.11
- }
-
- MapObjectView {
- model: routeModel
- delegate: Component {
- MapRoute {
- // TODO this interface is bit unclear
- route: path
- }
- }
+ onCoordinatesCaptured: {
+ messageDialog.title = "Coordinates"
+ messageDialog.text = "<b>Latitude:</b> " + roundNumber(latitude,4) + "<br/><b>Longitude:</b> " + roundNumber(longitude,4);
+ page.state = "Message"
}
- MapObjectView {
- model: geocodeModel
- delegate: Component {
- MapCircle {
- radius: 10000
- color: "red"
- center: place.coordinate
- }
- }
+ onShowRouteInfo: {
+ var value = map.routeModel.get(0).travelTime
+ var seconds = value % 60
+ value /= 60
+ value = Math.round(value)
+ var minutes = value % 60
+ value /= 60
+ value = Math.round(value)
+ var hours = value
+ var dist = roundNumber(map.routeModel.get(0).distance,0)
+
+ if (dist>1000) dist = dist/1000 + " km"
+ else dist = dist + " m"
+
+ messageDialog.title = "Route info"
+ messageDialog.text = "<b>Travel time:</b> " + hours + "h:"+ minutes + "m:" + seconds +"s<br/><b>Distance:</b> " + dist;
+
+ page.state = "Message"
}
- MapCircle {
- id : circle
- center : Coordinate {
- latitude : 51.5
- longitude : -0.11
- }
- color : "#80FF0000"
- radius : 1000.0
- MapMouseArea {
- onPositionChanged: {
- if (mouse.button == Qt.LeftButton)
- circle.center = mouse.coordinate
- if (mouse.button == Qt.RightButton)
- circle.radius = circle.center.distanceTo(mouse.coordinate)
- }
- }
+ onGeocodeFinished:{
+ var street, district, city, county, state, countryCode, country, latitude, longitude, text
+
+ if (map.geocodeModel.count == 0) messageDialog.state = "GeocodeError"
+ else if (map.geocodeModel.count > 1) messageDialog.state = "AmbiguousGeocode"
+ else if (map.status == GeocodeModel.Error) messageDialog.state = "UnknownGeocodeError"
+ else messageDialog.state = "LocationInfo"
+ page.state = "Message"
}
- MapMouseArea {
- property int lastX : -1
- property int lastY : -1
+ onShowGeocodeInfo:{
+ messageDialog.state = "LocationInfo"
+ page.state = "Message"
+ }
+ }
- onPressed : {
- if (page.state != "") page.state =""
- else {
- lastX = mouse.x
- lastY = mouse.y
- }
- }
- onReleased : {
- lastX = -1
- lastY = -1
- }
- onPositionChanged: {
- if (mouse.button == Qt.LeftButton) {
- if ((lastX != -1) && (lastY != -1)) {
- var dx = mouse.x - lastX
- var dy = mouse.y - lastY
- map.pan(-dx, -dy)
- }
- lastX = mouse.x
- 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
- }
- lastX = -1
- lastY = -1
+ function geocodeMessage(){
+ var street, district, city, county, state, countryCode, country, latitude, longitude, text
+ map.center = map.geocodeModel.get(0).coordinate
+ 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
+ city = map.geocodeModel.get(0).address.city
+ county = map.geocodeModel.get(0).address.county
+ state = map.geocodeModel.get(0).address.state
+ countryCode = map.geocodeModel.get(0).address.countryCode
+ country = map.geocodeModel.get(0).address.country
+
+ text = "<b>Latitude:</b> " + latitude + "<br/>"
+ text +="<b>Longitude:</b> " + longitude + "<br/>" + "<br/>"
+ if (street) text +="<b>Street: </b>"+ street + " <br/>"
+ if (district) text +="<b>District: </b>"+ district +" <br/>"
+ if (city) text +="<b>City: </b>"+ city + " <br/>"
+ if (county) text +="<b>County: </b>"+ county + " <br/>"
+ if (state) text +="<b>State: </b>"+ state + " <br/>"
+ if (countryCode) text +="<b>Country code: </b>"+ countryCode + " <br/>"
+ if (country) text +="<b>Country: </b>"+ country + " <br/>"
+ return text
+ }
+
+
+ function roundNumber(number, digits) {
+ var multiple = Math.pow(10, digits);
+ var rndedNum = Math.round(number * multiple) / multiple;
+ return rndedNum;
+ }
+
+ function verifyLongitude(longitude){
+ var lng
+ if (isNaN(longitude)) messageDialog.state = "LongitudeNotANumber"
+ else {
+ lng = parseFloat(longitude)
+ if ((lng> 180) || (lng<-180)) {
+ messageDialog.state = "LongitudeOutOfScope"
}
}
- } // Map
-
- Keys.onPressed: {
- if ((event.key == Qt.Key_Plus) || (event.key == Qt.Key_VolumeUp)) {
- map.zoomLevel += 1
- } else if ((event.key == Qt.Key_Minus) || (event.key == Qt.Key_VolumeDown)){
- map.zoomLevel -= 1
- } else if (event.key == Qt.Key_T) {
- if (map.mapType == Map.StreetMap) {
- map.mapType = Map.SatelliteMapDay
- } else if (map.mapType == Map.SatelliteMapDay) {
- map.mapType = Map.StreetMap
+ }
+
+ function verifyLatitude(latitude){
+ var lat
+ if (isNaN(latitude)) messageDialog.state = "LatitudeNotANumber"
+ else {
+ lat = parseFloat(latitude)
+ if ((lat> 90) || (lat<-90)) {
+ messageDialog.state = "LatitudeOutOfScope"
}
}
}
- // states of page
+//=====================States of page=====================
states: [
+ State {
+ name: ""
+ PropertyChanges { target: map; focus: true }
+ },
State {
name: "RevGeocode"
PropertyChanges { target: reverseGeocodeDialog; opacity: 1 }
- PropertyChanges { target: titleBar; hoverEnabled: false }
},
State {
name: "Route"
PropertyChanges { target: routeDialog; opacity: 1 }
- PropertyChanges { target: titleBar; hoverEnabled: false }
},
State {
name: "Search"
PropertyChanges { target: searchDialog; opacity: 1 }
- PropertyChanges { target: titleBar; hoverEnabled: false }
},
State {
name: "Geocode"
PropertyChanges { target: geocodeDialog; opacity: 1 }
- PropertyChanges { target: titleBar; hoverEnabled: false }
},
State {
- name: "ProviderInfo"
- PropertyChanges { target: providerInfoDialog; opacity: 1 }
- PropertyChanges { target: titleBar; hoverEnabled: false }
+ name: "Message"
+ PropertyChanges { target: messageDialog; opacity: 1 }
},
State {
name : "Options"
@@ -537,7 +640,7 @@ FocusScope {
}
]
- // state-transition animations for page
+//=====================State-transition animations for page=====================
transitions: [
Transition {
to: "RevGeocode"
@@ -556,7 +659,11 @@ FocusScope {
NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
},
Transition {
- to: "ProviderInfo"
+ to: "Message"
+ NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: ""
NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
},
Transition {
diff --git a/examples/declarative/mapviewer/mapviewer.qrc b/examples/declarative/mapviewer/mapviewer.qrc
index 46180e54..d5aae792 100644
--- a/examples/declarative/mapviewer/mapviewer.qrc
+++ b/examples/declarative/mapviewer/mapviewer.qrc
@@ -21,5 +21,10 @@
<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>
</qresource>
</RCC>
diff --git a/examples/declarative/mapviewer/qmlmapviewer.cpp b/examples/declarative/mapviewer/qmlmapviewer.cpp
index c4466df8..86b29f47 100644
--- a/examples/declarative/mapviewer/qmlmapviewer.cpp
+++ b/examples/declarative/mapviewer/qmlmapviewer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/declarative/mapviewer/resources/option_button.png b/examples/declarative/mapviewer/resources/option_button.png
new file mode 100755
index 00000000..cf8dcda7
--- /dev/null
+++ b/examples/declarative/mapviewer/resources/option_button.png
Binary files differ
diff --git a/examples/declarative/mapviewer/resources/option_button_selected.png b/examples/declarative/mapviewer/resources/option_button_selected.png
new file mode 100755
index 00000000..a0c01cf7
--- /dev/null
+++ b/examples/declarative/mapviewer/resources/option_button_selected.png
Binary files differ