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