Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

RouteModel

The RouteModel element provides access to routes. More...

Inherits QtObject

This type was introduced in Qt Location 5.0.

Properties

Methods

Detailed Description

The RouteModel element is used as part of a model/view grouping to retrieve geographic routes from a backend provider. Routes include data about driving directions between two points, walking directions with multiple waypoints, and various other similar concepts. It functions much like other Model elements in QML (see for example ListModel and XmlListModel), and interacts with views such as MapItemView, and ListView.

Like Map and GeocodeModel, all the data for a RouteModel to work comes from a services plugin. This is contained in the plugin property, and this must be set before the RouteModel can do any useful work.

Once the plugin is set, create a RouteQuery with the appropriate waypoints and other settings, and set the RouteModel's query property. If autoUpdate is enabled, the update will being automatically. Otherwise, the update method may be used. By default, autoUpdate is disabled.

The data stored and returned in the RouteModel consists of Route elements, as a list with the role name "routeData". See the documentation for Route for further details on its structure and contents.

Example Usage

The following snippet is two-part, showing firstly the declaration of elements, and secondly a short piece of procedural code using it. We set the routeModel's autoUpdate property to false, and call update once the query is set up, to avoid useless extra requests halfway through the set up of the query.

 Plugin {
     id: aPlugin
 }

 RouteQuery {
     id: aQuery
 }

 RouteModel {
     id: routeModel
     plugin: aPlugin
     query: aQuery
     autoUpdate: false
 }
 {
     aQuery.addWaypoint(...)
     aQuery.addWaypoint(...)
     aQuery.travelModes = ...
     routeModel.update()
 }

Property Documentation

autoUpdate : bool

This property controls whether the Model automatically updates in response to changes in its attached RouteQuery. The default value of this property is false.

If setting this value to 'true', note that any change at all in the RouteQuery object set in the query property will trigger a new request to be sent. If you are adjusting many properties of the RouteQuery with autoUpdate enabled, this can generate large numbers of useless (and later discarded) requests.


read-onlycount : int

This property holds how many routes the model currently has. Amongst other uses, you can use this value when accessing routes via the QtLocation5::RouteModel::get -method.


read-onlyerror : enumeration

This read-only property holds the latest error value of the routing request.

  • RouteModel.NoError - No error has occurred
  • RouteModel.EngineNotSetError - The plugin/service provider used does not support routing
  • RouteModel.CommunicationError - An error occurred while communicating with the service provider
  • RouteModel.ParseError - The response from the service provider was in an unrecognizable format
  • RouteModel.UnsupportedOptionError - The requested operation or one of the options for the operation are not supported by the service provider.
  • RouteModel.UnknownError - An error occurred which does not fit into any of the other categories

read-onlyerrorString : string

This read-only property holds the textual presentation of latest routing error. If no error has occurred or the model has been reset, an empty string is returned.

An empty string may also be returned if an error occurred which has no associated textual representation.


plugin : Plugin

This property holds the plugin that providers the actual routing service. Note that all plugins do not necessarily provide routing (could for example provide only geocoding or maps).

A valid plugin must be set before the RouteModel can perform any useful operations.

See also Plugin.


query : RouteQuery

This property holds the data of the route request. The primary data are the waypoint coordinates and possible further preferences (means of traveling, things to avoid on route etc).


read-onlystatus : enumeration

This read-only property holds the current status of the model.


Method Documentation

RouteModel::cancel()

Cancels any outstanding requests and clears errors. Model status will be set to either RouteModel.Null or RouteModel.Ready.


RouteModel::get(int)

Returns the Route at given index. Use count property to check the amount of routes available. The routes are indexed from zero, so the accessible range is 0...(count - 1).

If you access out of bounds, a zero (null object) is returned and a warning is issued.


RouteModel::reset()

Resets the model. All route data is cleared, any outstanding requests are aborted and possible errors are cleared. Model status will be set to RouteModel.Null


RouteModel::update()

Instructs the RouteModel to update its data. This is most useful when autoUpdate is disabled, to force a refresh when the query has been changed.


Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web