/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.0 import QtPositioning 5.2 import QtLocation 5.3 import QtLocation.examples 5.0 import "content/places" Item { id: page width: (parent && parent.width > 0) ? parent.width : 360 height: (parent && parent.height > 0) ? parent.height : 640 property variant map property variant startLocation property variant searchRegion: QtPositioning.circle(startLocation) property variant searchRegionItem property Plugin favoritesPlugin onMapChanged: editPlaceDialog.prepareDialog() Binding { target: page property: "startLocation" value: map ? map.center : QtPositioning.coordinate() } Rectangle { id: backgroundRect anchors.fill: parent color: "lightgrey" z: 2 } //=====================Menu===================== Menu { id:mainMenu anchors.bottom: parent.bottom z: backgroundRect.z + 3 Component.onCompleted: { addItem("Provider"); addItem("New"); addItem("Search"); } onClicked: page.state = page.state == "" ? button : ""; } Menu { id: providerMenu z: backgroundRect.z + 2 y: page.height horizontalOrientation: false exclusive: true Component.onCompleted: { var plugins = getPlacesPlugins() for (var i = 0; i 0) && !searchResultTab.open PropertyChanges { target: searchResultTab; opacity: 1 } }, State { name: "Open" when: (placeSearchModel.count > 0) && searchResultTab.open PropertyChanges { target: searchResultTab; y: mainMenu.height; opacity: 1 } } ] } Component { id: mapComponent MapComponent { z: backgroundRect.z + 1 anchors { top: searchBox.bottom bottom: mainMenu.top left: page.left right: page.right } MapItemView { model: placeSearchModel 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 sourceItem: Image { id: image source: "resources/marker.png" MouseArea { anchors.fill: parent onClicked: { searchResultView.showPlaceDetails({ distance: model.distance, place: model.place, }); searchResultTab.state = "Open"; } } } } } } } function createMap(placesPlugin) { var mapPlugin; if (placesPlugin.supportsMapping()) { mapPlugin = placesPlugin; } else { mapPlugin = Qt.createQmlObject('import QtLocation 5.3; Plugin { required.mapping: Plugin.AnyMappingFeatures;' + 'parameters: pluginParametersFromMap(pluginParameters) }', page); } if (map) map.destroy(); map = mapComponent.createObject(page); map.plugin = mapPlugin; } function getPlacesPlugins() { var plugin = Qt.createQmlObject('import QtLocation 5.3; Plugin {}', page); 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]+ '"}', page) if (tempPlugin.supportsPlaces()) myArray.push(tempPlugin.name) } return myArray; } function pluginParametersFromMap(pluginParameters) { var parameters = new Array() for (var prop in pluginParameters){ var parameter = Qt.createQmlObject('import QtLocation 5.3; PluginParameter{ name: "'+ prop + '"; value: "' + pluginParameters[prop]+'"}',page) parameters.push(parameter) } return parameters //createMap(placesPlugin) } //=====================States of page===================== states: [ State { name: "Provider" PropertyChanges { target: providerMenu; y: page.height - providerMenu.height - mainMenu.height } }, State { name: "New" PropertyChanges { target: newMenu; y: page.height - newMenu.height - mainMenu.height } }, State { name: "Search" PropertyChanges { target: searchMenu; y: page.height - searchMenu.height - mainMenu.height } }, State { name: "NewPlace" PropertyChanges { target: editPlaceDialog; title: "New Place"; opacity: 1 } }, State { name: "NewCategory" PropertyChanges { target: editCategoryDialog; title: "New Category"; opacity: 1 } }, State { name: "EditPlace" PropertyChanges { target: editPlaceDialog; title: "Edit Place"; opacity: 1 } }, State { name: "EditCategory" PropertyChanges { target: editCategoryDialog; opacity: 1 } }, State { name: "Search Center" PropertyChanges { target: searchCenterDialog; opacity: 1 } StateChangeScript { script: searchCenterDialog.prepareDialog() } }, State { name: "Search Bounding Box" PropertyChanges { target: searchBoxDialog; opacity: 1 } StateChangeScript { script: searchBoxDialog.prepareDialog() } }, State { name: "Search Bounding Circle" PropertyChanges { target: searchCircleDialog; opacity: 1 } StateChangeScript { script: searchCircleDialog.prepareDialog() } }, State { name: "Search Options" PropertyChanges { target: optionsDialog; opacity: 1 } StateChangeScript { script: optionsDialog.prepareDialog() } } ] //=====================State-transition animations for page===================== transitions: [ Transition { to: "" NumberAnimation { properties: "opacity,y,x,rotation" ; duration: 500; easing.type: Easing.Linear } }, Transition { to: "Provider" NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } }, Transition { to: "New" NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } }, Transition { to: "Search" NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear } } ] }