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
qgeocodereply.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
5
#
include
"qgeocodereply.h"
6
#
include
"qgeocodereply_p.h"
7
8
#
include
<
QtCore
/
QVariant
>
9
#
include
<
QtPositioning
/
QGeoLocation
>
10
11
QT_BEGIN_NAMESPACE
12
/*!
13
\class QGeoCodeReply
14
\inmodule QtLocation
15
\ingroup QtLocation-geocoding
16
\since 5.6
17
18
\brief The QGeoCodeReply class manages an operation started by an
19
instance of QGeoCodingManager.
20
21
Instances of QGeoCodeReply 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(QGeoCodeReply::Error,QString)
28
signals can be used to monitor the progress of the operation.
29
30
It is possible that a newly created QGeoCodeReply 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(QGeoCodeReply::Error,QString) signals, it is
34
important to check the result of isFinished() before making the connections
35
to the signals. The documentation for QGeoCodingManager demonstrates how
36
this might be carried out.
37
38
If the operation completes successfully the results will be able to be
39
accessed with locations().
40
*/
41
42
/*!
43
\enum QGeoCodeReply::Error
44
45
Describes an error which prevented the completion of the operation.
46
47
\value NoError
48
No error has occurred.
49
\value EngineNotSetError
50
The geocoding manager that was used did not have a QGeoCodingManagerEngine instance associated with it.
51
\value CommunicationError
52
An error occurred while communicating with the service provider.
53
\value ParseError
54
The response from the service provider was in an unrecognizable format.
55
\value UnsupportedOptionError
56
The requested operation or one of the options for the operation are not
57
supported by the service provider.
58
\value CombinationError
59
An error occurred while results where being combined from multiple sources.
60
\value UnknownError
61
An error occurred which does not fit into any of the other categories.
62
*/
63
64
/*!
65
Constructs a geocode reply with the specified \a parent.
66
*/
67
QGeoCodeReply::QGeoCodeReply(QObject *parent)
68
: QObject(parent),
69
d_ptr(
new
QGeoCodeReplyPrivate()) {}
70
71
/*!
72
Constructs a geocode reply with a given \a error and \a errorString and the specified \a parent.
73
*/
74
QGeoCodeReply::QGeoCodeReply(Error error,
const
QString &errorString, QObject *parent)
75
: QObject(parent),
76
d_ptr(
new
QGeoCodeReplyPrivate(error, errorString))
77
{}
78
79
/*!
80
Destroys this reply object.
81
*/
82
QGeoCodeReply::~QGeoCodeReply()
83
{
84
delete
d_ptr;
85
}
86
87
/*!
88
Sets whether or not this reply has finished to \a finished.
89
90
If \a finished is true, this will cause the finished() signal to be
91
emitted.
92
93
If the operation completed successfully, QGeoCodeReply::setLocations()
94
should be called before this function. If an error occurred,
95
QGeoCodeReply::setError() should be used instead.
96
*/
97
void
QGeoCodeReply::setFinished(
bool
finished)
98
{
99
d_ptr->isFinished = finished;
100
if
(d_ptr->isFinished)
101
emit
this
->finished();
102
}
103
104
/*!
105
Return true if the operation completed successfully or encountered an
106
error which cause the operation to come to a halt.
107
*/
108
bool
QGeoCodeReply::isFinished()
const
109
{
110
return
d_ptr->isFinished;
111
}
112
113
/*!
114
Sets the error state of this reply to \a error and the textual
115
representation of the error to \a errorString.
116
117
This will also cause errorOccurred() and finished() signals to be
118
emitted, in that order.
119
*/
120
void
QGeoCodeReply::setError(QGeoCodeReply::Error error,
const
QString &errorString)
121
{
122
d_ptr->error = error;
123
d_ptr->errorString = errorString;
124
emit
this
->errorOccurred(error, errorString);
125
setFinished(
true
);
126
}
127
128
/*!
129
Returns the error state of this reply.
130
131
If the result is QGeoCodeReply::NoError then no error has occurred.
132
*/
133
QGeoCodeReply::Error QGeoCodeReply::error()
const
134
{
135
return
d_ptr->error;
136
}
137
138
/*!
139
Returns the textual representation of the error state of this reply.
140
141
If no error has occurred this will return an empty string. It is possible
142
that an error occurred which has no associated textual representation, in
143
which case this will also return an empty string.
144
145
To determine whether an error has occurred, check to see if
146
QGeoCodeReply::error() is equal to QGeoCodeReply::NoError.
147
*/
148
QString QGeoCodeReply::errorString()
const
149
{
150
return
d_ptr->errorString;
151
}
152
153
/*!
154
Sets the viewport which contains the results to \a viewport.
155
*/
156
void
QGeoCodeReply::setViewport(
const
QGeoShape &viewport)
157
{
158
d_ptr->viewport = viewport;
159
}
160
161
/*!
162
Returns the viewport which contains the results.
163
164
This function will return \nullptr if no viewport bias
165
was specified in the QGeoCodingManager function which created this reply.
166
*/
167
QGeoShape QGeoCodeReply::viewport()
const
168
{
169
return
d_ptr->viewport;
170
}
171
172
/*!
173
Returns a list of locations.
174
175
The locations are the results of the operation corresponding to the
176
QGeoCodingManager function which created this reply.
177
*/
178
QList<QGeoLocation> QGeoCodeReply::locations()
const
179
{
180
return
d_ptr->locations;
181
}
182
183
/*!
184
Adds \a location to the list of locations in this reply.
185
*/
186
void
QGeoCodeReply::addLocation(
const
QGeoLocation &location)
187
{
188
d_ptr->locations.append(location);
189
}
190
191
/*!
192
Sets the list of \a locations in the reply.
193
*/
194
void
QGeoCodeReply::setLocations(
const
QList<QGeoLocation> &locations)
195
{
196
d_ptr->locations = locations;
197
}
198
199
/*!
200
\fn void QGeoCodeReply::aborted()
201
\since 5.9
202
203
This signal is emitted when the operation has been cancelled.
204
205
\sa abort()
206
*/
207
208
/*!
209
Cancels the operation immediately.
210
211
This will do nothing if the reply is finished.
212
213
\sa aborted()
214
*/
215
void
QGeoCodeReply::abort()
216
{
217
if
(!isFinished())
218
setFinished(
true
);
219
emit aborted();
220
}
221
222
/*!
223
Returns the limit on the number of responses from each data source.
224
225
If no limit was set this function will return -1.
226
227
This may be more than locations().length() if the number of responses
228
was less than the number requested.
229
*/
230
qsizetype QGeoCodeReply::limit()
const
231
{
232
return
d_ptr->limit;
233
}
234
235
/*!
236
Returns the offset into the entire result set at which to start
237
fetching results.
238
*/
239
qsizetype QGeoCodeReply::offset()
const
240
{
241
return
d_ptr->offset;
242
}
243
244
/*!
245
Sets the limit on the number of responses from each data source to \a limit.
246
247
If \a limit is -1 then all available responses will be returned.
248
*/
249
void
QGeoCodeReply::setLimit(qsizetype limit)
250
{
251
d_ptr->limit = limit;
252
}
253
254
/*!
255
Sets the offset in the entire result set at which to start
256
fetching result to \a offset.
257
*/
258
void
QGeoCodeReply::setOffset(qsizetype offset)
259
{
260
d_ptr->offset = offset;
261
}
262
263
/*!
264
\fn void QGeoCodeReply::finished()
265
266
This signal is emitted when this reply has finished processing.
267
268
If error() equals QGeoCodeReply::NoError then the processing
269
finished successfully.
270
271
This signal and QGeoCodingManager::finished() will be
272
emitted at the same time.
273
274
\note Do not delete this reply object in the slot connected to this
275
signal. Use deleteLater() instead.
276
*/
277
/*!
278
\fn void QGeoCodeReply::errorOccurred(QGeoCodeReply::Error error, const QString &errorString)
279
280
This signal is emitted when an error has been detected in the processing of
281
this reply. The finished() signal will probably follow.
282
283
The error will be described by the error code \a error. If \a errorString is
284
not empty it will contain a textual description of the error.
285
286
This signal and QGeoCodingManager::errorOccurred() will be emitted at the same time.
287
288
\note Do not delete this reply object in the slot connected to this
289
signal. Use deleteLater() instead.
290
*/
291
292
/*******************************************************************************
293
*******************************************************************************/
294
295
QGeoCodeReplyPrivate::QGeoCodeReplyPrivate() =
default
;
296
297
QGeoCodeReplyPrivate::QGeoCodeReplyPrivate(QGeoCodeReply::Error error,
const
QString &errorString)
298
: error(error), errorString(errorString), isFinished(
true
)
299
{}
300
301
const
QGeoCodeReplyPrivate *QGeoCodeReplyPrivate::get(
const
QGeoCodeReply &reply)
302
{
303
return
reply.d_ptr;
304
}
305
306
QGeoCodeReplyPrivate *QGeoCodeReplyPrivate::get(QGeoCodeReply &reply)
307
{
308
return
reply.d_ptr;
309
}
310
311
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qtlocation
src
location
maps
qgeocodereply.cpp
Generated on
for Qt by
1.16.1