diff options
Diffstat (limited to 'examples/location/places/content')
20 files changed, 2783 insertions, 0 deletions
diff --git a/examples/location/places/content/places/CategoryDelegate.qml b/examples/location/places/content/places/CategoryDelegate.qml new file mode 100644 index 00000000..4bb2b8e0 --- /dev/null +++ b/examples/location/places/content/places/CategoryDelegate.qml @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 +import QtLocation.examples 5.0 + +Item { + id: root + + property bool showSave: true + property bool showRemove: true + property bool showChildren: true + + signal clicked + signal arrowClicked + signal crossClicked + signal editClicked + + width: parent.width + height: textItem.height + + Item { + id: textItem + anchors.left: parent.left + anchors.right: arrow.left + anchors.verticalCenter: parent.verticalCenter + + height: Math.max(icon.height, name.height) + + Image { + id: icon + + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + source: category.icon.url() + } + + //! [CategoryModel delegate text] + Text { + id: name + + anchors.left: icon.right + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + + verticalAlignment: Text.AlignVCenter + + text: category.name + elide: Text.ElideRight + } + + MouseArea { + anchors.fill: parent + onClicked: root.clicked() + } + //! [CategoryModel delegate text] + } + + //! [CategoryModel delegate icon] + IconButton { + id: edit + + anchors.right: cross.left + anchors.verticalCenter: parent.verticalCenter + + visible: (placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.SaveCategoryFeature) : false) + && showSave + + source: "../../resources/pencil.png" + hoveredSource: "../../resources/pencil_hovered.png" + pressedSource: "../../resources/pencil_pressed.png" + + onClicked: root.editClicked() + } + + IconButton { + id: cross + + anchors.right: arrow.left + anchors.verticalCenter: parent.verticalCenter + visible: (placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.RemoveCategoryFeature) : false) + && showRemove + + source: "../../resources/cross.png" + hoveredSource: "../../resources/cross_hovered.png" + pressedSource: "../../resources/cross_pressed.png" + + onClicked: root.crossClicked() + } + + IconButton { + id: arrow + + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + visible: model.hasModelChildren && showChildren + + source: "../../resources/right.png" + pressedSource: "../../resources/right_pressed.png" + + onClicked: root.arrowClicked() + } + //! [CategoryModel delegate icon] +} diff --git a/examples/location/places/content/places/CategoryDialog.qml b/examples/location/places/content/places/CategoryDialog.qml new file mode 100644 index 00000000..289d8501 --- /dev/null +++ b/examples/location/places/content/places/CategoryDialog.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 +import QtLocation.examples 5.0 + +InputDialog { + title: "Edit Category" + + property Category category + + Behavior on opacity { NumberAnimation { duration: 500 } } + + Component.onCompleted: prepareDialog() + onCategoryChanged: prepareDialog() + + function prepareDialog() { + setModel([ + ["Name", category ? category.name : ""] + ]); + } + + //! [Category save] + onGoButtonClicked: { + var modifiedCategory = category ? category : Qt.createQmlObject('import QtLocation 5.0; Category { }', page); + modifiedCategory.plugin = placesPlugin; + + modifiedCategory.name = dialogModel.get(0).inputText; + + category = modifiedCategory; + + category.save(); + } + //! [Category save] +} diff --git a/examples/location/places/content/places/CategoryView.qml b/examples/location/places/content/places/CategoryView.qml new file mode 100644 index 00000000..9b28e892 --- /dev/null +++ b/examples/location/places/content/places/CategoryView.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 +import QtLocation.examples 5.0 + + +//! [CategoryModel view 1] +ListView { + id: root + + property bool showSave: true + property bool showRemove: true + property bool showChildren: true + + signal categoryClicked(variant category) + signal editClicked(variant category) +//! [CategoryModel view 1] + + anchors.topMargin: 10 + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.right: parent.right + anchors.rightMargin: 10 + + clip: true + snapMode: ListView.SnapToItem + spacing: 5 + +//! [CategoryModel view 2] + header: IconButton { + source: "../../resources/left.png" + pressedSource: "../../resources/left_pressed.png" + onClicked: categoryListModel.rootIndex = categoryListModel.parentModelIndex() + } +//! [CategoryModel view 2] + +//! [CategoryModel view 3] + model: VisualDataModel { + id: categoryListModel + model: categoryModel + delegate: CategoryDelegate { + id: categoryDelegate + + showSave: root.showSave + showRemove: root.showRemove + showChildren: root.showChildren + + onClicked: root.categoryClicked(category); + onArrowClicked: categoryListModel.rootIndex = categoryListModel.modelIndex(index) + onCrossClicked: category.remove(); + onEditClicked: root.editClicked(category); + } + } +} +//! [CategoryModel view 3] diff --git a/examples/location/places/content/places/EditorialDelegate.qml b/examples/location/places/content/places/EditorialDelegate.qml new file mode 100644 index 00000000..fa33bcf0 --- /dev/null +++ b/examples/location/places/content/places/EditorialDelegate.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 + +Item { + id: root + + width: parent.width + height: icon.height + 8 + + Image { + id: icon + + width: 64 + height: 64 + + anchors.verticalCenter: root.verticalCenter + anchors.left: root.left + anchors.leftMargin: 4 + + source: supplier.icon.url(Qt.size(64, 64), Icon.List) + fillMode: Image.PreserveAspectFit + } + + Text { + anchors.top: icon.top + anchors.topMargin: 4 + anchors.left: icon.right + anchors.leftMargin: 4 + anchors.right: root.right + anchors.rightMargin: 4 + + text: model.title.length > 0 ? model.title : qsTr("Untitled editorial") + font.bold: true + font.pixelSize: 16 + + wrapMode: Text.WordWrap + elide: Text.ElideRight + maximumLineCount: 2 + } + + MouseArea { + anchors.fill: parent + onClicked: { + placeContent.source = ""; + placeContent.data = model; + placeContent.source = "EditorialPage.qml"; + } + } +} diff --git a/examples/location/places/content/places/EditorialPage.qml b/examples/location/places/content/places/EditorialPage.qml new file mode 100644 index 00000000..60f175d3 --- /dev/null +++ b/examples/location/places/content/places/EditorialPage.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 + +Item { + anchors.fill: parent + + property variant d: parent ? parent.data : null + + Flickable { + anchors.fill: parent + + contentHeight: c.height + contentWidth: width + + Column { + id: c + + width: parent.width + clip: true + + Text { + text: d ? d.title : "" + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 24 + } + + Text { + text: d ? d.text : "" + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 20 + } + + Row { + Image { + width: 16 + height: 16 + + source: d ? d.supplier.icon.url(Qt.size(width, height), Icon.List) : "" + } + Text { + text: d ? d.supplier.name : "" + font.pixelSize: 16 + } + } + Text { + text: d ? d.supplier.url : "" + font.pixelSize: 16 + } + } + } +} diff --git a/examples/location/places/content/places/Group.qml b/examples/location/places/content/places/Group.qml new file mode 100644 index 00000000..ac44d905 --- /dev/null +++ b/examples/location/places/content/places/Group.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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 + +Item { + id: item1 + width: parent.width + height: childrenRect.height + 3 + + property alias text: heading.text + + Text { + id: heading + text: '#heading#' + anchors.left: parent.left + } + + Rectangle { + id: rectangle1 + width: parent.width + height: 1 + radius: 1 + border.width: 1 + border.color: "#808080" + anchors.top: heading.bottom + anchors.topMargin: 3 + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/location/places/content/places/MapComponent.qml b/examples/location/places/content/places/MapComponent.qml new file mode 100644 index 00000000..00ba9b2e --- /dev/null +++ b/examples/location/places/content/places/MapComponent.qml @@ -0,0 +1,237 @@ +/**************************************************************************** +** +** 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.0 +import QtLocation.examples 5.0 + +Map { + id: map + zoomLevel: (maximumZoomLevel - minimumZoomLevel)/2 + center { + // Brisbane + latitude: -27.5 + longitude: 153 + } + + gesture.flickDeceleration: 3000 + gesture.enabled: true + + 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] + + PositionSource{ + id: positionSource + active: followme + + onPositionChanged: { + map.center = positionSource.position.coordinate + } + } + + Slider { + id: zoomSlider; + minimum: map.minimumZoomLevel; + maximum: map.maximumZoomLevel; + opacity: 1 + visible: parent.visible + z: map.z+1 + anchors { + bottom: parent.bottom; + bottomMargin: 15; rightMargin: 10; leftMargin: 90 + left: parent.left + } + width: parent.width - anchors.rightMargin - anchors.leftMargin + value: map.zoomLevel + onValueChanged: { + map.zoomLevel = value + } + } + + signal coordinatesCaptured(double latitude, double longitude) + + Item {//scale + id: scale + parent: zoomSlider.parent + visible: scaleText.text != "0 m" + z: map.z + opacity: 0.6 + anchors { + bottom: zoomSlider.top; + bottomMargin: 8; + left: zoomSlider.left + } + Image { + id: scaleImageLeft + source: "../../resources/scale_end.png" + anchors.bottom: parent.bottom + anchors.left: parent.left + } + Image { + id: scaleImage + source: "../../resources/scale.png" + anchors.bottom: parent.bottom + anchors.left: scaleImageLeft.right + } + Image { + id: scaleImageRight + source: "../../resources/scale_end.png" + anchors.bottom: parent.bottom + anchors.left: scaleImage.right + } + Text { + id: scaleText + color: "#004EAE" + horizontalAlignment: Text.AlignHCenter + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.bottomMargin: 3 + text: "0 m" + font.pixelSize: 14 + } + Component.onCompleted: { + map.calculateScale(); + } + } + + Timer { + id: scaleTimer + interval: 100 + running: false + repeat: false + onTriggered: { + map.calculateScale() + } + } + + 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) || (event.key == Qt.Key_VolumeUp)) { + map.zoomLevel += 1 + } else if ((event.key == Qt.Key_Minus) || (event.key == Qt.Key_VolumeDown)){ + map.zoomLevel -= 1 + } + } + + 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 = formatDistance(dist) + scaleImage.width = (scaleImage.sourceSize.width * f) - 2 * scaleImageLeft.sourceSize.width + scaleText.text = text + } + + function roundNumber(number, digits) { + var multiple = Math.pow(10, digits); + return Math.round(number * multiple) / multiple; + } + + function formatTime(sec){ + var value = sec + var seconds = value % 60 + value /= 60 + value = (value > 1) ? Math.round(value) : 0 + var minutes = value % 60 + value /= 60 + value = (value > 1) ? Math.round(value) : 0 + var hours = value + if (hours > 0) value = hours + "h:"+ minutes + "m" + else value = minutes + "min" + return value + } + + function formatDistance(meters) + { + var dist = Math.round(meters) + if (dist > 1000 ){ + if (dist > 100000){ + dist = Math.round(dist / 1000) + } + else{ + dist = Math.round(dist / 100) + dist = dist / 10 + } + dist = dist + " km" + } + else{ + dist = dist + " m" + } + return dist + } +} diff --git a/examples/location/places/content/places/OptionsDialog.qml b/examples/location/places/content/places/OptionsDialog.qml new file mode 100644 index 00000000..7b7c9266 --- /dev/null +++ b/examples/location/places/content/places/OptionsDialog.qml @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 +import QtLocation.examples 5.0 + +Dialog { + id: dialog + + property alias isFavoritesEnabled: enableFavoritesButton.selected + property alias orderByDistance: orderByDistanceButton.selected + property alias orderByName: orderByNameButton.selected + property alias locales: localesInput.text + property int listItemHeight: 21 + + title: "Options" + + item: Column { + id: options + width: parent.width + spacing: gap + + TextWithLabel { + id: localesInput + + width: parent.width - gap + height: listItemHeight + label: "Locale(s)" + enabled: true + visible: placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.LocalizedPlacesFeature) : false; + } + + Optionbutton { + id: enableFavoritesButton + + function resetVisibility() { + //jsondb plug-in is no more but saving of places may come back + /*if (placesPlugin.name !== "places_jsondb") { + var pluginNames = placesPlugin.availableServiceProviders; + for (var i = 0; i < pluginNames.length; ++i) { + if (pluginNames[i] === "places_jsondb") { + enableFavoritesButton.visible = true; + return; + } + } + }*/ + enableFavoritesButton.visible = false; + } + + width: parent.width + text: "Enable favorites" + toggle: true + visible: false + + Component.onCompleted: { + resetVisibility(); + placesPlugin.nameChanged.connect(resetVisibility); + } + } + + Optionbutton { + id: orderByDistanceButton + width: parent.width + text: "Order by distance" + toggle: true + visible: true + onClicked: + if (selected) + orderByNameButton.selected = false; + } + Optionbutton { + id: orderByNameButton + width: parent.width + text: "Order by name" + toggle: true + visible: true + onClicked: + if (selected) + orderByDistanceButton.selected = false; + } + } +} diff --git a/examples/location/places/content/places/PlaceDelegate.qml b/examples/location/places/content/places/PlaceDelegate.qml new file mode 100644 index 00000000..90a2cceb --- /dev/null +++ b/examples/location/places/content/places/PlaceDelegate.qml @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 +import QtLocation.examples 5.0 +import "PlacesUtils.js" as PlacesUtils + +Item { + id: placeDelegate + + property Place place + property real distance + + signal searchForSimilar(variant place) + signal showReviews(variant place) + signal showEditorials(variant place) + signal showImages(variant place) + signal editPlace(variant place) + signal deletePlace(variant place) + + Flickable { + anchors.fill: parent + + contentHeight: c.height + contentWidth: width + + Column { + id: c + + width: parent.width + spacing: 2 + clip: true + + Row { + width: parent.width + + Image { + id: iconImage + width: 40 + height: 40 + source: place ? (place.favorite ? place.favorite.icon.url(Qt.size(40,40)) + : place.icon.url(Qt.size(40,40))) + : "" + visible: source != "" + } + + Text { + id: placeName + text: place ? (place.favorite ? place.favorite.name : place.name) : "" + font.pixelSize: 16 + font.bold: true + } + } + + RatingView { rating: (place && place.ratings) ? place.ratings.average : 0 } + + Group { text: qsTr("Address") } + Text { text: PlacesUtils.prettyDistance(distance) } + Text { + function placeAddress(place) { + if (!place) + return ""; + + if (place.location.address.text.length > 0) + return place.location.address.text; + + return place.location.address.street; + } + + text: placeAddress(place) + } + + Group { + text: qsTr("Categories") + visible: place && place.categories.length > 0 + } + Text { + function categoryNames(categories) { + var result = ""; + + for (var i = 0; i < categories.length; ++i) { + if (result == "") { + result = categories[i].name; + } else { + result = result + ", " + categories[i].name; + } + } + + return result; + } + + text: place ? categoryNames(place.categories) : "" + width: parent.width + wrapMode: Text.WordWrap + visible: place && place.categories.length > 0 + } + + Group { + text: qsTr("Contact details") + visible: phone.visible || fax.visible || email.visible || website.visible + } + Text { + id: phone + text: qsTr("Phone: ") + (place ? place.primaryPhone : "") + visible: place && place.primaryPhone.length > 0 + } + Text { + id: fax + text: qsTr("Fax: ") + (place ? place.primaryFax : "") + visible: place && place.primaryFax.length > 0 + } + Text { + id: email + text: place ? place.primaryEmail : "" + visible: place && place.primaryEmail.length > 0 + } + Text { + id: website + text: place ? '<a href=\"' + place.primaryWebsite + '\">' + place.primaryWebsite + '</a>' : "" + visible: place && String(place.primaryWebsite).length > 0 + onLinkActivated: Qt.openUrlExternally(place.primaryWebsite) + } + + Group { + text: qsTr("Additional information") + visible: extendedAttributes.count > 0 && extendedAttributes.height > 0 + } + + Repeater { + id: extendedAttributes + model: place ? place.extendedAttributes.keys() : null + delegate: Text { + text: place.extendedAttributes[modelData] ? + place.extendedAttributes[modelData].label + + place.extendedAttributes[modelData].text : "" + + visible: place.extendedAttributes[modelData] ? place.extendedAttributes[modelData].label.length > 0 : false + + width: c.width + wrapMode: Text.WordWrap + } + } + + Column { + id: buttons + + anchors.horizontalCenter: parent.horizontalCenter + + spacing: 5 + + Button { + text: qsTr("Editorials") + enabled: place && place.editorialModel.totalCount > 0 + onClicked: showEditorials(place) + } + Button { + text: qsTr("Reviews") + enabled: place && place.reviewModel.totalCount > 0 + onClicked: showReviews(place) + } + Button { + text: qsTr("Images") + enabled: place && place.imageModel.totalCount > 0 + onClicked: showImages(place) + } + Button { + text: qsTr("Find similar") + onClicked: searchForSimilar(place) + } + Button { + text: qsTr("Edit") + visible: placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.SavePlaceFeature) : false; + onClicked: editPlace(place) + } + + Button { + text: qsTr("Delete"); + visible: placesPlugin.name != "" ? placesPlugin.supportsPlaces(Plugin.RemovePlaceFeature) : false; + onClicked: deletePlace(place) + } + + Item { + width: parent.width + height: childrenRect.height + + Button { + id: saveButton; + function updateSaveStatus() { + if (updateSaveStatus.prevStatus === Place.Saving) { + switch (place.favorite.status) { + case Place.Ready: + break; + case Place.Error: + saveStatus.text = "Save Failed"; + saveStatus.visible = true; + console.log(place.favorite.errorString()); + break; + default: + } + } else if (updateSaveStatus.prevStatus == Place.Removing) { + place.favorite = null; + updateSaveStatus.prevStatus = Place.Ready + return; + + } + + updateSaveStatus.prevStatus = place.favorite.status; + } + + function reset() + { + saveButton.visible = (placeSearchModel.favoritesPlugin !== null); + saveStatus.visible = false; + } + + Component.onCompleted: { + reset(); + placeDelegate.placeChanged.connect(reset); + } + + text: (place && place.favorite !== null) ? qsTr("Remove Favorite") : qsTr("Save as Favorite") + onClicked: { + if (place.favorite === null) { + place.initializeFavorite(placeSearchModel.favoritesPlugin); + place.favorite.statusChanged.connect(updateSaveStatus); + place.favorite.save(); + } else { + place.favorite.statusChanged.connect(updateSaveStatus); + place.favorite.remove(); + } + } + } + + Text { + id: saveStatus + anchors.top: saveButton.bottom + visible: false + } + } + } + } + } +} diff --git a/examples/location/places/content/places/PlaceDialog.qml b/examples/location/places/content/places/PlaceDialog.qml new file mode 100644 index 00000000..ed08716d --- /dev/null +++ b/examples/location/places/content/places/PlaceDialog.qml @@ -0,0 +1,362 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 +import QtLocation.examples 5.0 + +Dialog { + id: root + property list<Category> __categories + property Place locationPlace + property bool __createdPlace: false + + signal completed; + + function prepareDialog(inputPlace) { + if (!inputPlace) { + locationPlace = Qt.createQmlObject('import QtLocation 5.0; Place { }', root); + __createdPlace = true; + } else { + locationPlace = inputPlace; + __createdPlace = false; + } + + setDataFields([ + ["Name", locationPlace ? locationPlace.name : ""], + ["Street", locationPlace ? locationPlace.location.address.street : ""], + ["District", locationPlace ? locationPlace.location.address.district : ""], + ["City", locationPlace ? locationPlace.location.address.city : ""], + ["County", locationPlace ? locationPlace.location.address.county : ""], + ["State", locationPlace ? locationPlace.location.address.state : ""], + ["Country code", locationPlace ? locationPlace.location.address.countryCode : ""], + ["Country", locationPlace ? locationPlace.location.address.country : ""], + ["Postal code", locationPlace ? locationPlace.location.address.postalCode : ""], + ["Latitude", locationPlace ? locationPlace.location.coordinate.latitude.toString() : ""], + ["Longitude", locationPlace ? locationPlace.location.coordinate.longitude.toString() : ""], + ["Phone", locationPlace ? locationPlace.primaryPhone : ""], + ["Fax", locationPlace ? locationPlace.primaryFax : ""], + ["Email", locationPlace ? locationPlace.primaryEmail : ""], + ["Website", locationPlace ? locationPlace.primaryWebsite.toString() : ""] + ]); + + __categories = locationPlace ? locationPlace.categories : new Array() + } + + function setDataFields(objects) + { + dataFieldsModel.clear(); + for (var i = 0; i < objects.length; i++) + dataFieldsModel.append({"labelText": objects[i][0], "inputText": objects[i][1]}) + } + + function processStatus() { + if (processStatus.prevStatus == Place.Saving) { + switch (locationPlace.status) { + case Place.Ready: + if (__createdPlace) { + locationPlace.destroy(); + __createdPlace = false; + processStatus.prevStatus = null; + } + completed(); + break; + case Place.Error: + console.log("Save failed:" + locationPlace.errorString()); + errorDialog.text = locationPlace.errorString(); + errorDialog.opacity = 1; + break; + } + } + + processStatus.prevStatus = locationPlace.status; + } + + Behavior on opacity { NumberAnimation { duration: 500 } } + + ErrorDialog { + id: errorDialog + title: "Save Place Failed" + } + + onGoButtonClicked: { + if (locationPlace.status == Place.Saving) + return; +//! [Place save] + locationPlace.plugin = placesPlugin; + + locationPlace.name = dataFieldsModel.get(0).inputText; + locationPlace.location.address.street = dataFieldsModel.get(1).inputText; + locationPlace.location.address.district = dataFieldsModel.get(2).inputText; + locationPlace.location.address.city = dataFieldsModel.get(3).inputText; + locationPlace.location.address.county = dataFieldsModel.get(4).inputText; + locationPlace.location.address.state = dataFieldsModel.get(5).inputText; + locationPlace.location.address.countryCode = dataFieldsModel.get(6).inputText; + locationPlace.location.address.country = dataFieldsModel.get(7).inputText; + locationPlace.location.address.postalCode = dataFieldsModel.get(8).inputText; + + var c = QtPositioning.coordinate(parseFloat(dataFieldsModel.get(9).inputText), + parseFloat(dataFieldsModel.get(10).inputText)); + locationPlace.location.coordinate = c; + var phone = Qt.createQmlObject('import QtLocation 5.0; ContactDetail { }', locationPlace); + phone.label = "Phone"; + phone.value = dataFieldsModel.get(11).inputText; + locationPlace.contactDetails.phone = phone; + + var fax = Qt.createQmlObject('import QtLocation 5.0; ContactDetail { }', locationPlace); + fax.label = "Fax"; + fax.value = dataFieldsModel.get(12).inputText; + locationPlace.contactDetails.fax = fax; + + var email = Qt.createQmlObject('import QtLocation 5.0; ContactDetail { }', locationPlace); + email.label = "Email"; + email.value = dataFieldsModel.get(13).inputText; + locationPlace.contactDetails.email = email; + + var website = Qt.createQmlObject('import QtLocation 5.0; ContactDetail { }', locationPlace); + website.label = "Website"; + website.value = dataFieldsModel.get(14).inputText; + locationPlace.contactDetails.website = website; + + locationPlace.categories = __categories; + locationPlace.statusChanged.connect(processStatus); + locationPlace.save(); +//! [Place save] + } + + onClearButtonClicked: { + for (var i = 0; i < dataFieldsModel.count; i++) + dataFieldsModel.set(i, {"inputText": ""}); + __categories = new Array(); + } + + onCancelButtonClicked: { + if (locationPlace && __createdPlace) + locationPlace.destroy(); + } + + onOpacityChanged: { + if (opacity == 0) + view.currentIndex = 0 + } + + ListModel { + id: dataFieldsModel + } + + item: ListView { + id: view + + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: 10 + + implicitHeight: flickable.contentHeight + + spacing: gap/2 + orientation: ListView.Horizontal + interactive: false + + model: VisualItemModel { + Item { + id: firstPage + width: view.width + height: view.height + + Flickable { + id: flickable + anchors.top: parent.top + anchors.topMargin: gap/2 + anchors.bottomMargin: gap/2 + height: parent.height + width: parent.width + interactive: height < contentHeight + contentWidth: parent.width + contentHeight:col.height + + clip: true + + Column { + id: col + anchors.top: parent.top + anchors.left: parent.left + width: parent.width - gap + spacing: gap/2 + + Repeater { + id: dataFields + model: dataFieldsModel + + TextWithLabel { + anchors.leftMargin: gap/2 + anchors.rightMargin: gap/2 + + width: parent ? parent.width : 0 + labelWidth: 95 + label: labelText + text: inputText + + onTextChanged: dataFieldsModel.set(index, {"inputText": text}) + } + } + + Group { + id: categoriesHeading + width: parent.width + anchors.topMargin: gap + + text: qsTr("Categories"); + } + + Repeater { + model: __categories + width: parent.width + + delegate: Item { + height: cross.height + width: parent.width + + Text { + id: categoryName + + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + text: model.modelData.name + } + + IconButton { + id: cross + + anchors.top: parent.top + anchors.right: parent.right + source: "../../resources/cross.png" + hoveredSource: "../../resources/cross_hovered.png" + pressedSource: "../../resources/cross_pressed.png" + + onClicked: { + var cats = new Array(); + for (var i =0; i < __categories.length; ++i) { + if (__categories[i].name != model.modelData.name) + cats.push(__categories[i]); + } + __categories = cats + } + } + } + } + + Button { + text: qsTr("Add Category") + onClicked: view.currentIndex = 1 + } + } + } + + Rectangle { + id: scrollbar + anchors.right: flickable.right + y: { + var yPosition = flickable.visibleArea.yPosition + if (yPosition < 0) + yPosition = 0 + if (yPosition > (1.0 - flickable.visibleArea.heightRatio)) + yPosition = (1.0 - flickable.visibleArea.heightRatio) + yPosition *flickable.height + } + + width: 10 + height: flickable.visibleArea.heightRatio * flickable.height + color: "gray" + radius: 5 + } + + } + + Item { + height:view.height + width: view.width + + Group { + id: chooseCategoryHeading + + anchors.top: parent.top + width: parent.width + text: qsTr("Choose Category"); + } + + CategoryView { + id: categoryView + + anchors.top: chooseCategoryHeading.bottom + anchors.bottom: categoryCancel.top + width: parent.width + + showSave: false + showRemove: false + showChildren: false + + onCategoryClicked: { + var categoriesList = new Array(); + var alreadyExists = false; + for (var i = 0; i < __categories.length; ++i) { + categoriesList.push(__categories[i]); + if (__categories[i].categoryId == category.categoryId) + alreadyExists = true; + } + + if (!alreadyExists) + categoriesList.push(category); + __categories = categoriesList + view.currentIndex = 0; + } + } + + Button { + id: categoryCancel + + anchors.bottom: parent.bottom + text: qsTr("Cancel ") + onClicked: view.currentIndex = 0 + } + } + } + } +} diff --git a/examples/location/places/content/places/PlaceEditorials.qml b/examples/location/places/content/places/PlaceEditorials.qml new file mode 100644 index 00000000..06cff09c --- /dev/null +++ b/examples/location/places/content/places/PlaceEditorials.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 + +Item { + anchors.fill: parent + + clip: true + + //! [PlaceEditorialModel view] + ListView { + anchors.fill: parent + + model: place.editorialModel + + delegate: EditorialDelegate { } + } + //! [PlaceEditorialModel view] +} diff --git a/examples/location/places/content/places/PlaceImages.qml b/examples/location/places/content/places/PlaceImages.qml new file mode 100644 index 00000000..be18a923 --- /dev/null +++ b/examples/location/places/content/places/PlaceImages.qml @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 + +Item { + id: root + + anchors.fill: parent + + clip: true + + GridView { + id: gridView + + anchors.fill: parent + + model: place.imageModel + + cellWidth: width / 3 + cellHeight: cellWidth + + delegate: Rectangle { + width: gridView.cellWidth + height: gridView.cellHeight + + color: "#30FFFFFF" + + Image { + anchors.fill: parent + anchors.margins: 5 + + source: url + + fillMode: Image.PreserveAspectFit + } + + MouseArea { + anchors.fill: parent + onClicked: { + listView.positionViewAtIndex(index, ListView.Contain); + root.state = "list"; + } + } + } + } + + ListView { + id: listView + + anchors.top: parent.top + anchors.bottom: position.top + width: parent.width + spacing: 10 + + model: place.imageModel + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + + visible: false + + delegate: Item { + width: listView.width + height: listView.height + + Image { + anchors.fill: parent + + source: url + + fillMode: Image.PreserveAspectFit + } + + Text { + text: supplier.name + "\n" + supplier.url + width: parent.width + anchors.bottom: parent.bottom + } + } + + MouseArea { + anchors.fill: parent + onClicked: root.state = "" + } + } + + Text { + id: position + + width: parent.width + anchors.bottom: parent.bottom + visible: listView.visible + + text: (listView.currentIndex + 1) + '/' + listView.model.totalCount + horizontalAlignment: Text.AlignRight + } + + states: [ + State { + name: "list" + PropertyChanges { + target: gridView + visible: false + } + PropertyChanges { + target: listView + visible: true + } + } + ] +} diff --git a/examples/location/places/content/places/PlaceReviews.qml b/examples/location/places/content/places/PlaceReviews.qml new file mode 100644 index 00000000..3d54c52c --- /dev/null +++ b/examples/location/places/content/places/PlaceReviews.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 + +Item { + anchors.fill: parent + + clip: true + +//! [ReviewModel delegate] + ListView { + anchors.fill: parent + + model: place.reviewModel + + delegate: ReviewDelegate { } + } +//! [ReviewModel delegate] +} diff --git a/examples/location/places/content/places/PlacesUtils.js b/examples/location/places/content/places/PlacesUtils.js new file mode 100644 index 00000000..756deb99 --- /dev/null +++ b/examples/location/places/content/places/PlacesUtils.js @@ -0,0 +1,12 @@ +.pragma library + +function prettyDistance(distance) { + if (distance < 1000) + return distance.toFixed(0) + "m"; + + var km = distance/1000; + if (km < 10) + return km.toFixed(1) + "km"; + + return km.toFixed(0) + "km"; +} diff --git a/examples/location/places/content/places/RatingView.qml b/examples/location/places/content/places/RatingView.qml new file mode 100644 index 00000000..255bb8b8 --- /dev/null +++ b/examples/location/places/content/places/RatingView.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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 + +Row { + property real rating: 0 + property int size: 32 + + Repeater { + model: Math.ceil(rating) + Image { + source: "../../resources/star.png" + width: size + height: size + } + } +} diff --git a/examples/location/places/content/places/ReviewDelegate.qml b/examples/location/places/content/places/ReviewDelegate.qml new file mode 100644 index 00000000..50753e09 --- /dev/null +++ b/examples/location/places/content/places/ReviewDelegate.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 + +Item { + id: root + + width: parent.width + height: icon.height + 8 + + Image { + id: icon + + width: 64 + height: 64 + + anchors.verticalCenter: root.verticalCenter + anchors.left: root.left + anchors.leftMargin: 4 + + source: supplier.icon.url(Qt.size(64, 64), Icon.List) + fillMode: Image.PreserveAspectFit + } + + Text { + anchors.top: icon.top + anchors.topMargin: 4 + anchors.left: icon.right + anchors.leftMargin: 4 + anchors.right: root.right + anchors.rightMargin: 4 + + text: model.title + font.bold: true + font.pixelSize: 16 + + wrapMode: Text.WordWrap + elide: Text.ElideRight + maximumLineCount: 2 + } + + RatingView { + anchors.bottom: icon.bottom + anchors.bottomMargin: 4 + anchors.left: icon.right + anchors.leftMargin: 4 + anchors.right: root.right + anchors.rightMargin: 4 + + rating: model.rating + size: 16 + } + + MouseArea { + anchors.fill: parent + onClicked: { + placeContent.source = ""; + placeContent.data = model; + placeContent.source = "ReviewPage.qml"; + } + } +} diff --git a/examples/location/places/content/places/ReviewPage.qml b/examples/location/places/content/places/ReviewPage.qml new file mode 100644 index 00000000..c7287e19 --- /dev/null +++ b/examples/location/places/content/places/ReviewPage.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 + +Item { + anchors.fill: parent + + property variant d: parent ? parent.data : null + + Flickable { + anchors.fill: parent + + contentHeight: c.height + contentWidth: width + + Column { + id: c + + width: parent.width + clip: true + + Text { + text: d ? d.title : "" + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 24 + } + + Text { + text: d ? Qt.formatDateTime(d.dateTime) : "" + width: parent.width + font.pixelSize: 18 + } + + RatingView { + size: 16 + rating: d ? d.rating : 0.0 + } + + Text { + text: d ? d.text : "" + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 20 + } + + Row { + Image { + width: 16 + height: 16 + + source: d ? d.supplier.icon.url(Qt.size(width, height), Icon.List) : "" + } + Text { + text: d ? d.supplier.name : "" + font.pixelSize: 16 + } + } + Text { + text: d ? d.supplier.url : "" + font.pixelSize: 16 + } + } + } +} diff --git a/examples/location/places/content/places/SearchBox.qml b/examples/location/places/content/places/SearchBox.qml new file mode 100644 index 00000000..335af339 --- /dev/null +++ b/examples/location/places/content/places/SearchBox.qml @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 +import QtLocation.examples 5.0 + +Rectangle { + id: searchRectangle + + property bool suggestionsEnabled: true + property int expandedHeight: childrenRect.height + readonly property int baseHeight: searchBox.height + 20 + + color: "#ECECEC" + + height: baseHeight + Behavior on height { + NumberAnimation { duration: 250 } + } + + clip: true + + TextWithLabel { + id: searchBox + label: "Search" + text: "sushi" + + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.right: row.left + anchors.rightMargin: 10 + anchors.top: parent.top + anchors.topMargin: 10 + + busy: placeSearchModel.status === PlaceSearchModel.Loading + + //! [PlaceSearchSuggestionModel search text changed] + onTextChanged: { + if (searchRectangle.suggestionsEnabled) { + if (text.length >= 3) { + if (suggestionModel != null) { + suggestionModel.searchTerm = text; + suggestionModel.update(); + } + } else { + searchRectangle.state = ""; + } + } + } + //! [PlaceSearchSuggestionModel search text changed] + } + + Row { + id: row + + anchors.right: parent.right + anchors.rightMargin: 10 + anchors.top: parent.top + anchors.topMargin: 10 + spacing: 10 + + IconButton { + id: searchButton + + anchors.verticalCenter: parent.verticalCenter + + source: "../../resources/search.png" + pressedSource: "../../resources/search_pressed.png" + + onClicked: { + placeSearchModel.searchForText(searchBox.text); + searchRectangle.state = ""; + } + } + + IconButton { + id: categoryButton + + source: "../../resources/categories.png" + pressedSource: "../../resources/categories_pressed.png" + + onClicked: { + if (searchRectangle.state !== "CategoriesShown") + searchRectangle.state = "CategoriesShown"; + else if (suggestionView.count > 0) + searchRectangle.state = "SuggestionsShown"; + else + searchRectangle.state = ""; + } + } + } + + CategoryView { + id: categoryView + + anchors.top: row.bottom + height: expandedHeight - y + visible: false + spacing: 5 + + onCategoryClicked: { + placeSearchModel.searchForCategory(category); + searchRectangle.state = ""; + } + + onEditClicked: { + editCategoryDialog.category = category; + page.state = "EditCategory"; + searchRectangle.state = ""; + } + } + + BusyIndicator { + id: busy + + visible: false + + anchors.centerIn: parent + } + + Text { + id: noCategories + + anchors.centerIn: parent + text: qsTr("No categories") + visible: false + } + + //! [PlaceSearchSuggestionModel view 1] + ListView { + id: suggestionView + //! [PlaceSearchSuggestionModel view 1] + + anchors.top: row.bottom + anchors.topMargin: 10 + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.right: parent.right + anchors.rightMargin: 10 + height: 450 + visible: false + + clip: true + snapMode: ListView.SnapToItem + + //! [PlaceSearchSuggestionModel view 2] + model: suggestionModel + delegate: Text { + text: suggestion + + width: parent.width + + MouseArea { + anchors.fill: parent + onClicked: { + suggestionsEnabled = false; + searchBox.text = suggestion; + suggestionsEnabled = true; + placeSearchModel.searchForText(suggestion); + searchRectangle.state = ""; + } + } + } + } + //! [PlaceSearchSuggestionModel view 2] + + //! [PlaceSearchSuggestionModel model] + PlaceSearchSuggestionModel { + id: suggestionModel + plugin: placesPlugin + searchArea: placeSearchModel.searchArea + + onStatusChanged: { + if (status == PlaceSearchSuggestionModel.Ready) + searchRectangle.state = "SuggestionsShown"; + } + } + //! [PlaceSearchSuggestionModel model] + + states: [ + State { + name: "CategoriesShown" + PropertyChanges { + target: searchRectangle + height: expandedHeight + } + PropertyChanges { + target: busy + visible: categoryModel.status === CategoryModel.Loading + } + PropertyChanges { + target: noCategories + visible: categoryView.count == 0 && !busy.visible + } + PropertyChanges { + target: categoryView + visible: true && !busy.visible + } + }, + State { + name: "SuggestionsShown" + PropertyChanges { + target: searchRectangle + height: childrenRect.height + 20 + } + PropertyChanges { + target: suggestionView + visible: true + } + } + ] +} diff --git a/examples/location/places/content/places/SearchResultDelegate.qml b/examples/location/places/content/places/SearchResultDelegate.qml new file mode 100644 index 00000000..76b64e83 --- /dev/null +++ b/examples/location/places/content/places/SearchResultDelegate.qml @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 +import "PlacesUtils.js" as PlacesUtils + +Item { + id: root + + signal displayPlaceDetails(variant data) + signal searchFor(string query) + + width: parent.width + height: childrenRect.height + 20 + + //! [PlaceSearchModel place delegate] + Component { + id: placeComponent + + Item { + id: placeRoot + + height: childrenRect.height + width: parent.width + + Rectangle { + anchors.fill: parent + color: "#dbffde" + visible: model.sponsored !== undefined ? model.sponsored : false + + Text { + text: qsTr("Sponsored result") + horizontalAlignment: Text.AlignRight + anchors.right: parent.right + anchors.bottom: parent.bottom + font.pixelSize: 8 + visible: model.sponsored !== undefined ? model.sponsored : false + } + } + + Row { + Image { + source: place.favorite ? "../../resources/star.png" : place.icon.url() + } + + Column { + anchors.verticalCenter: parent.verticalCenter + Text { + id: placeName + text: place.favorite ? place.favorite.name : place.name + } + + Text { + id: distanceText + font.italic: true + text: PlacesUtils.prettyDistance(distance) + } + } + } + + MouseArea { + anchors.fill: parent + + onPressed: placeRoot.state = "Pressed" + onReleased: placeRoot.state = "" + onCanceled: placeRoot.state = "" + + onClicked: { + if (model.type === undefined || type === PlaceSearchModel.PlaceResult) { + if (!place.detailsFetched) + place.getDetails(); + + root.displayPlaceDetails({ + distance: model.distance, + place: model.place, + }); + } + } + } + + states: [ + State { + name: "" + }, + State { + name: "Pressed" + PropertyChanges { target: placeName; color: "#1C94FC"} + PropertyChanges { target: distanceText; color: "#1C94FC"} + } + ] + } + } + //! [PlaceSearchModel place delegate] + + Component { + id: proposedSearchComponent + + Item { + id: proposedSearchRoot + + height: childrenRect.height + width: parent.width + + Row { + Image { + source: icon.url() + } + + Text { + id: proposedSearchTitle + anchors.verticalCenter: parent.verticalCenter + text: "Search for " + title + } + } + + MouseArea { + anchors.fill: parent + + onPressed: proposedSearchRoot.state = "Pressed" + onReleased: proposedSearchRoot.state = "" + onCanceled: proposedSearchRoot.state = "" + + onClicked: root.ListView.view.model.updateWith(index); + } + + states: [ + State { + name: "" + }, + State { + name: "Pressed" + PropertyChanges { target: proposedSearchTitle; color: "#1C94FC"} + } + ] + } + } + + Loader { + anchors.left: parent.left + anchors.right: parent.right + + sourceComponent: { + switch (model.type) { + case PlaceSearchModel.PlaceResult: + return placeComponent; + case PlaceSearchModel.ProposedSearchResult: + return proposedSearchComponent; + default: + //do nothing, don't assign component if result type not recognized + } + } + } +} diff --git a/examples/location/places/content/places/SearchResultView.qml b/examples/location/places/content/places/SearchResultView.qml new file mode 100644 index 00000000..b9d48776 --- /dev/null +++ b/examples/location/places/content/places/SearchResultView.qml @@ -0,0 +1,247 @@ +/**************************************************************************** +** +** 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 QtLocation 5.0 +import QtLocation.examples 5.0 + +Item { + id: root + + clip: true + + function showSearchResults() { + view.currentIndex = 0; + placeContentList.source = ""; + placeContentList.place = null; + } + + function showPlaceDetails(data) { + placeDetails.place = data.place; + placeDetails.distance = data.distance; + view.currentIndex = 1; + } + + ListView { + id: view + + orientation: ListView.Horizontal + interactive: false + anchors.fill: parent + snapMode: ListView.SnapOneItem + + model: VisualItemModel { + Item { + // search results (page 0) + + width: root.width + height: root.height + + Connections { + target: placeSearchModel + onStatusChanged: searchView.visible = true + } + + //! [PlaceSearchModel place list] + ListView { + id: searchView + + anchors.fill: parent + + model: placeSearchModel + delegate: SearchResultDelegate { + onDisplayPlaceDetails: showPlaceDetails(data) + onSearchFor: placeSearchModel.searchForText(query); + } + + footer: Item { + width: searchView.width + height: childrenRect.height + + Button { + text: qsTr("Previous") + onClicked: placeSearchModel.previousPage() + + anchors.left: parent.left + } + + Button { + text: qsTr("Clear") + onClicked: placeSearchModel.reset() + + anchors.horizontalCenter: parent.horizontalCenter + } + + Button { + text: qsTr("Next") + onClicked: placeSearchModel.nextPage() + + anchors.right: parent.right + } + } + } + //! [PlaceSearchModel place list] + } + Item { + // place details (page 1) + width: root.width + height: root.height + + IconButton { + id: placeBackButton + anchors.left: parent.left + + source: "../../resources/left.png" + pressedSource: "../../resources/left_pressed.png" + + onClicked: showSearchResults() + } + + PlaceDelegate { + id: placeDetails + + anchors.top: placeBackButton.bottom + anchors.bottom: parent.bottom + width: parent.width + anchors.margins: 10 + + onShowEditorials: { + placeContentList.source = ""; + placeContentList.place = place; + placeContentList.source = "PlaceEditorials.qml"; + view.currentIndex = 2; + } + + onShowReviews: { + placeContentList.source = ""; + placeContentList.place = place; + placeContentList.source = "PlaceReviews.qml"; + view.currentIndex = 2; + } + + onShowImages: { + placeContentList.source = ""; + placeContentList.place = place; + placeContentList.source = "PlaceImages.qml"; + view.currentIndex = 2; + } + + //! [PlaceRecommendationModel search] + onSearchForSimilar: { + placeContentList.source = ""; + placeSearchModel.searchForRecommendations(place.placeId); + } + //! [PlaceRecommendationModel search] + + onEditPlace: { + editPlaceDialog.prepareDialog(place); + page.state = "EditPlace" + } + + onDeletePlace: { + place.remove(); + showSearchResults(); + } + } + } + Item { + // content list (page 2) + width: root.width + height: root.height + + IconButton { + id: contentListBackButton + + source: "../../resources/left.png" + pressedSource: "../../resources/left_pressed.png" + + onClicked: view.currentIndex = 1 + } + + Loader { + id: placeContentList + + property Place place + + anchors.top: contentListBackButton.bottom + anchors.bottom: parent.bottom + width: parent.width + anchors.margins: 10 + + onStatusChanged: { + if (status === Loader.Null) + place = null; + } + } + } + Item { + // content (page 3) + width: root.width + height: root.height + + IconButton { + id: contentBackButton + + source: "../../resources/left.png" + pressedSource: "../../resources/left_pressed.png" + + onClicked: { + view.currentIndex = 2; + placeContent.source = ""; + placeContent.data = null; + } + } + + Loader { + id: placeContent + + anchors.top: contentBackButton.bottom + anchors.bottom: parent.bottom + width: parent.width + anchors.margins: 10 + + onLoaded: view.currentIndex = 3 + + property variant data + } + } + } + } +} |