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