PlaceSearchSuggestionModel QML Type▲
-
Import Statement: import QtLocation 6.5
-
Since:: QtLocation 5.5
-
Group: PlaceSearchSuggestionModel is part of qml-QtLocation5-places, qml-QtLocation5-places-models
I. 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:
Role |
Type |
Description |
---|---|---|
suggestion |
string |
Suggested 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
import
QtPositioning
import
QtLocation
PlaceSearchSuggestionModel {
id
:
suggestionModel
plugin
:
myPlugin
// Brisbane
searchArea
:
QtPositioning.circle(QtPositioning.coordinate(-
27.46778, 153.02778))
onSearchTermChanged
:
update()
}
ListView
{
model
:
suggestionModel
delegate
:
Text
{
text
:
suggestion }
}
I-1. See Also▲
See also PlaceSearchModel, QPlaceManager
II. Property Documentation▲
II-1. limit : int▲
This property holds the limit of the number of items that will be returned.
II-1-1. See Also▲
See also offset
II-2. offset : int▲
II-3. plugin : Plugin▲
This property holds the provider Plugin which will be used to perform the search.
II-4. searchArea : geoshape▲
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 geocircle its radius property may be left unset, in which case the Plugin will choose an appropriate radius for the search.
II-5. searchTerm : string▲
This property holds the partial search term used in query.
II-6. [read-only] status : enum▲
This property holds the status of the model. It can be one of:
No search query has been executed. The model is empty. |
|
The search query has completed, and the results are available. |
|
PlaceSearchSuggestionModel.Loading |
A search query is currently being executed. |
An error occurred when executing the previous search query. |
II-7. [read-only] suggestions : stringlist▲
This property holds the list of predicted search terms that the model currently has.
III. Method Documentation▲
III-1. void cancel()▲
Cancels an ongoing search suggestion operation immediately and sets the model status to PlaceSearchSuggestionModel.Ready. The model retains any search suggestions it had before the operation was started.
If an operation is not ongoing, invoking cancel() has no effect.
III-1-1. See Also▲
III-2. string errorString()▲
This read-only property holds the textual presentation of the 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.
III-3. void 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.
III-4. void 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 parameters 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
PlaceSeachSuggestionModel {
id
:
model
plugin
:
backendPlugin
searchArea
:
QtPositioning.circle(QtPositioning.coordinate(10
, 10
))
...
}
MouseArea {
...
onClicked
:
{
model.searchTerm =
"piz"
model.searchArea.center.latitude =
-
27.5
;
model.searchArea.cetner.longitude =
153
;
model.update();
}
}
A more detailed example can be found in the in Places (QML) example.