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