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
qgeocodereply_nokia.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
7
8#include <QtPositioning/QGeoShape>
9#include <QtCore/QCoreApplication>
10
11Q_DECLARE_METATYPE(QList<QGeoLocation>)
12
14
15// manualBoundsRequired will be true if the parser has to manually
16// check if a given result lies within the viewport bounds,
17// and false if the bounds information was able to be supplied
18// to the server in the request (so it should not return any
19// out-of-bounds results).
21 const QGeoShape &viewport, bool manualBoundsRequired,
22 QObject *parent)
23: QGeoCodeReply(parent), m_parsing(false), m_manualBoundsRequired(manualBoundsRequired)
24{
25 if (!reply) {
26 setError(UnknownError, QStringLiteral("Null reply"));
27 return;
28 }
29 qRegisterMetaType<QList<QGeoLocation> >();
30
32 this, &QGeoCodeReplyNokia::networkFinished);
34 this, &QGeoCodeReplyNokia::networkError);
36 connect(this, &QGeoCodeReply::aborted, [this](){ m_parsing = false; });
38
39
43}
44
48
49void QGeoCodeReplyNokia::networkFinished()
50{
51 QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
53
55 return;
56
57 QGeoCodeJsonParser *parser = new QGeoCodeJsonParser; // QRunnable, autoDelete = true.
58 if (m_manualBoundsRequired)
59 parser->setBounds(viewport());
60 connect(parser, &QGeoCodeJsonParser::results, this, &QGeoCodeReplyNokia::appendResults);
61 connect(parser, &QGeoCodeJsonParser::errorOccurred, this, &QGeoCodeReplyNokia::parseError);
62
63 m_parsing = true;
64 parser->parse(reply->readAll());
65}
66
67void QGeoCodeReplyNokia::networkError(QNetworkReply::NetworkError error)
68{
70
71 QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
74}
75
76void QGeoCodeReplyNokia::appendResults(const QList<QGeoLocation> &locations)
77{
78 if (!m_parsing)
79 return;
80
81 m_parsing = false;
83 setFinished(true);
84}
85
86void QGeoCodeReplyNokia::parseError(const QString &errorString)
87{
89
92}
93
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
void setBounds(const QGeoShape &bounds)
void errorOccurred(const QString &errorString)
void parse(const QByteArray &data)
void results(const QList< QGeoLocation > &locations)
QGeoCodeReplyNokia(QNetworkReply *reply, int limit, int offset, const QGeoShape &viewport, bool manualBoundsRequired, QObject *parent=nullptr)
\inmodule QtLocation
void setLimit(qsizetype limit)
Sets the limit on the number of responses from each data source to limit.
QGeoShape viewport() const
Returns the viewport which contains the results.
void setViewport(const QGeoShape &viewport)
Sets the viewport which contains the results to viewport.
Error error() const
Returns the error state of this reply.
void setFinished(bool finished)
Sets whether or not this reply has finished to finished.
void setError(Error error, const QString &errorString)
Sets the error state of this reply to error and the textual representation of the error to errorStrin...
void setLocations(const QList< QGeoLocation > &locations)
Sets the list of locations in the reply.
void setOffset(qsizetype offset)
Sets the offset in the entire result set at which to start fetching result to offset.
QString errorString() const
Returns the textual representation of the error state of this reply.
\inmodule QtPositioning
Definition qgeoshape.h:17
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
void errorOccurred(QNetworkReply::NetworkError)
NetworkError error() const
Returns the error that was found during the processing of this request.
virtual void abort()=0
Aborts the operation immediately and close down any network connections still open.
NetworkError
Indicates all possible error conditions found during the processing of the request.
void finished()
This signal is emitted when the reply has finished processing.
\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
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition qobject.cpp:2658
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void deleteLater()
\threadsafe
Definition qobject.cpp:2435
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
const char RESPONSE_NOT_RECOGNIZABLE[]
QT_BEGIN_NAMESPACE const char NOKIA_PLUGIN_CONTEXT_NAME[]
#define Q_DECLARE_METATYPE(TYPE)
Definition qmetatype.h:1525
GLenum GLuint GLintptr offset
GLint limit
GLuint const GLint * locations
#define QStringLiteral(str)
#define Q_UNUSED(x)
view viewport() -> scroll(dx, dy, deviceRect)
QNetworkReply * reply