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
qplacematchrequest.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// Qt-Security score:significant reason:default
4
6
7#include <QtCore/QSharedData>
8#include <QtCore/QList>
9#include <QtLocation/QPlace>
10#include <QtLocation/QPlaceResult>
11
13
15{
16public:
17 bool operator==(const QPlaceMatchRequestPrivate &other) const;
18
19 void clear();
20
23};
24
25QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QPlaceMatchRequestPrivate)
26
28{
29 return (places == other.places
30 && parameters == other.parameters);
31}
32
34{
35 places.clear();
36 parameters.clear();
37}
38
39/*!
40 \class QPlaceMatchRequest
41 \inmodule QtLocation
42 \ingroup QtLocation-places
43 \ingroup QtLocation-places-requests
44 \since 5.6
45
46 \brief The QPlaceMatchRequest class is used to find places from one manager that match those from another. It represents
47 a set of request parameters.
48
49 Places from another manager that may have corresponding/matching places in the current manager are assigned using setPlaces() or setResults().
50 A set of further parameters are specified which determines the criteria for matching.
51
52 The typical key for matching is the QPlaceMatchRequest::AlternativeId, the value is an alternative identifier attribute type of the format
53 x_id_<provider name> for example x_id_here. The provider name is name supplied to the QGeoServiceProvider instance.
54
55 See \l {Matching places between managers} for an example on how to use a match request.
56
57 \sa QPlaceMatchReply, QPlaceManager
58*/
59
60/*!
61 \variable QPlaceMatchRequest::AlternativeId
62 The key to specify that matching is to be accomplished via an alternative place identifier.
63*/
64const QString QPlaceMatchRequest::AlternativeId(QLatin1String("alternativeId"));
65
66/*!
67 Default constructor. Constructs a new request object.
68*/
69QPlaceMatchRequest::QPlaceMatchRequest()
70 : d_ptr(new QPlaceMatchRequestPrivate())
71{
72}
73
74/*!
75 Constructs a copy of \a other.
76*/
77QPlaceMatchRequest::QPlaceMatchRequest(const QPlaceMatchRequest &other) noexcept = default;
78
79/*!
80 Destroys the request object.
81*/
82QPlaceMatchRequest::~QPlaceMatchRequest() = default;
83
84/*!
85 Assigns \a other to this search request and returns a reference
86 to this match request.
87*/
88QPlaceMatchRequest &QPlaceMatchRequest::operator=(const QPlaceMatchRequest & other) noexcept
89{
90 if (this == &other)
91 return *this;
92 d_ptr = other.d_ptr;
93 return *this;
94}
95
96/*!
97 \fn bool QPlaceMatchRequest::operator==(const QPlaceMatchRequest &lhs, const QPlaceMatchRequest &rhs) noexcept
98
99 Returns true if \a lhs is equal to \a rhs, otherwise returns false.
100*/
101
102/*!
103 \fn bool QPlaceMatchRequest::operator!=(const QPlaceMatchRequest &lhs, const QPlaceMatchRequest &rhs) noexcept
104
105 Returns true if \a lhs is not equal to \a rhs, otherwise returns false.
106*/
107
108bool QPlaceMatchRequest::isEqual(const QPlaceMatchRequest &other) const noexcept
109{
110 Q_D(const QPlaceMatchRequest);
111 return *d == *other.d_func();
112}
113
114
115
116/*!
117 Returns a list of places which are to be matched.
118*/
119QList<QPlace> QPlaceMatchRequest::places() const
120{
121 Q_D(const QPlaceMatchRequest);
122 return d->places;
123}
124
125/*!
126 Sets a list of \a places which are to be matched.
127
128 \sa setResults()
129*/
130void QPlaceMatchRequest::setPlaces(const QList<QPlace> &places)
131{
132 Q_D(QPlaceMatchRequest);
133 d->places = places;
134}
135
136/*!
137 Convenience function which uses a set of search \a results to set
138 the places which should be matched.
139
140 \sa setPlaces()
141*/
142void QPlaceMatchRequest::setResults(const QList<QPlaceSearchResult> &results)
143{
144 Q_D(QPlaceMatchRequest);
145 QList<QPlace> places;
146 for (const QPlaceSearchResult &result : results) {
147 if (result.type() == QPlaceSearchResult::PlaceResult) {
148 QPlaceResult placeResult = result;
149 places.append(placeResult.place());
150 }
151 }
152
153 d->places = places;
154}
155
156/*!
157 Returns the parameters for matching places.
158*/
159QVariantMap QPlaceMatchRequest::parameters() const
160{
161 Q_D(const QPlaceMatchRequest);
162 return d->parameters;
163}
164
165/*!
166 Sets the \a parameters for matching places.
167*/
168void QPlaceMatchRequest::setParameters(const QVariantMap &parameters)
169{
170 Q_D(QPlaceMatchRequest);
171 d->parameters = parameters;
172}
173
174/*!
175 Clears the match request.
176*/
177void QPlaceMatchRequest::clear()
178{
179 Q_D(QPlaceMatchRequest);
180 d->clear();
181}
182
183inline QPlaceMatchRequestPrivate *QPlaceMatchRequest::d_func()
184{
185 return static_cast<QPlaceMatchRequestPrivate *>(d_ptr.data());
186}
187
188inline const QPlaceMatchRequestPrivate *QPlaceMatchRequest::d_func() const
189{
190 return static_cast<const QPlaceMatchRequestPrivate *>(d_ptr.constData());
191}
192
193QT_END_NAMESPACE
bool operator==(const QPlaceMatchRequestPrivate &other) const
Combined button and popup list for selecting options.