summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2013-01-08 16:55:38 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-23 18:32:35 +0100
commit02285d735e7d3bd8ddfb61b7ea5e16da4ad522d1 (patch)
tree6000899044feee17aae140df56eba1aa6126ffee /src/plugins
parentbbf9a9f61a18ccb478cbca414d85ed531f078966 (diff)
Add QPressureSensor
This adds a new QPressureSensor plus the assorted reading and filter classes, as well as a QML API. The Blackberry backend is ported to use the new reading class. Change-Id: Ifc86a2ae955a9337a67fd9a86ceabab908917cb3 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/sensors/blackberry/bbpressuresensor.cpp29
-rw-r--r--src/plugins/sensors/blackberry/bbpressuresensor.h19
-rw-r--r--src/plugins/sensors/blackberry/main.cpp2
3 files changed, 8 insertions, 42 deletions
diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.cpp b/src/plugins/sensors/blackberry/bbpressuresensor.cpp
index 01a2493b..8cb9b1ea 100644
--- a/src/plugins/sensors/blackberry/bbpressuresensor.cpp
+++ b/src/plugins/sensors/blackberry/bbpressuresensor.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Research In Motion
+** Copyright (C) 2013 Research In Motion
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtSensors module of the Qt Toolkit.
@@ -40,31 +40,8 @@
****************************************************************************/
#include "bbpressuresensor.h"
-class BbPressureReadingPrivate
-{
-public:
- BbPressureReadingPrivate()
- : pressure(0)
- {
- }
-
- qreal pressure;
-};
-
-IMPLEMENT_READING(BbPressureReading)
-
-qreal BbPressureReading::pressure() const
-{
- return d->pressure;
-}
-
-void BbPressureReading::setPressure(qreal pressure)
-{
- d->pressure = pressure;
-}
-
BbPressureSensor::BbPressureSensor(QSensor *sensor)
- : BbSensorBackend<BbPressureReading>(devicePath(), SENSOR_TYPE_PRESSURE, sensor)
+ : BbSensorBackend<QPressureReading>(devicePath(), SENSOR_TYPE_PRESSURE, sensor)
{
setDescription(QLatin1String("Pressure in Pascals"));
}
@@ -74,7 +51,7 @@ QString BbPressureSensor::devicePath()
return QLatin1String("/dev/sensor/pressure");
}
-bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, BbPressureReading *reading)
+bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading)
{
// TODO: I was unable to test this since the device I was testing this with did not have
// a pressure sensor. Verify that this works and check that the units are correct.
diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.h b/src/plugins/sensors/blackberry/bbpressuresensor.h
index 833832c4..7531bd68 100644
--- a/src/plugins/sensors/blackberry/bbpressuresensor.h
+++ b/src/plugins/sensors/blackberry/bbpressuresensor.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Research In Motion
+** Copyright (C) 2013 Research In Motion
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtSensors module of the Qt Toolkit.
@@ -42,20 +42,9 @@
#define BBPRESSURESENSOR_H
#include "bbsensorbackend.h"
+#include <qpressuresensor.h>
-class BbPressureReadingPrivate;
-
-class BbPressureReading : public QSensorReading
-{
- Q_OBJECT
- Q_PROPERTY(qreal pressure READ pressure)
- DECLARE_READING(BbPressureReading)
-public:
- qreal pressure() const;
- void setPressure(qreal pressure);
-};
-
-class BbPressureSensor : public BbSensorBackend<BbPressureReading>
+class BbPressureSensor : public BbSensorBackend<QPressureReading>
{
Q_OBJECT
@@ -65,7 +54,7 @@ public:
static QString devicePath();
protected:
- bool updateReadingFromEvent(const sensor_event_t &event, BbPressureReading *reading) Q_DECL_OVERRIDE;
+ bool updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading) Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/plugins/sensors/blackberry/main.cpp b/src/plugins/sensors/blackberry/main.cpp
index 54e4163a..7b4180a9 100644
--- a/src/plugins/sensors/blackberry/main.cpp
+++ b/src/plugins/sensors/blackberry/main.cpp
@@ -98,7 +98,7 @@ public:
if (sensorSupported(BbOrientationSensor::devicePath()))
QSensorManager::registerBackend(QOrientationSensor::type, bbOrientationSensorId, this);
if (sensorSupported(BbPressureSensor::devicePath()))
- QSensorManager::registerBackend("BbPressureSensor", bbPressureSensorId, this);
+ QSensorManager::registerBackend(QPressureSensor::type, bbPressureSensorId, this);
if (sensorSupported(BbProximitySensor::devicePath()))
QSensorManager::registerBackend(QProximitySensor::type, bbProximitySensorId, this);
if (sensorSupported(BbRotationSensor::devicePath()))