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
qplaceratings.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
"qplaceratings.h"
6
#
include
"qplaceratings_p.h"
7
8
QT_USE_NAMESPACE
9
10
QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QPlaceRatingsPrivate)
11
12
bool
QPlaceRatingsPrivate::operator==(
const
QPlaceRatingsPrivate &other)
const
13
{
14
return
average == other.average && maximum == other.maximum && count == other.count;
15
}
16
17
bool
QPlaceRatingsPrivate::isEmpty()
const
18
{
19
return
count == 0 && average == 0 && maximum == 0;
20
}
21
22
/*!
23
\class QPlaceRatings
24
\inmodule QtLocation
25
\ingroup QtLocation-places
26
\ingroup QtLocation-places-data
27
\since 5.6
28
29
\brief The QPlaceRatings class holds rating information about a place.
30
31
Rating information is used to describe how good a place is conceived to be.
32
Typically this information is visualized as a number of stars.
33
The average() function returns an aggregated ratings value out of a possible
34
maximum as given by the maximum() function.
35
36
\snippet places/requesthandler.h Ratings
37
*/
38
39
/*!
40
\qmlvaluetype ratings
41
\inqmlmodule QtLocation
42
\ingroup qml-QtLocation5-places
43
\ingroup qml-QtLocation5-places-data
44
\since QtLocation 6.5
45
46
\brief The ratings type holds place rating information.
47
48
Rating information is used to describe how \e good a place is conceived to be. Typically this
49
information is visualized as a number of stars. The \l {ratings::}{average} property gives an aggregated
50
ratings value out of a possible maximum as given by the \l {ratings::maximum} property.
51
*/
52
53
/*!
54
Constructs a new ratings object.
55
*/
56
QPlaceRatings::QPlaceRatings()
57
: d(
new
QPlaceRatingsPrivate)
58
{
59
}
60
61
/*!
62
Constructs a copy of \a other.
63
*/
64
QPlaceRatings::QPlaceRatings(
const
QPlaceRatings &other)
noexcept
=
default
;
65
66
/*!
67
Destroys the ratings object.
68
*/
69
QPlaceRatings::~QPlaceRatings() =
default
;
70
71
/*!
72
Assigns \a other to this ratings object and returns
73
a reference to this ratings object.
74
*/
75
QPlaceRatings &QPlaceRatings::operator=(
const
QPlaceRatings &other)
noexcept
76
{
77
if
(
this
== &other)
78
return
*
this
;
79
80
d = other.d;
81
return
*
this
;
82
}
83
84
/*!
85
\fn bool QPlaceRatings::operator==(const QPlaceRatings &lhs, const QPlaceRatings &rhs) noexcept
86
87
Returns true if \a lhs is equal to \a rhs, otherwise returns false.
88
*/
89
90
/*!
91
\fn bool QPlaceRatings::operator!=(const QPlaceRatings &lhs, const QPlaceRatings &rhs) noexcept
92
93
Returns true if \a lhs is not equal to \a rhs, otherwise returns false.
94
*/
95
96
bool
QPlaceRatings::isEqual(
const
QPlaceRatings &other)
const
noexcept
97
{
98
return
(*(d.constData()) == *(other.d.constData()));
99
}
100
101
/*!
102
\qmlproperty real ratings::average
103
104
This property holds the average of the individual ratings.
105
106
\sa maximum
107
*/
108
109
/*!
110
\property QPlaceRatings::average
111
\brief the average value of individual ratings.
112
*/
113
qreal QPlaceRatings::average()
const
114
{
115
return
d->average;
116
}
117
118
void
QPlaceRatings::setAverage(qreal average)
119
{
120
d->average = average;
121
}
122
123
/*!
124
\qmlproperty real ratings::maximum
125
126
This property holds the maximum rating value.
127
*/
128
129
/*!
130
\property QPlaceRatings::maximum
131
\brief the maximum possible rating value.
132
*/
133
qreal QPlaceRatings::maximum()
const
134
{
135
return
d->maximum;
136
}
137
138
void
QPlaceRatings::setMaximum(qreal max)
139
{
140
d->maximum = max;
141
}
142
143
/*!
144
\qmlproperty int ratings::count
145
146
This property holds the total number of individual user ratings
147
used in determining the overall ratings \l average.
148
*/
149
150
/*!
151
\property QPlaceRatings::count
152
\brief the total number of individual ratings.
153
*/
154
int
QPlaceRatings::count()
const
155
{
156
return
d->count;
157
}
158
159
void
QPlaceRatings::setCount(
int
count)
160
{
161
d->count = count;
162
}
163
164
/*!
165
Returns true if all fields of the place ratings are 0; otherwise returns false.
166
*/
167
bool
QPlaceRatings::isEmpty()
const
168
{
169
return
d->isEmpty();
170
}
171
172
#
include
"moc_qplaceratings.cpp"
qtlocation
src
location
places
qplaceratings.cpp
Generated on
for Qt by
1.18.0