1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 Research In Motion |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtSensors module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | #include <qaltimeter.h> |
40 | #include "qaltimeter_p.h" |
41 | |
42 | QT_BEGIN_NAMESPACE |
43 | |
44 | IMPLEMENT_READING(QAltimeterReading) |
45 | |
46 | /*! |
47 | \class QAltimeterReading |
48 | \ingroup sensors_reading |
49 | \inmodule QtSensors |
50 | \since 5.1 |
51 | |
52 | \brief The QAltimeterReading class holds readings from the altimeter sensor. |
53 | |
54 | The altitude is reported in meters relative to mean sea level. |
55 | */ |
56 | |
57 | /*! |
58 | \property QAltimeterReading::altitude |
59 | \brief The altitude in meters relative to mean sea level. |
60 | */ |
61 | |
62 | qreal QAltimeterReading::altitude() const |
63 | { |
64 | return d->altitude; |
65 | } |
66 | |
67 | /*! |
68 | Sets the altitude to \a altitude. |
69 | */ |
70 | void QAltimeterReading::setAltitude(qreal altitude) |
71 | { |
72 | d->altitude = altitude; |
73 | } |
74 | |
75 | // ===================================================================== |
76 | |
77 | /*! |
78 | \class QAltimeterFilter |
79 | \ingroup sensors_filter |
80 | \inmodule QtSensors |
81 | \since 5.1 |
82 | |
83 | \brief The QAltimeterFilter class is a convenience wrapper around QSensorFilter. |
84 | |
85 | The only difference is that the filter() method features a pointer to QAltimeterReading |
86 | instead of QSensorReading. |
87 | */ |
88 | |
89 | /*! |
90 | \fn QAltimeterFilter::filter(QAltimeterReading *reading) |
91 | |
92 | Called when \a reading changes. Returns false to prevent the reading from propagating. |
93 | |
94 | \sa QSensorFilter::filter() |
95 | */ |
96 | |
97 | bool QAltimeterFilter::filter(QSensorReading *reading) |
98 | { |
99 | return filter(reading: static_cast<QAltimeterReading*>(reading)); |
100 | } |
101 | |
102 | char const * const QAltimeter::type("QAltimeter" ); |
103 | |
104 | /*! |
105 | \class QAltimeter |
106 | \ingroup sensors_type |
107 | \inmodule QtSensors |
108 | \since 5.1 |
109 | |
110 | \brief The QAltimeter class is a convenience wrapper around QSensor. |
111 | |
112 | The only behavioural difference is that this class sets the type properly. |
113 | |
114 | This class also features a reading() function that returns a QAltimeterReading instead of a QSensorReading. |
115 | |
116 | For details about how the sensor works, see \l QAltimeterReading. |
117 | |
118 | \sa QAltimeterReading |
119 | */ |
120 | |
121 | /*! |
122 | Construct the sensor as a child of \a parent. |
123 | */ |
124 | QAltimeter::QAltimeter(QObject *parent) |
125 | : QSensor(QAltimeter::type, parent) |
126 | { |
127 | } |
128 | |
129 | /*! |
130 | Destroy the sensor. Stops the sensor if it has not already been stopped. |
131 | */ |
132 | QAltimeter::~QAltimeter() |
133 | { |
134 | } |
135 | |
136 | /*! |
137 | \fn QAltimeter::reading() const |
138 | |
139 | Returns the reading class for this sensor. |
140 | |
141 | \sa QSensor::reading() |
142 | */ |
143 | |
144 | QAltimeterReading *QAltimeter::reading() const |
145 | { |
146 | return static_cast<QAltimeterReading*>(QSensor::reading()); |
147 | } |
148 | |
149 | QT_END_NAMESPACE |
150 | |
151 | #include "moc_qaltimeter.cpp" |
152 | |