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
qdeclarativesearchsuggestionmodel.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 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
7#include <QtQml/QQmlInfo>
8#include <QtLocation/QGeoServiceProvider>
9
10#include <qplacemanager.h>
11#include <qplacesearchrequest.h>
13
15
193
197
207
216
223{
224 return m_suggestions;
225}
226
231{
233
234 if (!m_suggestions.isEmpty()) {
235 m_suggestions.clear();
236
237 if (!suppressSignal)
239 }
240}
241
246{
248
249 return m_suggestions.count();
250}
251
256{
257 if (!index.isValid())
258 return QVariant();
259
260 if (index.row() >= rowCount(index.parent()) || index.row() < 0)
261 return QVariant();
262
263 switch (role) {
264 case Qt::DisplayRole:
266 return m_suggestions.at(index.row());
267 }
268
269 return QVariant();
270}
271
273{
274 QHash<int, QByteArray> roleNames = QDeclarativeSearchModelBase::roleNames();
276 return roleNames;
277}
278
283{
284 if (!m_reply)
285 return;
286
288 m_reply = nullptr;
289
290 int initialCount = m_suggestions.count();
292
293 clearData(true);
294
295 QPlaceSearchSuggestionReply *suggestionReply = qobject_cast<QPlaceSearchSuggestionReply *>(reply);
296 m_suggestions = suggestionReply->suggestions();
297
298 if (initialCount != m_suggestions.count())
300
302
303 if (suggestionReply->error() != QPlaceReply::NoError)
304 setStatus(Error, suggestionReply->errorString());
305 else
307
308
310}
311
320
void endResetModel()
Completes a model reset operation.
virtual QHash< int, QByteArray > roleNames() const
void beginResetModel()
Begins a model reset operation.
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
virtual void clearData(bool suppressSignal=false)
void setStatus(Status status, const QString &errorString=QString())
QVariant data(const QModelIndex &index, int role) const override
int rowCount(const QModelIndex &parent) const override
void clearData(bool suppressSignal=false) override
QHash< int, QByteArray > roleNames() const override
QDeclarativeSearchSuggestionModel(QObject *parent=nullptr)
\qmltype PlaceSearchSuggestionModel \instantiates QDeclarativeSearchSuggestionModel \inqmlmodule QtLo...
QPlaceReply * sendQuery(QPlaceManager *manager, const QPlaceSearchRequest &request) override
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1303
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
void deleteLater()
\threadsafe
Definition qobject.cpp:2435
\inmodule QtLocation
\inmodule QtLocation
Definition qplacereply.h:15
QPlaceReply::Error error() const
Returns the error code.
QString errorString() const
Returns the error string of the reply.
\inmodule QtLocation
void setSearchTerm(const QString &term)
Sets the search term.
QString searchTerm() const
Returns the search term.
QStringList suggestions() const
Returns the search term suggestions.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.
@ DisplayRole
GLuint index
[2]
#define emit
#define Q_UNUSED(x)
QNetworkAccessManager manager
QNetworkRequest request(url)
QNetworkReply * reply