diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-02-10 18:17:11 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-04-13 14:53:01 +0000 |
commit | f9f75df2e126b8bc3b8ae22ee21909935a429a87 (patch) | |
tree | 60557b900b8af778a8f181e3f5254ed8f90d986c /examples/location/mapviewer/mapviewer.qml | |
parent | 4b05600862cb036369cd62835ea5de8609b84f35 (diff) |
Autoindent the code of mapviewer example.
Change-Id: Ib2db2761f6a3f3a36d40869ec6be42b8ea7ec376
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'examples/location/mapviewer/mapviewer.qml')
-rw-r--r-- | examples/location/mapviewer/mapviewer.qml | 620 |
1 files changed, 310 insertions, 310 deletions
diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml index 1ebb3da6..f782e08d 100644 --- a/examples/location/mapviewer/mapviewer.qml +++ b/examples/location/mapviewer/mapviewer.qml @@ -235,8 +235,8 @@ ApplicationWindow { var plugins = getPlugins() mainMenu.providerMenu.createMenu(plugins) for (var i = 0; i<plugins.length; i++) { - if (plugins[i] === "osm") - mainMenu.selectProvider(plugins[i]) + if (plugins[i] === "osm") + mainMenu.selectProvider(plugins[i]) } } @@ -245,365 +245,365 @@ ApplicationWindow { id: stackView anchors.fill: parent focus: true - initialItem: Item { + initialItem: Item { id: page - Rectangle { - id: backgroundRect - anchors.fill: parent - color: "lightgrey" - z:2 - } - - //=====================Dialogs===================== - Message { - id: messageDialog - z: backgroundRect.z + 2 - onOkButtonClicked: { - page.state = "" - } - onCancelButtonClicked: { - page.state = "" + Rectangle { + id: backgroundRect + anchors.fill: parent + color: "lightgrey" + z:2 } - states: [ - State{ - name: "GeocodeError" - PropertyChanges { target: messageDialog; title: "Geocode Error" } - PropertyChanges { target: messageDialog; text: "No data available for the specified location" } - }, - State{ - name: "UnknownGeocodeError" - PropertyChanges { target: messageDialog; title: "Geocode Error" } - PropertyChanges { target: messageDialog; text: "Unsuccessful geocode" } - }, - State{ - name: "AmbiguousGeocode" - PropertyChanges { target: messageDialog; title: "Ambiguous geocode" } - PropertyChanges { target: messageDialog; text: map.geocodeModel.count + " results found for the given address, please specify location" } - }, - State{ - name: "RouteError" - PropertyChanges { target: messageDialog; title: "Route Error" } - PropertyChanges { target: messageDialog; text: "Unable to find a route for the given points"} - }, - State{ - name: "Coordinates" - PropertyChanges { target: messageDialog; title: "Coordinates" } - }, - State{ - name: "LocationInfo" - PropertyChanges { target: messageDialog; title: "Location" } - PropertyChanges { target: messageDialog; text: geocodeMessage() } - }, - State{ - name: "Distance" - PropertyChanges { target: messageDialog; title: "Distance" } - }, - State{ - name: "ProviderError" - PropertyChanges { target: messageDialog; title: "Provider Error" } + //=====================Dialogs===================== + Message { + id: messageDialog + z: backgroundRect.z + 2 + onOkButtonClicked: { + page.state = "" + } + onCancelButtonClicked: { + page.state = "" } - ] - } - //Route Dialog -//! [routedialog0] - RouteDialog { - id: routeDialog + states: [ + State{ + name: "GeocodeError" + PropertyChanges { target: messageDialog; title: "Geocode Error" } + PropertyChanges { target: messageDialog; text: "No data available for the specified location" } + }, + State{ + name: "UnknownGeocodeError" + PropertyChanges { target: messageDialog; title: "Geocode Error" } + PropertyChanges { target: messageDialog; text: "Unsuccessful geocode" } + }, + State{ + name: "AmbiguousGeocode" + PropertyChanges { target: messageDialog; title: "Ambiguous geocode" } + PropertyChanges { target: messageDialog; text: map.geocodeModel.count + " results found for the given address, please specify location" } + }, + State{ + name: "RouteError" + PropertyChanges { target: messageDialog; title: "Route Error" } + PropertyChanges { target: messageDialog; text: "Unable to find a route for the given points"} + }, + State{ + name: "Coordinates" + PropertyChanges { target: messageDialog; title: "Coordinates" } + }, + State{ + name: "LocationInfo" + PropertyChanges { target: messageDialog; title: "Location" } + PropertyChanges { target: messageDialog; text: geocodeMessage() } + }, + State{ + name: "Distance" + PropertyChanges { target: messageDialog; title: "Distance" } + }, + State{ + name: "ProviderError" + PropertyChanges { target: messageDialog; title: "Provider Error" } + } + ] + } - property variant startCoordinate - property variant endCoordinate + //Route Dialog + //! [routedialog0] + RouteDialog { + id: routeDialog -//! [routedialog0] - Address { id: startAddress } - Address { id: endAddress } + property variant startCoordinate + property variant endCoordinate - z: backgroundRect.z + 2 + //! [routedialog0] + Address { id: startAddress } + Address { id: endAddress } - GeocodeModel { - id: tempGeocodeModel + z: backgroundRect.z + 2 - property int success: 0 + GeocodeModel { + id: tempGeocodeModel - onCountChanged: { - if (success == 1 && count == 1) { - query = endAddress - update(); - } - } + property int success: 0 - onStatusChanged: { - if ((status == GeocodeModel.Ready) && (count == 1)) { - success++ - if (success == 1){ - startCoordinate.latitude = get(0).coordinate.latitude - startCoordinate.longitude = get(0).coordinate.longitude - } - if (success == 2) { - endCoordinate.latitude = get(0).coordinate.latitude - endCoordinate.longitude = get(0).coordinate.longitude - success = 0 - routeDialog.calculateRoute() + onCountChanged: { + if (success == 1 && count == 1) { + query = endAddress + update(); } } - else if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error)){ - var st = (success == 0 ) ? "start" : "end" - messageDialog.state = "" - if ((status == GeocodeModel.Ready) && (count == 0 )) messageDialog.state = "UnknownGeocodeError" - else if (status == GeocodeModel.Error) { - messageDialog.state = "GeocodeError" - messageDialog.text = "Unable to find location for the " + st + " point" + + onStatusChanged: { + if ((status == GeocodeModel.Ready) && (count == 1)) { + success++ + if (success == 1){ + startCoordinate.latitude = get(0).coordinate.latitude + startCoordinate.longitude = get(0).coordinate.longitude + } + if (success == 2) { + endCoordinate.latitude = get(0).coordinate.latitude + endCoordinate.longitude = get(0).coordinate.longitude + success = 0 + routeDialog.calculateRoute() + } } - else if ((status == GeocodeModel.Ready) && (count > 1 )){ - messageDialog.state = "AmbiguousGeocode" - messageDialog.text = count + " results found for the " + st + " point, please specify location" + else if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error)){ + var st = (success == 0 ) ? "start" : "end" + messageDialog.state = "" + if ((status == GeocodeModel.Ready) && (count == 0 )) messageDialog.state = "UnknownGeocodeError" + else if (status == GeocodeModel.Error) { + messageDialog.state = "GeocodeError" + messageDialog.text = "Unable to find location for the " + st + " point" + } + else if ((status == GeocodeModel.Ready) && (count > 1 )){ + messageDialog.state = "AmbiguousGeocode" + messageDialog.text = count + " results found for the " + st + " point, please specify location" + } + success = 0 + page.state = "Message" + map.routeModel.clearAll() } - success = 0 - page.state = "Message" - map.routeModel.clearAll() } } - } - onGoButtonClicked: { - tempGeocodeModel.reset() - messageDialog.state = "" - if (routeDialog.byCoordinates) { - startCoordinate = QtPositioning.coordinate(parseFloat(routeDialog.startLatitude), - parseFloat(routeDialog.startLongitude)); - endCoordinate = QtPositioning.coordinate(parseFloat(routeDialog.endLatitude), - parseFloat(routeDialog.endLongitude)); + onGoButtonClicked: { + tempGeocodeModel.reset() + messageDialog.state = "" + if (routeDialog.byCoordinates) { + startCoordinate = QtPositioning.coordinate(parseFloat(routeDialog.startLatitude), + parseFloat(routeDialog.startLongitude)); + endCoordinate = QtPositioning.coordinate(parseFloat(routeDialog.endLatitude), + parseFloat(routeDialog.endLongitude)); - calculateRoute() - } - else { - startAddress.country = routeDialog.startCountry - startAddress.street = routeDialog.startStreet - startAddress.city = routeDialog.startCity + calculateRoute() + } + else { + startAddress.country = routeDialog.startCountry + startAddress.street = routeDialog.startStreet + startAddress.city = routeDialog.startCity - endAddress.country = routeDialog.endCountry - endAddress.street = routeDialog.endStreet - endAddress.city = routeDialog.endCity + endAddress.country = routeDialog.endCountry + endAddress.street = routeDialog.endStreet + endAddress.city = routeDialog.endCity - tempGeocodeModel.query = startAddress - tempGeocodeModel.update(); + tempGeocodeModel.query = startAddress + tempGeocodeModel.update(); + } + page.state = "" } - page.state = "" - } - - onCancelButtonClicked: { - page.state = "" - } -//! [routerequest0] - function calculateRoute() { - // clear away any old data in the query - map.routeQuery.clearWaypoints(); - - // add the start and end coords as waypoints on the route - map.routeQuery.addWaypoint(startCoordinate) - map.routeQuery.addWaypoint(endCoordinate) - map.routeQuery.travelModes = routeDialog.travelMode - map.routeQuery.routeOptimizations = routeDialog.routeOptimization -//! [routerequest0] - -//! [routerequest0 feature weight] - for (var i=0; i<9; i++) { - map.routeQuery.setFeatureWeight(i, 0) + onCancelButtonClicked: { + page.state = "" } - for (var i=0; i<routeDialog.features.length; i++) { - map.routeQuery.setFeatureWeight(routeDialog.features[i], RouteQuery.AvoidFeatureWeight) - } -//! [routerequest0 feature weight] + //! [routerequest0] + function calculateRoute() { + // clear away any old data in the query + map.routeQuery.clearWaypoints(); + + // add the start and end coords as waypoints on the route + map.routeQuery.addWaypoint(startCoordinate) + map.routeQuery.addWaypoint(endCoordinate) + map.routeQuery.travelModes = routeDialog.travelMode + map.routeQuery.routeOptimizations = routeDialog.routeOptimization + //! [routerequest0] + + //! [routerequest0 feature weight] + for (var i=0; i<9; i++) { + map.routeQuery.setFeatureWeight(i, 0) + } -//! [routerequest1] - map.routeModel.update(); + for (var i=0; i<routeDialog.features.length; i++) { + map.routeQuery.setFeatureWeight(routeDialog.features[i], RouteQuery.AvoidFeatureWeight) + } + //! [routerequest0 feature weight] - // center the map on the start coord - map.center = startCoordinate; -//! [routerequest1] - } -//! [routedialog1] - } -//! [routedialog1] - - //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) - } + //! [routerequest1] + map.routeModel.update(); -//! [geocode1] - Address { - id: geocodeAddress + // center the map on the start coord + map.center = startCoordinate; + //! [routerequest1] + } + //! [routedialog1] } + //! [routedialog1] + + //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) + } - onGoButtonClicked: { - // manage the UI state transitions - page.state = "" - messageDialog.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] + //! [geocode1] + Address { + id: geocodeAddress + } - onCancelButtonClicked: { - page.state = "" + onGoButtonClicked: { + // manage the UI state transitions + page.state = "" + messageDialog.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] - } -//! [geocode2] + //! [geocode2] - //Reverse Geocode Dialog - OwnControls.InputDialog { - id: reverseGeocodeDialog - title: "Reverse Geocode" - z: backgroundRect.z + 2 + //Reverse Geocode Dialog + OwnControls.InputDialog { + id: reverseGeocodeDialog + title: "Reverse Geocode" + z: backgroundRect.z + 2 - Component.onCompleted: { - var obj = [["Latitude","-27.575"],["Longitude", "153.088"]] - setModel(obj) - } + Component.onCompleted: { + var obj = [["Latitude","-27.575"],["Longitude", "153.088"]] + setModel(obj) + } - onGoButtonClicked: { - page.state = "" - messageDialog.state = "" - map.geocodeModel.query = QtPositioning.coordinate(parseFloat(dialogModel.get(0).inputText), - parseFloat(dialogModel.get(1).inputText)); - map.geocodeModel.update(); - } + onGoButtonClicked: { + page.state = "" + messageDialog.state = "" + map.geocodeModel.query = QtPositioning.coordinate(parseFloat(dialogModel.get(0).inputText), + parseFloat(dialogModel.get(1).inputText)); + map.geocodeModel.update(); + } - onCancelButtonClicked: { - page.state = "" + onCancelButtonClicked: { + page.state = "" + } } - } - //Get new coordinates for marker - OwnControls.InputDialog { - id: coordinatesDialog - title: "New coordinates" - z: backgroundRect.z + 2 + //Get new coordinates for marker + OwnControls.InputDialog { + id: coordinatesDialog + title: "New coordinates" + z: backgroundRect.z + 2 - Component.onCompleted: { - var obj = [["Latitude", ""],["Longitude", ""]] - setModel(obj) - } + Component.onCompleted: { + var obj = [["Latitude", ""],["Longitude", ""]] + setModel(obj) + } - onGoButtonClicked: { - page.state = "" - messageDialog.state = "" - var newLat = parseFloat(dialogModel.get(0).inputText) - var newLong = parseFloat(dialogModel.get(1).inputText) - - if (newLat !== "NaN" && newLong !== "NaN") { - var c = QtPositioning.coordinate(newLat, newLong); - if (c.isValid) { - map.markers[map.currentMarker].coordinate = c; - map.center = c; + onGoButtonClicked: { + page.state = "" + messageDialog.state = "" + var newLat = parseFloat(dialogModel.get(0).inputText) + var newLong = parseFloat(dialogModel.get(1).inputText) + + if (newLat !== "NaN" && newLong !== "NaN") { + var c = QtPositioning.coordinate(newLat, newLong); + if (c.isValid) { + map.markers[map.currentMarker].coordinate = c; + map.center = c; + } } } - } - onCancelButtonClicked: { - page.state = "" + onCancelButtonClicked: { + page.state = "" + } } - } - //Get new locale - OwnControls.InputDialog { - id: localeDialog - title: "New Locale" - z: backgroundRect.z + 2 + //Get new locale + OwnControls.InputDialog { + id: localeDialog + title: "New Locale" + z: backgroundRect.z + 2 - Component.onCompleted: { - var obj = [["Language", ""]] - setModel(obj) - } + Component.onCompleted: { + var obj = [["Language", ""]] + setModel(obj) + } - onGoButtonClicked: { - page.state = "" - messageDialog.state = "" - map.setLanguage(dialogModel.get(0).inputText.split(Qt.locale().groupSeparator)); - } + onGoButtonClicked: { + page.state = "" + messageDialog.state = "" + map.setLanguage(dialogModel.get(0).inputText.split(Qt.locale().groupSeparator)); + } - onCancelButtonClicked: { - page.state = "" + onCancelButtonClicked: { + page.state = "" + } } - } - //=====================States of page===================== - states: [ - State { - name: "RevGeocode" - PropertyChanges { target: reverseGeocodeDialog; opacity: 1 } - }, - State { - name: "Route" - PropertyChanges { target: routeDialog; opacity: 1 } - }, - State { - name: "Geocode" - PropertyChanges { target: geocodeDialog; opacity: 1 } - }, - State { - name: "Coordinates" - PropertyChanges { target: coordinatesDialog; opacity: 1 } - }, - State { - name: "Message" - PropertyChanges { target: messageDialog; opacity: 1 } - }, - State { - name : "Locale" - PropertyChanges { target: localeDialog; opacity: 1 } - } - ] - - //=====================State-transition animations for page===================== - transitions: [ - Transition { - to: "RevGeocode" - NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } - }, - Transition { - to: "Route" - 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 } - }, - Transition { - to: "Message" - NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } - }, - Transition { - to: "" - NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } - } - ] -} + //=====================States of page===================== + states: [ + State { + name: "RevGeocode" + PropertyChanges { target: reverseGeocodeDialog; opacity: 1 } + }, + State { + name: "Route" + PropertyChanges { target: routeDialog; opacity: 1 } + }, + State { + name: "Geocode" + PropertyChanges { target: geocodeDialog; opacity: 1 } + }, + State { + name: "Coordinates" + PropertyChanges { target: coordinatesDialog; opacity: 1 } + }, + State { + name: "Message" + PropertyChanges { target: messageDialog; opacity: 1 } + }, + State { + name : "Locale" + PropertyChanges { target: localeDialog; opacity: 1 } + } + ] + + //=====================State-transition animations for page===================== + transitions: [ + Transition { + to: "RevGeocode" + NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } + }, + Transition { + to: "Route" + 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 } + }, + Transition { + to: "Message" + NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } + }, + Transition { + to: "" + NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear } + } + ] + } } } |