From 02285d735e7d3bd8ddfb61b7ea5e16da4ad522d1 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Tue, 8 Jan 2013 16:55:38 +0100 Subject: 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 --- .../sensors/blackberry/bbpressuresensor.cpp | 29 +++------------------- src/plugins/sensors/blackberry/bbpressuresensor.h | 19 +++----------- src/plugins/sensors/blackberry/main.cpp | 2 +- 3 files changed, 8 insertions(+), 42 deletions(-) (limited to 'src/plugins') 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(devicePath(), SENSOR_TYPE_PRESSURE, sensor) + : BbSensorBackend(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 -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 +class BbPressureSensor : public BbSensorBackend { 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())) -- cgit v1.2.3