diff options
author | Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> | 2022-09-20 06:17:05 -0700 |
---|---|---|
committer | Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> | 2022-09-21 01:59:19 -0700 |
commit | d8f03e5e71de3d951f86f0b0413fd75d554b2039 (patch) | |
tree | b6a2418efbca9ecd1d43e3a4b74149247af8580c /examples | |
parent | ab4b06741ee2dbb70e43ae1660d6ccca4913a32c (diff) | |
download | qtlocation-d8f03e5e71de3d951f86f0b0413fd75d554b2039.tar.gz |
Port place example from qtquick1 to qtquick2
Modified places (location/examples/location/place) example to use
qtquick control 2 and its properties.
Fixes: QTBUG-105827
Change-Id: I78ddd50655bc914fdc10002caed154ee5aa19bcf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'examples')
24 files changed, 195 insertions, 183 deletions
diff --git a/examples/location/places/forms/Message.qml b/examples/location/places/forms/Message.qml index 83ce4f4a..2d3aa538 100644 --- a/examples/location/places/forms/Message.qml +++ b/examples/location/places/forms/Message.qml @@ -53,9 +53,9 @@ import QtQuick MessageForm { property string title property string message - property variant backPage + property var backPage - signal closeForm(variant backPage) + signal closeForm(var backPage) button.onClicked: { closeForm(backPage) diff --git a/examples/location/places/forms/PlaceDetails.qml b/examples/location/places/forms/PlaceDetails.qml index 2040ce5d..177346f0 100644 --- a/examples/location/places/forms/PlaceDetails.qml +++ b/examples/location/places/forms/PlaceDetails.qml @@ -53,13 +53,13 @@ import "../helper.js" as Helper PlaceDetailsForm { - property variant place + property var place property real distanceToPlace - signal searchForSimilar(variant place) - signal showReviews(variant place) - signal showEditorials(variant place) - signal showImages(variant place) + signal searchForSimilar(var place) + signal showReviews(var place) + signal showEditorials(var place) + signal showImages(var place) function placeAddress(place) { if (!place) @@ -75,7 +75,7 @@ PlaceDetailsForm { var result = ""; for (var i = 0; i < categories.length; ++i) { - if (result == "") { + if (result === "") { result = categories[i].name; } else { result = result + ", " + categories[i].name; @@ -115,7 +115,7 @@ PlaceDetailsForm { placeName.text = place ? (place.favorite ? place.favorite.name : place.name) : "" placeIcon.source = place ? (place.favorite ? place.favorite.icon.url(Qt.size(40,40)) : place.icon.url() == "" ? - "../resources/marker.png" + Qt.resolvedUrl("../resources/marker.png") : place.icon.url(Qt.size(40,40))) : "" ratingView.rating = (place && place.ratings) ? place.ratings.average : 0 distance.text = Helper.formatDistance(distanceToPlace) diff --git a/examples/location/places/forms/PlaceDetailsForm.ui.qml b/examples/location/places/forms/PlaceDetailsForm.ui.qml index f65f5e5c..53d241db 100644 --- a/examples/location/places/forms/PlaceDetailsForm.ui.qml +++ b/examples/location/places/forms/PlaceDetailsForm.ui.qml @@ -70,12 +70,9 @@ Item { property alias imagesButton: imagesButton property alias findSimilarButton: findSimilarButton property alias ratingView: ratingView - width: parent.width - height: parent.height ScrollView { id:scrollView - flickableItem.interactive: true anchors.fill: parent anchors.margins: 15 @@ -90,7 +87,7 @@ Item { Image { id: placeIcon - source: "../resources/marker.png" + source: Qt.resolvedUrl("../resources/marker.png") anchors.margins: 30 } @@ -112,8 +109,6 @@ Item { } Rectangle { - anchors.left: parent.left - anchors.right: parent.right Layout.columnSpan: 2 height: 1 color: "#46a2da" @@ -124,7 +119,6 @@ Item { id: addressBox Layout.fillWidth: true Layout.columnSpan: 2 - flat: true title: qsTr("Address") GridLayout { @@ -153,8 +147,6 @@ Item { } Rectangle { - anchors.left: parent.left - anchors.right: parent.right Layout.columnSpan: 2 height: 1 color: "#46a2da" @@ -165,7 +157,6 @@ Item { id: categoriesBox Layout.fillWidth: true Layout.columnSpan: 2 - flat: true title: qsTr("Categories") Label { @@ -176,8 +167,6 @@ Item { } Rectangle { - anchors.left: parent.left - anchors.right: parent.right height: 1 color: "#46a2da" visible: contactDetailsBox.visible @@ -187,7 +176,6 @@ Item { id: contactDetailsBox Layout.fillWidth: true Layout.columnSpan: 2 - flat: true title: qsTr("Contact details") GridLayout { id: gridLayout4 @@ -240,8 +228,6 @@ Item { Rectangle { Layout.columnSpan: 2 - anchors.left: parent.left - anchors.right: parent.right height: 1 color: "#46a2da" visible: informationBox.visible @@ -251,7 +237,6 @@ Item { id: informationBox Layout.fillWidth: true Layout.columnSpan: 2 - flat: true title: qsTr("Additional information") ColumnLayout { Label { diff --git a/examples/location/places/forms/SearchBoundingBox.qml b/examples/location/places/forms/SearchBoundingBox.qml index fae83389..5ecd331a 100644 --- a/examples/location/places/forms/SearchBoundingBox.qml +++ b/examples/location/places/forms/SearchBoundingBox.qml @@ -52,8 +52,8 @@ import QtQuick import QtPositioning SearchBoundingBoxForm { - property variant searchRegion - signal changeSearchBoundingBox(variant coordinate, real widthDeg, real heightDeg) + property var searchRegion + signal changeSearchBoundingBox(var coordinate, real widthDeg, real heightDeg) signal closeForm() goButton.onClicked: { diff --git a/examples/location/places/forms/SearchBoundingCircle.qml b/examples/location/places/forms/SearchBoundingCircle.qml index 0a01d570..707611d6 100644 --- a/examples/location/places/forms/SearchBoundingCircle.qml +++ b/examples/location/places/forms/SearchBoundingCircle.qml @@ -52,8 +52,8 @@ import QtQuick import QtPositioning SearchBoundingCircleForm { - property variant searchRegion - signal changeSearchBoundingCircle(variant coordinate, real radius) + property var searchRegion + signal changeSearchBoundingCircle(var coordinate, real radius) signal closeForm() goButton.onClicked: { diff --git a/examples/location/places/forms/SearchCenter.qml b/examples/location/places/forms/SearchCenter.qml index d243517a..7f2c1db8 100644 --- a/examples/location/places/forms/SearchCenter.qml +++ b/examples/location/places/forms/SearchCenter.qml @@ -53,8 +53,8 @@ import QtPositioning SearchCenterForm { property string title; - property variant coordinate - signal changeSearchCenter(variant coordinate) + property var coordinate + signal changeSearchCenter(var coordinate) signal closeForm() goButton.onClicked: { @@ -74,7 +74,7 @@ SearchCenterForm { Component.onCompleted: { latitude.text = "" + coordinate.latitude longitude.text = "" + coordinate.longitude - if (title.length != 0) + if (title.length !== 0) tabTitle.text = title; } } diff --git a/examples/location/places/forms/SearchOptions.qml b/examples/location/places/forms/SearchOptions.qml index 9b92f226..55350f28 100644 --- a/examples/location/places/forms/SearchOptions.qml +++ b/examples/location/places/forms/SearchOptions.qml @@ -77,12 +77,13 @@ SearchOptionsForm { } Component.onCompleted: { - locales.visible = root.plugin != null && root.plugin.supportsPlaces(Plugin.LocalizedPlacesFeature); + locales.visible = root.plugin !== null && root.plugin.supportsPlaces(Plugin.LocalizedPlacesFeature); favoritesButton.visible = false; // favoritesButton.enabled = placeSearchModel.favoritesPlugin !== null) // isFavoritesEnabled = true; locales.text = root.plugin.locales.join(Qt.locale().groupSeparator); - distanceOrderButton.checked = model.relevanceHint == PlaceSearchModel.DistanceHint - nameOrderButton.checked = model.relevanceHint == PlaceSearchModel.LexicalPlaceNameHint + distanceOrderButton.checked = model.relevanceHint === PlaceSearchModel.DistanceHint + nameOrderButton.checked = model.relevanceHint === PlaceSearchModel.LexicalPlaceNameHint + unspecifiedButton.checked = model.relevanceHint === PlaceSearchModel.UnspecifiedHint } } diff --git a/examples/location/places/forms/SearchOptionsForm.ui.qml b/examples/location/places/forms/SearchOptionsForm.ui.qml index 462abcac..0d04cd42 100644 --- a/examples/location/places/forms/SearchOptionsForm.ui.qml +++ b/examples/location/places/forms/SearchOptionsForm.ui.qml @@ -60,6 +60,7 @@ Item { property alias orderGroup: orderGroup property alias distanceOrderButton: distanceOrderButton property alias nameOrderButton: nameOrderButton + property alias unspecifiedButton: unspecifiedButton property alias favoritesButton: favoritesButton property alias locales: locales @@ -122,18 +123,26 @@ Item { Layout.columnSpan: 2 } - ExclusiveGroup { id: orderGroup } + ButtonGroup { id: orderGroup } + RadioButton { id: distanceOrderButton text: qsTr("Order by distance") - exclusiveGroup: orderGroup + ButtonGroup.group: orderGroup Layout.columnSpan: 2 } RadioButton { id: nameOrderButton text: qsTr("Order by name") - exclusiveGroup: orderGroup + ButtonGroup.group: orderGroup + Layout.columnSpan: 2 + } + + RadioButton { + id: unspecifiedButton + text: qsTr("Unspecified") + ButtonGroup.group: orderGroup Layout.columnSpan: 2 } @@ -162,8 +171,6 @@ Item { Layout.fillHeight: true Layout.columnSpan: 2 } - - } } } diff --git a/examples/location/places/items/MainMenu.qml b/examples/location/places/items/MainMenu.qml index ced7e777..33b7530a 100644 --- a/examples/location/places/items/MainMenu.qml +++ b/examples/location/places/items/MainMenu.qml @@ -53,31 +53,38 @@ import QtQuick.Controls import QtLocation MenuBar { - property variant providerMenu: providerMenu - property variant settingsMenu: settingsMenu + property var providerMenu: providerMenu + property var settingsMenu: settingsMenu - signal selectProvider(string providerName) - signal selectSetting(string setting); + signal selectProvider(providerName: string) + signal selectSetting(settings: string); + function getMenuItem(menuText, parentItem) { + var menuItem = Qt.createQmlObject('import QtQuick; import QtQuick.Controls; MenuItem {}', parent) + menuItem.text = qsTr(menuText) + return menuItem + } + function clearMenu(menu) { + while (menu.contentData.length > 0) + menu.removeItem(menu.itemAt(0)) + } Menu { id: providerMenu title: qsTr("Provider") - function createMenu(plugins) - { - clear() + function create(plugins) { + clearMenu(providerMenu) for (var i = 0; i < plugins.length; i++) { - createProviderMenuItem(plugins[i]); + createProvider(plugins[i]) } } - function createProviderMenuItem(provider) - { - var item = addItem(provider); - item.checkable = true; - item.triggered.connect(function(){selectProvider(provider)}) + function createProvider(itemVal) { + var item = getMenuItem(itemVal, providerMenu) + addItem(item) + item.triggered.connect(function(){selectProvider(itemVal)}) } } @@ -85,17 +92,17 @@ MenuBar { id: settingsMenu title: qsTr("Settings") - function createMenu(map) - { - clear() - var item = addItem(qsTr("Search Center")); - item.triggered.connect(function(){selectSetting("searchCenter")}) - item = addItem(qsTr("Search Bounding Box")); - item.triggered.connect(function(){selectSetting("searchBoundingBox")}) - item = addItem(qsTr("Search Bounding Circle")); - item.triggered.connect(function(){selectSetting("searchBoundingCircle")}) - item = addItem(qsTr("Search Options")); - item.triggered.connect(function(){selectSetting("SearchOptions")}) + function create(settings) { + clearMenu(settingsMenu) + for (var i = 0; i < settings.length; i++) { + createSetting(settings[i]) + } + } + + function createSetting(itemVal) { + var item = getMenuItem(itemVal, providerMenu) + addItem(item) + item.triggered.connect(function(){selectSetting(itemVal)}) } } } diff --git a/examples/location/places/items/MapComponent.qml b/examples/location/places/items/MapComponent.qml index 8faccbc1..9be4e4af 100644 --- a/examples/location/places/items/MapComponent.qml +++ b/examples/location/places/items/MapComponent.qml @@ -57,7 +57,7 @@ import "../helper.js" as Helper Map { id: map property bool followme: false - property variant scaleLengths: [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000] + property var scaleLengths: [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000] function calculateScale() { @@ -101,7 +101,7 @@ Map { onCenterChanged:{ scaleTimer.restart() if (map.followme) - if (map.center != positionSource.position.coordinate) map.followme = false + if (map.center !== positionSource.position.coordinate) map.followme = false } onZoomLevelChanged:{ @@ -147,19 +147,19 @@ Map { Image { id: scaleImageLeft - source: "../../resources/scale_end.png" + source: Qt.resolvedUrl("../resources/scale_end.png") anchors.bottom: parent.bottom anchors.right: scaleImage.left } Image { id: scaleImage - source: "../../resources/scale.png" + source: Qt.resolvedUrl("../resources/scale.png") anchors.bottom: parent.bottom anchors.right: scaleImageRight.left } Image { id: scaleImageRight - source: "../../resources/scale_end.png" + source: Qt.resolvedUrl("../resources/scale_end.png") anchors.bottom: parent.bottom anchors.right: parent.right } @@ -209,8 +209,8 @@ Map { Slider { id: zoomSlider; z: map.z + 3 - minimumValue: map.minimumZoomLevel; - maximumValue: map.maximumZoomLevel; + from: map.minimumZoomLevel; + to: map.maximumZoomLevel; anchors.margins: 10 anchors.bottom: scale.top anchors.top: parent.top diff --git a/examples/location/places/items/SearchBar.qml b/examples/location/places/items/SearchBar.qml index ce681436..602de6eb 100644 --- a/examples/location/places/items/SearchBar.qml +++ b/examples/location/places/items/SearchBar.qml @@ -69,7 +69,7 @@ ToolBar { } function showSearch(text) { - if (text != null) { + if (text !== null) { searchText.ignoreTextChange = true searchText.text = text searchText.ignoreTextChange = false @@ -97,12 +97,12 @@ ToolBar { } ToolButton { id: searchButton - iconSource: "../../resources/search.png" + icon.source: Qt.resolvedUrl("../resources/search.png") onClicked: doSearch(searchText.text) } ToolButton { id: categoryButton - iconSource: "../../resources/categories.png" + icon.source: Qt.resolvedUrl("../resources/categories.png") onClicked: showCategories() } } @@ -116,12 +116,12 @@ ToolBar { visible: opacity ? true : false ToolButton { id: backButton - iconSource: "../../resources/left.png" + icon.source: Qt.resolvedUrl("../resources/left.png") onClicked: goBack() } ToolButton { id: mapButton - iconSource: "../../resources/search.png" + icon.source: Qt.resolvedUrl("../resources/search.png") onClicked: showMap() } Item { diff --git a/examples/location/places/places.qml b/examples/location/places/places.qml index cd756dc7..89c41438 100644 --- a/examples/location/places/places.qml +++ b/examples/location/places/places.qml @@ -58,19 +58,18 @@ import "items" ApplicationWindow { id: appWindow property Map map - property variant parameters - property variant searchLocation: map ? map.center : QtPositioning.coordinate() - property variant searchRegion: QtPositioning.circle(searchLocation) - property variant searchRegionItem + property var parameters + property var searchLocation: map ? map.center : QtPositioning.coordinate() + property var searchRegion: QtPositioning.circle(searchLocation) + property var searchRegionItem property Plugin favoritesPlugin function getPlugins() { - var plugin = Qt.createQmlObject('import QtLocation 5.3; Plugin {}', appWindow); + var plugin = Qt.createQmlObject('import QtLocation; Plugin {}', appWindow); var myArray = new Array; for (var i = 0; i < plugin.availableServiceProviders.length; i++) { - var tempPlugin = Qt.createQmlObject ('import QtLocation 5.3; Plugin {name: "' + plugin.availableServiceProviders[i]+ '"}', appWindow) - + var tempPlugin = Qt.createQmlObject ('import QtLocation; Plugin {name: "' + plugin.availableServiceProviders[i]+ '"}', appWindow) if (tempPlugin.supportsPlaces() && tempPlugin.supportsMapping() ) myArray.push(tempPlugin.name) } @@ -80,14 +79,14 @@ ApplicationWindow { function initializeProviders(pluginParameters) { - var parameters = new Array() + var parameters = [] for (var prop in pluginParameters) { - var parameter = Qt.createQmlObject('import QtLocation 5.3; PluginParameter{ name: "'+ prop + '"; value: "' + pluginParameters[prop]+'"}',appWindow) + var parameter = Qt.createQmlObject('import QtLocation; PluginParameter{ name: "'+ prop + '"; value: "' + pluginParameters[prop]+'"}',appWindow) parameters.push(parameter) } appWindow.parameters = parameters var plugins = getPlugins() - mainMenu.providerMenu.createMenu(plugins) + mainMenu.providerMenu.create(plugins) for (var i = 0; i<plugins.length; i++) { if (plugins[i] === "osm") mainMenu.selectProvider(plugins[i]) @@ -97,9 +96,9 @@ ApplicationWindow { function createMap(provider) { var plugin; if (parameters && parameters.length>0) - plugin = Qt.createQmlObject ('import QtLocation 5.3; 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.3; Plugin{ name:"' + provider + '"}', appWindow) + plugin = Qt.createQmlObject ('import QtLocation; Plugin{ name:"' + provider + '"}', appWindow) if (map) map.destroy(); @@ -117,48 +116,46 @@ ApplicationWindow { height: 640 visible: true menuBar: mainMenu - toolBar: searchBar + header: searchBar MainMenu { id: mainMenu - onSelectProvider: { + + property var settings: ["Search Center", "Search Bounding Box", "Search Bounding Circle", "Search Options"] + + onSelectProvider: function (providerName) { stackView.pop(page) - for (var i = 0; i < providerMenu.items.length; i++) { - providerMenu.items[i].checked = providerMenu.items[i].text === providerName + for (var i = 0; i < providerMenu.contentData.length; i++) { + providerMenu.contentData[i].checked = providerMenu.contentData[i].text === providerName } - createMap(providerName) if (map.error === Map.NoError) { - settingsMenu.createMenu(map); + settingsMenu.create(settings) } else { - settingsMenu.clear(); + mainMenu.clearMenu(settingsMenu) } } - onSelectSetting: { - stackView.pop({tem:page,immediate: true}) + + onSelectSetting: function (setting) { + stackView.pop({item:page,immediate: true}) switch (setting) { - case "searchCenter": - stackView.push({ item: Qt.resolvedUrl("forms/SearchCenter.qml") , - properties: { "coordinate": map.center}}) + case "Search Center": + stackView.push(Qt.resolvedUrl("forms/SearchCenter.qml"), { "coordinate": map.center }) stackView.currentItem.changeSearchCenter.connect(stackView.changeSearchCenter) stackView.currentItem.closeForm.connect(stackView.closeForm) break - case "searchBoundingBox": - stackView.push({ item: Qt.resolvedUrl("forms/SearchBoundingBox.qml") , - properties: { "searchRegion": searchRegion}}) + case "Search Bounding Box": + stackView.push(Qt.resolvedUrl("forms/SearchBoundingBox.qml"), { "searchRegion": searchRegion }) stackView.currentItem.changeSearchBoundingBox.connect(stackView.changeSearchBoundingBox) stackView.currentItem.closeForm.connect(stackView.closeForm) break - case "searchBoundingCircle": - stackView.push({ item: Qt.resolvedUrl("forms/SearchBoundingCircle.qml") , - properties: { "searchRegion": searchRegion}}) + case "Search Bounding Circle": + stackView.push(Qt.resolvedUrl("forms/SearchBoundingCircle.qml"), { "searchRegion": searchRegion }) stackView.currentItem.changeSearchBoundingCircle.connect(stackView.changeSearchBoundingCircle) stackView.currentItem.closeForm.connect(stackView.closeForm) break - case "SearchOptions": - stackView.push({ item: Qt.resolvedUrl("forms/SearchOptions.qml") , - properties: { "plugin": map.plugin, - "model": placeSearchModel}}) + case "Search Options": + stackView.push(Qt.resolvedUrl("forms/SearchOptions.qml"), { "plugin": map.plugin, "model": placeSearchModel }) stackView.currentItem.changeSearchSettings.connect(stackView.changeSearchSettings) stackView.currentItem.closeForm.connect(stackView.closeForm) break @@ -184,17 +181,18 @@ ApplicationWindow { } onGoBack: stackView.pop() //! [PlaceSearchSuggestionModel search text changed 2] - onSearchTextChanged: { + onSearchTextChanged: function (searchText) { if (searchText.length >= 3 && suggestionModel != null) { suggestionModel.searchTerm = searchText; suggestionModel.update(); } } //! [PlaceSearchSuggestionModel search text changed 2] - onDoSearch: { + onDoSearch: function (searchText) { if (searchText.length > 0) placeSearchModel.searchForText(searchText); } + onShowMap: stackView.pop(page) //! [PlaceSearchSuggestionModel search text changed 3] } @@ -205,41 +203,45 @@ ApplicationWindow { function showMessage(title,message,backPage) { - push({ item: Qt.resolvedUrl("forms/Message.qml") , - properties: { - "title" : title, - "message" : message, - "backPage" : backPage - }}) + stackView.push(Qt.resolvedUrl("forms/Message.qml") , + { + "title" : title, + "message" : message, + "backPage" : backPage + }) currentItem.closeForm.connect(closeMessage) } function closeMessage(backPage) { - pop(backPage) + stackView.pop(backPage) } function closeForm() { - pop(page) + stackView.pop(page) } function enterCategory(index) { - push({ item: Qt.resolvedUrl("views/CategoryView.qml") , - properties: { "categoryModel": categoryModel, - "rootIndex" : index - }}) + stackView.push(Qt.resolvedUrl("views/CategoryView.qml"), + { + "categoryModel": categoryModel, + "rootIndex" : index + }) currentItem.showSubcategories.connect(stackView.enterCategory) currentItem.searchCategory.connect(placeSearchModel.searchForCategory) } function showSuggestions() { - if (currentItem.objectName != "suggestionView") { + if (currentItem.objectName !== "suggestionView") { stackView.pop(page) - push({ item: Qt.resolvedUrl("views/SuggestionView.qml") , - properties: { "suggestionModel": suggestionModel } + stackView.push(Qt.resolvedUrl("views/SuggestionView.qml"), + { + "suggestionModel": suggestionModel, + "width": stackView.width, + "height": stackView.height }) currentItem.objectName = "suggestionView" currentItem.suggestionSelected.connect(searchBar.showSearch) @@ -249,10 +251,13 @@ ApplicationWindow { function showPlaces() { - if (currentItem.objectName != "searchResultView") { + if (currentItem.objectName !== "searchResultView") { stackView.pop({tem:page,immediate: true}) - push({ item: Qt.resolvedUrl("views/SearchResultView.qml") , - properties: { "placeSearchModel": placeSearchModel } + stackView.push(Qt.resolvedUrl("views/SearchResultView.qml"), + { + "placeSearchModel": placeSearchModel, + "width": stackView.width, + "height": stackView.height }) currentItem.showPlaceDetails.connect(showPlaceDatails) currentItem.showMap.connect(searchBar.showMap) @@ -262,9 +267,12 @@ ApplicationWindow { function showPlaceDatails(place, distance) { - push({ item: Qt.resolvedUrl("forms/PlaceDetails.qml") , - properties: { "place": place, - "distanceToPlace": distance } + stackView.push(Qt.resolvedUrl("forms/PlaceDetails.qml") , + { + "place": place, + "distanceToPlace": distance, + "width": stackView.width, + "height": stackView.height }) currentItem.searchForSimilar.connect(searchForSimilar) currentItem.showReviews.connect(showReviews) @@ -274,38 +282,53 @@ ApplicationWindow { function showEditorials(place) { - push({ item: Qt.resolvedUrl("views/EditorialView.qml") , - properties: { "place": place } + stackView.push(Qt.resolvedUrl("views/EditorialView.qml"), + { + "place": place, + "width": stackView.width, + "height": stackView.height }) currentItem.showEditorial.connect(showEditorial) } function showReviews(place) { - push({ item: Qt.resolvedUrl("views/ReviewView.qml") , - properties: { "place": place } + stackView.push(Qt.resolvedUrl("views/ReviewView.qml") , + { + "place": place, + "width": stackView.width, + "height": stackView.height }) currentItem.showReview.connect(showReview) } function showImages(place) { - push({ item: Qt.resolvedUrl("views/ImageView.qml") , - properties: { "place": place } + stackView.push(Qt.resolvedUrl("views/ImageView.qml") , + { + "place": place, + "width": stackView.width, + "height": stackView.height }) } function showEditorial(editorial) { - push({ item: Qt.resolvedUrl("views/EditorialPage.qml") , - properties: { "editorial": editorial } + stackView.push(Qt.resolvedUrl("views/EditorialPage.qml") , + { + "editorial": editorial, + "width": stackView.width, + "height": stackView.height }) } function showReview(review) { - push({ item: Qt.resolvedUrl("views/ReviewPage.qml") , - properties: { "review": review } + stackView.push(Qt.resolvedUrl("views/ReviewPage.qml") , + { + "review": review, + "width": stackView.width, + "height": stackView.height }) } @@ -328,7 +351,7 @@ ApplicationWindow { map.removeMapItem(searchRegionItem); searchRegionItem.destroy(); } - searchRegionItem = Qt.createQmlObject('import QtLocation 5.3; MapRectangle { color: "#46a2da"; border.color: "#190a33"; border.width: 2; opacity: 0.25 }', page, "MapRectangle"); + searchRegionItem = Qt.createQmlObject('import QtLocation; MapRectangle { color: "#46a2da"; border.color: "#190a33"; border.width: 2; opacity: 0.25 }', page, "MapRectangle"); searchRegionItem.topLeft = searchRegion.topLeft; searchRegionItem.bottomRight = searchRegion.bottomRight; map.addMapItem(searchRegionItem); @@ -344,7 +367,7 @@ ApplicationWindow { map.removeMapItem(searchRegionItem); searchRegionItem.destroy(); } - searchRegionItem = Qt.createQmlObject('import QtLocation 5.3; MapCircle { color: "#46a2da"; border.color: "#190a33"; border.width: 2; opacity: 0.25 }', page, "MapRectangle"); + searchRegionItem = Qt.createQmlObject('import QtLocation; MapCircle { color: "#46a2da"; border.color: "#190a33"; border.width: 2; opacity: 0.25 }', page, "MapRectangle"); searchRegionItem.center = searchRegion.center; searchRegionItem.radius = searchRegion.radius; map.addMapItem(searchRegionItem); @@ -355,7 +378,7 @@ ApplicationWindow { stackView.pop(page) /*if (isFavoritesEnabled) { if (favoritesPlugin == null) - favoritesPlugin = Qt.createQmlObject('import QtLocation 5.3; Plugin { name: "places_jsondb" }', page); + favoritesPlugin = Qt.createQmlObject('import QtLocation; Plugin { name: "places_jsondb" }', page); favoritesPlugin.parameters = pluginParametersFromMap(pluginParameters); placeSearchModel.favoritesPlugin = favoritesPlugin; } else { @@ -457,10 +480,10 @@ ApplicationWindow { height: page.height onErrorChanged: { - if (map.error != Map.NoError) { + if (map.error !== Map.NoError) { var title = qsTr("ProviderError"); var message = map.errorString + "<br/><br/><b>" + qsTr("Try to select other provider") + "</b>"; - if (map.error == Map.MissingRequiredParameterError) + if (map.error === Map.MissingRequiredParameterError) message += "<br/>" + qsTr("or see") + " \'mapviewer --help\' " + qsTr("how to pass plugin parameters."); stackView.showMessage(title,message); @@ -498,6 +521,7 @@ ApplicationWindow { anchors.fill: parent Behavior on opacity { NumberAnimation{} } } + BusyIndicator { id: busyIndicator anchors.centerIn: parent diff --git a/examples/location/places/views/CategoryDelegate.qml b/examples/location/places/views/CategoryDelegate.qml index 238cbdb5..2080b928 100644 --- a/examples/location/places/views/CategoryDelegate.qml +++ b/examples/location/places/views/CategoryDelegate.qml @@ -60,7 +60,6 @@ Item { signal searchCategory() signal showSubcategories() - width: parent.width height: Math.max(icon.height, labelItem.height * 2) Image { @@ -107,7 +106,7 @@ Item { anchors.verticalCenter: parent.verticalCenter anchors.rightMargin: 15 visible: model.hasModelChildren - iconSource: "../../resources/right.png" + icon.source: Qt.resolvedUrl("../resources/right.png") onClicked: root.showSubcategories() } //! [CategoryModel delegate arrow] diff --git a/examples/location/places/views/CategoryView.qml b/examples/location/places/views/CategoryView.qml index 6d364f35..95614bdf 100644 --- a/examples/location/places/views/CategoryView.qml +++ b/examples/location/places/views/CategoryView.qml @@ -56,11 +56,11 @@ import QtQml.Models //! [CategoryModel view] ListView { id: root - property variant categoryModel - property variant rootIndex + property var categoryModel + property var rootIndex - signal searchCategory(variant category) - signal showSubcategories(variant index) + signal searchCategory(var category) + signal showSubcategories(var index) snapMode: ListView.SnapToItem @@ -69,6 +69,7 @@ ListView { model: root.categoryModel rootIndex: root.rootIndex delegate: CategoryDelegate { + width: ListView.view.width onSearchCategory: root.searchCategory(category); onShowSubcategories: root.showSubcategories(delegeteDataModel.modelIndex(index)) } diff --git a/examples/location/places/views/EditorialDelegate.qml b/examples/location/places/views/EditorialDelegate.qml index 4c424f17..fae686d1 100644 --- a/examples/location/places/views/EditorialDelegate.qml +++ b/examples/location/places/views/EditorialDelegate.qml @@ -56,7 +56,6 @@ Item { id: root signal showEditorial() - width: parent.width height: icon.height + 8 Image { diff --git a/examples/location/places/views/EditorialPage.qml b/examples/location/places/views/EditorialPage.qml index c1cf3f85..4cf92dd8 100644 --- a/examples/location/places/views/EditorialPage.qml +++ b/examples/location/places/views/EditorialPage.qml @@ -55,9 +55,7 @@ import QtQuick.Layouts Item { id: root - property variant editorial - width: parent.width - height: parent.height + property var editorial ScrollView { id: scrollView diff --git a/examples/location/places/views/EditorialView.qml b/examples/location/places/views/EditorialView.qml index 721e26f2..0e086f55 100644 --- a/examples/location/places/views/EditorialView.qml +++ b/examples/location/places/views/EditorialView.qml @@ -55,11 +55,10 @@ import QtLocation ListView { id:view property Place place - signal showEditorial(variant editorial) - width: parent.width - height: parent.height + signal showEditorial(var editorial) model: place.editorialModel delegate: EditorialDelegate { + width: ListView.view.width onShowEditorial: view.showEditorial(model) } } diff --git a/examples/location/places/views/RatingView.qml b/examples/location/places/views/RatingView.qml index 0fc22038..6f51fa73 100644 --- a/examples/location/places/views/RatingView.qml +++ b/examples/location/places/views/RatingView.qml @@ -57,7 +57,7 @@ Row { Repeater { model: Math.ceil(rating) Image { - source: "../../resources/star.png" + source: Qt.resolvedUrl("../resources/star.png") width: size height: size } diff --git a/examples/location/places/views/ReviewDelegate.qml b/examples/location/places/views/ReviewDelegate.qml index b593893d..9c08f03f 100644 --- a/examples/location/places/views/ReviewDelegate.qml +++ b/examples/location/places/views/ReviewDelegate.qml @@ -56,7 +56,6 @@ Item { id: root signal showReview() - width: parent.width height: icon.height + 8 Image { diff --git a/examples/location/places/views/ReviewPage.qml b/examples/location/places/views/ReviewPage.qml index 3698c719..ad803240 100644 --- a/examples/location/places/views/ReviewPage.qml +++ b/examples/location/places/views/ReviewPage.qml @@ -55,9 +55,7 @@ import QtQuick.Layouts Item { id: root - property variant review - width: parent.width - height: parent.height + property var review ScrollView { id: scrollView diff --git a/examples/location/places/views/ReviewView.qml b/examples/location/places/views/ReviewView.qml index 953433b4..820c34a9 100644 --- a/examples/location/places/views/ReviewView.qml +++ b/examples/location/places/views/ReviewView.qml @@ -55,11 +55,10 @@ import QtLocation ListView { id:view property Place place - signal showReview(variant review) - width: parent.width - height: parent.height + signal showReview(var review) model: place.reviewModel delegate: ReviewDelegate { + width: ListView.view.width onShowReview: view.showReview(model) } } diff --git a/examples/location/places/views/SearchResultDelegate.qml b/examples/location/places/views/SearchResultDelegate.qml index 991d377e..6560e1ba 100644 --- a/examples/location/places/views/SearchResultDelegate.qml +++ b/examples/location/places/views/SearchResultDelegate.qml @@ -57,10 +57,9 @@ import "../helper.js" as Helper Item { id: root - signal showPlaceDetails(variant place,variant distance) + signal showPlaceDetails(var place,var distance) signal searchFor(string query) - width: parent.width height: childrenRect.height //! [PlaceSearchModel place delegate] @@ -102,7 +101,7 @@ Item { Image { // anchors.verticalCenter: parent.verticalCenter id:icon - source: place.favorite ? "../../resources/star.png" : place.icon.url() + source: place.favorite ? Qt.resolvedUrl("../resources/star.png") : place.icon.url() Layout.rowSpan: 2 } diff --git a/examples/location/places/views/SearchResultView.qml b/examples/location/places/views/SearchResultView.qml index 52da14ce..43b9ab81 100644 --- a/examples/location/places/views/SearchResultView.qml +++ b/examples/location/places/views/SearchResultView.qml @@ -56,22 +56,19 @@ import QtQuick.Layouts //! [PlaceSearchModel place list] ListView { id: searchView - width: parent.width - height: parent.height - property variant placeSearchModel - signal showPlaceDetails(variant place, variant distance) + property var placeSearchModel + signal showPlaceDetails(var place, var distance) signal showMap() model: placeSearchModel delegate: SearchResultDelegate { - onShowPlaceDetails: searchView.showPlaceDetails(place, distance) - onSearchFor: placeSearchModel.searchForText(query); + width: ListView.view.width + onShowPlaceDetails: function (place, distance) { searchView.showPlaceDetails(place, distance) } + onSearchFor: function (query) { placeSearchModel.searchForText(query) } } - footer: - - RowLayout { + footer: RowLayout { width: parent.width Button { diff --git a/examples/location/places/views/SuggestionView.qml b/examples/location/places/views/SuggestionView.qml index b2e87723..990e2541 100644 --- a/examples/location/places/views/SuggestionView.qml +++ b/examples/location/places/views/SuggestionView.qml @@ -54,14 +54,14 @@ import QtQuick.Controls //! [PlaceSearchSuggestionModel view 1] ListView { id: suggestionView - property variant suggestionModel + property var suggestionModel signal suggestionSelected(string text) //! [PlaceSearchSuggestionModel view 1] snapMode: ListView.SnapToItem //! [PlaceSearchSuggestionModel view 2] model: suggestionModel delegate: Item { - width: parent.width + width. ListView.view.width height: label.height * 1.5 Label { id: label |