Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgeotiledmapreply.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// Qt-Security score:significant reason:default
4
7
8#include <qdebug.h>
9
11/*!
12 \class QGeoTiledMapReply
13 \inmodule QtLocation
14 \ingroup QtLocation-impl
15 \since 5.6
16 \internal
17
18 \brief The QGeoTiledMapReply class manages a tile fetch operation started
19 by an instance of QGeoTiledManagerEngine.
20
21 Instances of QGeoTiledMapReply manage the state and results of these
22 operations.
23
24 The isFinished(), error() and errorString() methods provide information
25 on whether the operation has completed and if it completed successfully.
26
27 The finished() and errorOccurred(QGeoTiledMapReply::Error,QString)
28 signals can be used to monitor the progress of the operation.
29
30 It is possible that a newly created QGeoTiledMapReply may be in a finished
31 state, most commonly because an error has occurred. Since such an instance
32 will never emit the finished() or
33 errorOccurred(QGeoTiledMapReply::Error,QString) signals, it is
34 important to check the result of isFinished() before making the connections
35 to the signals.
36
37 If the operation completes successfully the results are accessed by
38 mapImageData() and mapImageFormat().
39*/
40
41/*!
42 \enum QGeoTiledMapReply::Error
43
44 Describes an error which prevented the completion of the operation.
45
46 \value NoError
47 No error has occurred.
48 \value CommunicationError
49 An error occurred while communicating with the service provider.
50 \value ParseError
51 The response from the service provider was in an unrecognizable format
52 supported by the service provider.
53 \value UnknownError
54 An error occurred which does not fit into any of the other categories.
55*/
56
57/*!
58 Constructs a tiled map reply object based on \a request, with parent \a parent.
59*/
60QGeoTiledMapReply::QGeoTiledMapReply(const QGeoTileSpec &spec, QObject *parent)
61 : QObject(parent),
62 d_ptr(new QGeoTiledMapReplyPrivate(spec))
63{
64}
65
66/*!
67 Constructs a tiled map reply object with a given \a error and \a errorString and the specified \a parent.
68*/
69QGeoTiledMapReply::QGeoTiledMapReply(Error error, const QString &errorString, QObject *parent)
70 : QObject(parent),
71 d_ptr(new QGeoTiledMapReplyPrivate(error, errorString)) {}
72
73/*!
74 Destroys this tiled map reply object.
75*/
76QGeoTiledMapReply::~QGeoTiledMapReply()
77{
78 delete d_ptr;
79}
80
81/*!
82 Sets whether or not this reply has finished to \a finished.
83
84 If \a finished is true, this will cause the finished() signal to be
85 emitted.
86
87 If the operation completed successfully,
88 QGeoTiledMapReply::setMapImageData() should be called before this
89 function. If an error occurred, QGeoTiledMapReply::setError() should be used
90 instead.
91*/
92void QGeoTiledMapReply::setFinished(bool finished)
93{
94 d_ptr->isFinished = finished;
95 if (d_ptr->isFinished)
96 emit this->finished();
97}
98
99/*!
100 Return true if the operation completed successfully or encountered an
101 error which cause the operation to come to a halt.
102*/
103bool QGeoTiledMapReply::isFinished() const
104{
105 return d_ptr->isFinished;
106}
107
108/*!
109 Sets the error state of this reply to \a error and the textual
110 representation of the error to \a errorString.
111
112 This will also cause errorOccurred() and finished() signals to be emitted, in that
113 order.
114*/
115void QGeoTiledMapReply::setError(QGeoTiledMapReply::Error error, const QString &errorString)
116{
117 d_ptr->error = error;
118 d_ptr->errorString = errorString;
119 emit errorOccurred(error, errorString);
120 setFinished(true);
121}
122
123/*!
124 Returns the error state of this reply.
125
126 If the result is QGeoTiledMapReply::NoError then no error has occurred.
127*/
128QGeoTiledMapReply::Error QGeoTiledMapReply::error() const
129{
130 return d_ptr->error;
131}
132
133/*!
134 Returns the textual representation of the error state of this reply.
135
136 If no error has occurred this will return an empty string. It is possible
137 that an error occurred which has no associated textual representation, in
138 which case this will also return an empty string.
139
140 To determine whether an error has occurred, check to see if
141 QGeoTiledMapReply::error() is equal to QGeoTiledMapReply::NoError.
142*/
143QString QGeoTiledMapReply::errorString() const
144{
145 return d_ptr->errorString;
146}
147
148/*!
149 Returns whether the reply is coming from a cache.
150*/
151bool QGeoTiledMapReply::isCached() const
152{
153 return d_ptr->isCached;
154}
155
156/*!
157 Sets whether the reply is coming from a cache to \a cached.
158*/
159void QGeoTiledMapReply::setCached(bool cached)
160{
161 d_ptr->isCached = cached;
162}
163
164/*!
165 Returns the request which corresponds to this reply.
166*/
167QGeoTileSpec QGeoTiledMapReply::tileSpec() const
168{
169 return d_ptr->spec;
170}
171
172/*!
173 Returns the tile image data.
174*/
175QByteArray QGeoTiledMapReply::mapImageData() const
176{
177 return d_ptr->mapImageData;
178}
179
180/*!
181 Sets the tile image data to \a data.
182*/
183void QGeoTiledMapReply::setMapImageData(const QByteArray &data)
184{
185 d_ptr->mapImageData = data;
186}
187
188/*!
189 Returns the format of the tile image.
190*/
191QString QGeoTiledMapReply::mapImageFormat() const
192{
193 return d_ptr->mapImageFormat;
194}
195
196/*!
197 Sets the format of the tile image to \a format.
198*/
199void QGeoTiledMapReply::setMapImageFormat(const QString &format)
200{
201 d_ptr->mapImageFormat = format;
202}
203
204/*!
205 Cancels the operation immediately.
206
207 This will do nothing if the reply is finished.
208*/
209void QGeoTiledMapReply::abort()
210{
211 if (!isFinished())
212 setFinished(true);
213 emit aborted();
214}
215
216/*!
217 \fn void QGeoTiledMapReply::finished()
218
219 This signal is emitted when this reply has finished processing.
220
221 If error() equals QGeoTiledMapReply::NoError then the processing
222 finished successfully.
223
224 This signal and QGeoRoutingManager::finished() will be
225 emitted at the same time.
226
227 \note Do not delete this reply object in the slot connected to this
228 signal. Use deleteLater() instead.
229*/
230
231/*!
232 \fn void QGeoTiledMapReply::errorOccurred(QGeoTiledMapReply::Error error, const QString &errorString)
233
234 This signal is emitted when an error has been detected in the processing of
235 this reply. The finished() signal will probably follow.
236
237 The error will be described by the error code \a error. If \a errorString is
238 not empty it will contain a textual description of the error.
239
240 This signal and QGeoRoutingManager::errorOccurred() will be emitted at the same time.
241
242 \note Do not delete this reply object in the slot connected to this
243 signal. Use deleteLater() instead.
244*/
245
246/*******************************************************************************
247*******************************************************************************/
248
249QGeoTiledMapReplyPrivate::QGeoTiledMapReplyPrivate(const QGeoTileSpec &spec)
250 : spec(spec)
251{}
252
253QGeoTiledMapReplyPrivate::QGeoTiledMapReplyPrivate(QGeoTiledMapReply::Error error, const QString &errorString)
254 : error(error),
255 errorString(errorString),
256 isFinished(true)
257{}
258
259QT_END_NAMESPACE
Combined button and popup list for selecting options.