From 0de0ead684a322103ec9cff3dcf5153ef4c1545c Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Fri, 20 Jul 2012 10:30:39 +0200 Subject: Blackberry: Remove custom BbProximityReading BbProximityReading extended QProximityReading with a distance and a reflectance property. Reflectance is already available in the IR proximity sensor, while distance isn't supported on any device. Change-Id: I413d3e35b0ccae29592dc11c287c3af6d5133ecc Reviewed-by: Adam Parco Reviewed-by: Sean Harmer --- .../sensors/blackberry/bbproximitysensor.cpp | 59 +--------------------- src/plugins/sensors/blackberry/bbproximitysensor.h | 30 +---------- 2 files changed, 4 insertions(+), 85 deletions(-) diff --git a/src/plugins/sensors/blackberry/bbproximitysensor.cpp b/src/plugins/sensors/blackberry/bbproximitysensor.cpp index 8781c6f6..7871be82 100644 --- a/src/plugins/sensors/blackberry/bbproximitysensor.cpp +++ b/src/plugins/sensors/blackberry/bbproximitysensor.cpp @@ -40,61 +40,8 @@ ****************************************************************************/ #include "bbproximitysensor.h" -class BbProximityReadingPrivate -{ -public: - BbProximityReadingPrivate() - : distance(0), - reflectance(0) - { - } - - qreal distance; - qreal reflectance; -}; - -BbProximityReading::BbProximityReading(QObject *parent) - : QProximityReading(parent), - d(new BbProximityReadingPrivate) -{ -} - -BbProximityReading::~BbProximityReading() -{ -} - -void BbProximityReading::copyValuesFrom(QSensorReading *other) -{ - QProximityReading::copyValuesFrom(other); - const BbProximityReading * const reading = qobject_cast(other); - if (reading) { - d->distance = reading->distance(); - d->reflectance = reading->reflectance(); - } -} - -qreal BbProximityReading::distance() const -{ - return d->distance; -} - -void BbProximityReading::setDistance(qreal distance) -{ - d->distance = distance; -} - -qreal BbProximityReading::reflectance() const -{ - return d->reflectance; -} - -void BbProximityReading::setReflectance(qreal reflectance) -{ - d->reflectance = reflectance; -} - BbProximitySensor::BbProximitySensor(QSensor *sensor) - : BbSensorBackend(devicePath(), SENSOR_TYPE_PROXIMITY, sensor) + : BbSensorBackend(devicePath(), SENSOR_TYPE_PROXIMITY, sensor) { setDescription(QLatin1String("Proximity")); } @@ -104,14 +51,12 @@ QString BbProximitySensor::devicePath() return QLatin1String("/dev/sensor/prox"); } -bool BbProximitySensor::updateReadingFromEvent(const sensor_event_t &event, BbProximityReading *reading) +bool BbProximitySensor::updateReadingFromEvent(const sensor_event_t &event, QProximityReading *reading) { // TODO: I was unable to test this since the device I was testing this with did not have // a proximity sensor. Verify that this works, check that the units are correct // and that the threshold makes sense. const qreal minProximity = sensor()->outputRanges().first().minimum; reading->setClose(event.proximity_s.distance <= minProximity); - reading->setDistance(event.proximity_s.distance); - reading->setReflectance(1.0f - event.proximity_s.normalized); return true; } diff --git a/src/plugins/sensors/blackberry/bbproximitysensor.h b/src/plugins/sensors/blackberry/bbproximitysensor.h index e7851fe6..55a51a25 100644 --- a/src/plugins/sensors/blackberry/bbproximitysensor.h +++ b/src/plugins/sensors/blackberry/bbproximitysensor.h @@ -44,33 +44,7 @@ #include "bbsensorbackend.h" #include -class BbProximityReadingPrivate; - -// We extend QProximityReading with two new properties -class BbProximityReading : public QProximityReading -{ - Q_OBJECT - - // Distance in cm - Q_PROPERTY(qreal distance READ distance) - - // Same as in QIRProximityReading - Q_PROPERTY(qreal reflectance READ reflectance) - -public: - explicit BbProximityReading(QObject *parent = 0); - ~BbProximityReading(); - void copyValuesFrom(QSensorReading *other); - qreal distance() const; - void setDistance(qreal distance); - qreal reflectance() const; - void setReflectance(qreal reflectance); - -private: - QScopedPointer d; -}; - -class BbProximitySensor : public BbSensorBackend +class BbProximitySensor : public BbSensorBackend { Q_OBJECT @@ -80,7 +54,7 @@ public: static QString devicePath(); protected: - bool updateReadingFromEvent(const sensor_event_t &event, BbProximityReading *reading) Q_DECL_OVERRIDE; + bool updateReadingFromEvent(const sensor_event_t &event, QProximityReading *reading) Q_DECL_OVERRIDE; }; #endif -- cgit v1.2.3