summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-02-10 18:17:11 +0100
committerMichal Klocek <michal.klocek@theqtcompany.com>2015-04-13 14:53:47 +0000
commit6d50e7cd5ed38b9ea00e0fea8c525b64e6eba0e0 (patch)
treec0b71f1d9d09267436f79447e7974d7a1d92b7b7 /examples
parentb07ecac7cd8844af2818fb732a02b212a91b9a1c (diff)
downloadqtlocation-6d50e7cd5ed38b9ea00e0fea8c525b64e6eba0e0.tar.gz
Replaces gecode dialog in mapviewer example.
Geocode dialog use qtquickcontrols now. Change-Id: Ifeecf3c5d230e5feefb1383d2a177a3a5411715e Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/location/mapviewer/Geocode.qml89
-rw-r--r--examples/location/mapviewer/mapviewer.qml65
-rw-r--r--examples/location/mapviewer/mapviewerwrapper.qrc1
3 files changed, 103 insertions, 52 deletions
diff --git a/examples/location/mapviewer/Geocode.qml b/examples/location/mapviewer/Geocode.qml
new file mode 100644
index 00000000..5aeb6fcd
--- /dev/null
+++ b/examples/location/mapviewer/Geocode.qml
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company Ltd 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.4
+import QtPositioning 5.2
+import "forms"
+
+//Geocode Dialog
+//! [geocode0]
+GeocodeForm {
+ //! [geocode0]
+
+ property variant address
+ signal showPlace(variant address)
+ signal closeForm()
+
+ //! [geocode1]
+ goButton.onClicked: {
+ // fill out the Address element
+ address.street = street.text
+ address.city = city.text
+ address.state = state.text
+ address.country = country.text
+ address.postalCode = postalCode.text
+ showPlace(address)
+ }
+ //! [geocode1]
+
+ clearButton.onClicked: {
+ street.text = ""
+ city.text = ""
+ state.text = ""
+ country.text = ""
+ postalCode.text = ""
+ }
+ //! [geocode2]
+
+ cancelButton.onClicked: {
+ closeForm()
+ }
+
+ Component.onCompleted: {
+ street.text = address.street
+ city.text = address.city
+ state.text = address.state
+ country.text = address.country
+ postalCode.text = address.postalCode
+ }
+}
+//! [geocode2]
+
+
diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml
index d46adb4c..621f0726 100644
--- a/examples/location/mapviewer/mapviewer.qml
+++ b/examples/location/mapviewer/mapviewer.qml
@@ -124,6 +124,11 @@ ApplicationWindow {
"fromCoordinate": fromCoordinate}})
stackView.currentItem.showRoute.connect(showRoute)
stackView.currentItem.closeForm.connect(closeForm)
+ } else if (tool === "Geocode") {
+ stackView.push({ item: Qt.resolvedUrl("Geocode.qml") ,
+ properties: { "address": fromAddress}})
+ stackView.currentItem.showPlace.connect(showPlace)
+ stackView.currentItem.closeForm.connect(closeForm)
} else {
stackView.pop(page)
page.state = tool
@@ -179,6 +184,12 @@ ApplicationWindow {
stackView.pop(page);
//! [routerequest1]
}
+
+ function showPlace(geocode) {
+ // send the geocode request
+ map.geocodeModel.query = geocode
+ map.geocodeModel.update()
+ }
}
function showMessage(title,message,backPage) {
@@ -258,7 +269,7 @@ ApplicationWindow {
showMessage(qsTr("Ambiguous geocode"), map.geocodeModel.count + " " + \
qsTr("results found for the given address, please specify location"));\
} else { \
- showMessage(qsTr("Location"), geocodeMessage());\
+ showMessage(qsTr("Location"), geocodeMessage(),page);\
;}\
} else if (map.geocodeModel.status == GeocodeModel.Error) {\
showMessage(qsTr("Geocode Error"),qsTr("Unsuccessful geocode")); \
@@ -277,7 +288,7 @@ ApplicationWindow {
page.state = "Locale";\
}\
onShowGeocodeInfo:{\
- showMessage(qsTr("Location"),geocodeMessage());\
+ showMessage(qsTr("Location"),geocodeMessage(),page);\
}\
onResetState: {\
page.state = "";\
@@ -343,48 +354,6 @@ ApplicationWindow {
//=====================Dialogs=====================
- //Geocode Dialog
- //! [geocode0]
- OwnControls.InputDialog {
- id: geocodeDialog
- //! [geocode0]
- title: "Geocode"
- z: backgroundRect.z + 2
-
- Component.onCompleted: {
- var obj = [["Street", "Brandl St"],["City", "Eight Mile Plains"],["State", ""],["Country","Australia"], ["Postal code", ""]]
- setModel(obj)
- }
-
- //! [geocode1]
- Address {
- id: geocodeAddress
- }
-
- onGoButtonClicked: {
- // manage the UI state transitions
- page.state = ""
-
- // fill out the Address element
- geocodeAddress.street = dialogModel.get(0).inputText
- geocodeAddress.city = dialogModel.get(1).inputText
- geocodeAddress.state = dialogModel.get(2).inputText
- geocodeAddress.country = dialogModel.get(3).inputText
- geocodeAddress.postalCode = dialogModel.get(4).inputText
-
- // send the geocode request
- map.geocodeModel.query = geocodeAddress
- map.geocodeModel.update()
- }
- //! [geocode1]
-
- onCancelButtonClicked: {
- page.state = ""
- }
- //! [geocode2]
- }
- //! [geocode2]
-
//Reverse Geocode Dialog
OwnControls.InputDialog {
id: reverseGeocodeDialog
@@ -466,10 +435,6 @@ ApplicationWindow {
PropertyChanges { target: reverseGeocodeDialog; opacity: 1 }
},
State {
- name: "Geocode"
- PropertyChanges { target: geocodeDialog; opacity: 1 }
- },
- State {
name: "Coordinates"
PropertyChanges { target: coordinatesDialog; opacity: 1 }
},
@@ -486,10 +451,6 @@ ApplicationWindow {
NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
},
Transition {
- to: "Geocode"
- NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
- },
- Transition {
to: "Coordinates"
NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
},
diff --git a/examples/location/mapviewer/mapviewerwrapper.qrc b/examples/location/mapviewer/mapviewerwrapper.qrc
index 0276d50c..2bf905ad 100644
--- a/examples/location/mapviewer/mapviewerwrapper.qrc
+++ b/examples/location/mapviewer/mapviewerwrapper.qrc
@@ -20,5 +20,6 @@
<file>Message.qml</file>
<file>RouteCoordinate.qml</file>
<file>RouteAddress.qml</file>
+ <file>Geocode.qml</file>
</qresource>
</RCC>