From 27cc67b75373905931448c3228e20a6c8d0797e6 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Thu, 31 Jan 2013 18:13:12 +0100 Subject: Add a QAmbientTemperatureSensor class. Port the Blackberry backend to use it. Change-Id: I6d4395f5ab9e0ce3fb6f76c47282929103929557 Reviewed-by: Lorn Potter --- .../sensors/blackberry/bbtemperaturesensor.cpp | 27 ++-------------------- .../sensors/blackberry/bbtemperaturesensor.h | 17 +++----------- src/plugins/sensors/blackberry/main.cpp | 2 +- 3 files changed, 6 insertions(+), 40 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp b/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp index f3ec6342..b38fba4d 100644 --- a/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp +++ b/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp @@ -40,31 +40,8 @@ ****************************************************************************/ #include "bbtemperaturesensor.h" -class BbTemperatureReadingPrivate -{ -public: - BbTemperatureReadingPrivate() - : temperature(0) - { - } - - qreal temperature; -}; - -IMPLEMENT_READING(BbTemperatureReading) - -qreal BbTemperatureReading::temperature() const -{ - return d->temperature; -} - -void BbTemperatureReading::setTemperature(qreal temperature) -{ - d->temperature = temperature; -} - BbTemperatureSensor::BbTemperatureSensor(QSensor *sensor) - : BbSensorBackend(devicePath(), SENSOR_TYPE_TEMPERATURE, sensor) + : BbSensorBackend(devicePath(), SENSOR_TYPE_TEMPERATURE, sensor) { setDescription(QLatin1String("Temperature in degrees Celsius")); } @@ -74,7 +51,7 @@ QString BbTemperatureSensor::devicePath() return QLatin1String("/dev/sensor/temp"); } -bool BbTemperatureSensor::updateReadingFromEvent(const sensor_event_t &event, BbTemperatureReading *reading) +bool BbTemperatureSensor::updateReadingFromEvent(const sensor_event_t &event, QAmbientTemperatureReading *reading) { // TODO: I was unable to test this since the device I was testing this with did not have // a temperature sensor. Verify that this works and check that the units are correct. diff --git a/src/plugins/sensors/blackberry/bbtemperaturesensor.h b/src/plugins/sensors/blackberry/bbtemperaturesensor.h index 1b9ea1bf..a24c67e7 100644 --- a/src/plugins/sensors/blackberry/bbtemperaturesensor.h +++ b/src/plugins/sensors/blackberry/bbtemperaturesensor.h @@ -42,20 +42,9 @@ #define BBTEMPERATURESENSOR_H #include "bbsensorbackend.h" +#include -class BbTemperatureReadingPrivate; - -class BbTemperatureReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal temperature READ temperature) - DECLARE_READING(BbTemperatureReading) -public: - qreal temperature() const; - void setTemperature(qreal temperature); -}; - -class BbTemperatureSensor : public BbSensorBackend +class BbTemperatureSensor : public BbSensorBackend { Q_OBJECT @@ -65,7 +54,7 @@ public: static QString devicePath(); protected: - bool updateReadingFromEvent(const sensor_event_t &event, BbTemperatureReading *reading); + bool updateReadingFromEvent(const sensor_event_t &event, QAmbientTemperatureReading *reading); }; #endif diff --git a/src/plugins/sensors/blackberry/main.cpp b/src/plugins/sensors/blackberry/main.cpp index ce7aa23f..9d8e87fe 100644 --- a/src/plugins/sensors/blackberry/main.cpp +++ b/src/plugins/sensors/blackberry/main.cpp @@ -114,7 +114,7 @@ public: if (sensorSupported(BbRotationSensor::devicePath())) QSensorManager::registerBackend(QRotationSensor::type, bbRotationSensorId, this); if (sensorSupported(BbTemperatureSensor::devicePath())) - QSensorManager::registerBackend("BbTemperatureSensor", bbTemperatureSensorId, this); + QSensorManager::registerBackend(QAmbientTemperatureSensor::type, bbTemperatureSensorId, this); } QSensorBackend *createBackend(QSensor *sensor) Q_DECL_OVERRIDE -- cgit v1.2.3