PlaceRecommendationModelThe PlaceRecommendationModel element provides a model of place recommendations. More... This type was introduced in Qt Location 5.0. Properties
MethodsDetailed DescriptionPlaceRecommendationModel 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:
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 } } PagingThe 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 DocumentationThis 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. 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. 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. 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. This property holds place identifier used in the recommendation search query. 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. This property holds the status of the model. It can be one of:
Method DocumentationCancels an ongoing search query. See also execute() and status. Returns the data for a given role at the specified row index. 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. 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(); } } |