forked from vladest/googlemaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qgeomapreplygooglemaps.cpp
72 lines (58 loc) · 1.45 KB
/
qgeomapreplygooglemaps.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "qgeomapreplygooglemaps.h"
#include <QNetworkAccessManager>
#include <QNetworkCacheMetaData>
#include <QDateTime>
QT_BEGIN_NAMESPACE
QGeoMapReplyGooglemaps::QGeoMapReplyGooglemaps(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent)
: QGeoTiledMapReply(spec, parent),
m_reply(reply)
{
connect(m_reply,
SIGNAL(finished()),
this,
SLOT(networkFinished()));
connect(m_reply,
SIGNAL(error(QNetworkReply::NetworkError)),
this,
SLOT(networkError(QNetworkReply::NetworkError)));
}
QGeoMapReplyGooglemaps::~QGeoMapReplyGooglemaps()
{
}
QNetworkReply *QGeoMapReplyGooglemaps::networkReply() const
{
return m_reply;
}
void QGeoMapReplyGooglemaps::abort()
{
if (!m_reply)
return;
m_reply->abort();
}
void QGeoMapReplyGooglemaps::networkFinished()
{
if (!m_reply)
return;
if (m_reply->error() != QNetworkReply::NoError)
return;
setMapImageData(m_reply->readAll());
const int _mid = tileSpec().mapId();
if (_mid == 2)
setMapImageFormat("jpeg");
else
setMapImageFormat("png");
setFinished(true);
m_reply->deleteLater();
m_reply = 0;
}
void QGeoMapReplyGooglemaps::networkError(QNetworkReply::NetworkError error)
{
Q_UNUSED(error);
if (!m_reply)
return;
setFinished(true);
setCached(false);
m_reply->deleteLater();
m_reply = 0;
}
QT_END_NAMESPACE