Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qplacemanagerengine.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
7
8#include <QtCore/QLocale>
9#include <QtCore/QMap>
10#include <QtCore/QMetaType>
11#include <QtCore/QUrl>
12#include <QtCore/QVariant>
13
14#include "qplace.h"
15#include "qplacecategory.h"
16#include "qplaceicon.h"
17
18QT_BEGIN_NAMESPACE
19
20/*!
21 \class QPlaceManagerEngine
22 \inmodule QtLocation
23 \ingroup QtLocation-impl
24 \ingroup QtLocation-places
25 \ingroup QtLocation-places-manager
26 \since 5.6
27
28 \brief The QPlaceManagerEngine class provides an interface for
29 implementers of QGeoServiceProvider plugins who want to provide access to place
30 functionality.
31
32 \note There are no source or binary compatibility guarantees for the
33 backend classes. The API is only guaranteed to work with the Qt version it
34 was developed against. API changes will however only be made in minor
35 releases. (6.6, 6.7, and so on.)
36
37 Application developers need not concern themselves with the QPlaceManagerEngine.
38 Backend implementers however will need to derive from QPlaceManagerEngine and provide
39 implementations for the abstract virtual functions.
40
41 For more information on writing a backend see the \l {Places Backend} documentation.
42
43 \sa QPlaceManager
44*/
45
46/*!
47 Constructs a new engine with the specified \a parent, using \a parameters to pass any
48 implementation specific data to the engine.
49*/
50QPlaceManagerEngine::QPlaceManagerEngine(const QVariantMap &parameters,
51 QObject *parent)
52: QObject(parent), d_ptr(new QPlaceManagerEnginePrivate)
53{
54 qRegisterMetaType<QPlaceReply::Error>();
55 qRegisterMetaType<QPlaceReply *>();
56 Q_UNUSED(parameters);
57}
58
59/*!
60 Destroys this engine.
61*/
62QPlaceManagerEngine::~QPlaceManagerEngine()
63{
64 delete d_ptr;
65}
66
67/*!
68 \internal
69 Sets the name which this engine implementation uses to distinguish itself
70 from the implementations provided by other plugins to \a managerName.
71
72 This function does not need to be called by engine implementers,
73 it is implicitly called by QGeoServiceProvider to set the manager
74 name to be the same as the provider's.
75*/
76void QPlaceManagerEngine::setManagerName(const QString &managerName)
77{
78 d_ptr->managerName = managerName;
79}
80
81/*!
82 Returns the name which this engine implementation uses to distinguish
83 itself from the implementations provided by other plugins.
84
85 The manager name is automatically set to be the same
86 as the QGeoServiceProviderFactory::providerName().
87*/
88QString QPlaceManagerEngine::managerName() const
89{
90 return d_ptr->managerName;
91}
92
93/*!
94 \internal
95 Sets the version of this engine implementation to \a managerVersion.
96
97 The combination of managerName() and managerVersion() should be unique
98 amongst plugin implementations.
99*/
100void QPlaceManagerEngine::setManagerVersion(int managerVersion)
101{
102 d_ptr->managerVersion = managerVersion;
103}
104
105/*!
106 Returns the version of this engine implementation.
107
108 The manager version is automatically set to be the same
109 as the QGeoServiceProviderFactory::providerVersion().
110*/
111int QPlaceManagerEngine::managerVersion() const
112{
113 return d_ptr->managerVersion;
114}
115
116/*!
117 Retrieves details of place corresponding to the given \a placeId.
118*/
119QPlaceDetailsReply *QPlaceManagerEngine::getPlaceDetails(const QString &placeId)
120{
121 Q_UNUSED(placeId);
122
123 return new QPlaceDetailsReplyUnsupported(this);
124}
125
126/*!
127 Retrieves content for a place according to the parameters specified in \a request.
128*/
129QPlaceContentReply *QPlaceManagerEngine::getPlaceContent(const QPlaceContentRequest &request)
130{
131 Q_UNUSED(request);
132
133 return new QPlaceContentReplyUnsupported(this);
134}
135
136/*!
137 Searches for places according to the parameters specified in \a request.
138*/
139QPlaceSearchReply *QPlaceManagerEngine::search(const QPlaceSearchRequest &request)
140{
141 Q_UNUSED(request);
142
143 return new QPlaceSearchReplyUnsupported(QPlaceReply::UnsupportedError,
144 QStringLiteral("Place search is not supported."), this);
145}
146
147/*!
148 Requests a set of search term suggestions according to the parameters specified in \a request.
149*/
150QPlaceSearchSuggestionReply *QPlaceManagerEngine::searchSuggestions(
151 const QPlaceSearchRequest &request)
152{
153 Q_UNUSED(request);
154
155 return new QPlaceSearchSuggestionReplyUnsupported(this);
156}
157
158/*!
159 Saves a specified \a place to the manager engine's datastore.
160*/
161QPlaceIdReply *QPlaceManagerEngine::savePlace(const QPlace &place)
162{
163 Q_UNUSED(place);
164
165 return new QPlaceIdReplyUnsupported(QStringLiteral("Save place is not supported"),
166 QPlaceIdReply::SavePlace, this);
167}
168
169/*!
170 Removes the place corresponding to \a placeId from the manager engine's datastore.
171*/
172QPlaceIdReply *QPlaceManagerEngine::removePlace(const QString &placeId)
173{
174 Q_UNUSED(placeId);
175
176 return new QPlaceIdReplyUnsupported(QStringLiteral("Remove place is not supported"),
177 QPlaceIdReply::RemovePlace, this);
178}
179
180/*!
181 Saves a \a category that is a child of the category specified by \a parentId. An empty
182 \a parentId means \a category is saved as a top level category.
183*/
184QPlaceIdReply *QPlaceManagerEngine::saveCategory(const QPlaceCategory &category,
185 const QString &parentId)
186{
187 Q_UNUSED(category);
188 Q_UNUSED(parentId);
189
190 return new QPlaceIdReplyUnsupported(QStringLiteral("Save category is not supported"),
191 QPlaceIdReply::SaveCategory, this);
192}
193
194/*!
195 Removes the category corresponding to \a categoryId from the manager engine's datastore.
196*/
197
198QPlaceIdReply *QPlaceManagerEngine::removeCategory(const QString &categoryId)
199{
200 Q_UNUSED(categoryId);
201
202 return new QPlaceIdReplyUnsupported(QStringLiteral("Remove category is not supported"),
203 QPlaceIdReply::RemoveCategory, this);
204}
205
206/*!
207 Initializes the categories of the manager engine.
208*/
209QPlaceReply *QPlaceManagerEngine::initializeCategories()
210{
211 return new QPlaceReplyUnsupported(QStringLiteral("Categories are not supported."), this);
212}
213
214/*!
215 Returns the parent category identifier of the category corresponding to \a categoryId.
216*/
217QString QPlaceManagerEngine::parentCategoryId(const QString &categoryId) const
218{
219 Q_UNUSED(categoryId);
220
221 return QString();
222}
223
224/*!
225 Returns the child category identifiers of the category corresponding to \a categoryId. If
226 \a categoryId is empty then all top level category identifiers are returned.
227*/
228QStringList QPlaceManagerEngine::childCategoryIds(const QString &categoryId) const
229{
230 Q_UNUSED(categoryId);
231
232 return QStringList();
233}
234
235/*!
236 Returns the category corresponding to the given \a categoryId.
237*/
238QPlaceCategory QPlaceManagerEngine::category(const QString &categoryId) const
239{
240 Q_UNUSED(categoryId);
241
242 return QPlaceCategory();
243}
244
245/*!
246 Returns a list of categories that are children of the category corresponding to \a parentId.
247 If \a parentId is empty, all the top level categories are returned.
248*/
249QList<QPlaceCategory> QPlaceManagerEngine::childCategories(const QString &parentId) const
250{
251 Q_UNUSED(parentId);
252
253 return QList<QPlaceCategory>();
254}
255
256/*!
257 Returns a list of preferred locales. The locales are used as a hint to the manager engine for
258 what language place and category details should be returned in.
259
260 If the first specified locale cannot be accommodated, the manager engine falls back to the next
261 and so forth.
262
263 Support for locales may vary from provider to provider. For those that do support it, by
264 default, the \l {QLocale::setDefault()}{global default locale} will be used. If the manager
265 engine has no locales assigned to it, it implicitly uses the global default locale. For
266 engines that do not support locales, the locale list is always empty.
267*/
268QList<QLocale> QPlaceManagerEngine::locales() const
269{
270 return QList<QLocale>();
271}
272
273/*!
274 Set the list of preferred \a locales.
275*/
276void QPlaceManagerEngine::setLocales(const QList<QLocale> &locales)
277{
278 Q_UNUSED(locales);
279}
280
281/*!
282 Returns the manager instance used to create this engine.
283*/
284QPlaceManager *QPlaceManagerEngine::manager() const
285{
286 return d_ptr->manager;
287}
288
289/*!
290 Returns a pruned or modified version of the \a original place
291 which is suitable to be saved by the manager engine.
292
293 Only place details that are supported by this manager is
294 present in the modified version. Manager specific data such
295 as the place id, is not copied over from the \a original.
296*/
297QPlace QPlaceManagerEngine::compatiblePlace(const QPlace &original) const
298{
299 Q_UNUSED(original);
300 return QPlace();
301}
302
303/*!
304 Returns a reply which contains a list of places which correspond/match those
305 specified in \a request.
306*/
307QPlaceMatchReply * QPlaceManagerEngine::matchingPlaces(const QPlaceMatchRequest &request)
308{
309 Q_UNUSED(request);
310
311 return new QPlaceMatchReplyUnsupported(this);
312}
313
314/*!
315 QUrl QPlaceManagerEngine::constructIconUrl(const QPlaceIcon &icon, const QSize &size)
316
317 Constructs an icon url from a given \a icon, \a size. The URL of the icon
318 image that most closely matches the given parameters is returned.
319*/
320QUrl QPlaceManagerEngine::constructIconUrl(const QPlaceIcon &icon, const QSize &size) const
321{
322 Q_UNUSED(icon);
323 Q_UNUSED(size);
324
325 return QUrl();
326}
327
328/*!
329 \fn void QPlaceManagerEngine::finished(QPlaceReply *reply)
330
331 This signal is emitted when \a reply has finished processing.
332
333 If reply->error() equals QPlaceReply::NoError then the processing
334 finished successfully.
335
336 This signal and QPlaceReply::finished() will be emitted at the same time.
337
338 \note Do not delete the \a reply object in the slot connected to this signal.
339 Use deleteLater() instead.
340*/
341
342/*!
343 \fn void QPlaceManagerEngine::errorOccurred(QPlaceReply * reply, QPlaceReply::Error error, const QString &errorString = QString());
344
345 This signal is emitted when an error has been detected in the processing of
346 \a reply. The QPlaceManager::finished() signal will probably follow.
347
348 The error will be described by the error code \a error. If \a errorString is
349 not empty it will contain a textual description of the error meant for developers
350 and not end users.
351
352 This signal and QPlaceReply::errorOccurred() will be emitted at the same time.
353
354 \note Do not delete the \a reply object in the slot connected to this signal.
355 Use deleteLater() instead.
356*/
357
358/*!
359 \fn void QPlaceManagerEngine::placeAdded(const QString &placeId)
360
361 This signal is emitted if a place has been added to the manager engine's datastore.
362 The particular added place is specified by \a placeId.
363
364 This signal is only emitted by manager engines that support the QPlaceManager::NotificationsFeature.
365 \sa dataChanged()
366*/
367
368/*!
369 \fn void QPlaceManagerEngine::placeUpdated(const QString &placeId)
370
371 This signal is emitted if a place has been modified in the manager engine's datastore.
372 The particular modified place is specified by \a placeId.
373
374 This signal is only emitted by manager engines that support the QPlaceManager::NotificationsFeature.
375 \sa dataChanged()
376*/
377
378/*!
379 \fn void QPlaceManagerEngine::placeRemoved(const QString &placeId)
380
381 This signal is emitted if a place has been removed from the manager engine's datastore.
382 The particular place that has been removed is specified by \a placeId.
383
384 This signal is only emitted by manager engines that support the QPlaceManager::NotificationsFeature.
385 \sa dataChanged()
386*/
387
388/*!
389 \fn void QPlaceManagerEngine::categoryAdded(const QPlaceCategory &category, const QString &parentId)
390
391 This signal is emitted if a \a category has been added to the manager engine's datastore.
392 The parent of the \a category is specified by \a parentId.
393
394 This signal is only emitted by manager engines that support the QPlaceManager::NotificationsFeature.
395 \sa dataChanged()
396*/
397
398/*!
399 \fn void QPlaceManagerEngine::categoryUpdated(const QPlaceCategory &category, const QString &parentId)
400
401 This signal is emitted if a \a category has been modified in the manager engine's datastore.
402 The parent of the modified category is specified by \a parentId.
403
404 This signal is only emitted by manager engines that support the QPlaceManager::NotificationsFeature.
405 \sa dataChanged()
406*/
407
408/*!
409 \fn void QPlaceManagerEngine::categoryRemoved(const QString &categoryId, const QString &parentId)
410
411 This signal is emitted when the category corresponding to \a categoryId has
412 been removed from the manager engine's datastore. The parent of the removed category
413 is specified by \a parentId.
414
415 This signal is only emitted by manager engines that support the QPlaceManager::NotificationsFeature.
416 \sa dataChanged()
417*/
418
419/*!
420 * \fn QPlaceManagerEngine::dataChanged()
421
422 This signal is emitted by the engine if there are large scale changes to its
423 underlying datastore and the engine considers these changes radical enough
424 to require clients to reload all data.
425
426 If the signal is emitted, no other signals will be emitted for the associated changes.
427*/
428
429QT_END_NAMESPACE