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
qplacereply.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
4#include "qplacereply.h"
6
7QT_USE_NAMESPACE
8
9/*!
10 \class QPlaceReply
11 \inmodule QtLocation
12 \ingroup QtLocation-places
13 \ingroup QtLocation-places-replies
14 \since 5.6
15
16 \brief The QPlaceReply class manages an operation started by an instance of QPlaceManager and
17 serves as a base class for more specialized replies.
18
19 The QPlaceReply and each of its specialized subclasses manage the
20 state and results of their corresponding operations. The QPlaceReply itself is used
21 for operations that have no results, that is, it only necessary to know if the operation
22 succeeded or failed.
23
24 The finished() signal can be used to monitor the progress of an operation.
25 Once an operation is complete, the error() and errorString() methods provide information
26 on whether the operation completed successfully. If successful, the reply
27 will contain the results for that operation, that is, each subclass will have appropriate
28 functions to retrieve the results of an operation.
29
30 \sa QPlaceManager
31*/
32
33/*!
34 \enum QPlaceReply::Error
35
36 Describes an error which occurred during an operation.
37 \value NoError
38 No error has occurred
39 \value PlaceDoesNotExistError
40 A specified place could not be found
41 \value CategoryDoesNotExistError
42 A specified category could not be found
43 \value CommunicationError
44 An error occurred communicating with the service provider.
45 \value ParseError
46 The response from the service provider or an import file was in an unrecognizable format
47 \value PermissionsError
48 The operation failed because of insufficient permissions.
49 \value UnsupportedError
50 The operation was not supported by the service provider.
51 \value BadArgumentError.
52 A parameter that was provided was invalid.
53 \value CancelError
54 The operation was canceled.
55 \value UnknownError
56 An error occurred which does not fit into any of the other categories.
57*/
58
59/*!
60 \enum QPlaceReply::Type
61
62 Describes the reply's type.
63 \value Reply
64 This is a generic reply.
65 \value DetailsReply
66 This is a reply for the retrieval of place details
67 \value SearchReply
68 This is a reply for the place search operation.
69 \value SearchSuggestionReply
70 This is a reply for a search suggestion operation.
71 \value ContentReply
72 This is a reply for content associated with a place.
73 \value IdReply
74 This is a reply that returns an identifier of a place or category.
75 Typically used for place or category save and remove operations.
76 \value MatchReply
77 This is a reply that returns places that match
78 those from another provider.
79*/
80
81/*!
82 Constructs a reply object with a given \a parent.
83*/
84QPlaceReply::QPlaceReply(QObject *parent)
85 : QObject(parent),d_ptr(new QPlaceReplyPrivate)
86{
87}
88
89/*!
90 \internal
91*/
92QPlaceReply::QPlaceReply(QPlaceReplyPrivate *dd, QObject *parent)
93 : QObject(parent),d_ptr(dd)
94{
95}
96
97/*!
98 Destroys the reply object.
99*/
100QPlaceReply::~QPlaceReply()
101{
102 if (!isFinished()) {
103 abort();
104 }
105 delete d_ptr;
106}
107
108/*!
109 Return true if the reply has completed.
110*/
111bool QPlaceReply::isFinished() const
112{
113 return d_ptr->isFinished;
114}
115
116/*!
117 Returns the type of the reply.
118*/
119QPlaceReply::Type QPlaceReply::type() const
120{
121 return QPlaceReply::Reply;
122}
123
124/*!
125 Sets the status of whether the reply is \a finished
126 or not. This function does not cause the finished() signal
127 to be emitted.
128*/
129void QPlaceReply::setFinished(bool finished)
130{
131 d_ptr->isFinished = finished;
132}
133
134/*!
135 Sets the \a error and \a errorString of the reply.
136 This function does not cause the
137 QPlaceReply::errorOccurred(QPlaceReply::Error, const QString &errorString)
138 signal to be emitted.
139*/
140void QPlaceReply::setError(QPlaceReply::Error error, const QString &errorString)
141{
142 d_ptr->error = error;
143 d_ptr->errorString = errorString;
144}
145
146/*!
147 Returns the error string of the reply. The error string is intended to be
148 used by developers only and is not fit to be displayed to an end user.
149
150 If no error has occurred, the string is empty.
151*/
152QString QPlaceReply::errorString() const
153{
154 return d_ptr->errorString;
155}
156
157/*!
158 Returns the error code.
159*/
160QPlaceReply::Error QPlaceReply::error() const
161{
162 return d_ptr->error;
163}
164
165/*!
166 \fn void QPlaceReply::aborted()
167 \since 5.9
168
169 This signal is emitted when the operation has been cancelled.
170
171 \sa abort()
172*/
173
174/*!
175 Cancels the operation immediately.
176
177 \sa aborted()
178*/
179void QPlaceReply::abort()
180{
181 emit aborted();
182}
183
184/*!
185 \fn void QPlaceReply::finished()
186
187 This signal is emitted when this reply has finished processing.
188
189 If error() equals QPlaceReply::NoError then the processing
190 finished successfully.
191
192 This signal and QPlaceManager::finished() will be
193 emitted at the same time.
194
195 \note Do not delete this reply object in the slot connected to this
196 signal. Use deleteLater() instead.
197*/
198
199/*!
200 \fn void QPlaceReply::contentUpdated()
201
202 This signal is emitted when this reply has updated content available.
203 Depending on the plugin, this signal may never be emitted or emitted
204 multiple times before \l QPlaceReply::finished() is emitted, as some
205 backends are able to return the requested content asynchronously and
206 incrementally.
207
208 \note Do not delete or deleteLater this reply object in the slot
209 connected to this signal. Do it only upon \l QPlaceReply::finished.
210*/
211
212/*!
213 \fn void QPlaceReply::errorOccurred(QPlaceReply::Error error, const QString &errorString)
214
215 This signal is emitted when an error has been detected in the processing of
216 this reply. The finished() signal will probably follow.
217
218 The error will be described by the error code \a error. If \a errorString is
219 not empty it will contain a textual description of the error meant for
220 developers and not end users.
221
222 This signal and QPlaceManager::errorOccurred() will be emitted at the same time.
223
224 \note Do not delete this reply object in the slot connected to this
225 signal. Use deleteLater() instead.
226*/