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  · 

PlaceSearchSuggestionModel

The PlaceSearchSuggestionModel element provides access to search term suggestions. More...

Inherits QtObject

This type was introduced in Qt Location 5.0.

Properties

Methods

Detailed Description

The PlaceSearchSuggestionModel can be used to provide search term suggestions as the user enters their search term. The properties of this model should match that of the PlaceSearchModel, which will be used to perform the actual search query, to ensure that the search suggestion results are relevant.

There are two ways of accessing the data provided by this model, either through the suggestions property or through views and delegates. The latter is the preferred method.

The offset and limit properties can be used to access paged suggestions. When the offset and limit properties are set the suggestions between offset and (offset + limit - 1) will be returned. Support for paging may vary from plugin to plugin.

The model returns data for the following roles:

RoleTypeDescription
suggestionstringSuggested search term.

The following example shows how to use the PlaceSearchSuggestionModel to get suggested search terms from a partial search term. The searchArea is set to match what would be used to perform the actual place search with PlaceSearchModel.

 import QtQuick 2.0
 import QtLocation 5.0

 PlaceSearchSuggestionModel {
     id: suggestionModel

     plugin: myPlugin

     searchArea: BoundingCircle {
         center: Coordinate {
             // Brisbane
             longitude: 153.02778
             latitude: -27.46778
         }
     }

     onSearchTermChanged: update()
 }

 ListView {
     model: suggestionModel
     delegate: Text { text: suggestion }
 }

See also PlaceSearchModel and QPlaceManager.

Property Documentation

errorString : string

This read-only property holds the textual presentation of latest search suggestion model error. If no error has occurred, or if the model was cleared, 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 limit of the number of items that will be returned.

See also offset.


offset : int

This property holds the index of the first item in the model.

See also limit.


plugin : Plugin

This property holds the provider Plugin which will be used to perform the search.


searchArea : BoundingArea

This property holds the search area. Search suggestion results returned by the model will be relevant to the given search area.

If this property is set to a BoundingCircle its radius property may be left unset, in which case the Plugin will choose an appropriate radius for the search.


searchTerm : string

This property holds the partial search term used in query.


read-onlystatus : enum

This property holds the status of the model. It can be one of:

PlaceSearchSuggestionModel.NullNo search query has been executed. The model is empty.
PlaceSearchSuggestionModel.ReadyThe search query has completed, and the results are available.
PlaceSearchSuggestionModel.LoadingA search query is currently being executed.
PlaceSearchSuggestionModel.ErrorAn error occurred when executing the previous search query.

read-onlysuggestions : stringlist

This property holds the list of predicted search terms that the model currently has.


Method Documentation

PlaceSearchSuggestionModel::cancel()

Cancels an ongoing search suggestion operation.

See also execute() and status.


PlaceSearchSuggestionModel::reset()

Resets the model. All search suggestions are cleared, any outstanding requests are aborted and possible errors are cleared. Model status will be set to PlaceSearchSuggestionModel.Null.


PlaceSearchSuggestionModel::update()

Updates the model based on the provided query parameters. The model will be populated with a list of search suggestions for the partial searchTerm and searchArea. If the plugin supports it, other paramaters such as limit and offset may be specified. update() submits the set of parameters to the plugin to process.

While the model is updating the status of the model is set to PlaceSearchSuggestionModel.Loading. If the model is successfully updated, the status is set to PlaceSearchSuggestionModel.Ready, while if it unsuccessfully completes, the status is set to PlaceSearchSuggestionModel.Error and the model cleared.

This example shows use of the model

 BoundingCircle {
     id: searchLocation
     center: Coordinate {
         latitude: 10
         longitude: 10
     }
 }

 PlaceSeachSuggestionModel {
     id: model
     plugin: backendPlugin
     searchArea: searchLocation
     ...
 }

 MouseArea {
     ...
     onClicked: {
         model.searchTerm = "piz"
         searchLocation.center.latitude = -27.5
         searchLocation.cetner.longitude = 153
         model.update();
     }
 }

A more detailed example can be found in the in places example.

See also cancel() and status.


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