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
qplacecontentrequest.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
7
8QT_BEGIN_NAMESPACE
9
10QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QPlaceContentRequestPrivate)
11
12bool QPlaceContentRequestPrivate::operator==(const QPlaceContentRequestPrivate &other) const
13{
14 return contentType == other.contentType
15 && limit == other.limit;
16}
17
18void QPlaceContentRequestPrivate::clear()
19{
20 contentType = QPlaceContent::NoType;
21 limit = -1;
22}
23
24/*!
25 \class QPlaceContentRequest
26 \inmodule QtLocation
27 \ingroup QtLocation-places
28 \ingroup QtLocation-places-requests
29 \since 5.6
30
31 \brief The QPlaceContentRequest class represents the parameters of a content request.
32
33 The QPlaceContentRequest class is used in conjunction with a QPlaceManager to
34 retrieve rich content like images and reviews in a paginated fashion.
35 The following code would request a set of 5 images from the 10th index:
36
37 \snippet places/requesthandler.h Content request
38 \dots
39 \dots
40 \snippet places/requesthandler.h Content handler
41
42 \sa QPlaceContentReply
43*/
44
45/*!
46 Constructs a new request object.
47*/
48QPlaceContentRequest::QPlaceContentRequest()
49 : d_ptr(new QPlaceContentRequestPrivate())
50{
51}
52
53/*!
54 Constructs a copy of \a other.
55*/
56QPlaceContentRequest::QPlaceContentRequest(const QPlaceContentRequest &other) noexcept = default;
57
58/*!
59 Destroys the request object
60*/
61QPlaceContentRequest::~QPlaceContentRequest() = default;
62
63/*!
64 Assigns \a other to this content request and returns a reference
65 to this content request.
66*/
67QPlaceContentRequest &QPlaceContentRequest::operator=(const QPlaceContentRequest & other) noexcept
68{
69 if (this == &other)
70 return *this;
71
72 d_ptr = other.d_ptr;
73 return *this;
74}
75
76/*!
77 \fn bool QPlaceContentRequest::operator==(const QPlaceContentRequest &lhs, const QPlaceContentRequest &rhs) noexcept
78 Returns true if \a lhs is equal to \a rhs, otherwise returns false.
79*/
80
81/*!
82 \fn bool QPlaceContentRequest::operator!=(const QPlaceContentRequest &lhs, const QPlaceContentRequest &rhs) noexcept
83 Returns true if \a lhs is not equal to \a rhs, otherwise returns false.
84*/
85
86bool QPlaceContentRequest::isEqual(const QPlaceContentRequest &other) const noexcept
87{
88 Q_D(const QPlaceContentRequest);
89 return *d == *other.d_func();
90}
91
92/*!
93 Returns the type of content to be requested, for example reviews or images
94*/
95QPlaceContent::Type QPlaceContentRequest::contentType() const
96{
97 Q_D(const QPlaceContentRequest);
98 return d->contentType;
99}
100
101/*!
102 Sets the \a type of content to be requested.
103*/
104void QPlaceContentRequest::setContentType(QPlaceContent::Type type)
105{
106 Q_D(QPlaceContentRequest);
107 d->contentType = type;
108}
109
110/*!
111 Returns the identifier of the place content is to be fetched for.
112*/
113QString QPlaceContentRequest::placeId() const
114{
115 Q_D(const QPlaceContentRequest);
116 return d->placeId;
117}
118
119/*!
120 Sets the identifier of the place to fetch content for to \a identifier.
121*/
122void QPlaceContentRequest::setPlaceId(const QString &identifier)
123{
124 Q_D(QPlaceContentRequest);
125 d->placeId = identifier;
126}
127
128/*!
129 Returns backend specific additional content context associated with this place content request.
130*/
131QVariant QPlaceContentRequest::contentContext() const
132{
133 Q_D(const QPlaceContentRequest);
134 return d->contentContext;
135}
136
137/*!
138 Sets the content context to \a context.
139
140 \note This method is intended to be used by geo service plugins when returning place content
141 results.
142
143 The content context is used by backends to store additional content context related to the
144 content request. Other relevant fields should also be filled in. For example, if the content
145 request is for image content the content type should also be set with \l setContentType(). The
146 content context allows additional context to be kept which is not directly accessible via the
147 Qt Location API.
148
149 The content context can be of any type storable in a QVariant. The value of the content context
150 is not intended to be used directly by applications.
151*/
152void QPlaceContentRequest::setContentContext(const QVariant &context)
153{
154 Q_D(QPlaceContentRequest);
155 d->contentContext = context;
156}
157
158/*!
159 Returns the maximum number of content items to retrieve.
160
161 A negative value for limit means that it is undefined. It is left up to the backend
162 provider to choose an appropriate number of items to return.
163
164 The default limit is -1.
165*/
166int QPlaceContentRequest::limit() const
167{
168 Q_D(const QPlaceContentRequest);
169 return d->limit;
170}
171
172/*!
173 Set the maximum number of content items to retrieve to
174 \a limit.
175*/
176void QPlaceContentRequest::setLimit(int limit)
177{
178 Q_D(QPlaceContentRequest);
179 d->limit = limit;
180}
181
182/*!
183 Clears the content request.
184*/
185void QPlaceContentRequest::clear()
186{
187 Q_D(QPlaceContentRequest);
188 d->clear();
189}
190
191inline QPlaceContentRequestPrivate *QPlaceContentRequest::d_func()
192{
193 return static_cast<QPlaceContentRequestPrivate *>(d_ptr.data());
194}
195
196inline const QPlaceContentRequestPrivate *QPlaceContentRequest::d_func() const
197{
198 return static_cast<const QPlaceContentRequestPrivate *>(d_ptr.constData());
199}
200
201QT_END_NAMESPACE