summaryrefslogtreecommitdiffstats
path: root/examples/location/places/items
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-04-30 11:43:44 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-05-27 12:23:28 +0000
commita5d615f5b49b29f91f979b4b338f7febbe445ebf (patch)
treec36c0d873259e0bbf8e0bb8849e6882de196e942 /examples/location/places/items
parent208a3723a02cda6ad1a99736c90bdc538c22a39a (diff)
Rewrite 'places' example to use qtquickcontrols
This is a squash commit of: * add qtquickcontrols window to 'places' example * add MenuBar to 'places' example * replace Slider in 'places' example * add stackView and MessageForm to 'places' example * replace SearchBox in 'places' example * replace SearchCenter dialog in 'places' example * replace SearchBoundingBox dialog in 'places' example * replace SearchBoundingCircle dialog in 'places' example * tune up categoryDelegate in 'places' example * tune up SearchResultDelegate in 'places' example * tune up PlacesDelegate in 'places' example * replace OptionsDialog in 'places' example * remove 'common' controls from location * clean up filenames in 'places' example * update MapComponent in 'places' example * code style formating of places.qml * remove backgroundRect from 'places' example * tune up EditorialPage in 'places' example * tune up ImageView in 'places' example * tune up ReviewPage in 'places' example * tune up SuggestionView in 'places' example * update imports version numbers in 'places' example * change searchBox and busyIndicator * update design in 'places' example Change-Id: I680c8b88f26689cb9728ee61617f7d2d3aa2a172 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'examples/location/places/items')
-rw-r--r--examples/location/places/items/MainMenu.qml91
-rw-r--r--examples/location/places/items/MapComponent.qml214
-rw-r--r--examples/location/places/items/SearchBar.qml122
3 files changed, 427 insertions, 0 deletions
diff --git a/examples/location/places/items/MainMenu.qml b/examples/location/places/items/MainMenu.qml
new file mode 100644
index 00000000..1437d3c3
--- /dev/null
+++ b/examples/location/places/items/MainMenu.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company Ltd 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.5
+import QtQuick.Controls 1.4
+import QtLocation 5.5
+
+MenuBar {
+ property variant providerMenu: providerMenu
+ property variant settingsMenu: settingsMenu
+
+ signal selectProvider(string providerName)
+ signal selectSetting(string setting);
+
+
+
+ Menu {
+ id: providerMenu
+ title: qsTr("Provider")
+
+ function createMenu(plugins)
+ {
+ clear()
+ for (var i = 0; i < plugins.length; i++) {
+ createProviderMenuItem(plugins[i]);
+ }
+ }
+
+ function createProviderMenuItem(provider)
+ {
+ var item = addItem(provider);
+ item.checkable = true;
+ item.triggered.connect(function(){selectProvider(provider)})
+ }
+ }
+
+ Menu {
+ 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")})
+ }
+ }
+}
diff --git a/examples/location/places/items/MapComponent.qml b/examples/location/places/items/MapComponent.qml
new file mode 100644
index 00000000..de4e04a7
--- /dev/null
+++ b/examples/location/places/items/MapComponent.qml
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company Ltd 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.5
+import QtQuick.Controls 1.4
+import QtPositioning 5.5
+import QtLocation 5.5
+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]
+
+ function calculateScale()
+ {
+ var coord1, coord2, dist, text, f
+ f = 0
+ coord1 = map.toCoordinate(Qt.point(0,scale.y))
+ coord2 = map.toCoordinate(Qt.point(0+scaleImage.sourceSize.width,scale.y))
+ dist = Math.round(coord1.distanceTo(coord2))
+
+ if (dist === 0) {
+ // not visible
+ } else {
+ for (var i = 0; i < scaleLengths.length-1; i++) {
+ if (dist < (scaleLengths[i] + scaleLengths[i+1]) / 2 ) {
+ f = scaleLengths[i] / dist
+ dist = scaleLengths[i]
+ break;
+ }
+ }
+ if (f === 0) {
+ f = dist / scaleLengths[i]
+ dist = scaleLengths[i]
+ }
+ }
+
+ text = Helper.formatDistance(dist)
+ scaleImage.width = (scaleImage.sourceSize.width * f) - 2 * scaleImageLeft.sourceSize.width
+ scaleText.text = text
+ }
+
+ center {
+ // The Qt Company in Oslo
+ latitude: 59.9485
+ longitude: 10.7686
+ }
+
+ gesture.flickDeceleration: 3000
+ gesture.enabled: true
+ onCopyrightLinkActivated: Qt.openUrlExternally(link)
+
+ onCenterChanged:{
+ scaleTimer.restart()
+ if (map.followme)
+ if (map.center != positionSource.position.coordinate) map.followme = false
+ }
+
+ onZoomLevelChanged:{
+ scaleTimer.restart()
+ if (map.followme) map.center = positionSource.position.coordinate
+ }
+
+ onWidthChanged:{
+ scaleTimer.restart()
+ }
+
+ onHeightChanged:{
+ scaleTimer.restart()
+ }
+
+ Keys.onPressed: {
+ if (event.key === Qt.Key_Plus) {
+ map.zoomLevel++
+ } else if (event.key === Qt.Key_Minus) {
+ map.zoomLevel--
+ }
+ }
+
+ Timer {
+ id: scaleTimer
+ interval: 100
+ running: false
+ repeat: false
+ onTriggered: {
+ map.calculateScale()
+ }
+ }
+
+ Item {
+ id: scale
+ visible: scaleText.text != "0 m"
+ z: map.z + 3
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ anchors.margins: 20
+ height: scaleText.height * 2
+ width: scaleImage.width
+
+ Image {
+ id: scaleImageLeft
+ source: "../../resources/scale_end.png"
+ anchors.bottom: parent.bottom
+ anchors.right: scaleImage.left
+ }
+ Image {
+ id: scaleImage
+ source: "../../resources/scale.png"
+ anchors.bottom: parent.bottom
+ anchors.right: scaleImageRight.left
+ }
+ Image {
+ id: scaleImageRight
+ source: "../../resources/scale_end.png"
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ }
+ Label {
+ id: scaleText
+ color: "#004EAE"
+ anchors.centerIn: parent
+ text: "0 m"
+ }
+ Component.onCompleted: {
+ map.calculateScale();
+ }
+ }
+
+ MapQuickItem {
+ id: poiTheQtComapny
+ sourceItem: Rectangle { width: 14; height: 14; color: "#e41e25"; border.width: 2; border.color: "white"; smooth: true; radius: 7 }
+ coordinate {
+ latitude: 59.9485
+ longitude: 10.7686
+ }
+ opacity:1.0
+ anchorPoint: Qt.point(sourceItem.width/2, sourceItem.height/2)
+ }
+
+ MapQuickItem {
+ sourceItem: Text{
+ text: "The Qt Company"
+ color:"#242424"
+ font.bold: true
+ styleColor: "#ECECEC"
+ style: Text.Outline
+ }
+ coordinate: poiTheQtComapny.coordinate
+ anchorPoint: Qt.point(-poiTheQtComapny.sourceItem.width * 0.5,poiTheQtComapny.sourceItem.height * 1.5)
+ }
+
+ PositionSource{
+ id: positionSource
+ active: followme
+
+ onPositionChanged: {
+ map.center = positionSource.position.coordinate
+ }
+ }
+
+ Slider {
+ id: zoomSlider;
+ z: map.z + 3
+ minimumValue: map.minimumZoomLevel;
+ maximumValue: map.maximumZoomLevel;
+ anchors.margins: 10
+ anchors.bottom: scale.top
+ anchors.top: parent.top
+ anchors.right: parent.right
+ orientation : Qt.Vertical
+ value: map.zoomLevel
+ onValueChanged: {
+ map.zoomLevel = value
+ }
+ }
+}
diff --git a/examples/location/places/items/SearchBar.qml b/examples/location/places/items/SearchBar.qml
new file mode 100644
index 00000000..e5a3b330
--- /dev/null
+++ b/examples/location/places/items/SearchBar.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company Ltd 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.5
+import QtQuick.Controls 1.4
+import QtQuick.Layouts 1.2
+
+ToolBar {
+
+ property bool busyIndicatorRunning : false
+ property bool searchBarVisbile: true
+
+ signal doSearch(string searchText)
+ signal searchTextChanged(string searchText)
+ signal showCategories()
+ signal goBack()
+ signal showMap()
+
+ onSearchBarVisbileChanged: {
+ searchBar.opacity = searchBarVisbile ? 1 : 0
+ backBar.opacity = searchBarVisbile ? 0 : 1
+ }
+
+ function showSearch(text) {
+ if (text != null) {
+ searchText.ignoreTextChange = true
+ searchText.text = text
+ searchText.ignoreTextChange = false
+ }
+ }
+
+ RowLayout {
+ id: searchBar
+ width: parent.width
+ height: parent.height
+ Behavior on opacity { NumberAnimation{} }
+ visible: opacity ? true : false
+ TextField {
+ id: searchText
+ Behavior on opacity { NumberAnimation{} }
+ visible: opacity ? true : false
+ property bool ignoreTextChange: false
+ placeholderText: qsTr("Type place...")
+ Layout.fillWidth: true
+ onTextChanged: {
+ if (!ignoreTextChange)
+ searchTextChanged(text)
+ }
+ onAccepted: doSearch(searchText.text)
+ }
+ ToolButton {
+ id: searchButton
+ iconSource: "../../resources/search.png"
+ onClicked: doSearch(searchText.text)
+ }
+ ToolButton {
+ id: categoryButton
+ iconSource: "../../resources/categories.png"
+ onClicked: showCategories()
+ }
+ }
+
+ RowLayout {
+ id: backBar
+ width: parent.width
+ height: parent.height
+ opacity: 0
+ Behavior on opacity { NumberAnimation{} }
+ visible: opacity ? true : false
+ ToolButton {
+ id: backButton
+ iconSource: "../../resources/left.png"
+ onClicked: goBack()
+ }
+ ToolButton {
+ id: mapButton
+ iconSource: "../../resources/search.png"
+ onClicked: showMap()
+ }
+ Item {
+ Layout.fillWidth: true
+ }
+ }
+}
+