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
qplaceresult.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 "qplaceresult.h"
6#include <QtCore/qnumeric.h>
7
8QT_USE_NAMESPACE
9
10bool QPlaceResultPrivate::compare(const QPlaceSearchResultPrivate *other) const
11{
12 const QPlaceResultPrivate *od = static_cast<const QPlaceResultPrivate *>(other);
13 return QPlaceSearchResultPrivate::compare(other)
14 && ((qIsNaN(distance) && qIsNaN(od->distance))
15 || qFuzzyCompare(distance, od->distance))
16 && place == od->place
17 && sponsored == od->sponsored;
18}
19
20/*!
21 \class QPlaceResult
22 \inmodule QtLocation
23 \ingroup QtLocation-places
24 \ingroup QtLocation-places-data
25 \since 5.6
26
27 \brief The QPlaceResult class represents a search result containing a place.
28
29 The PlaceResult holds the distance to the place from the center of the search request,
30 an instance of the place and an indication of whether the result is
31 sponsored or \l {http://en.wikipedia.org/wiki/Organic_search}{organic}.
32
33 The intended usage is that a QPlaceSearchResult can be converted into a QPlaceResult
34 like so:
35
36 \snippet places/requesthandler.h Convert search result
37
38 The implementation is handled in such a way that object slicing is not an issue.
39
40 \sa QPlaceSearchResult
41*/
42
43/*!
44 Constructs a new place result object.
45*/
46QPlaceResult::QPlaceResult()
47: QPlaceSearchResult(new QPlaceResultPrivate)
48{
49}
50
51/*!
52 Destructor.
53*/
54QPlaceResult::~QPlaceResult()
55{
56}
57
58/*!
59 \fn QPlaceResult::QPlaceResult(const QPlaceSearchResult &other)
60 Constructs a copy of \a other if possible, otherwise constructs a default place result.
61*/
63
65
66/*!
67 Returns the distance of the place to the search center. This
68 field is only relevant provided the search request contained
69 a search area with a search center. Otherwise,
70 the distance is NaN indicating an undefined distance. The default value
71 for distance is NaN.
72*/
73qreal QPlaceResult::distance() const
74{
75 Q_D(const QPlaceResult);
76 return d->distance;
77}
78
79/*!
80 Set the \a distance of the search result's place from a search center.
81*/
82void QPlaceResult::setDistance(qreal distance)
83{
84 Q_D(QPlaceResult);
85 d->distance = distance;
86}
87
88/*!
89 Returns the place of the search result.
90*/
91QPlace QPlaceResult::place() const
92{
93 Q_D(const QPlaceResult);
94 return d->place;
95}
96
97/*!
98 Sets the \a place that this result refers to.
99*/
100void QPlaceResult::setPlace(const QPlace &place)
101{
102 Q_D(QPlaceResult);
103 d->place = place;
104}
105
106/*!
107 Returns true if the result is a sponsored result.
108
109 \sa setSponsored()
110*/
111bool QPlaceResult::isSponsored() const
112{
113 Q_D(const QPlaceResult);
114 return d->sponsored;
115}
116
117/*!
118 Sets whether the result is a \a sponsored result or not.
119
120 \sa isSponsored()
121*/
122void QPlaceResult::setSponsored(bool sponsored)
123{
124 Q_D(QPlaceResult);
125 d->sponsored = sponsored;
126}
#define Q_IMPLEMENT_SEARCHRESULT_D_FUNC(Class)
#define Q_IMPLEMENT_SEARCHRESULT_COPY_CTOR(Class)