From ffbee9903b993c0487b825af32f49fc6f8989492 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Mon, 2 Jul 2012 09:48:06 +0200 Subject: Blackberry: Remove rotation property from orientation reading The rotation property is redundant, as it can be deduced from the orientation. Furthermore, for FaceUp and FaceDown orientations, the rotation is always 0, further confusing the issue. Change-Id: I4348cd56fe713358d388a09829224159eab8b6b8 Reviewed-by: Giuseppe D'Angelo --- .../sensors/blackberry/bborientationsensor.cpp | 46 ++-------------------- .../sensors/blackberry/bborientationsensor.h | 24 +---------- 2 files changed, 5 insertions(+), 65 deletions(-) diff --git a/src/plugins/sensors/blackberry/bborientationsensor.cpp b/src/plugins/sensors/blackberry/bborientationsensor.cpp index 3f592f9..f23c5ae 100644 --- a/src/plugins/sensors/blackberry/bborientationsensor.cpp +++ b/src/plugins/sensors/blackberry/bborientationsensor.cpp @@ -40,47 +40,8 @@ ****************************************************************************/ #include "bborientationsensor.h" -class BbOrientationReadingPrivate -{ -public: - BbOrientationReadingPrivate() - : rotation(0) - { - } - - int rotation; -}; - -BbOrientationReading::BbOrientationReading(QObject *parent) - : QOrientationReading(parent), - d(new BbOrientationReadingPrivate) -{ -} - -BbOrientationReading::~BbOrientationReading() -{ -} - -void BbOrientationReading::copyValuesFrom(QSensorReading *other) -{ - QOrientationReading::copyValuesFrom(other); - const BbOrientationReading * const reading = qobject_cast(other); - if (reading) - d->rotation = reading->rotation(); -} - -int BbOrientationReading::rotation() const -{ - return d->rotation; -} - -void BbOrientationReading::setRotation(int rotation) -{ - d->rotation = rotation; -} - BbOrientationSensor::BbOrientationSensor(QSensor *sensor) - : BbSensorBackend(devicePath(), SENSOR_TYPE_ORIENTATION, sensor) + : BbSensorBackend(devicePath(), SENSOR_TYPE_ORIENTATION, sensor) { setDescription(QLatin1String("Device orientation")); } @@ -92,7 +53,7 @@ QString BbOrientationSensor::devicePath() void BbOrientationSensor::start() { - BbSensorBackend::start(); + BbSensorBackend::start(); // Orientation rarely changes, so enable skiping of duplicates sensor_devctl_skipdupevent_u deviceSkip; @@ -117,7 +78,7 @@ bool BbOrientationSensor::addDefaultRange() return false; } -bool BbOrientationSensor::updateReadingFromEvent(const sensor_event_t &event, BbOrientationReading *reading) +bool BbOrientationSensor::updateReadingFromEvent(const sensor_event_t &event, QOrientationReading *reading) { QOrientationReading::Orientation qtOrientation = QOrientationReading::Undefined; const QByteArray face(event.orientation.face); @@ -129,6 +90,5 @@ bool BbOrientationSensor::updateReadingFromEvent(const sensor_event_t &event, Bb else if (face == "FACE_DOWN") qtOrientation = QOrientationReading::FaceDown; reading->setOrientation(qtOrientation); - reading->setRotation(event.orientation.screen); return true; } diff --git a/src/plugins/sensors/blackberry/bborientationsensor.h b/src/plugins/sensors/blackberry/bborientationsensor.h index 8dcb271..e9b6da2 100644 --- a/src/plugins/sensors/blackberry/bborientationsensor.h +++ b/src/plugins/sensors/blackberry/bborientationsensor.h @@ -44,27 +44,7 @@ #include "bbsensorbackend.h" #include -class BbOrientationReadingPrivate; - -// We extend QOrientationReading with the "rotation" property -class BbOrientationReading : public QOrientationReading -{ - Q_OBJECT - - // Screen Rotation in degrees - 0, 90, 180 or 270 - Q_PROPERTY(int rotation READ rotation) -public: - explicit BbOrientationReading(QObject *parent = 0); - ~BbOrientationReading(); - void copyValuesFrom(QSensorReading *other) Q_DECL_OVERRIDE; - int rotation() const; - void setRotation(int rotation); - -private: - QScopedPointer d; -}; - -class BbOrientationSensor : public BbSensorBackend +class BbOrientationSensor : public BbSensorBackend { Q_OBJECT @@ -78,7 +58,7 @@ public: bool addDefaultRange() Q_DECL_OVERRIDE; protected: - bool updateReadingFromEvent(const sensor_event_t &event, BbOrientationReading *reading) Q_DECL_OVERRIDE; + bool updateReadingFromEvent(const sensor_event_t &event, QOrientationReading *reading) Q_DECL_OVERRIDE; }; #endif -- cgit v1.2.1