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
qplacecontentreplyimpl.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
4#include "jsonparserhelpers.h"
9
10
11#include <QCoreApplication>
12#include <QtCore/QJsonDocument>
13#include <QtCore/QJsonObject>
14
16
20 : QPlaceContentReply(engine), m_engine(engine)
21{
23 if (!reply) {
24 setError(UnknownError, QStringLiteral("Null reply"));
25 return;
26 }
28
30 this, &QPlaceContentReplyImpl::replyFinished);
32 this, &QPlaceContentReplyImpl::replyError);
35}
36
40
41void QPlaceContentReplyImpl::setError(QPlaceReply::Error error_, const QString &errorString)
42{
45 setFinished(true);
46 emit finished();
47}
48
49void QPlaceContentReplyImpl::replyFinished()
50{
51 QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
53
55 return;
56
58 if (!document.isObject()) {
60 return;
61 }
62
63 QJsonObject object = document.object();
64
66 int totalCount;
67 QPlaceContentRequest previous;
69
70 parseCollection(request().contentType(), object, &collection, &totalCount,
71 &previous, &next, m_engine);
72
74 setContent(collection);
75 setPreviousPageRequest(previous);
77
78 setFinished(true);
79 emit finished();
80}
81
82void QPlaceContentReplyImpl::replyError(QNetworkReply::NetworkError error)
83{
84 QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
87 setError(QPlaceReply::CancelError, QStringLiteral("Request cancelled"));
88 else
90}
91
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
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.
\inmodule QtCore\reentrant
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
Definition qjsonobject.h:20
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.
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
QPlaceContentReplyImpl(const QPlaceContentRequest &request, QNetworkReply *reply, QPlaceManagerEngineNokiaV2 *engine)
\inmodule QtLocation
int totalCount() const
Returns the total number of content objects for a place.
void setPreviousPageRequest(const QPlaceContentRequest &previous)
Sets the place content request that can be used to request the previous batch of place content result...
void setTotalCount(int total)
Sets the total number of content objects for a place.
void setRequest(const QPlaceContentRequest &request)
Sets the content request used to generate this this reply.
void setContent(const QPlaceContent::Collection &content)
Sets the content of the reply.
void setNextPageRequest(const QPlaceContentRequest &next)
Sets the place content request that can be used to request the next batch of place content results to...
QPlaceContentRequest request() const
Returns the content request that was used to generate this reply.
\inmodule QtLocation
QPlaceReply::Error error() const
Returns the error code.
void errorOccurred(QPlaceReply::Error error, const QString &errorString=QString())
This signal is emitted when an error has been detected in the processing of this reply.
void finished()
This signal is emitted when this reply has finished processing.
Error
Describes an error which occurred during an operation.
Definition qplacereply.h:18
void aborted()
QString errorString() const
Returns the error string of the reply.
void setError(QPlaceReply::Error error, const QString &errorString)
Sets the error and errorString of the reply.
void setFinished(bool finished)
Sets the status of whether the reply is finished or not.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
void parseCollection(QPlaceContent::Type type, const QJsonObject &object, QPlaceContent::Collection *collection, int *totalCount, QPlaceContentRequest *previous, QPlaceContentRequest *next, const QPlaceManagerEngineNokiaV2 *engine)
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
emscripten::val document()
Definition qwasmdom.h:49
DBusConnection const char DBusError * error
QT_BEGIN_NAMESPACE const char NOKIA_PLUGIN_CONTEXT_NAME[]
const char PARSE_ERROR[]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QStringLiteral(str)
#define emit
QNetworkRequest request(url)
QNetworkReply * reply
QJSEngine engine
[0]