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  · 

GeocodeModel

The GeocodeModel element provides support for searching operations related to geographic information. More...

Inherits QtObject

This type was introduced in Qt Location 5.0.

Properties

Methods

Detailed Description

The GeocodeModel element is used as part of a model/view grouping to match addresses or search strings with geographic locations. How the geographic locations generated are used or displayed is decided by any Views attached to the GeocodeModel (for example a MapItemView or ListView).

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

Once the plugin is set, the query property can be used to specify the address or search string to match. If autoUpdate is enabled, the Model will update its output automatically. Otherwise, the update method may be used. By default, autoUpdate is disabled.

The data stored and returned in the GeocodeModel consists of Location elements, as a list with the role name "locationData". See the documentation for Location 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 geocodeModel's autoUpdate property to false, and call update once the query is set up. In this case, as we use a string value in query, only one update would occur, even with autoUpdate enabled. However, if we provided an Address object we may inadvertently trigger multiple requests whilst setting its properties.

 Plugin {
     id: aPlugin
 }

 GeocodeModel {
     id: geocodeModel
     plugin: aPlugin
     autoUpdate: false
 }
 {
     geocodeModel.query = "53 Brandl St, Eight Mile Plains, Australia"
     geocodeModel.update()
 }

Property Documentation

autoUpdate : bool

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

If setting this value to 'true' and using an Address or Coordinate element as the query, note that any change at all in the element's properties will trigger a new request to be sent. If you are adjusting many properties of the element whilst autoUpdate is enabled, this can generate large numbers of useless (and later discarded) requests.


read-onlycount : int

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


read-onlyerror : enumeration

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

  • GeocodeModel.NoError - No error has occurred
  • GeocodeModel.EngineNotSetError - The plugin/service provider used does not support (reverse) geocoding
  • GeocodeModel.CommunicationError - An error occurred while communicating with the service provider
  • GeocodeModel.ParseError - The response from the service provider was in an unrecognizable format
  • GeocodeModel.UnsupportedOptionError - The requested operation or one of the options for the operation are not supported by the service provider.
  • GeocodeModel.CombinationError - An error occurred while results where being combined from multiple sources
  • GeocodeModel.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 geocoding 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.


limit : int

This property holds the maximum number of results. The limit and offset values are only applicable with free string geocoding (that is they are not considered when using addresses or coordinates in the search query).

If limit is -1 the entire result set will be returned, otherwise at most limit results will be returned. The limit and offset results can be used together to implement paging.


offset : int

This property tells not to return the first 'offset' number of the results. The limit and offset values are only applicable with free string geocoding (that is they are not considered when using addresses or coordinates in the search query).

The limit and offset results can be used together to implement paging.


plugin : Plugin

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

See also Plugin.


query : QVariant

This property holds the data of the geocoding request. The property accepts three types of queries which determine both the data and the type of action to be performed:

  • Address - Geocoding (address to coordinate)
  • Coordinate - Reverse geocoding (coordinate to address)
  • string - Geocoding (address to coordinate)

read-onlystatus : enumeration

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


Method Documentation

GeocodeModel::cancel()

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


GeocodeModel::get(int)

Returns the Location at given index. Use count property to check the amount of locations available. The locations 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.


GeocodeModel::reset()

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


GeocodeModel::update()

Instructs the GeocodeModel 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