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 "qmlpressuresensor_p.h"
4#include <QtSensors/QPressureSensor>
5
6/*!
7 \qmltype PressureSensor
8//! \instantiates QmlPressureSensor
9 \ingroup qml-sensors_type
10 \inqmlmodule QtSensors
11 \since QtSensors 5.1
12 \inherits Sensor
13 \brief The PressureSensor element reports on atmospheric pressure values.
14
15 The PressureSensor element reports on atmospheric pressure values.
16
17 This element wraps the QPressureSensor class. Please see the documentation for
18 QPressureSensor for details.
19
20 \sa PressureReading
21*/
22
23QmlPressureSensor::QmlPressureSensor(QObject *parent)
24 : QmlSensor(parent)
25 , m_sensor(new QPressureSensor(this))
26{
27}
28
29QmlPressureSensor::~QmlPressureSensor()
30{
31}
32
33QmlSensorReading *QmlPressureSensor::createReading() const
34{
35 return new QmlPressureReading(m_sensor);
36}
37
38QSensor *QmlPressureSensor::sensor() const
39{
40 return m_sensor;
41}
42
43/*!
44 \qmltype PressureReading
45//! \instantiates QmlPressureReading
46 \ingroup qml-sensors_reading
47 \inqmlmodule QtSensors
48 \since QtSensors 5.1
49 \inherits SensorReading
50 \brief The PressureReading element holds the most recent PressureSensor reading.
51
52 The PressureReading element holds the most recent PressureSensor reading.
53
54 This element wraps the QPressureReading class. Please see the documentation for
55 QPressureReading for details.
56
57 This element cannot be directly created.
58*/
59
60QmlPressureReading::QmlPressureReading(QPressureSensor *sensor)
61 : m_sensor(sensor)
62 , m_pressure(0)
63 , m_temperature(0)
64{
65}
66
67QmlPressureReading::~QmlPressureReading()
68{
69}
70
71/*!
72 \qmlproperty qreal PressureReading::pressure
73 This property holds the atmospheric pressure value in Pascals.
74
75 Please see QPressureReading::pressure for information about this property.
76*/
77
78qreal QmlPressureReading::pressure() const
79{
80 return m_pressure;
81}
82
83QBindable<qreal> QmlPressureReading::bindablePressure() const
84{
85 return &m_pressure;
86}
87
88/*!
89 \qmlproperty qreal PressureReading::temperature
90 This property holds the pressure sensor's temperature value in degrees Celsius.
91
92 Please see QPressureReading::temperature for information about this property.
93 \since QtSensors 5.2
94*/
95
96qreal QmlPressureReading::temperature() const
97{
98 return m_temperature;
99}
100
101QBindable<qreal> QmlPressureReading::bindableTemperature() const
102{
103 return &m_temperature;
104}
105
106QSensorReading *QmlPressureReading::reading() const
107{
108 return m_sensor->reading();
109}
110
111void QmlPressureReading::readingUpdate()
112{
113 m_pressure = m_sensor->reading()->pressure();
114 m_temperature = m_sensor->reading()->temperature();
115}
116

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