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