Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdeclarativesearchmodelbase.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
6#include "error_messages_p.h"
7
8#include <QtCore/QCoreApplication>
9#include <QtQml/QQmlInfo>
10#include <QtLocation/QGeoServiceProvider>
11#include <QtLocation/QPlaceIcon>
12#include <QtLocation/QPlaceManager>
13#include <QtLocation/QPlaceSearchRequest>
14#include <QtLocation/QPlaceSearchReply>
15#include <QtPositioning/QGeoCircle>
16#include <QtPositioning/QGeoPolygon>
17#include <QtLocation/private/qplacesearchrequest_p.h>
18
20
25
29
37
42{
43 if (m_plugin == plugin)
44 return;
45
47
48 if (m_complete)
50}
51
67
72{
74 QGeoRoute route;
75 bool routeSearchArea = false;
76 if (searchArea.userType() == qMetaTypeId<QGeoRectangle>()) {
78 } else if (searchArea.userType() == qMetaTypeId<QGeoCircle>()) {
80 } else if (searchArea.userType() == qMetaTypeId<QGeoShape>()) {
82 } else if (searchArea.typeId() == qMetaTypeId<QGeoRoute>()) {
83 route = searchArea.value<QGeoRoute>();
84 if (route == QGeoRoute())
85 return;
86 routeSearchArea = true;
87 }
88
90 // Invalidating the other thing
91 if (routeSearchArea)
93 else
95
96 if (m_request.searchArea() == s
97 && (route == QGeoRoute() || rp->routeSearchArea == route)) {
98 return;
99 }
100
101 if (routeSearchArea)
102 rp->routeSearchArea = route;
103 else
106}
107
112{
113 return m_request.limit();
114}
115
120{
121 if (m_request.limit() == limit)
122 return;
123
126}
127
132{
133 return m_previousPageRequest != QPlaceSearchRequest();
134}
135
140{
141 return m_nextPageRequest != QPlaceSearchRequest();
142}
143
151
156{
157 Status prevStatus = m_status;
158
159 m_status = status;
160 m_errorString = errorString;
161
162 if (prevStatus != m_status)
164}
165
170{
171 if (m_reply)
172 return;
173
175
176 if (!m_plugin) {
177 clearData();
179 return;
180 }
181
183 if (!serviceProvider) {
184 clearData();
186 .arg(m_plugin->name()));
187 return;
188 }
189
190 QPlaceManager *placeManager = serviceProvider->placeManager();
191 if (!placeManager) {
192 clearData();
194 .arg(m_plugin->name()).arg(serviceProvider->errorString()));
195 return;
196 }
197
198 m_reply = sendQuery(placeManager, m_request);
199 if (!m_reply) {
200 clearData();
202 return;
203 }
204
205 m_reply->setParent(this);
210}
211
216{
217 if (!m_reply)
218 return;
219
220 if (!m_reply->isFinished())
221 m_reply->abort();
222
223 if (m_reply) {
225 m_reply = nullptr;
226 }
227
229}
230
241
246{
247 return m_errorString;
248}
249
254{
255 if (m_previousPageRequest == QPlaceSearchRequest())
256 return;
257
258 m_request = m_previousPageRequest;
259 update();
260}
261
266{
267 if (m_nextPageRequest == QPlaceSearchRequest())
268 return;
269
270 m_request = m_nextPageRequest;
271 update();
272}
273
278{
279 Q_UNUSED(suppressSignal);
280}
281
288
293{
294 m_complete = true;
295}
296
301{
303 if (plugin != m_plugin) {
304 if (m_plugin) {
306 this, &QDeclarativeSearchModelBase::pluginNameChanged);
307 }
308 if (plugin) {
310 this, &QDeclarativeSearchModelBase::pluginNameChanged);
311 }
313 }
314
315 if (m_plugin) {
317 if (serviceProvider) {
318 QPlaceManager *placeManager = serviceProvider->placeManager();
319 if (placeManager) {
320 if (placeManager->childCategoryIds().isEmpty()) {
321 QPlaceReply *reply = placeManager->initializeCategories();
323 }
324 }
325 }
326 }
327
329}
330
335
339void QDeclarativeSearchModelBase::pluginNameChanged()
340{
342}
343
348{
349 if (m_previousPageRequest == previous)
350 return;
351
352 m_previousPageRequest = previous;
354}
355
357{
358 if (m_nextPageRequest == next)
359 return;
360
361 m_nextPageRequest = next;
363}
364
void endResetModel()
Completes a model reset operation.
void beginResetModel()
Begins a model reset operation.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
void nameChanged(const QString &name)
QGeoServiceProvider * sharedGeoServiceProvider() const
void setSearchArea(const QVariant &searchArea)
virtual void clearData(bool suppressSignal=false)
QDeclarativeSearchModelBase(QObject *parent=nullptr)
QDeclarativeGeoServiceProvider * plugin
void setPlugin(QDeclarativeGeoServiceProvider *plugin)
virtual void queryFinished()=0
virtual void initializePlugin(QDeclarativeGeoServiceProvider *plugin)
QDeclarativeGeoServiceProvider * m_plugin
Q_INVOKABLE QString errorString() const
void setPreviousPageRequest(const QPlaceSearchRequest &previous)
void setNextPageRequest(const QPlaceSearchRequest &next)
void setStatus(Status status, const QString &errorString=QString())
virtual QPlaceReply * sendQuery(QPlaceManager *manager, const QPlaceSearchRequest &request)=0
\inmodule QtPositioning
Definition qgeocircle.h:15
\inmodule QtPositioning
Definition qgeopolygon.h:16
\inmodule QtPositioning
\inmodule QtLocation
Definition qgeoroute.h:24
\inmodule QtLocation
QPlaceManager * placeManager() const
Returns the QPlaceManager made available by the service provider.
QString errorString() const
Returns a string describing the error which occurred during the last operation that was performed by ...
\inmodule QtPositioning
Definition qgeoshape.h:17
@ PolygonType
Definition qgeoshape.h:35
@ RectangleType
Definition qgeoshape.h:32
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
void setParent(QObject *parent)
Makes the object a child of parent.
Definition qobject.cpp:2195
void deleteLater()
\threadsafe
Definition qobject.cpp:2435
\inmodule QtLocation
QStringList childCategoryIds(const QString &parentId=QString()) const
Returns the child category identifiers of the category corresponding to parentId.
QPlaceReply * initializeCategories()
Initializes the categories of the manager.
\inmodule QtLocation
Definition qplacereply.h:15
void finished()
This signal is emitted when this reply has finished processing.
virtual void abort()
Cancels the operation immediately.
bool isFinished() const
Return true if the reply has completed.
void contentUpdated()
This signal is emitted when this reply has updated content available.
static const QPlaceSearchRequestPrivate * get(const QPlaceSearchRequest &request)
\inmodule QtLocation
QGeoShape searchArea() const
Returns the search area which will be used to limit search results.
int limit() const
Returns the maximum number of search results to retrieve.
void setLimit(int limit)
Set the maximum number of search results to retrieve to limit.
void setSearchArea(const QGeoShape &area)
Sets the search request to search within the given area.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
T value() const &
Definition qvariant.h:516
int userType() const
Definition qvariant.h:339
int typeId() const
Returns the storage type of the value stored in the variant.
Definition qvariant.h:340
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
QT_BEGIN_NAMESPACE const char CONTEXT_NAME[]
const char PLUGIN_ERROR[]
const char PLUGIN_PROVIDER_ERROR[]
const char UNABLE_TO_MAKE_REQUEST[]
const char PLUGIN_PROPERTY_NOT_SET[]
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
GLdouble s
[6]
Definition qopenglext.h:235
GLint limit
SSL_CTX int void * arg
#define emit
#define Q_UNUSED(x)
myObject disconnect()
[26]
QNetworkReply * reply