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 "qmlambienttemperaturesensor_p.h"
4#include <QtSensors/QAmbientTemperatureSensor>
5
6/*!
7 \qmltype AmbientTemperatureSensor
8//! \instantiates QmlAmbientTemperatureSensor
9 \ingroup qml-sensors_type
10 \inqmlmodule QtSensors
11 \since QtSensors 5.1
12 \inherits Sensor
13 \brief The AmbientTemperatureSensor element reports on the ambient temperature.
14
15 The AmbientTemperatureSensor element reports on the ambient temperature.
16
17 This element wraps the QAmbientTemperatureSensor class. Please see the documentation for
18 QAmbientTemperatureSensor for details.
19
20 \sa AmbientTemperatureReading
21*/
22
23QmlAmbientTemperatureSensor::QmlAmbientTemperatureSensor(QObject *parent)
24 : QmlSensor(parent)
25 , m_sensor(new QAmbientTemperatureSensor(this))
26{
27}
28
29QmlAmbientTemperatureSensor::~QmlAmbientTemperatureSensor()
30{
31}
32
33QmlSensorReading *QmlAmbientTemperatureSensor::createReading() const
34{
35 return new QmlAmbientTemperatureReading(m_sensor);
36}
37
38QSensor *QmlAmbientTemperatureSensor::sensor() const
39{
40 return m_sensor;
41}
42
43/*!
44 \qmltype AmbientTemperatureReading
45//! \instantiates QmlAmbientTemperatureReading
46 \ingroup qml-sensors_reading
47 \inqmlmodule QtSensors
48 \since QtSensors 5.1
49 \inherits SensorReading
50 \brief The AmbientTemperatureReading element holds the most recent temperature reading.
51
52 The AmbientTemperatureReading element holds the most recent temperature reading.
53
54 This element wraps the QAmbientTemperatureReading class. Please see the documentation for
55 QAmbientTemperatureReading for details.
56
57 This element cannot be directly created.
58*/
59
60QmlAmbientTemperatureReading::QmlAmbientTemperatureReading(QAmbientTemperatureSensor *sensor)
61 : m_sensor(sensor)
62 , m_temperature(0)
63{
64}
65
66QmlAmbientTemperatureReading::~QmlAmbientTemperatureReading()
67{
68}
69
70/*!
71 \qmlproperty qreal AmbientTemperatureReading::temperature
72 This property holds the ambient temperature in degree Celsius.
73
74 Please see QAmbientTemperatureReading::temperature for information about this property.
75*/
76
77qreal QmlAmbientTemperatureReading::temperature() const
78{
79 return m_temperature;
80}
81
82QBindable<qreal> QmlAmbientTemperatureReading::bindableTemperature() const
83{
84 return &m_temperature;
85}
86
87QSensorReading *QmlAmbientTemperatureReading::reading() const
88{
89 return m_sensor->reading();
90}
91
92void QmlAmbientTemperatureReading::readingUpdate()
93{
94 m_temperature = m_sensor->reading()->temperature();
95}
96

source code of qtsensors/src/sensorsquick/qmlambienttemperaturesensor.cpp