From 02285d735e7d3bd8ddfb61b7ea5e16da4ad522d1 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Tue, 8 Jan 2013 16:55:38 +0100 Subject: Add QPressureSensor This adds a new QPressureSensor plus the assorted reading and filter classes, as well as a QML API. The Blackberry backend is ported to use the new reading class. Change-Id: Ifc86a2ae955a9337a67fd9a86ceabab908917cb3 Reviewed-by: Thomas McGuire --- src/imports/sensors/plugins.qmltypes | 11 ++ src/imports/sensors/qmlpressuresensor.cpp | 133 +++++++++++++++++++ src/imports/sensors/qmlpressuresensor.h | 88 ++++++++++++ src/imports/sensors/sensors.cpp | 3 + src/imports/sensors/sensors.pro | 2 + .../sensors/blackberry/bbpressuresensor.cpp | 29 +--- src/plugins/sensors/blackberry/bbpressuresensor.h | 19 +-- src/plugins/sensors/blackberry/main.cpp | 2 +- src/sensors/doc/src/compatmap.qdoc | 6 + src/sensors/qpressuresensor.cpp | 147 +++++++++++++++++++++ src/sensors/qpressuresensor.h | 88 ++++++++++++ src/sensors/qpressuresensor_p.h | 72 ++++++++++ src/sensors/sensors.pro | 1 + tests/auto/qsensor/test_backends.h | 4 + tests/auto/qsensor/tst_qsensor.cpp | 4 + 15 files changed, 567 insertions(+), 42 deletions(-) create mode 100644 src/imports/sensors/qmlpressuresensor.cpp create mode 100644 src/imports/sensors/qmlpressuresensor.h create mode 100644 src/sensors/qpressuresensor.cpp create mode 100644 src/sensors/qpressuresensor.h create mode 100644 src/sensors/qpressuresensor_p.h diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes index 00d8c366..1429ae79 100644 --- a/src/imports/sensors/plugins.qmltypes +++ b/src/imports/sensors/plugins.qmltypes @@ -117,6 +117,17 @@ Module { exports: ["OrientationReading 5.0", "OrientationReading 5.1"] Property { name: "orientation"; type: "QOrientationReading::Orientation"; isReadonly: true } } + Component { + name: "QmlPressureReading" + prototype: "QmlSensorReading" + exports: ["PressureReading 5.1"] + Property { name: "pressure"; type: "double"; isReadonly: true } + } + Component { + name: "QmlPressureSensor" + prototype: "QmlSensor" + exports: ["PressureSensor 5.1"] + } Component { name: "QmlProximitySensor" prototype: "QmlSensor" diff --git a/src/imports/sensors/qmlpressuresensor.cpp b/src/imports/sensors/qmlpressuresensor.cpp new file mode 100644 index 00000000..a21f7c0d --- /dev/null +++ b/src/imports/sensors/qmlpressuresensor.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtSensors module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qmlpressuresensor.h" +#include + +/*! + \qmltype PressureSensor + \instantiates QmlPressureSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors 5.0 + \since QtSensors 5.1 + \inherits Sensor + \brief The PressureSensor element reports on atmospheric pressure values. + + The PressureSensor element reports on atmospheric pressure values. + + This element wraps the QPressureSensor class. Please see the documentation for + QPressureSensor for details. + + \sa PressureReading +*/ + +QmlPressureSensor::QmlPressureSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QPressureSensor(this)) +{ +} + +QmlPressureSensor::~QmlPressureSensor() +{ +} + +QmlSensorReading *QmlPressureSensor::createReading() const +{ + return new QmlPressureReading(m_sensor); +} + +QSensor *QmlPressureSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype PressureReading + \instantiates QmlPressureReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors 5.0 + \since QtSensors 5.1 + \inherits SensorReading + \brief The PressureReading element holds the most recent PressureSensor reading. + + The PressureReading element holds the most recent PressureSensor reading. + + This element wraps the QPressureReading class. Please see the documentation for + QPressureReading for details. + + This element cannot be directly created. +*/ + +QmlPressureReading::QmlPressureReading(QPressureSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) + , m_pressure(0) +{ +} + +QmlPressureReading::~QmlPressureReading() +{ +} + +/*! + \qmlproperty qreal PressureReading::pressure + This property holds the atmospheric pressure value in Pascals. + + Please see QPressureReading::pressure for information about this property. +*/ + +qreal QmlPressureReading::pressure() const +{ + return m_pressure; +} + +QSensorReading *QmlPressureReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlPressureReading::readingUpdate() +{ + qreal pressure = m_sensor->reading()->pressure(); + if (m_pressure != pressure) { + m_pressure = pressure; + Q_EMIT pressureChanged(); + } +} diff --git a/src/imports/sensors/qmlpressuresensor.h b/src/imports/sensors/qmlpressuresensor.h new file mode 100644 index 00000000..e150c7df --- /dev/null +++ b/src/imports/sensors/qmlpressuresensor.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtSensors module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QMLPRESSURESENSOR_H +#define QMLPRESSURESENSOR_H + +#include "qmlsensor.h" + +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + +class QPressureSensor; + +class QmlPressureSensor : public QmlSensor +{ + Q_OBJECT +public: + explicit QmlPressureSensor(QObject *parent = 0); + ~QmlPressureSensor(); + +private: + QSensor *sensor() const Q_DECL_OVERRIDE; + QmlSensorReading *createReading() const Q_DECL_OVERRIDE; + + QPressureSensor *m_sensor; +}; + +class QmlPressureReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged) +public: + explicit QmlPressureReading(QPressureSensor *sensor); + ~QmlPressureReading(); + + qreal pressure() const; + +Q_SIGNALS: + void pressureChanged(); + +private: + QSensorReading *reading() const Q_DECL_OVERRIDE; + void readingUpdate() Q_DECL_OVERRIDE; + + QPressureSensor *m_sensor; + qreal m_pressure; +}; + +QT_END_NAMESPACE +QT_END_HEADER +#endif diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp index 95fc8ccc..9392baf3 100644 --- a/src/imports/sensors/sensors.cpp +++ b/src/imports/sensors/sensors.cpp @@ -66,6 +66,7 @@ #include "qmllightsensor.h" #include "qmlmagnetometer.h" #include "qmlorientationsensor.h" +#include "qmlpressuresensor.h" #include "qmlproximitysensor.h" #include "qmlrotationsensor.h" #include "qmltapsensor.h" @@ -150,6 +151,8 @@ public: qmlRegisterUncreatableType(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading")); qmlRegisterType (package, major, minor, "OrientationSensor"); qmlRegisterUncreatableType(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading")); + qmlRegisterType (package, major, minor, "PressureSensor"); + qmlRegisterUncreatableType(package, major, minor, "PressureReading", QLatin1String("Cannot create PressureReading")); qmlRegisterType (package, major, minor, "ProximitySensor"); qmlRegisterUncreatableType(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading")); qmlRegisterType (package, major, minor, "RotationSensor"); diff --git a/src/imports/sensors/sensors.pro b/src/imports/sensors/sensors.pro index 76362014..82241511 100644 --- a/src/imports/sensors/sensors.pro +++ b/src/imports/sensors/sensors.pro @@ -16,6 +16,7 @@ HEADERS += \ qmllightsensor.h \ qmlmagnetometer.h \ qmlorientationsensor.h \ + qmlpressuresensor.h\ qmlproximitysensor.h \ qmltapsensor.h \ qmlrotationsensor.h \ @@ -34,6 +35,7 @@ SOURCES += sensors.cpp \ qmllightsensor.cpp \ qmlmagnetometer.cpp \ qmlorientationsensor.cpp \ + qmlpressuresensor.cpp\ qmlproximitysensor.cpp \ qmltapsensor.cpp \ qmlrotationsensor.cpp \ diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.cpp b/src/plugins/sensors/blackberry/bbpressuresensor.cpp index 01a2493b..8cb9b1ea 100644 --- a/src/plugins/sensors/blackberry/bbpressuresensor.cpp +++ b/src/plugins/sensors/blackberry/bbpressuresensor.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2012 Research In Motion +** Copyright (C) 2013 Research In Motion ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtSensors module of the Qt Toolkit. @@ -40,31 +40,8 @@ ****************************************************************************/ #include "bbpressuresensor.h" -class BbPressureReadingPrivate -{ -public: - BbPressureReadingPrivate() - : pressure(0) - { - } - - qreal pressure; -}; - -IMPLEMENT_READING(BbPressureReading) - -qreal BbPressureReading::pressure() const -{ - return d->pressure; -} - -void BbPressureReading::setPressure(qreal pressure) -{ - d->pressure = pressure; -} - BbPressureSensor::BbPressureSensor(QSensor *sensor) - : BbSensorBackend(devicePath(), SENSOR_TYPE_PRESSURE, sensor) + : BbSensorBackend(devicePath(), SENSOR_TYPE_PRESSURE, sensor) { setDescription(QLatin1String("Pressure in Pascals")); } @@ -74,7 +51,7 @@ QString BbPressureSensor::devicePath() return QLatin1String("/dev/sensor/pressure"); } -bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, BbPressureReading *reading) +bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading) { // TODO: I was unable to test this since the device I was testing this with did not have // a pressure sensor. Verify that this works and check that the units are correct. diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.h b/src/plugins/sensors/blackberry/bbpressuresensor.h index 833832c4..7531bd68 100644 --- a/src/plugins/sensors/blackberry/bbpressuresensor.h +++ b/src/plugins/sensors/blackberry/bbpressuresensor.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2012 Research In Motion +** Copyright (C) 2013 Research In Motion ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtSensors module of the Qt Toolkit. @@ -42,20 +42,9 @@ #define BBPRESSURESENSOR_H #include "bbsensorbackend.h" +#include -class BbPressureReadingPrivate; - -class BbPressureReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal pressure READ pressure) - DECLARE_READING(BbPressureReading) -public: - qreal pressure() const; - void setPressure(qreal pressure); -}; - -class BbPressureSensor : public BbSensorBackend +class BbPressureSensor : public BbSensorBackend { Q_OBJECT @@ -65,7 +54,7 @@ public: static QString devicePath(); protected: - bool updateReadingFromEvent(const sensor_event_t &event, BbPressureReading *reading) Q_DECL_OVERRIDE; + bool updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading) Q_DECL_OVERRIDE; }; #endif diff --git a/src/plugins/sensors/blackberry/main.cpp b/src/plugins/sensors/blackberry/main.cpp index 54e4163a..7b4180a9 100644 --- a/src/plugins/sensors/blackberry/main.cpp +++ b/src/plugins/sensors/blackberry/main.cpp @@ -98,7 +98,7 @@ public: if (sensorSupported(BbOrientationSensor::devicePath())) QSensorManager::registerBackend(QOrientationSensor::type, bbOrientationSensorId, this); if (sensorSupported(BbPressureSensor::devicePath())) - QSensorManager::registerBackend("BbPressureSensor", bbPressureSensorId, this); + QSensorManager::registerBackend(QPressureSensor::type, bbPressureSensorId, this); if (sensorSupported(BbProximitySensor::devicePath())) QSensorManager::registerBackend(QProximitySensor::type, bbProximitySensorId, this); if (sensorSupported(BbRotationSensor::devicePath())) diff --git a/src/sensors/doc/src/compatmap.qdoc b/src/sensors/doc/src/compatmap.qdoc index 0fd4951c..065ff79e 100644 --- a/src/sensors/doc/src/compatmap.qdoc +++ b/src/sensors/doc/src/compatmap.qdoc @@ -106,6 +106,12 @@ + Pressure Sensor + + + + + Proximity Sensor diff --git a/src/sensors/qpressuresensor.cpp b/src/sensors/qpressuresensor.cpp new file mode 100644 index 00000000..ea8a79bb --- /dev/null +++ b/src/sensors/qpressuresensor.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtSensors module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "qpressuresensor_p.h" + +QT_BEGIN_NAMESPACE + +IMPLEMENT_READING(QPressureReading) + +/*! + \class QPressureReading + \ingroup sensors_reading + \inmodule QtSensors + \since 5.1 + + \brief The QPressureReading class holds readings from the pressure sensor. + + \section2 QPressureReading Units + + The pressure sensor returns atmospheric pressure values in Pascals. +*/ + +/*! + \property QPressureReading::pressure + \brief The measured atmospheric pressure. + + Returned as Pascals. + \sa {QPressureReading Units} +*/ + +qreal QPressureReading::pressure() const +{ + return d->pressure; +} + +/*! + Sets the pressure to \a pressure. +*/ +void QPressureReading::setPressure(qreal pressure) +{ + d->pressure = pressure; +} + +// ===================================================================== + +/*! + \class QPressureFilter + \ingroup sensors_filter + \inmodule QtSensors + \since 5.1 + + \brief The QPressureFilter class is a convenience wrapper around QSensorFilter. + + The only difference is that the filter() method features a pointer to QPressureReading + instead of QSensorReading. +*/ + +/*! + \fn QPressureFilter::filter(QPressureReading *reading) + + Called when \a reading changes. Returns false to prevent the reading from propagating. + + \sa QSensorFilter::filter() +*/ + +char const * const QPressureSensor::type("QPressureSensor"); + +/*! + \class QPressureSensor + \ingroup sensors_type + \inmodule QtSensors + \since 5.1 + + \brief The QPressureSensor class is a convenience wrapper around QSensor. + + The only behavioural difference is that this class sets the type properly. + + This class also features a reading() function that returns a QPressureReading instead of a QSensorReading. + + For details about how the sensor works, see \l QPressureReading. + + \sa QPressureReading +*/ + +/*! + Construct the sensor as a child of \a parent. +*/ +QPressureSensor::QPressureSensor(QObject *parent) + : QSensor(QPressureSensor::type, parent) +{ +} + +/*! + Destroy the sensor. Stops the sensor if it has not already been stopped. +*/ +QPressureSensor::~QPressureSensor() +{ +} + +/*! + \fn QPressureSensor::reading() const + + Returns the reading class for this sensor. + + \sa QSensor::reading() +*/ + +#include "moc_qpressuresensor.cpp" +QT_END_NAMESPACE diff --git a/src/sensors/qpressuresensor.h b/src/sensors/qpressuresensor.h new file mode 100644 index 00000000..80c99f0e --- /dev/null +++ b/src/sensors/qpressuresensor.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtSensors module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QPRESSURESENSOR_H +#define QPRESSURESENSOR_H + +#include + +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + +QT_MODULE(QtSensors) + +class QPressureReadingPrivate; + +class Q_SENSORS_EXPORT QPressureReading : public QSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal pressure READ pressure) + DECLARE_READING(QPressureReading) +public: + qreal pressure() const; + void setPressure(qreal pressure); +}; + +class Q_SENSORS_EXPORT QPressureFilter : public QSensorFilter +{ +public: + virtual bool filter(QPressureReading *reading) = 0; +private: + bool filter(QSensorReading *reading) Q_DECL_OVERRIDE + { return filter(static_cast(reading)); } +}; + +class Q_SENSORS_EXPORT QPressureSensor : public QSensor +{ + Q_OBJECT +public: + explicit QPressureSensor(QObject *parent = 0); + ~QPressureSensor(); + QPressureReading *reading() const { return static_cast(QSensor::reading()); } + static char const * const type; + +private: + Q_DISABLE_COPY(QPressureSensor) +}; + +QT_END_NAMESPACE +QT_END_HEADER + +#endif diff --git a/src/sensors/qpressuresensor_p.h b/src/sensors/qpressuresensor_p.h new file mode 100644 index 00000000..4067ccbe --- /dev/null +++ b/src/sensors/qpressuresensor_p.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtSensors module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QPRESSURESENSOR_P_H +#define QPRESSURESENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + +class QPressureReadingPrivate +{ +public: + QPressureReadingPrivate() + : pressure(0) + { + } + + qreal pressure; +}; + +QT_END_NAMESPACE +QT_END_HEADER + +#endif diff --git a/src/sensors/sensors.pro b/src/sensors/sensors.pro index 2cb33468..6f943aba 100644 --- a/src/sensors/sensors.pro +++ b/src/sensors/sensors.pro @@ -62,6 +62,7 @@ SENSORS=\ qtapsensor\ qtiltsensor\ qgyroscope\ + qpressuresensor\ for(s,SENSORS) { # Client API diff --git a/tests/auto/qsensor/test_backends.h b/tests/auto/qsensor/test_backends.h index a36a8586..e47cfd57 100644 --- a/tests/auto/qsensor/test_backends.h +++ b/tests/auto/qsensor/test_backends.h @@ -54,6 +54,7 @@ void unregister_test_backends(); #include #include #include +#include #include #include #include @@ -120,6 +121,9 @@ PREPARE_SENSORINTERFACE(QMagnetometer, QMagnetometerReading, QMagnetometerFilter PREPARE_SENSORINTERFACE(QOrientationSensor, QOrientationReading, QOrientationFilter, { reading->setOrientation(QOrientationReading::LeftUp); }) +PREPARE_SENSORINTERFACE(QPressureSensor, QPressureReading, QPressureFilter, { + reading->setPressure(1.0); +}) PREPARE_SENSORINTERFACE(QProximitySensor, QProximityReading, QProximityFilter, { reading->setClose(true); }) diff --git a/tests/auto/qsensor/tst_qsensor.cpp b/tests/auto/qsensor/tst_qsensor.cpp index 3852f7ea..3dbcb68e 100644 --- a/tests/auto/qsensor/tst_qsensor.cpp +++ b/tests/auto/qsensor/tst_qsensor.cpp @@ -877,6 +877,10 @@ private slots: QCOMPARE(reading->orientation(), QOrientationReading::LeftUp); }) + TEST_SENSORINTERFACE(QPressureSensor, QPressureReading, { + QCOMPARE(reading->pressure(), 1.0); + }) + TEST_SENSORINTERFACE(QProximitySensor, QProximityReading, { QCOMPARE(reading->close(), true); }) -- cgit v1.2.3