diff options
author | Thomas McGuire <thomas.mcguire.qnx@kdab.com> | 2012-07-20 10:30:39 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-24 11:22:59 +0200 |
commit | 0de0ead684a322103ec9cff3dcf5153ef4c1545c (patch) | |
tree | 2e2b91a63cfdd2d079204eacd47eb02c5f9df3bd /src/plugins | |
parent | 48d6a32c0c4b81183dc9239194cefab218bd2363 (diff) |
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 <aparco@rim.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/sensors/blackberry/bbproximitysensor.cpp | 59 | ||||
-rw-r--r-- | 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<const BbProximityReading *>(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<BbProximityReading>(devicePath(), SENSOR_TYPE_PROXIMITY, sensor) + : BbSensorBackend<QProximityReading>(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 <qproximitysensor.h> -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<BbProximityReadingPrivate> d; -}; - -class BbProximitySensor : public BbSensorBackend<BbProximityReading> +class BbProximitySensor : public BbSensorBackend<QProximityReading> { 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 |