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
qgeoroutereply.cpp
Go to the documentation of this file.
1
// Copyright (C) 2022 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
"qgeoroutereply.h"
5
#
include
"qgeoroutereply_p.h"
6
7
QT_BEGIN_NAMESPACE
8
9
/*!
10
\class QGeoRouteReply
11
\inmodule QtLocation
12
\ingroup QtLocation-routing
13
\since 5.6
14
15
\brief The QGeoRouteReply class manages an operation started by an instance
16
of QGeoRoutingManager.
17
18
Instances of QGeoRouteReply manage the state and results of these
19
operations.
20
21
The isFinished(), error() and errorString() methods provide information
22
on whether the operation has completed and if it completed successfully.
23
24
The finished() and errorOccurred(QGeoRouteReply::Error,QString)
25
signals can be used to monitor the progress of the operation.
26
27
It is possible that a newly created QGeoRouteReply may be in a finished
28
state, most commonly because an error has occurred. Since such an instance
29
will never emit the finished() or
30
errorOccurred(QGeoRouteReply::Error,QString) signals, it is
31
important to check the result of isFinished() before making the connections
32
to the signals. The documentation for QGeoRoutingManager demonstrates how
33
this might be carried out.
34
35
If the operation completes successfully the results will be able to be
36
accessed with routes().
37
*/
38
39
/*!
40
\enum QGeoRouteReply::Error
41
42
Describes an error which prevented the completion of the operation.
43
44
\value NoError
45
No error has occurred.
46
\value EngineNotSetError
47
The routing manager that was used did not have a QGeoRoutingManagerEngine instance associated with it.
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
\value UnsupportedOptionError
53
The requested operation or one of the options for the operation are not
54
supported by the service provider.
55
\value UnknownError
56
An error occurred which does not fit into any of the other categories.
57
*/
58
59
/*!
60
Constructs a route reply object based on \a request, with the specified \a parent.
61
*/
62
QGeoRouteReply::QGeoRouteReply(
const
QGeoRouteRequest &request, QObject *parent)
63
: QObject(parent),
64
d_ptr(
new
QGeoRouteReplyPrivate(request))
65
{
66
}
67
68
/*!
69
Constructs a route reply with a given \a error and \a errorString and the specified \a parent.
70
*/
71
QGeoRouteReply::QGeoRouteReply(Error error,
const
QString &errorString, QObject *parent)
72
: QObject(parent),
73
d_ptr(
new
QGeoRouteReplyPrivate(error, errorString)) {}
74
75
/*!
76
Destroys this route reply object.
77
*/
78
QGeoRouteReply::~QGeoRouteReply()
79
{
80
delete
d_ptr;
81
}
82
83
/*!
84
Sets whether or not this reply has finished to \a finished.
85
86
If \a finished is true, this will cause the finished() signal to be
87
emitted.
88
89
If the operation completed successfully, QGeoRouteReply::setRoutes() should
90
be called before this function. If an error occurred,
91
QGeoRouteReply::setError() should be used instead.
92
*/
93
void
QGeoRouteReply::setFinished(
bool
finished)
94
{
95
d_ptr->isFinished = finished;
96
if
(d_ptr->isFinished)
97
emit
this
->finished();
98
}
99
100
/*!
101
Return true if the operation completed successfully or encountered an
102
error which cause the operation to come to a halt.
103
*/
104
bool
QGeoRouteReply::isFinished()
const
105
{
106
return
d_ptr->isFinished;
107
}
108
109
/*!
110
Sets the error state of this reply to \a error and the textual
111
representation of the error to \a errorString.
112
113
This will also cause errorOccurred() and finished() signals to be emitted, in that
114
order.
115
*/
116
void
QGeoRouteReply::setError(QGeoRouteReply::Error error,
const
QString &errorString)
117
{
118
d_ptr->error = error;
119
d_ptr->errorString = errorString;
120
emit errorOccurred(error, errorString);
121
setFinished(
true
);
122
}
123
124
/*!
125
Returns the error state of this reply.
126
127
If the result is QGeoRouteReply::NoError then no error has occurred.
128
*/
129
QGeoRouteReply::Error QGeoRouteReply::error()
const
130
{
131
return
d_ptr->error;
132
}
133
134
/*!
135
Returns the textual representation of the error state of this reply.
136
137
If no error has occurred this will return an empty string. It is possible
138
that an error occurred which has no associated textual representation, in
139
which case this will also return an empty string.
140
141
To determine whether an error has occurred, check to see if
142
QGeoRouteReply::error() is equal to QGeoRouteReply::NoError.
143
*/
144
QString QGeoRouteReply::errorString()
const
145
{
146
return
d_ptr->errorString;
147
}
148
149
/*!
150
Returns the route request which specified the route.
151
*/
152
QGeoRouteRequest QGeoRouteReply::request()
const
153
{
154
return
d_ptr->request;
155
}
156
157
/*!
158
Returns the list of routes which were requested.
159
*/
160
QList<QGeoRoute> QGeoRouteReply::routes()
const
161
{
162
return
d_ptr->routes;
163
}
164
165
/*!
166
Sets the list of routes in the reply to \a routes.
167
*/
168
void
QGeoRouteReply::setRoutes(
const
QList<QGeoRoute> &routes)
169
{
170
d_ptr->routes = routes;
171
}
172
173
/*!
174
Appends the list of \a routes to the existing list.
175
*/
176
void
QGeoRouteReply::addRoutes(
const
QList<QGeoRoute> &routes)
177
{
178
d_ptr->routes.append(routes);
179
}
180
181
/*!
182
\fn void QGeoRouteReply::aborted()
183
\since 5.9
184
185
This signal is emitted when the operation has been cancelled.
186
187
\sa abort()
188
*/
189
190
/*!
191
Cancels the operation immediately.
192
193
This will do nothing if the reply is finished.
194
*/
195
void
QGeoRouteReply::abort()
196
{
197
emit aborted();
198
}
199
200
/*!
201
\fn void QGeoRouteReply::finished()
202
203
This signal is emitted when this reply has finished processing.
204
205
If error() equals QGeoRouteReply::NoError then the processing
206
finished successfully.
207
208
This signal and QGeoRoutingManager::finished() will be
209
emitted at the same time.
210
211
\note Do not delete this reply object in the slot connected to this
212
signal. Use deleteLater() instead.
213
*/
214
/*!
215
\fn void QGeoRouteReply::errorOccurred(QGeoRouteReply::Error error, const QString &errorString)
216
217
This signal is emitted when an error has been detected in the processing of
218
this reply. The finished() signal will probably follow.
219
220
The error will be described by the error code \a error. If \a errorString is
221
not empty it will contain a textual description of the error.
222
223
This signal and QGeoRoutingManager::errorOccurred() will be emitted at the same time.
224
225
\note Do not delete this reply object in the slot connected to this
226
signal. Use deleteLater() instead.
227
*/
228
229
/*******************************************************************************
230
*******************************************************************************/
231
232
QGeoRouteReplyPrivate
::
QGeoRouteReplyPrivate
(
const
QGeoRouteRequest &request)
233
:
request
(
request
)
234
{}
235
236
QGeoRouteReplyPrivate
::QGeoRouteReplyPrivate(QGeoRouteReply::Error error, QString errorString)
237
: error(error),
238
errorString(errorString),
239
isFinished
(
true
)
240
{}
241
242
QT_END_NAMESPACE
QGeoRouteReplyPrivate
Definition
qgeoroutereply_p.h:28
QGeoRouteReplyPrivate::isFinished
bool isFinished
Definition
qgeoroutereply_p.h:35
QGeoRouteReplyPrivate::QGeoRouteReplyPrivate
QGeoRouteReplyPrivate(const QGeoRouteRequest &request)
Definition
qgeoroutereply.cpp:232
QPlatformGraphicsBufferHelper
\inmodule QtGui
qtlocation
src
location
maps
qgeoroutereply.cpp
Generated on
for Qt by
1.14.0