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
geotiledmapreply_esri.cpp
Go to the documentation of this file.
1// Copyright (C) 2013-2018 Esri <contracts@esri.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtLocation/private/qgeotilespec_p.h>
7
9
10static const unsigned char pngSignature[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00};
11static const unsigned char jpegSignature[] = {0xFF, 0xD8, 0xFF, 0x00};
12static const unsigned char gifSignature[] = {0x47, 0x49, 0x46, 0x38, 0x00};
13
15 QObject *parent) :
16 QGeoTiledMapReply(spec, parent)
17{
18 if (!reply) {
19 setError(UnknownError, QStringLiteral("Null reply"));
20 return;
21 }
23 this, &GeoTiledMapReplyEsri::networkReplyFinished);
25 this, &GeoTiledMapReplyEsri::networkReplyError);
28}
29
33
34void GeoTiledMapReplyEsri::networkReplyFinished()
35{
36 QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
38
40 return;
41
43
44 bool validFormat = true;
45 if (imageData.startsWith(reinterpret_cast<const char*>(pngSignature)))
47 else if (imageData.startsWith(reinterpret_cast<const char*>(jpegSignature)))
49 else if (imageData.startsWith(reinterpret_cast<const char*>(gifSignature)))
51 else
52 validFormat = false;
53
54 if (validFormat)
56
57 setFinished(true);
58}
59
60void GeoTiledMapReplyEsri::networkReplyError(QNetworkReply::NetworkError error)
61{
62 QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
65 setFinished(true);
66 else
68}
69
GeoTiledMapReplyEsri(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent=nullptr)
\inmodule QtCore
Definition qbytearray.h:57
bool startsWith(QByteArrayView bv) const
Definition qbytearray.h:223
\inmodule QtLocation
void setMapImageFormat(const QString &format)
Sets the format of the tile image to format.
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 setMapImageData(const QByteArray &data)
Sets the tile image data to data.
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
static const unsigned char gifSignature[]
static QT_BEGIN_NAMESPACE const unsigned char pngSignature[]
static const unsigned char jpegSignature[]
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
#define QStringLiteral(str)
QByteArray imageData
[15]
QNetworkReply * reply