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  · 

PlaceRecommendationModel

The PlaceRecommendationModel element provides a model of place recommendations. More...

This type was introduced in Qt Location 5.0.

Properties

Methods

Detailed Description

PlaceRecommendationModel provides a model of place recommendation results that are similar to the place identified by the placeId property.

The following roles can be used to access each recommendation result:

RoleTypeDescription
distancerealIf a search area has been specified and is supported by the plugin, the distance is from the recommended place to the search center, otherwise the distance is from the recommended place to the place identified by placeId. If no area has been specified, the distance is NaN.
placePlaceThe recommended place.

The following example shows how to use the PlaceRecommendationModel to search for recommendations in similar to a given place by providing a place identifier. Note that model does not incrementally fetch recommendations but rather performs a single fetch when execute() is run. The count is set to the number of recommendations returned during the fetch.

 import QtQuick 2.0
 import QtLocation 5.0

 PlaceRecommendationModel {
     id: recommendationModel

     plugin: myPlugin

     placeId: place.placeId

     Component.onCompleted: update()
 }

 ListView {
     model: recommendationModel
     delegate: Text { text: 'Name: ' + place.name }
 }

Paging

The PlaceRecommendationModel API has some limited support for paging. The offset and limit properties can be used to access paged search results. When the offset and limit properties are set the search results between offset and (offset + limit - 1) will be returned. For example, if the backend has 5 recommendations in total [a,b,c,d,e], an offset of 0 specifies that the first item returned in the model will be 'a'. An offset of 1 secifies that the first item in the model will be 'b' and so on. The limit specifies the maximum number of items to be returned. For example, assuming an offset of 0 and limit of 3 then a,b,c is returned. If the offset exceeds (or equals) the total number of items, then 0 results are returned in the model. Note that the API currently does not support a means to retrieve the total number of items available from the backed. Also note that support for offset and limit can vary according to the plugin.

See also PlaceSearchModel, CategoryModel, and QPlaceManager.

Property Documentation

count : int

This property holds the number of results the model has.

Note that it does not refer to the total number of recommendations available in the backend. The total number of recommendations is not currently supported by the API.


errorString : string

This read-only property holds the textual presentation of latest place recommendation 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.


favoritesMatchParameters : VariantMap

This property holds a set of parameters used to specify how recommended places are matched to favorites in the favoritesPlugin.

By default the parameter map is empty and implies that the favorites plugin matches by alternative identifiers. Generally, an application developer will not need to set this property.

In cases where the favorites plugin does not support matching by alternative identifiers, then the backend plugin documentation should be consulted to see precisely what key-value parameters to set.


favoritesPlugin : Plugin

This property holds the Plugin which will be used to look for favorites. Any places from the recommendation search which can be cross-referenced or matched in the favoritesPlugin will have their favorite property set to the corresponding Place from the favoritesPlugin.

If the favoritesPlugin is not set, the favorite property of the places in the results will always be null.

See also Favorites.


limit : int

This property holds the maximum number of items that will be returned.

See also offset.


offset : int

This property holds the index of the first search result in the model.

See also limit.


placeId : string

This property holds place identifier used in the recommendation search query.


plugin : Plugin

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


searchArea : BoundingArea

This property holds the search area. Search results returned by the model will be within the 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.

Support for specifying a search area can vary according according to the plugin backend implementation. For example, some may support a search center only while others may only support bounding boxes.


status : enum

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

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

Method Documentation

PlaceRecommendationModel::cancel()

Cancels an ongoing search query.

See also execute() and status.


PlaceRecommendationModel::data(int index, string role)

Returns the data for a given role at the specified row index.


PlaceRecommendationModel::reset()

Resets the model. All place recommendations are cleared, any outstanding requests are aborted and possible errors are cleared. Model status will be set to PlaceRecommendationModel.Null.


PlaceRecommendationModel::update()

Updates the model based on the provided query parameters. The model will be populated with a list of places similar to the place identified by the placeId property. If the plugin supports it, additional parameters such as limit and offset may be specified and then update() submits the set of criteria to the plugin to process.

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

 PlaceRecomendationModel {
     id: model
     plugin:  backendPlugin
     ...
 }

 MouseArea {
     ...
     onClicked: {
         model.placeId = place.placeId
         limit = -1;
         offset = 0;
         model.update();
     }
 }

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