QPlaceManager

QPlaceManager class provides the interface which allows clients to access places stored in a particular backend. 更多

Inheritance diagram of PySide2.QtLocation.QPlaceManager

概要

函数

信号

详细描述

The following table gives an overview of the functionality provided by the QPlaceManager

功能

描述

Searching for places

Using set of parameters such as a search term and search area, relevant places can be returned to the user.

Categories

Places can be classified as belonging to different categories. The manager supports access to these categories.

Search term suggestions

Given a partially complete search term, a list of potential search terms can be given.

Recommendations

Given an existing place, a set of similar recommended places can be suggested to the user.

Rich Content

Rich content such as images, reviews etc can be retrieved in a paged fashion.

Place or Category management

Places and categories may be saved and removed. It is possible for notifications to be given when this happens.

本地化

Different locales may be specified to return place data in different languages.

Obtaining a QPlaceManager Instance

Creation of a QPlaceManager is facilitated by the QGeoServiceProvider 。见 Initializing a manager for an example on how to create a manager.

Asynchronous Interface

QPlaceManager class provides an abstraction of the datastore which contains place information. The functions provided by the QPlaceManager and primarily asynchronous and follow a request-reply model. Typically a request is given to the manager, consisting of a various set of parameters and a reply object is created. The reply object has a signal to notify when the request is done, and once completed, the reply contains the results of the request, along with any errors that occurred, if any.

An asynchronous request is generally handled as follows:

        //1) Make an appropriate request
        QPlaceSearchRequest searchRequest;
        searchRequest.setSearchTerm("ice cream");
        searchRequest.setSearchArea(QGeoCircle(QGeoCoordinate(12.34, 56.78)));
        //2) Use the manager to initiate a request and retrieve a reply object
        QPlaceSearchReply * searchReply = manager->search(searchRequest);
        //3) Connect the reply object to a slot which is invoked upon operation completion
        connect(searchReply, SIGNAL(finished()), this, SLOT(processSearchReply()));
    ...
    ...
<Code snippet "places/requesthandler.h:Simple search handler" not found>
												

Common Operations for a list of examples demonstrating how the QPlaceManger is used.

Category Initialization

Sometime during startup of an application, the initializeCategories() function should be called to setup the categories. Initializing the categories enables the usage of the following functions:

If the categories need to be refreshed or reloaded, the initializeCategories() function may be called again.

PySide2.QtLocation.QPlaceManager. category ( categoryId )
参数

categoryId – unicode

返回类型

QPlaceCategory

Returns the category corresponding to the given categoryId .

PySide2.QtLocation.QPlaceManager. categoryAdded ( category , parentId )
参数
PySide2.QtLocation.QPlaceManager. categoryRemoved ( categoryId , parentId )
参数
  • categoryId – unicode

  • parentId – unicode

PySide2.QtLocation.QPlaceManager. categoryUpdated ( category , parentId )
参数
PySide2.QtLocation.QPlaceManager. childCategories ( [ parentId="" ] )
参数

parentId – unicode

返回类型

Returns a list of categories that are children of the category corresponding to parentId 。若 parentId is empty, all the top level categories are returned.

PySide2.QtLocation.QPlaceManager. childCategoryIds ( [ parentId="" ] )
参数

parentId – unicode

返回类型

字符串列表

Returns the child category identifiers of the category corresponding to parentId 。若 parentId is empty then all top level category identifiers are returned.

PySide2.QtLocation.QPlaceManager. compatiblePlace ( place )
参数

place QPlace

返回类型

QPlace

Returns a pruned or modified version of the original place which is suitable to be saved into this manager.

Only place details that are supported by this manager is present in the modified version. Manager specific data such as the place id, is not copied over from the original .

PySide2.QtLocation.QPlaceManager. dataChanged ( )
PySide2.QtLocation.QPlaceManager. error ( arg__1 , error [ , errorString="" ] )
参数
PySide2.QtLocation.QPlaceManager. finished ( reply )
参数

reply QPlaceReply

PySide2.QtLocation.QPlaceManager. getPlaceContent ( request )
参数

request QPlaceContentRequest

