From 7504d62658da0ee8a3e376e5e6b9ecd4d6574848 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 15 Nov 2021 17:31:54 +0200 Subject: Migrate mapviewer to Qt 6 Task-number: QTBUG-96795 Pick-to: 6.2 Change-Id: Iac955b1018d7092a7d684718bf89bb2908ee3c16 Reviewed-by: Volker Hilsheimer --- examples/location/mapviewer/forms/Geocode.qml | 4 +- .../location/mapviewer/forms/GeocodeForm.ui.qml | 6 +- examples/location/mapviewer/forms/Locale.qml | 8 +-- .../location/mapviewer/forms/LocaleForm.ui.qml | 14 ++-- 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 | 6 +- examples/location/mapviewer/forms/RouteAddress.qml | 6 +- .../mapviewer/forms/RouteAddressForm.ui.qml | 6 +- .../location/mapviewer/forms/RouteCoordinate.qml | 4 +- .../mapviewer/forms/RouteCoordinateForm.ui.qml | 6 +- 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 | 12 ++-- examples/location/mapviewer/map/MapSliders.qml | 28 ++++---- examples/location/mapviewer/map/Marker.qml | 4 +- examples/location/mapviewer/map/MiniMap.qml | 6 +- 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 | 77 +++++++++++----------- .../location/mapviewer/menus/ItemPopupMenu.qml | 4 +- examples/location/mapviewer/menus/MainMenu.qml | 75 ++++++++++++++------- examples/location/mapviewer/menus/MapPopupMenu.qml | 4 +- .../location/mapviewer/menus/MarkerPopupMenu.qml | 4 +- 29 files changed, 174 insertions(+), 146 deletions(-) (limited to 'examples') diff --git a/examples/location/mapviewer/forms/Geocode.qml b/examples/location/mapviewer/forms/Geocode.qml index 80cc0edd..106d98f0 100644 --- a/examples/location/mapviewer/forms/Geocode.qml +++ b/examples/location/mapviewer/forms/Geocode.qml @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtPositioning 5.5 +import QtQuick +import QtPositioning GeocodeForm { diff --git a/examples/location/mapviewer/forms/GeocodeForm.ui.qml b/examples/location/mapviewer/forms/GeocodeForm.ui.qml index ee4b20a4..f3f563df 100644 --- a/examples/location/mapviewer/forms/GeocodeForm.ui.qml +++ b/examples/location/mapviewer/forms/GeocodeForm.ui.qml @@ -48,9 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Item { property alias goButton: goButton diff --git a/examples/location/mapviewer/forms/Locale.qml b/examples/location/mapviewer/forms/Locale.qml index 031172d4..25cd9826 100644 --- a/examples/location/mapviewer/forms/Locale.qml +++ b/examples/location/mapviewer/forms/Locale.qml @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtPositioning 5.5 +import QtQuick +import QtPositioning LocaleForm { property string locale @@ -58,12 +58,12 @@ LocaleForm { goButton.onClicked: { - if (!languageGroup.current) return + if (!languageGroup.checkedButton) return if (otherRadioButton.checked) { selectLanguage(language.text) } else { - selectLanguage(languageGroup.current.text) + selectLanguage(languageGroup.checkedButton.text) } } diff --git a/examples/location/mapviewer/forms/LocaleForm.ui.qml b/examples/location/mapviewer/forms/LocaleForm.ui.qml index 82ebaf96..eb0c93ea 100644 --- a/examples/location/mapviewer/forms/LocaleForm.ui.qml +++ b/examples/location/mapviewer/forms/LocaleForm.ui.qml @@ -48,9 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Item { property alias clearButton: clearButton @@ -104,25 +104,25 @@ Item { columns: 2 anchors.fill: parent - ExclusiveGroup { id: languageGroup } + ButtonGroup { id: languageGroup } RadioButton { id: enRadioButton text: qsTr("en") - exclusiveGroup: languageGroup + ButtonGroup.group: languageGroup Layout.columnSpan: 2 } RadioButton { id: frRadioButton text: qsTr("fr") - exclusiveGroup: languageGroup + ButtonGroup.group: languageGroup Layout.columnSpan: 2 } RadioButton { id: otherRadioButton text: qsTr("Other") - exclusiveGroup: languageGroup + ButtonGroup.group: languageGroup } TextField { diff --git a/examples/location/mapviewer/forms/Message.qml b/examples/location/mapviewer/forms/Message.qml index 0a73344d..83ce4f4a 100644 --- a/examples/location/mapviewer/forms/Message.qml +++ b/examples/location/mapviewer/forms/Message.qml @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.5 +import QtQuick MessageForm { property string title diff --git a/examples/location/mapviewer/forms/MessageForm.ui.qml b/examples/location/mapviewer/forms/MessageForm.ui.qml index cff76c07..96ae2a5a 100644 --- a/examples/location/mapviewer/forms/MessageForm.ui.qml +++ b/examples/location/mapviewer/forms/MessageForm.ui.qml @@ -48,9 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Item { id: root diff --git a/examples/location/mapviewer/forms/ReverseGeocode.qml b/examples/location/mapviewer/forms/ReverseGeocode.qml index 803df2d1..60804ae3 100644 --- a/examples/location/mapviewer/forms/ReverseGeocode.qml +++ b/examples/location/mapviewer/forms/ReverseGeocode.qml @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtPositioning 5.5 +import QtQuick +import QtPositioning //Reverse Geocode Dialog ReverseGeocodeForm { diff --git a/examples/location/mapviewer/forms/ReverseGeocodeForm.ui.qml b/examples/location/mapviewer/forms/ReverseGeocodeForm.ui.qml index 6ba0e20f..89019834 100644 --- a/examples/location/mapviewer/forms/ReverseGeocodeForm.ui.qml +++ b/examples/location/mapviewer/forms/ReverseGeocodeForm.ui.qml @@ -48,9 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Item { property alias clearButton: clearButton diff --git a/examples/location/mapviewer/forms/RouteAddress.qml b/examples/location/mapviewer/forms/RouteAddress.qml index 4c463a4f..78f29226 100644 --- a/examples/location/mapviewer/forms/RouteAddress.qml +++ b/examples/location/mapviewer/forms/RouteAddress.qml @@ -48,9 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtLocation 5.6 -import QtPositioning 5.5 +import QtQuick +import QtLocation +import QtPositioning 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 22543820..b6d65436 100644 --- a/examples/location/mapviewer/forms/RouteAddressForm.ui.qml +++ b/examples/location/mapviewer/forms/RouteAddressForm.ui.qml @@ -49,9 +49,9 @@ ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Item { property alias fromStreet: fromStreet diff --git a/examples/location/mapviewer/forms/RouteCoordinate.qml b/examples/location/mapviewer/forms/RouteCoordinate.qml index 6d4bd65b..a5bbc5ae 100644 --- a/examples/location/mapviewer/forms/RouteCoordinate.qml +++ b/examples/location/mapviewer/forms/RouteCoordinate.qml @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtPositioning 5.5 +import QtQuick +import QtPositioning RouteCoordinateForm { property variant toCoordinate diff --git a/examples/location/mapviewer/forms/RouteCoordinateForm.ui.qml b/examples/location/mapviewer/forms/RouteCoordinateForm.ui.qml index f71d2512..78e5eb09 100644 --- a/examples/location/mapviewer/forms/RouteCoordinateForm.ui.qml +++ b/examples/location/mapviewer/forms/RouteCoordinateForm.ui.qml @@ -49,9 +49,9 @@ ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Item { property alias fromLatitude: fromLatitude diff --git a/examples/location/mapviewer/forms/RouteList.qml b/examples/location/mapviewer/forms/RouteList.qml index 9cf889db..51f69daf 100644 --- a/examples/location/mapviewer/forms/RouteList.qml +++ b/examples/location/mapviewer/forms/RouteList.qml @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 +import QtQuick +import QtQuick.Controls import "../helper.js" as Helper //! [routeinfomodel0] diff --git a/examples/location/mapviewer/forms/RouteListDelegate.qml b/examples/location/mapviewer/forms/RouteListDelegate.qml index 81fe2e08..2a5f765b 100644 --- a/examples/location/mapviewer/forms/RouteListDelegate.qml +++ b/examples/location/mapviewer/forms/RouteListDelegate.qml @@ -48,9 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Item { id: root diff --git a/examples/location/mapviewer/forms/RouteListHeader.qml b/examples/location/mapviewer/forms/RouteListHeader.qml index 968395b5..a4c10c82 100644 --- a/examples/location/mapviewer/forms/RouteListHeader.qml +++ b/examples/location/mapviewer/forms/RouteListHeader.qml @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 +import QtQuick +import QtQuick.Controls Item { property alias travelTime: travelTimeLabel diff --git a/examples/location/mapviewer/map/CircleItem.qml b/examples/location/mapviewer/map/CircleItem.qml index d06aeb78..a0eb84c4 100644 --- a/examples/location/mapviewer/map/CircleItem.qml +++ b/examples/location/mapviewer/map/CircleItem.qml @@ -47,8 +47,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.5 -import QtLocation 5.6 +import QtQuick +import QtLocation //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 cc5507c9..27cbb732 100644 --- a/examples/location/mapviewer/map/ImageItem.qml +++ b/examples/location/mapviewer/map/ImageItem.qml @@ -47,8 +47,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.5; -import QtLocation 5.6 +import QtQuick +import QtLocation 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 c7ac36df..a9ace12f 100644 --- a/examples/location/mapviewer/map/MapComponent.qml +++ b/examples/location/mapviewer/map/MapComponent.qml @@ -47,10 +47,10 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtLocation 5.9 -import QtPositioning 5.5 +import QtQuick +import QtQuick.Controls +import QtLocation +import QtPositioning import "../helper.js" as Helper //! [top] @@ -595,7 +595,7 @@ Map { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton - onPressed : { + onPressed: (mouse) => { map.lastX = mouse.x map.lastY = mouse.y map.pressX = mouse.x @@ -603,7 +603,7 @@ Map { lastCoordinate = map.toCoordinate(Qt.point(mouse.x, mouse.y)) } - onPositionChanged: { + onPositionChanged: (mouse) => { if (mouse.button == Qt.LeftButton) { map.lastX = mouse.x map.lastY = mouse.y diff --git a/examples/location/mapviewer/map/MapSliders.qml b/examples/location/mapviewer/map/MapSliders.qml index ed475d0f..49fb5659 100644 --- a/examples/location/mapviewer/map/MapSliders.qml +++ b/examples/location/mapviewer/map/MapSliders.qml @@ -48,10 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.6 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Controls 2.0 as C2 +import QtQuick +import QtQuick.Controls Row { id: containerRow @@ -85,11 +83,15 @@ Row { xScale: rightEdge() ? 1 : -1 } - style: ButtonStyle { - background: Rectangle { - color: "transparent" - } - } +// style: ButtonStyle { +// background: Rectangle { +// color: "transparent" +// } +// } + background: Rectangle { + color: "transparent" + } + property real shear: 0.333 property real buttonOpacity: 0.5 @@ -220,7 +222,7 @@ Row { id: sliderRow height: sliderContainer.slidersHeight - C2.Slider { + Slider { id: zoomSlider height: parent.height orientation : Qt.Vertical @@ -231,7 +233,7 @@ Row { containerRow.mapSource.zoomLevel = value } } - C2.Slider { + Slider { id: bearingSlider height: parent.height from: 0 @@ -242,7 +244,7 @@ Row { containerRow.mapSource.bearing = value; } } - C2.Slider { + Slider { id: tiltSlider height: parent.height orientation : Qt.Vertical @@ -253,7 +255,7 @@ Row { containerRow.mapSource.tilt = value; } } - C2.Slider { + Slider { id: fovSlider height: parent.height orientation : Qt.Vertical diff --git a/examples/location/mapviewer/map/Marker.qml b/examples/location/mapviewer/map/Marker.qml index 095e5f93..8c5d9284 100644 --- a/examples/location/mapviewer/map/Marker.qml +++ b/examples/location/mapviewer/map/Marker.qml @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.5; -import QtLocation 5.6 +import QtQuick +import QtLocation //! [mqi-top] MapQuickItem { diff --git a/examples/location/mapviewer/map/MiniMap.qml b/examples/location/mapviewer/map/MiniMap.qml index 78d2b01e..43298d85 100644 --- a/examples/location/mapviewer/map/MiniMap.qml +++ b/examples/location/mapviewer/map/MiniMap.qml @@ -48,9 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtPositioning 5.3 -import QtLocation 5.6 +import QtQuick +import QtPositioning +import QtLocation Rectangle{ diff --git a/examples/location/mapviewer/map/PolygonItem.qml b/examples/location/mapviewer/map/PolygonItem.qml index b2ece6d8..f1f35c8a 100644 --- a/examples/location/mapviewer/map/PolygonItem.qml +++ b/examples/location/mapviewer/map/PolygonItem.qml @@ -47,8 +47,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.5 -import QtLocation 5.6 +import QtQuick +import QtLocation //TODO: remove me when items are integrated diff --git a/examples/location/mapviewer/map/PolylineItem.qml b/examples/location/mapviewer/map/PolylineItem.qml index 8741ca26..d6fc947d 100644 --- a/examples/location/mapviewer/map/PolylineItem.qml +++ b/examples/location/mapviewer/map/PolylineItem.qml @@ -47,8 +47,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.5 -import QtLocation 5.6 +import QtQuick +import QtLocation //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 176327b6..343f6558 100644 --- a/examples/location/mapviewer/map/RectangleItem.qml +++ b/examples/location/mapviewer/map/RectangleItem.qml @@ -47,8 +47,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.5 -import QtLocation 5.6 +import QtQuick +import QtLocation MapRectangle { id: mapRectangle diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml index e8b016aa..bad561a6 100644 --- a/examples/location/mapviewer/mapviewer.qml +++ b/examples/location/mapviewer/mapviewer.qml @@ -48,10 +48,10 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtLocation 5.6 -import QtPositioning 5.5 +import QtQuick +import QtQuick.Controls +import QtLocation +import QtPositioning import "map" import "menus" import "helper.js" as Helper @@ -73,9 +73,9 @@ ApplicationWindow { var plugin if (parameters && parameters.length>0) - plugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin{ name:"' + provider + '"; parameters: appWindow.parameters}', appWindow) + plugin = Qt.createQmlObject ('import QtLocation; Plugin{ name:"' + provider + '"; parameters: appWindow.parameters}', appWindow) else - plugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin{ name:"' + provider + '"}', appWindow) + plugin = Qt.createQmlObject ('import QtLocation; Plugin{ name:"' + provider + '"}', appWindow) if (minimap) { minimap.destroy() @@ -120,10 +120,10 @@ ApplicationWindow { function getPlugins() { - var plugin = Qt.createQmlObject ('import QtLocation 5.6; Plugin {}', appWindow) + var plugin = Qt.createQmlObject ('import QtLocation; Plugin {}', appWindow) var myArray = new Array() for (var i = 0; i { stackView.pop() - for (var i = 0; i < providerMenu.items.length; i++) { - providerMenu.items[i].checked = providerMenu.items[i].text === providerName + for (var i = 0; i < providerMenu.count; i++) { + providerMenu.actionAt(i).checked = providerMenu.actionAt(i).text === providerName } createMap(providerName) @@ -207,53 +207,53 @@ ApplicationWindow { } } - onSelectMapType: { + onSelectMapType: (mapType) => { stackView.pop(page) - for (var i = 0; i < mapTypeMenu.items.length; i++) { - mapTypeMenu.items[i].checked = mapTypeMenu.items[i].text === mapType.name + for (var i = 0; i < mapTypeMenu.count; i++) { + mapTypeMenu.actionAt(i).checked = mapTypeMenu.actionAt(i).text === mapType.name } map.activeMapType = mapType } - onSelectTool: { + onSelectTool: (tool) => { switch (tool) { case "AddressRoute": stackView.pop({item:page, immediate: true}) - stackView.push({ item: Qt.resolvedUrl("forms/RouteAddress.qml") , - properties: { "plugin": map.plugin, + stackView.push("forms/RouteAddress.qml" , + { "plugin": map.plugin, "toAddress": toAddress, - "fromAddress": fromAddress}}) + "fromAddress": fromAddress}) stackView.currentItem.showRoute.connect(map.calculateCoordinateRoute) stackView.currentItem.showMessage.connect(stackView.showMessage) stackView.currentItem.closeForm.connect(stackView.closeForm) break case "CoordinateRoute": stackView.pop({item:page, immediate: true}) - stackView.push({ item: Qt.resolvedUrl("forms/RouteCoordinate.qml") , - properties: { "toCoordinate": toCoordinate, - "fromCoordinate": fromCoordinate}}) + stackView.push("forms/RouteCoordinate.qml" , + { "toCoordinate": toCoordinate, + "fromCoordinate": fromCoordinate}) stackView.currentItem.showRoute.connect(map.calculateCoordinateRoute) stackView.currentItem.closeForm.connect(stackView.closeForm) break case "Geocode": stackView.pop({item:page, immediate: true}) - stackView.push({ item: Qt.resolvedUrl("forms/Geocode.qml") , - properties: { "address": fromAddress}}) + stackView.push("forms/Geocode.qml", + { "address": fromAddress}) stackView.currentItem.showPlace.connect(map.geocode) stackView.currentItem.closeForm.connect(stackView.closeForm) break case "RevGeocode": stackView.pop({item:page, immediate: true}) - stackView.push({ item: Qt.resolvedUrl("forms/ReverseGeocode.qml") , - properties: { "coordinate": fromCoordinate}}) + stackView.push("forms/ReverseGeocode.qml", + { "coordinate": fromCoordinate }) stackView.currentItem.showPlace.connect(map.geocode) stackView.currentItem.closeForm.connect(stackView.closeForm) break case "Language": stackView.pop({item:page, immediate: true}) - stackView.push({ item: Qt.resolvedUrl("forms/Locale.qml") , - properties: { "locale": map.plugin.locales[0]}}) + stackView.push("forms/Locale.qml", + { "locale": map.plugin.locales[0]}) stackView.currentItem.selectLanguage.connect(setLanguage) stackView.currentItem.closeForm.connect(stackView.closeForm) break @@ -268,7 +268,7 @@ ApplicationWindow { } } - onToggleMapState: { + onToggleMapState: (state) => { stackView.pop(page) switch (state) { case "FollowMe": @@ -334,9 +334,10 @@ ApplicationWindow { function askForCoordinate() { - stackView.push({ item: Qt.resolvedUrl("forms/ReverseGeocode.qml") , - properties: { "title": qsTr("New Coordinate"), - "coordinate": map.markers[map.currentMarker].coordinate}}) + console.log("askForCoordinate") + stackView.push("forms/ReverseGeocode.qml", + { "title": qsTr("New Coordinate"), + "coordinate": map.markers[map.currentMarker].coordinate}) stackView.currentItem.showPlace.connect(moveMarker) stackView.currentItem.closeForm.connect(stackView.closeForm) } @@ -446,12 +447,12 @@ support" function showMessage(title,message,backPage) { - push({ item: Qt.resolvedUrl("forms/Message.qml") , - properties: { + push("forms/Message.qml", + { "title" : title, "message" : message, "backPage" : backPage - }}) + }) currentItem.closeForm.connect(closeMessage) } @@ -467,10 +468,10 @@ support" function showRouteListPage() { - push({ item: Qt.resolvedUrl("forms/RouteList.qml") , - properties: { + push("forms/RouteList.qml", + { "routeModel" : map.routeModel - }}) + }) currentItem.closeForm.connect(closeForm) } } diff --git a/examples/location/mapviewer/menus/ItemPopupMenu.qml b/examples/location/mapviewer/menus/ItemPopupMenu.qml index 998a75b3..ea6fd3b9 100644 --- a/examples/location/mapviewer/menus/ItemPopupMenu.qml +++ b/examples/location/mapviewer/menus/ItemPopupMenu.qml @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 +import QtQuick +import QtQuick.Controls Menu { property variant type diff --git a/examples/location/mapviewer/menus/MainMenu.qml b/examples/location/mapviewer/menus/MainMenu.qml index baf03572..d2cf4731 100644 --- a/examples/location/mapviewer/menus/MainMenu.qml +++ b/examples/location/mapviewer/menus/MainMenu.qml @@ -48,9 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtLocation 5.6 +import QtQuick +import QtQuick.Controls +import QtLocation MenuBar { property variant providerMenu: providerMenu @@ -64,13 +64,19 @@ MenuBar { signal selectTool(string tool); signal toggleMapState(string state) + function clearMenu(menu) + { + while (menu.count) + menu.removeItem(menu.itemAt(0)) + } + Menu { id: providerMenu title: qsTr("Provider") function createMenu(plugins) { - clear() + clearMenu(providerMenu) for (var i = 0; i < plugins.length; i++) { createProviderMenuItem(plugins[i]); } @@ -78,9 +84,8 @@ MenuBar { function createProviderMenuItem(provider) { - var item = addItem(provider); - item.checkable = true; - item.triggered.connect(function(){selectProvider(provider)}) + var action = Qt.createQmlObject('import QtQuick.Controls; Action{ text: "' + provider + '"; checkable: true; onTriggered: function(){selectProvider("' + provider + '")} }', providerMenu) + addAction(action) } } @@ -88,21 +93,25 @@ MenuBar { id: mapTypeMenu title: qsTr("MapType") + Component { + id: mapTypeMenuActionComponent + Action { + + } + } function createMenu(map) { - clear() + clearMenu(mapTypeMenu) for (var i = 0; i