The QPlaceManager class provides the interface which allows clients to access places stored in a particular backend. 更多...
头: | #include <QPlaceManager> |
qmake: | QT += location |
Since: | Qt 5.6 |
继承: | QObject |
该类在 Qt 5.6 引入。
virtual | ~QPlaceManager () |
QPlaceCategory | category (const QString & categoryId ) const |
QList<QPlaceCategory> | childCategories (const QString & parentId = QString()) const |
QStringList | childCategoryIds (const QString & parentId = QString()) const |
QPlace | compatiblePlace (const QPlace & original ) |
QPlaceContentReply * | getPlaceContent (const QPlaceContentRequest & request ) const |
QPlaceDetailsReply * | getPlaceDetails (const QString & placeId ) const |
QPlaceReply * | initializeCategories () |
QList<QLocale> | locales () const |
QString | managerName () const |
int | managerVersion () const |
QPlaceMatchReply * | matchingPlaces (const QPlaceMatchRequest & request ) const |
QString | parentCategoryId (const QString & categoryId ) const |
QPlaceIdReply * | removeCategory (const QString & categoryId ) |
QPlaceIdReply * | removePlace (const QString & placeId ) |
QPlaceIdReply * | saveCategory (const QPlaceCategory & category , const QString & parentId = QString()) |
QPlaceIdReply * | savePlace (const QPlace & place ) |
QPlaceSearchReply * | search (const QPlaceSearchRequest & request ) const |
QPlaceSearchSuggestionReply * | searchSuggestions (const QPlaceSearchRequest & request ) const |
void | setLocale (const QLocale & locale ) |
void | setLocales (const QList<QLocale> & locales ) |
void | categoryAdded (const QPlaceCategory & category , const QString & parentId ) |
void | categoryRemoved (const QString & categoryId , const QString & parentId ) |
void | categoryUpdated (const QPlaceCategory & category , const QString & parentId ) |
void | dataChanged () |
void | error (QPlaceReply * reply , QPlaceReply::Error error , const QString & errorString = QString()) |
void | finished (QPlaceReply * reply ) |
void | placeAdded (const QString & placeId ) |
void | placeRemoved (const QString & placeId ) |
void | placeUpdated (const QString & placeId ) |
The following table gives an overview of the functionality provided by the QPlaceManager
Creation of a QPlaceManager is facilitated by the QGeoServiceProvider 。见 Initializing a manager for an example on how to create a manager.
The 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())); ... ... //4) Have the slot appropriately process the results of the operation void processSearchReply() { if (searchReply->error() == QPlaceReply::NoError) { foreach (const QPlaceSearchResult &result, searchReply->results()) { if (result.type() == QPlaceSearchResult::PlaceResult) qDebug() << "Title:" << result.title(); } } //5) Discard the rely object when done. searchReply->deleteLater(); searchReply = 0; }
见 Common Operations for a list of examples demonstrating how the QPlaceManger is used.
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.
[signal]
void
QPlaceManager::
categoryAdded
(const
QPlaceCategory
&
category
, const
QString
&
parentId
)
This signal is emitted if a category has been added to the manager's datastore. The parent of the category is specified by parentId .
This signal is only emitted by managers that support the QPlaceManager::NotificationsFeature.
另请参阅 dataChanged ().
[signal]
void
QPlaceManager::
categoryRemoved
(const
QString
&
categoryId
, const
QString
&
parentId
)
This signal is emitted when the category corresponding to categoryId has been removed from the manager's datastore. The parent of the removed category is specified by parentId .
This signal is only emitted by managers that support the QPlaceManager::NotificationsFeature.
另请参阅 dataChanged ().
[signal]
void
QPlaceManager::
categoryUpdated
(const
QPlaceCategory
&
category
, const
QString
&
parentId
)
This signal is emitted if a category has been modified in the manager's datastore. The parent of the modified category is specified by parentId .
This signal is only emitted by managers that support the QPlaceManager::NotificationsFeature.
另请参阅 dataChanged ().
[signal]
void
QPlaceManager::
dataChanged
()
This signal is emitted by the manager if there are large scale changes to its underlying datastore and the manager considers these changes radical enough to require clients to reload all data.
If the signal is emitted, no other signals will be emitted for the associated changes.
This signal is only emitted by managers that support the QPlaceManager::NotificationsFeature.
[signal]
void
QPlaceManager::
error
(
QPlaceReply
*
reply
,
QPlaceReply::Error
error
, const
QString
&
errorString
= QString())
This signal is emitted when an error has been detected in the processing of reply 。 QPlaceManager::finished () signal will probably follow.
The error will be described by the error code error 。若 errorString is not empty it will contain a textual description of the error meant for developers and not end users.
This signal and QPlaceReply::error () will be emitted at the same time.
注意: 不要删除 reply 对象在连接到此信号的槽中。使用 deleteLater () 代替。
[signal]
void
QPlaceManager::
finished
(
QPlaceReply
*
reply
)
此信号发射当 reply has finished processing.
If reply-> error () 等于 QPlaceReply::NoError then the processing finished successfully.
This signal and QPlaceReply::finished () will be emitted at the same time.
注意: 不要删除 reply 对象在连接到此信号的槽中。使用 deleteLater () 代替。
[signal]
void
QPlaceManager::
placeAdded
(const
QString
&
placeId
)
This signal is emitted if a place has been added to the manager engine's datastore. The particular added place is specified by placeId .
This signal is only emitted by managers that support the QPlaceManager::NotificationsFeature.
另请参阅 dataChanged ().
[signal]
void
QPlaceManager::
placeRemoved
(const
QString
&
placeId
)
This signal is emitted if a place has been removed from the manager's datastore. The particular place that has been removed is specified by placeId .
This signal is only emitted by managers that support the QPlaceManager::NotificationsFeature.
另请参阅 dataChanged ().
[signal]
void
QPlaceManager::
placeUpdated
(const
QString
&
placeId
)
This signal is emitted if a place has been modified in the manager's datastore. The particular modified place is specified by placeId .
This signal is only emitted by managers that support the QPlaceManager::NotificationsFeature.
另请参阅 dataChanged ().
[虚拟]
QPlaceManager::
~QPlaceManager
()
Destroys the manager. This destructor is used internally by QGeoServiceProvider and should never need to be called in application code.
Returns the category corresponding to the given categoryId .
Returns a list of categories that are children of the category corresponding to parentId 。若 parentId is empty, all the top level categories are returned.
Returns the child category identifiers of the category corresponding to parentId 。若 parentId is empty then all top level category identifiers are returned.
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 .
Retrieves content for a place according to the parameters specified in request .
见 Fetching Rich Content for an example of usage.
Retrieves a details of place corresponding to the given placeId .
见 Fetching Place Details for an example of usage.
Initializes the categories of the manager.
见 Using Categories for an example of usage.
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 ().
Returns the name of the manager
Returns the manager version.
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.
Returns the parent category identifier of the category corresponding to categoryId .
Removes the category corresponding to categoryId from the manager.
见 Removing a category for an example of usage.
Removes the place corresponding to placeId from the manager.
见 Removing a place cpp for an example of usage.
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.
Saves a specified place .
见 Saving a place cpp for an example of usage.
Searches for places according to the parameters specified in request .
见 Discovery/Search for an example of usage.
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.
Convenience function which sets the manager's list of preferred locales to a single locale .
Set the list of preferred locales .
另请参阅 locales ().