summaryrefslogtreecommitdiff
path: root/examples/location/places
diff options
context:
space:
mode:
Diffstat (limited to 'examples/location/places')
-rw-r--r--examples/location/places/items/MapComponent.qml32
-rw-r--r--examples/location/places/items/SearchBar.qml9
-rw-r--r--examples/location/places/places.qml101
-rw-r--r--examples/location/places/resources/left.pngbin141 -> 6466 bytes
-rw-r--r--examples/location/places/resources/right.pngbin147 -> 6417 bytes
-rw-r--r--examples/location/places/resources/search.pngbin259 -> 7154 bytes
-rw-r--r--examples/location/places/views/CategoryDelegate.qml28
-rw-r--r--examples/location/places/views/CategoryView.qml2
8 files changed, 90 insertions, 82 deletions
diff --git a/examples/location/places/items/MapComponent.qml b/examples/location/places/items/MapComponent.qml
index fe282564..90ad0691 100644
--- a/examples/location/places/items/MapComponent.qml
+++ b/examples/location/places/items/MapComponent.qml
@@ -7,8 +7,8 @@ import QtPositioning
import QtLocation
import "../helper.js" as Helper
-Map {
- id: map
+MapView {
+ id: view
property bool followme: false
property var scaleLengths: [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000]
@@ -41,32 +41,30 @@ Map {
scaleText.text = text
}
- center {
+ map.center {
// The Qt Company in Oslo
latitude: 59.9485
longitude: 10.7686
}
- gesture.flickDeceleration: 3000
- gesture.enabled: true
- onCopyrightLinkActivated: Qt.openUrlExternally(link)
+ map.onCopyrightLinkActivated: Qt.openUrlExternally(link)
- onCenterChanged:{
+ map.onCenterChanged: {
scaleTimer.restart()
if (map.followme)
if (map.center !== positionSource.position.coordinate) map.followme = false
}
- onZoomLevelChanged:{
+ map.onZoomLevelChanged: {
scaleTimer.restart()
if (map.followme) map.center = positionSource.position.coordinate
}
- onWidthChanged:{
+ onWidthChanged: {
scaleTimer.restart()
}
- onHeightChanged:{
+ onHeightChanged: {
scaleTimer.restart()
}
@@ -84,7 +82,7 @@ Map {
running: false
repeat: false
onTriggered: {
- map.calculateScale()
+ view.calculateScale()
}
}
@@ -123,12 +121,13 @@ Map {
text: "0 m"
}
Component.onCompleted: {
- map.calculateScale();
+ view.calculateScale();
}
}
MapQuickItem {
- id: poiTheQtComapny
+ parent: view.map
+ id: poiTheQtCompany
sourceItem: Rectangle { width: 14; height: 14; color: "#e41e25"; border.width: 2; border.color: "white"; smooth: true; radius: 7 }
coordinate {
latitude: 59.9485
@@ -139,6 +138,7 @@ Map {
}
MapQuickItem {
+ parent: view.map
sourceItem: Text{
text: "The Qt Company"
color:"#242424"
@@ -146,8 +146,8 @@ Map {
styleColor: "#ECECEC"
style: Text.Outline
}
- coordinate: poiTheQtComapny.coordinate
- anchorPoint: Qt.point(-poiTheQtComapny.sourceItem.width * 0.5,poiTheQtComapny.sourceItem.height * 1.5)
+ coordinate: poiTheQtCompany.coordinate
+ anchorPoint: Qt.point(-poiTheQtCompany.sourceItem.width * 0.5,poiTheQtCompany.sourceItem.height * 1.5)
}
PositionSource{
@@ -155,7 +155,7 @@ Map {
active: followme
onPositionChanged: {
- map.center = positionSource.position.coordinate
+ view.map.center = positionSource.position.coordinate
}
}
diff --git a/examples/location/places/items/SearchBar.qml b/examples/location/places/items/SearchBar.qml
index a06fdba2..706e40cf 100644
--- a/examples/location/places/items/SearchBar.qml
+++ b/examples/location/places/items/SearchBar.qml
@@ -29,10 +29,10 @@ ToolBar {
}
}
+ height: searchBar.height
RowLayout {
id: searchBar
width: parent.width
- height: parent.height
Behavior on opacity { NumberAnimation{} }
visible: opacity ? true : false
TextField {
@@ -42,6 +42,8 @@ ToolBar {
property bool ignoreTextChange: false
placeholderText: qsTr("Type place...")
Layout.fillWidth: true
+ Layout.topMargin: 2
+ Layout.bottomMargin: 2
onTextChanged: {
if (!ignoreTextChange)
searchTextChanged(text)
@@ -52,11 +54,15 @@ ToolBar {
id: searchButton
icon.source: Qt.resolvedUrl("../resources/search.png")
onClicked: doSearch(searchText.text)
+ Layout.topMargin: 2
+ Layout.bottomMargin: 2
}
ToolButton {
id: categoryButton
icon.source: Qt.resolvedUrl("../resources/categories.png")
onClicked: showCategories()
+ Layout.topMargin: 2
+ Layout.bottomMargin: 2
}
}
@@ -82,4 +88,3 @@ ToolBar {
}
}
}
-
diff --git a/examples/location/places/places.qml b/examples/location/places/places.qml
index 329cc685..2698a56c 100644
--- a/examples/location/places/places.qml
+++ b/examples/location/places/places.qml
@@ -10,14 +10,12 @@ import "items"
ApplicationWindow {
id: appWindow
- property Map map
+ property MapView view
property var parameters
- property var searchLocation: map ? map.center : QtPositioning.coordinate()
- property var searchRegion: QtPositioning.circle(searchLocation)
+ property var searchLocation: view ? view.map.center : QtPositioning.coordinate()
+ property var searchRegion: QtPositioning.circle(searchLocation, 5000)
property var searchRegionItem
- property Plugin favoritesPlugin
-
function getPlugins() {
var plugin = Qt.createQmlObject('import QtLocation; Plugin {}', appWindow);
var myArray = new Array;
@@ -53,15 +51,21 @@ ApplicationWindow {
else
plugin = Qt.createQmlObject ('import QtLocation; Plugin{ name:"' + provider + '"}', appWindow)
- if (map)
- map.destroy();
- map = mapComponent.createObject(page);
- map.plugin = plugin;
- map.zoomLevel = (map.maximumZoomLevel - map.minimumZoomLevel)/2
+ if (view)
+ view.destroy();
+ view = mapComponent.createObject(page);
+ view.map.plugin = plugin;
+ view.map.zoomLevel = (view.map.maximumZoomLevel - view.map.minimumZoomLevel)/2
categoryModel.plugin = plugin;
categoryModel.update();
placeSearchModel.plugin = plugin;
suggestionModel.plugin = plugin;
+
+ searchRegionItem = Qt.createQmlObject('import QtLocation; MapCircle { parent: view.map; color: "#46a2da"; border.color: "#190a33"; border.width: 2; opacity: 0.25 }', view.map);
+ searchRegionItem.center = searchRegion.center;
+ searchRegionItem.radius = searchRegion.radius;
+ view.map.addMapItem(searchRegionItem);
+
}
title: qsTr("Places")
@@ -82,7 +86,7 @@ ApplicationWindow {
providerMenu.contentData[i].checked = providerMenu.contentData[i].text === providerName
}
createMap(providerName)
- if (map.error === Map.NoError) {
+ if (view.map.error === Map.NoError) {
settingsMenu.create(settings)
} else {
mainMenu.clearMenu(settingsMenu)
@@ -93,7 +97,7 @@ ApplicationWindow {
stackView.pop({item:page,immediate: true})
switch (setting) {
case "Search Center":
- stackView.push(Qt.resolvedUrl("forms/SearchCenter.qml"), { "coordinate": map.center })
+ stackView.push(Qt.resolvedUrl("forms/SearchCenter.qml"), { "coordinate": view.map.center })
stackView.currentItem.changeSearchCenter.connect(stackView.changeSearchCenter)
stackView.currentItem.closeForm.connect(stackView.closeForm)
break
@@ -108,7 +112,7 @@ ApplicationWindow {
stackView.currentItem.closeForm.connect(stackView.closeForm)
break
case "Search Options":
- stackView.push(Qt.resolvedUrl("forms/SearchOptions.qml"), { "plugin": map.plugin, "model": placeSearchModel })
+ stackView.push(Qt.resolvedUrl("forms/SearchOptions.qml"), { "plugin": view.map.plugin, "model": placeSearchModel })
stackView.currentItem.changeSearchSettings.connect(stackView.changeSearchSettings)
stackView.currentItem.closeForm.connect(stackView.closeForm)
break
@@ -127,8 +131,8 @@ ApplicationWindow {
stackView.currentItem &&
stackView.currentItem.objectName != "suggestionView" ? false : true
onShowCategories: {
- if (map && map.plugin) {
- stackView.pop({tem:page,immediate: true})
+ if (view && view.map.plugin) {
+ stackView.pop({item: page,immediate: true})
stackView.enterCategory()
}
}
@@ -288,9 +292,9 @@ ApplicationWindow {
function changeSearchCenter(coordinate)
{
stackView.pop(page)
- map.center = coordinate;
+ view.map.center = coordinate;
if (searchRegionItem) {
- map.removeMapItem(searchRegionItem);
+ view.map.removeMapItem(searchRegionItem);
searchRegionItem.destroy();
}
}
@@ -298,51 +302,43 @@ ApplicationWindow {
function changeSearchBoundingBox(coordinate,widthDeg,heightDeg)
{
stackView.pop(page)
- map.center = coordinate
- searchRegion = QtPositioning.rectangle(map.center, widthDeg, heightDeg)
+ view.map.center = coordinate
+ searchRegion = QtPositioning.rectangle(view.map.center, widthDeg, heightDeg)
if (searchRegionItem) {
- map.removeMapItem(searchRegionItem);
+ view.map.removeMapItem(searchRegionItem);
searchRegionItem.destroy();
}
- searchRegionItem = Qt.createQmlObject('import QtLocation; MapRectangle { color: "#46a2da"; border.color: "#190a33"; border.width: 2; opacity: 0.25 }', page, "MapRectangle");
+ searchRegionItem = Qt.createQmlObject('import QtLocation; MapRectangle { parent: view.map; color: "#46a2da"; border.color: "#190a33"; border.width: 2; opacity: 0.25 }', page);
searchRegionItem.topLeft = searchRegion.topLeft;
searchRegionItem.bottomRight = searchRegion.bottomRight;
- map.addMapItem(searchRegionItem);
+ view.map.addMapItem(searchRegionItem);
}
function changeSearchBoundingCircle(coordinate,radius)
{
stackView.pop(page)
- map.center = coordinate;
+ view.map.center = coordinate;
searchRegion = QtPositioning.circle(coordinate, radius)
if (searchRegionItem) {
- map.removeMapItem(searchRegionItem);
+ view.map.removeMapItem(searchRegionItem);
searchRegionItem.destroy();
}
- searchRegionItem = Qt.createQmlObject('import QtLocation; MapCircle { color: "#46a2da"; border.color: "#190a33"; border.width: 2; opacity: 0.25 }', page, "MapRectangle");
+ searchRegionItem = Qt.createQmlObject('import QtLocation; MapCircle { parent: view.map; color: "#46a2da"; border.color: "#190a33"; border.width: 2; opacity: 0.25 }', page);
searchRegionItem.center = searchRegion.center;
searchRegionItem.radius = searchRegion.radius;
- map.addMapItem(searchRegionItem);
+ view.map.addMapItem(searchRegionItem);
}
function changeSearchSettings(orderByDistance, orderByName, locales)
{
stackView.pop(page)
- /*if (isFavoritesEnabled) {
- if (favoritesPlugin == null)
- favoritesPlugin = Qt.createQmlObject('import QtLocation; Plugin { name: "places_jsondb" }', page);
- favoritesPlugin.parameters = pluginParametersFromMap(pluginParameters);
- placeSearchModel.favoritesPlugin = favoritesPlugin;
- } else {
- placeSearchModel.favoritesPlugin = null;
- }*/
placeSearchModel.favoritesPlugin = null;
placeSearchModel.relevanceHint = orderByDistance ? PlaceSearchModel.DistanceHint :
orderByName ? PlaceSearchModel.LexicalPlaceNameHint :
PlaceSearchModel.UnspecifiedHint;
- map.plugin.locales = locales.split(Qt.locale().groupSeparator);
+ view.map.plugin.locales = locales.split(Qt.locale().groupSeparator);
}
//! [PlaceRecommendationModel search]
@@ -431,11 +427,12 @@ ApplicationWindow {
MapComponent {
width: page.width
height: page.height
+ id: view
- onErrorChanged: {
+ map.onErrorChanged: {
if (map.error !== Map.NoError) {
var title = qsTr("ProviderError");
- var message = map.errorString + "<br/><br/><b>" + qsTr("Try to select other provider") + "</b>";
+ var message = map.errorString + "<br/><br/><b>" + qsTr("Try to select other provider") + "</b>";
if (map.error === Map.MissingRequiredParameterError)
message += "<br/>" + qsTr("or see") + " \'mapviewer --help\' "
+ qsTr("how to pass plugin parameters.");
@@ -445,20 +442,32 @@ ApplicationWindow {
MapItemView {
model: placeSearchModel
+ parent: view.map
+
delegate: MapQuickItem {
coordinate: model.type === PlaceSearchModel.PlaceResult ? place.location.coordinate : QtPositioning.coordinate()
-
visible: model.type === PlaceSearchModel.PlaceResult
- anchorPoint.x: image.width * 0.28
- anchorPoint.y: image.height
+ anchorPoint.x: image.width * 0.5
+ anchorPoint.y: image.height * 0.5
- sourceItem: Image {
- id: image
- source: "resources/marker.png"
- MouseArea {
- anchors.fill: parent
- onClicked: stackView.showPlaceDatails(model.place,model.distance)
+ sourceItem: Column {
+ TapHandler {
+ onTapped: stackView.showPlaceDatails(model.place,model.distance)
+ }
+ HoverHandler {
+ cursorShape: Qt.PointingHandCursor
+ }
+
+ Image {
+ id: image
+ source: place.icon.url(Qt.size(64,64))
+ anchors.horizontalCenter: parent.horizontalCenter;
+ }
+ Text {
+ id: text
+ text: title;
+ font.bold: true
}
}
}
diff --git a/examples/location/places/resources/left.png b/examples/location/places/resources/left.png
index 8241a47a..3badbac1 100644
--- a/examples/location/places/resources/left.png
+++ b/examples/location/places/resources/left.png
Binary files differ
diff --git a/examples/location/places/resources/right.png b/examples/location/places/resources/right.png
index 37a1b1d3..f4d34e70 100644
--- a/examples/location/places/resources/right.png
+++ b/examples/location/places/resources/right.png
Binary files differ
diff --git a/examples/location/places/resources/search.png b/examples/location/places/resources/search.png
index ce8c27aa..e2bbd134 100644
--- a/examples/location/places/resources/search.png
+++ b/examples/location/places/resources/search.png
Binary files differ
diff --git a/examples/location/places/views/CategoryDelegate.qml b/examples/location/places/views/CategoryDelegate.qml
index ef013de8..75ff071b 100644
--- a/examples/location/places/views/CategoryDelegate.qml
+++ b/examples/location/places/views/CategoryDelegate.qml
@@ -26,7 +26,7 @@ Item {
Rectangle {
anchors.fill: parent
color: "#44ffffff"
- visible: mouse.pressed
+ visible: tapHanlder.pressed
}
//! [CategoryModel delegate text]
@@ -34,14 +34,19 @@ Item {
id: labelItem
text: category.name
anchors.left: icon.right
+ anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
- anchors.right: arrow.left
}
- MouseArea {
- id: mouse
- anchors.fill: parent
- onClicked: root.searchCategory()
+ TapHandler {
+ id: tapHanlder
+ onTapped: {
+ if (model.hasModelChildren) {
+ root.showSubcategories()
+ } else {
+ root.searchCategory()
+ }
+ }
}
//! [CategoryModel delegate text]
@@ -52,15 +57,4 @@ Item {
height: 1
color: "#46a2da"
}
- //! [CategoryModel delegate arrow]
- ToolButton {
- id: arrow
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.rightMargin: 15
- visible: model.hasModelChildren
- 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 7e5fc33a..96b798cb 100644
--- a/examples/location/places/views/CategoryView.qml
+++ b/examples/location/places/views/CategoryView.qml
@@ -24,7 +24,7 @@ ListView {
delegate: CategoryDelegate {
width: ListView.view.width
onSearchCategory: root.searchCategory(category);
- onShowSubcategories: root.showSubcategories(delegeteDataModel.modelIndex(index))
+ onShowSubcategories: root.showSubcategories(delegeteDataModel.modelIndex(index));
}
}
}