summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2013-01-31 18:13:12 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-08 11:17:53 +0100
commit27cc67b75373905931448c3228e20a6c8d0797e6 (patch)
tree094faff84d478c3d74764e3b87e26d4843bbeca2 /src/plugins
parent2dba878107fbe290782af720981ce28ec3723e7a (diff)
Add a QAmbientTemperatureSensor class.
Port the Blackberry backend to use it. Change-Id: I6d4395f5ab9e0ce3fb6f76c47282929103929557 Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/sensors/blackberry/bbtemperaturesensor.cpp27
-rw-r--r--src/plugins/sensors/blackberry/bbtemperaturesensor.h17
-rw-r--r--src/plugins/sensors/blackberry/main.cpp2
3 files changed, 6 insertions, 40 deletions
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<BbTemperatureReading>(devicePath(), SENSOR_TYPE_TEMPERATURE, sensor)
+ : BbSensorBackend<QAmbientTemperatureReading>(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 <qambienttemperaturesensor.h>
-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<BbTemperatureReading>
+class BbTemperatureSensor : public BbSensorBackend<QAmbientTemperatureReading>
{
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