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
qgeoroutereply_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 <qgeorouterequest.h>
9
10#include <QtCore/QCoreApplication>
11
12Q_DECLARE_METATYPE(QList<QGeoRoute>)
13
15
17 const QList<QNetworkReply *> &replies,
18 QObject *parent)
19: QGeoRouteReply(request, parent), m_parsers(0)
20{
21 qRegisterMetaType<QList<QGeoRoute> >();
22
23 bool failure = false;
24 for (QNetworkReply *reply : replies) {
25 if (!reply) {
26 failure = true;
27 continue;
28 }
30 this, &QGeoRouteReplyNokia::networkFinished);
32 this, &QGeoRouteReplyNokia::networkError);
35 }
36 if (failure)
37 setError(UnknownError, QStringLiteral("Null reply"));
38 else
39 connect(this, &QGeoRouteReply::aborted, [this](){ m_parsers = 0; });
40}
41
45
46void QGeoRouteReplyNokia::networkFinished()
47{
48 QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
50
53 return;
54 }
55
58 this, &QGeoRouteReplyNokia::appendResults);
60 this, &QGeoRouteReplyNokia::parserError);
61
62 ++m_parsers;
63 parser->parse(reply->readAll());
64}
65
66void QGeoRouteReplyNokia::networkError(QNetworkReply::NetworkError error)
67{
69 return;
70 QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
73 if (error != QNetworkReply::OperationCanceledError) // Any error not caused by abort()
74 emit aborted(); // aborts all unfinished replies and sets m_parsers to 0
75}
76
77void QGeoRouteReplyNokia::appendResults(const QList<QGeoRoute> &routes)
78{
79 if (!m_parsers)
80 return;
81
82 --m_parsers;
84
85 if (!m_parsers)
86 setFinished(true);
87}
88
89void QGeoRouteReplyNokia::parserError(const QString &errorString)
90{
92 emit aborted();
95}
96
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
QGeoRouteReplyNokia(const QGeoRouteRequest &request, const QList< QNetworkReply * > &replies, QObject *parent=nullptr)
\inmodule QtLocation
QList< QGeoRoute > routes() const
Returns the list of routes which were requested.
Error error() const
Returns the error state of this reply.
void addRoutes(const QList< QGeoRoute > &routes)
Appends the list of routes to the existing list.
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...
QGeoRouteRequest request() const
Returns the route request which specified the route.
QString errorString() const
Returns the textual representation of the error state of this reply.
void setFinished(bool finished)
Sets whether or not this reply has finished to finished.
\inmodule QtLocation
void parse(const QByteArray &data)
void results(const QList< QGeoRoute > &routes)
void errorOccurred(const QString &errorString)
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
#define QStringLiteral(str)
#define emit
#define Q_UNUSED(x)
QNetworkRequest request(url)
QNetworkReply * reply