From cbb9a5302581fcea7d17e08661fc20429329dd31 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 28 May 2015 14:59:13 +0200 Subject: Improve 'mapviewer' example readability * fix Map Component creation * same QML components version across the files * use "Proceed" instead of "Go !" for buttons Change-Id: Ia75b0663a8b08241c0f842dacf80da089a6ee841 Reviewed-by: Alex Blasche --- examples/location/mapviewer/forms/Geocode.qml | 4 +- .../location/mapviewer/forms/GeocodeForm.ui.qml | 8 +- examples/location/mapviewer/forms/Locale.qml | 4 +- .../location/mapviewer/forms/LocaleForm.ui.qml | 7 +- examples/location/mapviewer/forms/Message.qml | 2 +- .../location/mapviewer/forms/MessageForm.ui.qml | 6 +- .../location/mapviewer/forms/ReverseGeocode.qml | 4 +- .../mapviewer/forms/ReverseGeocodeForm.ui.qml | 8 +- examples/location/mapviewer/forms/RouteAddress.qml | 6 +- .../mapviewer/forms/RouteAddressForm.ui.qml | 8 +- .../location/mapviewer/forms/RouteCoordinate.qml | 4 +- .../mapviewer/forms/RouteCoordinateForm.ui.qml | 8 +- examples/location/mapviewer/forms/RouteList.qml | 4 +- .../location/mapviewer/forms/RouteListDelegate.qml | 6 +- .../location/mapviewer/forms/RouteListHeader.qml | 4 +- examples/location/mapviewer/map/CircleItem.qml | 4 +- examples/location/mapviewer/map/ImageItem.qml | 4 +- examples/location/mapviewer/map/MapComponent.qml | 8 +- examples/location/mapviewer/map/Marker.qml | 4 +- examples/location/mapviewer/map/MiniMap.qml | 4 +- examples/location/mapviewer/map/PolygonItem.qml | 4 +- examples/location/mapviewer/map/PolylineItem.qml | 4 +- examples/location/mapviewer/map/RectangleItem.qml | 4 +- examples/location/mapviewer/mapviewer.qml | 115 ++++++++++----------- .../location/mapviewer/menus/ItemPopupMenu.qml | 4 +- examples/location/mapviewer/menus/MainMenu.qml | 6 +- examples/location/mapviewer/menus/MapPopupMenu.qml | 4 +- .../location/mapviewer/menus/MarkerPopupMenu.qml | 4 +- 28 files changed, 121 insertions(+), 131 deletions(-) diff --git a/examples/location/mapviewer/forms/Geocode.qml b/examples/location/mapviewer/forms/Geocode.qml index 4484b301..9e273257 100644 --- a/examples/location/mapviewer/forms/Geocode.qml +++ b/examples/location/mapviewer/forms/Geocode.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtPositioning 5.2 +import QtQuick 2.5 +import QtPositioning 5.5 GeocodeForm { diff --git a/examples/location/mapviewer/forms/GeocodeForm.ui.qml b/examples/location/mapviewer/forms/GeocodeForm.ui.qml index 76befee5..3ed715a0 100644 --- a/examples/location/mapviewer/forms/GeocodeForm.ui.qml +++ b/examples/location/mapviewer/forms/GeocodeForm.ui.qml @@ -38,9 +38,9 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.2 Item { property alias goButton: goButton @@ -150,7 +150,7 @@ Item { Button { id: goButton - text: qsTr("Go !") + text: qsTr("Proceed") } Button { diff --git a/examples/location/mapviewer/forms/Locale.qml b/examples/location/mapviewer/forms/Locale.qml index ed42476d..6e76c98a 100644 --- a/examples/location/mapviewer/forms/Locale.qml +++ b/examples/location/mapviewer/forms/Locale.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtPositioning 5.2 +import QtQuick 2.5 +import QtPositioning 5.5 LocaleForm { property string locale diff --git a/examples/location/mapviewer/forms/LocaleForm.ui.qml b/examples/location/mapviewer/forms/LocaleForm.ui.qml index b2444791..a146aed4 100644 --- a/examples/location/mapviewer/forms/LocaleForm.ui.qml +++ b/examples/location/mapviewer/forms/LocaleForm.ui.qml @@ -38,9 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 +import QtQuick 2.5 +import QtQuick.Layouts 1.2 Item { property alias clearButton: clearButton @@ -128,7 +127,7 @@ Item { Button { id: goButton - text: qsTr("Go !") + text: qsTr("Proceed") } Button { diff --git a/examples/location/mapviewer/forms/Message.qml b/examples/location/mapviewer/forms/Message.qml index e7230afb..5d12c1f9 100644 --- a/examples/location/mapviewer/forms/Message.qml +++ b/examples/location/mapviewer/forms/Message.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 2.4 +import QtQuick 2.5 MessageForm { property string title diff --git a/examples/location/mapviewer/forms/MessageForm.ui.qml b/examples/location/mapviewer/forms/MessageForm.ui.qml index 398ea273..a3008413 100644 --- a/examples/location/mapviewer/forms/MessageForm.ui.qml +++ b/examples/location/mapviewer/forms/MessageForm.ui.qml @@ -38,9 +38,9 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.2 Item { id: root diff --git a/examples/location/mapviewer/forms/ReverseGeocode.qml b/examples/location/mapviewer/forms/ReverseGeocode.qml index 53738c4d..9e3cd65f 100644 --- a/examples/location/mapviewer/forms/ReverseGeocode.qml +++ b/examples/location/mapviewer/forms/ReverseGeocode.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtPositioning 5.2 +import QtQuick 2.5 +import QtPositioning 5.5 //Reverse Geocode Dialog ReverseGeocodeForm { diff --git a/examples/location/mapviewer/forms/ReverseGeocodeForm.ui.qml b/examples/location/mapviewer/forms/ReverseGeocodeForm.ui.qml index 35a2d33d..29eaec9f 100644 --- a/examples/location/mapviewer/forms/ReverseGeocodeForm.ui.qml +++ b/examples/location/mapviewer/forms/ReverseGeocodeForm.ui.qml @@ -38,9 +38,9 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.2 Item { property alias clearButton: clearButton @@ -118,7 +118,7 @@ Item { Button { id: goButton - text: qsTr("Go !") + text: qsTr("Proceed") } Button { diff --git a/examples/location/mapviewer/forms/RouteAddress.qml b/examples/location/mapviewer/forms/RouteAddress.qml index 54c5f687..09bc80bb 100644 --- a/examples/location/mapviewer/forms/RouteAddress.qml +++ b/examples/location/mapviewer/forms/RouteAddress.qml @@ -38,9 +38,9 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtLocation 5.3 -import QtPositioning 5.3 +import QtQuick 2.5 +import QtLocation 5.5 +import QtPositioning 5.5 RouteAddressForm { property alias plugin : tempGeocodeModel.plugin; diff --git a/examples/location/mapviewer/forms/RouteAddressForm.ui.qml b/examples/location/mapviewer/forms/RouteAddressForm.ui.qml index 1c2e6bd7..3f98dc05 100644 --- a/examples/location/mapviewer/forms/RouteAddressForm.ui.qml +++ b/examples/location/mapviewer/forms/RouteAddressForm.ui.qml @@ -39,9 +39,9 @@ ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.2 Item { property alias fromStreet: fromStreet @@ -174,7 +174,7 @@ Item { Button { id: goButton - text: qsTr("Go!") + text: qsTr("Proceed") } Button { diff --git a/examples/location/mapviewer/forms/RouteCoordinate.qml b/examples/location/mapviewer/forms/RouteCoordinate.qml index 5a42310b..f195ac7d 100644 --- a/examples/location/mapviewer/forms/RouteCoordinate.qml +++ b/examples/location/mapviewer/forms/RouteCoordinate.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtPositioning 5.2 +import QtQuick 2.5 +import QtPositioning 5.5 RouteCoordinateForm { property variant toCoordinate diff --git a/examples/location/mapviewer/forms/RouteCoordinateForm.ui.qml b/examples/location/mapviewer/forms/RouteCoordinateForm.ui.qml index db473b06..bd492d3d 100644 --- a/examples/location/mapviewer/forms/RouteCoordinateForm.ui.qml +++ b/examples/location/mapviewer/forms/RouteCoordinateForm.ui.qml @@ -39,9 +39,9 @@ ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.2 Item { property alias fromLatitude: fromLatitude @@ -151,7 +151,7 @@ Item { Layout.alignment: Qt.AlignRight Button { id: goButton - text: qsTr("Go !") + text: qsTr("Proceed") } Button { diff --git a/examples/location/mapviewer/forms/RouteList.qml b/examples/location/mapviewer/forms/RouteList.qml index a2d7e9df..27fa572e 100644 --- a/examples/location/mapviewer/forms/RouteList.qml +++ b/examples/location/mapviewer/forms/RouteList.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.3 +import QtQuick 2.5 +import QtQuick.Controls 1.4 import "../helper.js" as Helper //! [routeinfomodel0] diff --git a/examples/location/mapviewer/forms/RouteListDelegate.qml b/examples/location/mapviewer/forms/RouteListDelegate.qml index 789bc78c..2dc9981a 100644 --- a/examples/location/mapviewer/forms/RouteListDelegate.qml +++ b/examples/location/mapviewer/forms/RouteListDelegate.qml @@ -38,9 +38,9 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.3 -import QtQuick.Layouts 1.1 +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.2 Item { id: root diff --git a/examples/location/mapviewer/forms/RouteListHeader.qml b/examples/location/mapviewer/forms/RouteListHeader.qml index 5c702810..383f892a 100644 --- a/examples/location/mapviewer/forms/RouteListHeader.qml +++ b/examples/location/mapviewer/forms/RouteListHeader.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.3 +import QtQuick 2.5 +import QtQuick.Controls 1.4 Item { property alias travelTime: travelTimeLabel diff --git a/examples/location/mapviewer/map/CircleItem.qml b/examples/location/mapviewer/map/CircleItem.qml index 16eb1313..3f663149 100644 --- a/examples/location/mapviewer/map/CircleItem.qml +++ b/examples/location/mapviewer/map/CircleItem.qml @@ -37,8 +37,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.0 -import QtLocation 5.3 +import QtQuick 2.5 +import QtLocation 5.5 //TODO: remove/refactor me when items are integrated diff --git a/examples/location/mapviewer/map/ImageItem.qml b/examples/location/mapviewer/map/ImageItem.qml index 9b213406..27456ed9 100644 --- a/examples/location/mapviewer/map/ImageItem.qml +++ b/examples/location/mapviewer/map/ImageItem.qml @@ -37,8 +37,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.0; -import QtLocation 5.3 +import QtQuick 2.5; +import QtLocation 5.5 MapQuickItem { //to be used inside MapComponent only id: imageItem diff --git a/examples/location/mapviewer/map/MapComponent.qml b/examples/location/mapviewer/map/MapComponent.qml index 4c0e961b..0cb84fdf 100644 --- a/examples/location/mapviewer/map/MapComponent.qml +++ b/examples/location/mapviewer/map/MapComponent.qml @@ -37,10 +37,10 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.3 -import QtLocation 5.3 -import QtPositioning 5.2 +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtLocation 5.5 +import QtPositioning 5.5 import "../helper.js" as Helper //! [top] diff --git a/examples/location/mapviewer/map/Marker.qml b/examples/location/mapviewer/map/Marker.qml index afa985ff..a8851a4c 100644 --- a/examples/location/mapviewer/map/Marker.qml +++ b/examples/location/mapviewer/map/Marker.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.0; -import QtLocation 5.3 +import QtQuick 2.5; +import QtLocation 5.5 //! [mqi-top] MapQuickItem { diff --git a/examples/location/mapviewer/map/MiniMap.qml b/examples/location/mapviewer/map/MiniMap.qml index fbd000ef..29a6a880 100644 --- a/examples/location/mapviewer/map/MiniMap.qml +++ b/examples/location/mapviewer/map/MiniMap.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtLocation 5.3 +import QtQuick 2.5 +import QtLocation 5.5 Rectangle{ id: miniMapRect diff --git a/examples/location/mapviewer/map/PolygonItem.qml b/examples/location/mapviewer/map/PolygonItem.qml index b6f5fd2f..b28ff22c 100644 --- a/examples/location/mapviewer/map/PolygonItem.qml +++ b/examples/location/mapviewer/map/PolygonItem.qml @@ -37,8 +37,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.0 -import QtLocation 5.3 +import QtQuick 2.5 +import QtLocation 5.5 //TODO: remove me when items are integrated diff --git a/examples/location/mapviewer/map/PolylineItem.qml b/examples/location/mapviewer/map/PolylineItem.qml index f94ec950..4861e5af 100644 --- a/examples/location/mapviewer/map/PolylineItem.qml +++ b/examples/location/mapviewer/map/PolylineItem.qml @@ -37,8 +37,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.0 -import QtLocation 5.3 +import QtQuick 2.5 +import QtLocation 5.5 //TODO: remove/refactor me when items are integrated diff --git a/examples/location/mapviewer/map/RectangleItem.qml b/examples/location/mapviewer/map/RectangleItem.qml index 36ec3c0f..57b0a483 100644 --- a/examples/location/mapviewer/map/RectangleItem.qml +++ b/examples/location/mapviewer/map/RectangleItem.qml @@ -37,8 +37,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.0 -import QtLocation 5.3 +import QtQuick 2.5 +import QtLocation 5.5 MapRectangle { id: mapRectangle diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml index 08967ded..adcd3fe8 100644 --- a/examples/location/mapviewer/mapviewer.qml +++ b/examples/location/mapviewer/mapviewer.qml @@ -38,10 +38,10 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.3 -import QtLocation 5.3 -import QtPositioning 5.2 +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtLocation 5.5 +import QtPositioning 5.5 import "map" import "menus" import "helper.js" as Helper @@ -72,64 +72,7 @@ ApplicationWindow { minimap = null } - map = Qt.createQmlObject ('import QtLocation 5.3;\ - import "map";\ - import "helper.js" as Helper;\ - MapComponent{\ - width: page.width;\ - height: page.height;\ - onFollowmeChanged: {mainMenu.isFollowMe = map.followme}\ - onSupportedMapTypesChanged: {mainMenu.mapTypeMenu.createMenu(map)}\ - onCoordinatesCaptured: {\ - var text = "" + qsTr("Latitude:") + " " + Helper.roundNumber(latitude,4) + "
" + qsTr("Longitude:") + " " + Helper.roundNumber(longitude,4);\ - stackView.showMessage(qsTr("Coordinates"),text);\ - }\ - onGeocodeFinished:{\ - if (map.geocodeModel.status == GeocodeModel.Ready) {\ - if (map.geocodeModel.count == 0) {\ - stackView.showMessage(qsTr("Geocode Error"),qsTr("Unsuccessful geocode"));\ - } else if (map.geocodeModel.count > 1) { \ - stackView.showMessage(qsTr("Ambiguous geocode"), map.geocodeModel.count + " " + \ - qsTr("results found for the given address, please specify location"));\ - } else { \ - stackView.showMessage(qsTr("Location"), geocodeMessage(),page);\ - ;}\ - } else if (map.geocodeModel.status == GeocodeModel.Error) {\ - stackView.showMessage(qsTr("Geocode Error"),qsTr("Unsuccessful geocode")); \ - }\ - }\ - onRouteError: {\ - stackView.showMessage(qsTr("Route Error"),qsTr("Unable to find a route for the given points"),page);\ - }\ - onShowGeocodeInfo:{\ - stackView.showMessage(qsTr("Location"),geocodeMessage(),page);\ - }\ - onErrorChanged: {\ - if (map.error != Map.NoError) {\ - var title = qsTr("ProviderError");\ - var message = map.errorString + "

" + qsTr("Try to select other provider") + "";\ - if (map.error == Map.MissingRequiredParameterError) \ - message += "
" + qsTr("or see") + " \'mapviewer --help\' "\ - + qsTr("how to pass plugin parameters.");\ - stackView.showMessage(title,message);\ - }\ - }\ - onShowMainMenu: {\ - mapPopupMenu.show(coordinate);\ - }\ - onShowMarkerMenu: {\ - markerPopupMenu.show(coordinate);\ - }\ - onShowRouteMenu: {\ - itemPopupMenu.show("Route",coordinate);\ - }\ - onShowPointMenu: {\ - itemPopupMenu.show("Point",coordinate);\ - }\ - onShowRouteList: {\ - stackView.showRouteListPage(); - }\ - }',page) + map = mapComponent.createObject(page); map.plugin = plugin; map.zoomLevel = (map.maximumZoomLevel - map.minimumZoomLevel)/2 } @@ -476,4 +419,52 @@ ApplicationWindow { currentItem.closeForm.connect(closeForm) } } + + Component { + id: mapComponent + + MapComponent{ + width: page.width + height: page.height + onFollowmeChanged: mainMenu.isFollowMe = map.followme + onSupportedMapTypesChanged: mainMenu.mapTypeMenu.createMenu(map) + onCoordinatesCaptured: { + var text = "" + qsTr("Latitude:") + " " + Helper.roundNumber(latitude,4) + "
" + qsTr("Longitude:") + " " + Helper.roundNumber(longitude,4) + stackView.showMessage(qsTr("Coordinates"),text); + } + onGeocodeFinished:{ + if (map.geocodeModel.status == GeocodeModel.Ready) { + if (map.geocodeModel.count == 0) { + stackView.showMessage(qsTr("Geocode Error"),qsTr("Unsuccessful geocode")) + } else if (map.geocodeModel.count > 1) { + stackView.showMessage(qsTr("Ambiguous geocode"), map.geocodeModel.count + " " + + qsTr("results found for the given address, please specify location")) + } else { + stackView.showMessage(qsTr("Location"), geocodeMessage(),page) + } + } else if (map.geocodeModel.status == GeocodeModel.Error) { + stackView.showMessage(qsTr("Geocode Error"),qsTr("Unsuccessful geocode")) + } + } + onRouteError: stackView.showMessage(qsTr("Route Error"),qsTr("Unable to find a route for the given points"),page) + + onShowGeocodeInfo: stackView.showMessage(qsTr("Location"),geocodeMessage(),page) + + onErrorChanged: { + if (map.error != Map.NoError) { + var title = qsTr("ProviderError") + var message = map.errorString + "

" + qsTr("Try to select other provider") + "" + if (map.error == Map.MissingRequiredParameterError) + message += "
" + qsTr("or see") + " \'mapviewer --help\' " + + qsTr("how to pass plugin parameters.") + stackView.showMessage(title,message); + } + } + onShowMainMenu: mapPopupMenu.show(coordinate) + onShowMarkerMenu: markerPopupMenu.show(coordinate) + onShowRouteMenu: itemPopupMenu.show("Route",coordinate) + onShowPointMenu: itemPopupMenu.show("Point",coordinate) + onShowRouteList: stackView.showRouteListPage() + } + } } diff --git a/examples/location/mapviewer/menus/ItemPopupMenu.qml b/examples/location/mapviewer/menus/ItemPopupMenu.qml index 6b604aaa..8d7e2f70 100644 --- a/examples/location/mapviewer/menus/ItemPopupMenu.qml +++ b/examples/location/mapviewer/menus/ItemPopupMenu.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.3 +import QtQuick 2.5 +import QtQuick.Controls 1.4 Menu { property variant type diff --git a/examples/location/mapviewer/menus/MainMenu.qml b/examples/location/mapviewer/menus/MainMenu.qml index 31c4a53b..2d402bd0 100644 --- a/examples/location/mapviewer/menus/MainMenu.qml +++ b/examples/location/mapviewer/menus/MainMenu.qml @@ -38,9 +38,9 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.3 -import QtLocation 5.3 +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtLocation 5.5 MenuBar { property variant providerMenu: providerMenu diff --git a/examples/location/mapviewer/menus/MapPopupMenu.qml b/examples/location/mapviewer/menus/MapPopupMenu.qml index 4bb9e0a2..b8cc8412 100644 --- a/examples/location/mapviewer/menus/MapPopupMenu.qml +++ b/examples/location/mapviewer/menus/MapPopupMenu.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.3 +import QtQuick 2.5 +import QtQuick.Controls 1.4 Menu { property variant coordinate diff --git a/examples/location/mapviewer/menus/MarkerPopupMenu.qml b/examples/location/mapviewer/menus/MarkerPopupMenu.qml index c5bc5740..61855ff4 100644 --- a/examples/location/mapviewer/menus/MarkerPopupMenu.qml +++ b/examples/location/mapviewer/menus/MarkerPopupMenu.qml @@ -38,8 +38,8 @@ ** ****************************************************************************/ -import QtQuick 2.4 -import QtQuick.Controls 1.3 +import QtQuick 2.5 +import QtQuick.Controls 1.4 Menu { property int currentMarker -- cgit v1.2.3