diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2012-08-16 13:32:43 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-28 10:07:49 +0200 |
commit | 059388adce26be48868cd741b4c5d751298fb4d8 (patch) | |
tree | 1a8a41c0f280b7ab3c502b49527bd609d1c0884a /examples/declarative | |
parent | 7dd46f8c96a4bdaca2809ff97b773f358392516f (diff) | |
download | qtlocation-059388adce26be48868cd741b4c5d751298fb4d8.tar.gz |
Convert GeoShape, GeoRectangle and GeoCircle into QML value types.v5.0.0-beta1
This replaces the GeoShape, GeoRectangle and GeoCircle QML elements with
value types. A value type is a better fit for shape types. It is very
similar to a rect with some utility functions.
Declare QGeoShape, QGeoRectangle and QGeoCircle as movable types.
Update documentation.
Change-Id: Id6c48e1e841c68f2f0c5c6a9c4a6580a57e2dfb6
Reviewed-by: abcd <amos.choy@nokia.com>
Diffstat (limited to 'examples/declarative')
-rw-r--r-- | examples/declarative/places/places.qml | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/examples/declarative/places/places.qml b/examples/declarative/places/places.qml index 35911a4c..df9ec2f3 100644 --- a/examples/declarative/places/places.qml +++ b/examples/declarative/places/places.qml @@ -48,12 +48,19 @@ Item { width: (parent && parent.width > 0) ? parent.width : 360 height: (parent && parent.height > 0) ? parent.height : 640 property variant map - property variant searchRegion : startLocation + property variant startLocation + property variant searchRegion: QtLocation.circle(startLocation) property variant searchRegionItem property Plugin favoritesPlugin onMapChanged: editPlaceDialog.prepareDialog() + Binding { + target: page + property: "startLocation" + value: map ? map.center : QtLocation.coordinate() + } + Rectangle { id: backgroundRect anchors.fill: parent @@ -207,10 +214,11 @@ Item { onGoButtonClicked: { var c = QtLocation.coordinate(parseFloat(dialogModel.get(0).inputText), parseFloat(dialogModel.get(1).inputText)); - searchRegion = startLocation; map.center = c; + searchRegion = Qt.binding(function() { return QtLocation.circle(startLocation) }); + if (searchRegionItem) { map.removeMapItem(searchRegionItem); searchRegionItem.destroy(); @@ -241,16 +249,14 @@ Item { onCancelButtonClicked: page.state = "" onGoButtonClicked: { - var newRegion = Qt.createQmlObject('import QtLocation 5.0; GeoRectangle {}', page, "GeoCircle"); var c = QtLocation.coordinate(parseFloat(dialogModel.get(0).inputText), parseFloat(dialogModel.get(1).inputText)); - newRegion.center = c; - newRegion.width = dialogModel.get(2).inputText; - newRegion.height = dialogModel.get(3).inputText; + var r = QtLocation.rectangle(c, parseFloat(dialogModel.get(2).inputText), + parseFloat(dialogModel.get(3).inputText)); map.center = c; - searchRegion = newRegion; + searchRegion = r; if (searchRegionItem) { map.removeMapItem(searchRegionItem); @@ -258,8 +264,8 @@ Item { } searchRegionItem = Qt.createQmlObject('import QtLocation 5.0; MapRectangle { color: "red"; opacity: 0.4 }', page, "MapRectangle"); - searchRegionItem.topLeft = newRegion.topLeft; - searchRegionItem.bottomRight = newRegion.bottomRight; + searchRegionItem.topLeft = r.topLeft; + searchRegionItem.bottomRight = r.bottomRight; map.addMapItem(searchRegionItem); page.state = ""; @@ -286,15 +292,13 @@ Item { onCancelButtonClicked: page.state = "" onGoButtonClicked: { - var newRegion = Qt.createQmlObject('import QtLocation 5.0; GeoCircle {}', page, "GeoCircle"); var c = QtLocation.coordinate(parseFloat(dialogModel.get(0).inputText), parseFloat(dialogModel.get(1).inputText)); - newRegion.center = c; - newRegion.radius = dialogModel.get(2).inputText; + var circle = QtLocation.circle(c, parseFloat(dialogModel.get(2).inputText)); map.center = c; - searchRegion = newRegion; + searchRegion = circle; if (searchRegionItem) { map.removeMapItem(searchRegionItem); @@ -302,8 +306,8 @@ Item { } searchRegionItem = Qt.createQmlObject('import QtLocation 5.0; MapCircle { color: "red"; opacity: 0.4 }', page, "MapRectangle"); - searchRegionItem.center = newRegion.center; - searchRegionItem.radius = newRegion.radius; + searchRegionItem.center = circle.center; + searchRegionItem.radius = circle.radius; map.addMapItem(searchRegionItem); page.state = ""; @@ -347,16 +351,6 @@ Item { } } - GeoCircle { - id: startLocation - } - - Binding { - target: startLocation - property: "center" - value: map ? map.center : QtLocation.coordinate() - } - //! [PlaceSearchModel model] PlaceSearchModel { id: placeSearchModel |