| 1 | // Copyright (C) 2016 Research In Motion |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | #include <qambienttemperaturesensor.h> |
| 4 | #include "qambienttemperaturesensor_p.h" |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | IMPLEMENT_READING(QAmbientTemperatureReading) |
| 9 | |
| 10 | /*! |
| 11 | \class QAmbientTemperatureReading |
| 12 | \ingroup sensors_reading |
| 13 | \inmodule QtSensors |
| 14 | \since 5.1 |
| 15 | |
| 16 | \brief The QAmbientTemperatureReading class holds readings of the ambient temperature. |
| 17 | |
| 18 | The ambient (room) temperature is the temperature in degree Celsius. |
| 19 | */ |
| 20 | |
| 21 | /*! |
| 22 | \property QAmbientTemperatureReading::temperature |
| 23 | \brief The ambient temperature |
| 24 | |
| 25 | Measured in degree Celsius. |
| 26 | */ |
| 27 | |
| 28 | qreal QAmbientTemperatureReading::temperature() const |
| 29 | { |
| 30 | return d->temperature; |
| 31 | } |
| 32 | |
| 33 | /*! |
| 34 | Sets ambient temperature to \a temperature. |
| 35 | */ |
| 36 | void QAmbientTemperatureReading::setTemperature(qreal temperature) |
| 37 | { |
| 38 | d->temperature = temperature; |
| 39 | } |
| 40 | |
| 41 | // ===================================================================== |
| 42 | |
| 43 | /*! |
| 44 | \class QAmbientTemperatureFilter |
| 45 | \ingroup sensors_filter |
| 46 | \inmodule QtSensors |
| 47 | \since 5.1 |
| 48 | |
| 49 | \brief The QAmbientTemperatureFilter class is a convenience wrapper around QSensorFilter. |
| 50 | |
| 51 | The only difference is that the filter() method features a pointer to QAmbientTemperatureReading |
| 52 | instead of QSensorReading. |
| 53 | */ |
| 54 | |
| 55 | /*! |
| 56 | \fn QAmbientTemperatureFilter::filter(QAmbientTemperatureReading *reading) |
| 57 | |
| 58 | Called when \a reading changes. Returns false to prevent the reading from propagating. |
| 59 | |
| 60 | \sa QSensorFilter::filter() |
| 61 | */ |
| 62 | |
| 63 | bool QAmbientTemperatureFilter::filter(QSensorReading *reading) |
| 64 | { |
| 65 | return filter(reading: static_cast<QAmbientTemperatureReading*>(reading)); |
| 66 | } |
| 67 | |
| 68 | char const * const QAmbientTemperatureSensor::sensorType("QAmbientTemperatureSensor" ); |
| 69 | |
| 70 | /*! |
| 71 | \class QAmbientTemperatureSensor |
| 72 | \ingroup sensors_type |
| 73 | \inmodule QtSensors |
| 74 | \since 5.1 |
| 75 | |
| 76 | \brief The QAmbientTemperatureSensor class is a convenience wrapper around QSensor. |
| 77 | |
| 78 | The only behavioural difference is that this class sets the type properly. |
| 79 | |
| 80 | This class also features a reading() function that returns a QAmbientTemperatureReading instead of a QSensorReading. |
| 81 | |
| 82 | For details about how the sensor works, see \l QAmbientTemperatureReading. |
| 83 | |
| 84 | \sa QAmbientTemperatureReading |
| 85 | */ |
| 86 | |
| 87 | /*! |
| 88 | Construct the sensor as a child of \a parent. |
| 89 | */ |
| 90 | QAmbientTemperatureSensor::QAmbientTemperatureSensor(QObject *parent) |
| 91 | : QSensor(QAmbientTemperatureSensor::sensorType, parent) |
| 92 | { |
| 93 | } |
| 94 | |
| 95 | /*! |
| 96 | Destroy the sensor. Stops the sensor if it has not already been stopped. |
| 97 | */ |
| 98 | QAmbientTemperatureSensor::~QAmbientTemperatureSensor() |
| 99 | { |
| 100 | } |
| 101 | |
| 102 | /*! |
| 103 | \fn QAmbientTemperatureSensor::reading() const |
| 104 | |
| 105 | Returns the reading class for this sensor. |
| 106 | |
| 107 | \sa QSensor::reading() |
| 108 | */ |
| 109 | |
| 110 | QAmbientTemperatureReading *QAmbientTemperatureSensor::reading() const |
| 111 | { |
| 112 | return static_cast<QAmbientTemperatureReading*>(QSensor::reading()); |
| 113 | } |
| 114 | |
| 115 | QT_END_NAMESPACE |
| 116 | |
| 117 | #include "moc_qambienttemperaturesensor.cpp" |
| 118 | |