From 351e07dc2c96f70867dca6aaf7d2eb2919ba3d01 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 20 Feb 2015 15:43:08 +0100 Subject: Fix QtLocation QML snippets Most of the snippets did not work and/or had outdated API usage. Change-Id: Ib8949ab6d007c4eaa3638fb40473bf6d217edd36 Reviewed-by: Michal Klocek Reviewed-by: Alex Blasche --- src/location/doc/snippets/declarative/routing.qml | 54 ++++++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'src/location/doc/snippets/declarative/routing.qml') diff --git a/src/location/doc/snippets/declarative/routing.qml b/src/location/doc/snippets/declarative/routing.qml index 8f03ea37..cc091672 100644 --- a/src/location/doc/snippets/declarative/routing.qml +++ b/src/location/doc/snippets/declarative/routing.qml @@ -39,32 +39,47 @@ ****************************************************************************/ //! [QtQuick import] -import QtQuick 2.0 +import QtQuick 2.3 //! [QtQuick import] +import QtPositioning 5.3 //! [QtLocation import] import QtLocation 5.3 //! [QtLocation import] Item { - //! [RouteManeuver] - Text { - text: "Distance till next maneuver: " + routeManeuver.distanceToNextInstruction + " meters, estimated time: " + routeManeuver.timeToNextInstruction + " seconds." + width: 1000 + height: 400 + + Plugin { + id: aPlugin + name: "osm" } - //! [RouteManeuver] - //! [RouteSegment] - Text { - text: "Segment distance " + routeSegment.distance + " meters, " + routeSegment.path.length + " points." + RouteQuery { + id: aQuery + waypoints: [ + { latitude: -27.575, longitude: 153.088}, + { latitude: -27.465, longitude: 153.023} + ] + travelModes: RouteQuery.CarTravel + routeOptimizations: RouteQuery.ShortestRoute } - //! [RouteSegment] - //! [Route Maneuver List] + //! [Route Maneuver List1] RouteModel { id: routeModel // model initialization + //! [Route Maneuver List1] + plugin: aPlugin + autoUpdate: true + query: aQuery + //! [Route Maneuver List2] } + ListView { + id: listview + anchors.fill: parent spacing: 10 model: routeModel.status == RouteModel.Ready ? routeModel.get(0).segments : null visible: model ? true : false @@ -74,10 +89,25 @@ Item { property bool hasManeuver : modelData.maneuver && modelData.maneuver.valid visible: hasManeuver Text { text: (1 + index) + "." } + Text { text: hasManeuver ? modelData.maneuver.instructionText : "" } + //! [Route Maneuver List2] + property RouteManeuver routeManeuver: modelData.maneuver + property RouteSegment routeSegment: modelData + + //! [RouteManeuver] + Text { + text: "Distance till next maneuver: " + routeManeuver.distanceToNextInstruction + + " meters, estimated time: " + routeManeuver.timeToNextInstruction + " seconds." + } + //! [RouteManeuver] + + //! [RouteSegment] Text { - text: hasManeuver ? modelData.maneuver.instructionText : "" + text: "Segment distance " + routeSegment.distance + " meters, " + routeSegment.path.length + " points." } + //! [RouteSegment] + //! [Route Maneuver List3] } } - //! [Route Maneuver List] + //! [Route Maneuver List3] } -- cgit v1.2.1