返回类型

QPlaceContentReply

Retrieves content for a place according to the parameters specified in request .

Fetching Rich Content for an example of usage.

PySide2.QtLocation.QPlaceManager. getPlaceDetails ( placeId )
参数

placeId – unicode

返回类型

QPlaceDetailsReply

Retrieves a details of place corresponding to the given placeId .

Fetching Place Details for an example of usage.

PySide2.QtLocation.QPlaceManager. initializeCategories ( )
返回类型

QPlaceReply

Initializes the categories of the manager.

Using Categories for an example of usage.

PySide2.QtLocation.QPlaceManager. locales ( )
返回类型

Returns a list of preferred locales. The locales are used as a hint to the manager for what language place and category details should be returned in.

If the first specified locale cannot be accommodated, the manager falls back to the next and so forth. Some manager backends may not support a set of locales which are rigidly defined. An arbitrary example is that some places in France could have French and English localizations, while certain areas in America may only have the English localization available. In this example, the set of supported locales is context dependent on the search location.

If the manager cannot accommodate any of the preferred locales, the manager falls back to using a supported language that is backend specific.

Support for locales may vary from provider to provider. For those that do support it, by default, the global default locale is set as the manager’s only locale.

For managers that do not support locales, the locale list is always empty.

另请参阅

setLocales()

PySide2.QtLocation.QPlaceManager. managerName ( )
返回类型

unicode

Returns the name of the manager

PySide2.QtLocation.QPlaceManager. managerVersion ( )
返回类型

int

Returns the manager version.

PySide2.QtLocation.QPlaceManager. matchingPlaces ( request )
参数

request QPlaceMatchRequest

返回类型

QPlaceMatchReply

Returns a reply which contains a list of places which correspond/match those specified in the request . The places specified in the request come from a different manager.

PySide2.QtLocation.QPlaceManager. parentCategoryId ( categoryId )
参数

categoryId – unicode

返回类型

unicode

Returns the parent category identifier of the category corresponding to categoryId .

PySide2.QtLocation.QPlaceManager. placeAdded ( placeId )
参数

placeId – unicode

PySide2.QtLocation.QPlaceManager. placeRemoved ( placeId )
参数

placeId – unicode

PySide2.QtLocation.QPlaceManager. placeUpdated ( placeId )
参数

placeId – unicode

PySide2.QtLocation.QPlaceManager. removeCategory ( categoryId )
参数

categoryId – unicode

返回类型

QPlaceIdReply

Removes the category corresponding to categoryId from the manager.

Removing a category for an example of usage.

PySide2.QtLocation.QPlaceManager. removePlace ( placeId )
参数

placeId – unicode

返回类型

QPlaceIdReply

Removes the place corresponding to placeId from the manager.

Removing a place cpp for an example of usage.

PySide2.QtLocation.QPlaceManager. saveCategory ( category [ , parentId="" ] )
参数
返回类型

QPlaceIdReply

Saves a category that is a child of the category specified by parentId . An empty parentId means category is saved as a top level category.

Saving a category for an example of usage.

PySide2.QtLocation.QPlaceManager. savePlace ( place )
参数

place QPlace

返回类型

QPlaceIdReply

Saves a specified place .

Saving a place cpp for an example of usage.

PySide2.QtLocation.QPlaceManager. search ( query )
参数

query QPlaceSearchRequest

返回类型

QPlaceSearchReply

Searches for places according to the parameters specified in request .

Discovery/Search for an example of usage.

PySide2.QtLocation.QPlaceManager. searchSuggestions ( request )
参数

request QPlaceSearchRequest

返回类型

QPlaceSearchSuggestionReply

Requests a set of search term suggestions according to the parameters specified in request request can hold the incomplete search term, along with other data such as a search area to narrow down relevant results.

Search Suggestions for an example of usage.

PySide2.QtLocation.QPlaceManager. setLocale ( locale )
参数

locale QLocale

Convenience function which sets the manager’s list of preferred locales to a single locale .

PySide2.QtLocation.QPlaceManager. setLocales ( locale )
参数

locale

Set the list of preferred locales .

另请参阅

locales()