diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-05-23 13:18:07 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-05-23 13:18:07 +0200 |
commit | e8237a3d19e90c31af6d5a6c5e3a2f7815740226 (patch) | |
tree | 24696c0400318684bc00cf36d41a445051b67b96 | |
parent | f57241666fd4b7074cbe33567827293e2a0a9ad5 (diff) | |
parent | 3d75c54b8d0d055eff2a41cef7733b6204f8241c (diff) | |
download | qtsensors-e8237a3d19e90c31af6d5a6c5e3a2f7815740226.tar.gz |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I497c153fe555fbfbbd5fbb40f65f614ee33b065d
70 files changed, 578 insertions, 102 deletions
diff --git a/dist/changes-5.1.0 b/dist/changes-5.1.0 new file mode 100644 index 0000000..de84468 --- /dev/null +++ b/dist/changes-5.1.0 @@ -0,0 +1,52 @@ +Qt 5.1 introduces many new features and improvements as well as bugfixes +over the 5.0.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://qt-project.org/doc/qt-5.1 + +The Qt version 5.1 series is binary compatible with the 5.0.x series. +Applications compiled for 5.0 will continue to run with 5.1. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt-project.org/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + + - Add a QAmbientTemperatureSensor class. + - Add a QAltimeter class. + - Add QHolsterSensor + - Add API for duplicate skipping + - Add QPressureSensor + - Add QSensor::isFeatureSupported() + - Add linux sys accelerometer reader backend + - Introduce QRotationReading::setFromEuler() in favor of set{X/Y/Z}() + - Add support for the compass sensor + - Add support for the pressure sensor + - Add support for the IR proximity sensor + - Add support for tilt sensor + - Add sensor backend for sensorfw + - Add freefall sensor gesture + +Qt for Android +-------------- + + - Sensor implementation for Android + +Qt for BlackBerry +----------------- + + - Support QMagnetometer::returnGeoValues + - Prevent spurious calls to dataAvailable() when stopped + +Qt for iOS +---------- + + - Implement accelerometer for iOS + diff --git a/examples/sensors/accelbubble/accelbubble.pro b/examples/sensors/accelbubble/accelbubble.pro index 523ebf0..3986e4a 100644 --- a/examples/sensors/accelbubble/accelbubble.pro +++ b/examples/sensors/accelbubble/accelbubble.pro @@ -3,6 +3,9 @@ TARGET = accelbubble QT += quick SOURCES = main.cpp +RESOURCES += \ + accelbubble.qrc + app.files = \ $$files(*.qml) \ icon.png \ diff --git a/examples/sensors/accelbubble/accelbubble.qrc b/examples/sensors/accelbubble/accelbubble.qrc new file mode 100644 index 0000000..f3ca2f0 --- /dev/null +++ b/examples/sensors/accelbubble/accelbubble.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>accelbubble.qml</file> + <file>content/Bluebubble2.png</file> + </qresource> +</RCC> diff --git a/examples/sensors/cubehouse/cubehouse.pro b/examples/sensors/cubehouse/cubehouse.pro index 1fd1ef3..9f54308 100644 --- a/examples/sensors/cubehouse/cubehouse.pro +++ b/examples/sensors/cubehouse/cubehouse.pro @@ -12,3 +12,6 @@ app.files = \ target.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/cubehouse app.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/cubehouse INSTALLS += target app + +RESOURCES += \ + cubehouse.qrc diff --git a/examples/sensors/cubehouse/cubehouse.qrc b/examples/sensors/cubehouse/cubehouse.qrc new file mode 100644 index 0000000..144151b --- /dev/null +++ b/examples/sensors/cubehouse/cubehouse.qrc @@ -0,0 +1,13 @@ +<RCC> + <qresource prefix="/"> + <file>Cube.qml</file> + <file>cubehouse.qml</file> + <file>Room.qml</file> + <file>Table.qml</file> + <file>content/ground.jpg</file> + <file>content/wall.jpg</file> + <file>content/roof.jpg</file> + <file>content/qtlogo.png</file> + <file>mesh/table.3ds</file> + </qresource> +</RCC> diff --git a/examples/sensors/grue/qml.pro b/examples/sensors/grue/qml.pro index 7593538..d7444ca 100644 --- a/examples/sensors/grue/qml.pro +++ b/examples/sensors/grue/qml.pro @@ -3,6 +3,9 @@ TARGET = grue QT += quick SOURCES = main.cpp +RESOURCES += \ + qml.qrc + app.files = \ icon.png \ $$files(*.qml) \ diff --git a/examples/sensors/grue/qml.qrc b/examples/sensors/grue/qml.qrc new file mode 100644 index 0000000..55b269b --- /dev/null +++ b/examples/sensors/grue/qml.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>grue.qml</file> + <file>grue.png</file> + </qresource> +</RCC> diff --git a/examples/sensors/maze/maze.pro b/examples/sensors/maze/maze.pro index 2ce2308..b57c0a9 100644 --- a/examples/sensors/maze/maze.pro +++ b/examples/sensors/maze/maze.pro @@ -13,3 +13,6 @@ app.files = \ target.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/maze app.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/maze INSTALLS += target app + +RESOURCES += \ + maze.qrc diff --git a/examples/sensors/maze/maze.qrc b/examples/sensors/maze/maze.qrc new file mode 100644 index 0000000..1091619 --- /dev/null +++ b/examples/sensors/maze/maze.qrc @@ -0,0 +1,21 @@ +<RCC> + <qresource prefix="/"> + <file>Congratulation.qml</file> + <file>LabyrinthSquare.qml</file> + <file>lib.js</file> + <file>maze.qml</file> + <file>Mouse.qml</file> + <file>components/ApplicationWindow.qml</file> + <file>components/Button.qml</file> + <file>components/images/button_background_disabled.png</file> + <file>components/images/button_background_pressed.png</file> + <file>components/images/button_background_normal.png</file> + <file>content/00.png</file> + <file>content/start.png</file> + <file>content/mouse_down.gif</file> + <file>content/congratulations.gif</file> + <file>content/cheeseeating.gif</file> + <file>content/cheese.png</file> + <file>content/01.png</file> + </qresource> +</RCC> diff --git a/examples/sensors/qmlqtsensors/qmlqtsensors.pro b/examples/sensors/qmlqtsensors/qmlqtsensors.pro index 5275db5..b63bd6a 100644 --- a/examples/sensors/qmlqtsensors/qmlqtsensors.pro +++ b/examples/sensors/qmlqtsensors/qmlqtsensors.pro @@ -3,6 +3,9 @@ TARGET = qmlqtsensors QT += quick SOURCES = main.cpp +RESOURCES += \ + qmlqtsensors.qrc + app.files = \ $$files(*.qml) \ icon.png \ diff --git a/examples/sensors/qmlqtsensors/qmlqtsensors.qrc b/examples/sensors/qmlqtsensors/qmlqtsensors.qrc new file mode 100644 index 0000000..2f6630b --- /dev/null +++ b/examples/sensors/qmlqtsensors/qmlqtsensors.qrc @@ -0,0 +1,10 @@ +<RCC> + <qresource prefix="/"> + <file>qmlqtsensors.qml</file> + <file>components/ApplicationWindow.qml</file> + <file>components/Button.qml</file> + <file>components/images/button_background_disabled.png</file> + <file>components/images/button_background_normal.png</file> + <file>components/images/button_background_pressed.png</file> + </qresource> +</RCC> diff --git a/examples/sensors/qmlsensorgestures/qml.pro b/examples/sensors/qmlsensorgestures/qml.pro index c24dd21..9bcba7f 100644 --- a/examples/sensors/qmlsensorgestures/qml.pro +++ b/examples/sensors/qmlsensorgestures/qml.pro @@ -10,3 +10,6 @@ app.files = \ target.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/qmlsensorgestures app.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/qmlsensorgestures INSTALLS += target app + +RESOURCES += \ + qml.qrc diff --git a/examples/sensors/qmlsensorgestures/qml.qrc b/examples/sensors/qmlsensorgestures/qml.qrc new file mode 100644 index 0000000..af48a3e --- /dev/null +++ b/examples/sensors/qmlsensorgestures/qml.qrc @@ -0,0 +1,9 @@ +<RCC> + <qresource prefix="/"> + <file>Button.qml</file> + <file>GestureList.qml</file> + <file>GesturesView.qml</file> + <file>GestureView.qml</file> + <file>qmlsensorgestures.qml</file> + </qresource> +</RCC> diff --git a/examples/sensors/sensor_explorer/qml.pro b/examples/sensors/sensor_explorer/qml.pro index e5b081f..e9fe0bf 100644 --- a/examples/sensors/sensor_explorer/qml.pro +++ b/examples/sensors/sensor_explorer/qml.pro @@ -12,3 +12,6 @@ app.files = \ target.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/sensor_explorer app.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/sensor_explorer INSTALLS += target app + +RESOURCES += \ + qml.qrc diff --git a/examples/sensors/sensor_explorer/qml.qrc b/examples/sensors/sensor_explorer/qml.qrc new file mode 100644 index 0000000..3f11f3e --- /dev/null +++ b/examples/sensors/sensor_explorer/qml.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/"> + <file>PropertyList.qml</file> + <file>SensorList.qml</file> + <file>sensor_explorer.qml</file> + <file>components/ApplicationWindow.qml</file> + <file>components/TextField.qml</file> + <file>components/Button.qml</file> + <file>components/images/button_background_disabled.png</file> + <file>components/images/textfield_background_normal.png</file> + <file>components/images/textfield_background_disabled.png</file> + <file>components/images/button_background_pressed.png</file> + <file>components/images/button_background_normal.png</file> + <file>content/listitem_select.png</file> + </qresource> +</RCC> diff --git a/examples/sensors/sensors.pro b/examples/sensors/sensors.pro index dea7609..1c3f8d0 100644 --- a/examples/sensors/sensors.pro +++ b/examples/sensors/sensors.pro @@ -5,9 +5,7 @@ SUBDIRS += grue qtHaveModule(quick) { SUBDIRS += \ accelbubble \ - cubehouse \ qmlsensorgestures \ - maze \ qmlqtsensors \ sensor_explorer \ shakeit @@ -16,4 +14,10 @@ qtHaveModule(quick) { qtHaveModule(widgets): SUBDIRS += \ sensorgestures +qtHaveModule(3d): SUBDIRS += \ + cubehouse + +qtHaveModule(systeminfo): SUBDIRS += \ + maze + OTHER_FILES = stub.h diff --git a/examples/sensors/shakeit/shakeit.pro b/examples/sensors/shakeit/shakeit.pro index 7335191..cb36f73 100644 --- a/examples/sensors/shakeit/shakeit.pro +++ b/examples/sensors/shakeit/shakeit.pro @@ -3,6 +3,9 @@ TARGET = shakeit QT += quick SOURCES = main.cpp +RESOURCES += \ + shakeit.qrc + app.files = \ $$files(*.qml) \ icon.png \ diff --git a/examples/sensors/shakeit/shakeit.qrc b/examples/sensors/shakeit/shakeit.qrc new file mode 100644 index 0000000..1a2c75d --- /dev/null +++ b/examples/sensors/shakeit/shakeit.qrc @@ -0,0 +1,10 @@ +<RCC> + <qresource prefix="/"> + <file>shakeit.qml</file> + <file>audio/loopy2a_mono.wav</file> + <file>audio/phone.wav</file> + <file>content/triangle.png</file> + <file>content/triangle2.png</file> + <file>content/triangle3.png</file> + </qresource> +</RCC> diff --git a/examples/sensors/stub.h b/examples/sensors/stub.h index c74cffa..b105f93 100644 --- a/examples/sensors/stub.h +++ b/examples/sensors/stub.h @@ -45,7 +45,7 @@ {\ QGuiApplication app(argc,argv);\ QQuickView view;\ - view.setSource(QUrl::fromLocalFile(#NAME ".qml"));\ + view.setSource(QUrl("qrc:///" #NAME ".qml"));\ view.show();\ return app.exec();\ } diff --git a/src/plugins/sensors/android/jar/bundledjar.pro b/src/plugins/sensors/android/jar/bundledjar.pro new file mode 100644 index 0000000..2f6f195 --- /dev/null +++ b/src/plugins/sensors/android/jar/bundledjar.pro @@ -0,0 +1,3 @@ +TARGET = QtSensors-bundled +CONFIG += bundled_jar_file +include(jar.pri) diff --git a/src/plugins/sensors/android/jar/distributedjar.pro b/src/plugins/sensors/android/jar/distributedjar.pro new file mode 100644 index 0000000..2099826 --- /dev/null +++ b/src/plugins/sensors/android/jar/distributedjar.pro @@ -0,0 +1,2 @@ +TARGET = QtSensors +include(jar.pri) diff --git a/src/plugins/sensors/android/jar/jar.pri b/src/plugins/sensors/android/jar/jar.pri new file mode 100644 index 0000000..7e5916c --- /dev/null +++ b/src/plugins/sensors/android/jar/jar.pri @@ -0,0 +1,13 @@ +load(qt_build_paths) + +CONFIG += java +DESTDIR = $$MODULE_BASE_OUTDIR/jar + +JAVACLASSPATH += $$PWD/src + +JAVASOURCES += \ + $$PWD/src/org/qtproject/qt5/android/sensors/QtSensors.java + +# install +target.path = $$[QT_INSTALL_PREFIX]/jar +INSTALLS += target diff --git a/src/plugins/sensors/android/jar/jar.pro b/src/plugins/sensors/android/jar/jar.pro index 82f945b..70373fe 100644 --- a/src/plugins/sensors/android/jar/jar.pro +++ b/src/plugins/sensors/android/jar/jar.pro @@ -1,14 +1,3 @@ -load(qt_build_paths) +TEMPLATE = subdirs +SUBDIRS += bundledjar.pro distributedjar.pro -CONFIG += java -TARGET = QtSensors -DESTDIR = $$MODULE_BASE_OUTDIR/jar - -JAVACLASSPATH += $$PWD/src - -JAVASOURCES += \ - $$PWD/src/org/qtproject/qt5/android/sensors/QtSensors.java - -# install -target.path = $$[QT_INSTALL_PREFIX]/jar -INSTALLS += target diff --git a/src/plugins/sensors/blackberry/bbmagnetometer.cpp b/src/plugins/sensors/blackberry/bbmagnetometer.cpp index 45fd49b..a58dfe9 100644 --- a/src/plugins/sensors/blackberry/bbmagnetometer.cpp +++ b/src/plugins/sensors/blackberry/bbmagnetometer.cpp @@ -56,9 +56,7 @@ bool BbMagnetometer::updateReadingFromEvent(const sensor_event_t &event, QMagnet float x, y, z; QMagnetometer * const magnetometer = qobject_cast<QMagnetometer *>(sensor()); - Q_ASSERT(magnetometer); - const bool returnGeoValues = magnetometer->returnGeoValues(); - if (returnGeoValues) { + if (magnetometer && magnetometer->returnGeoValues()) { switch (event.accuracy) { case SENSOR_ACCURACY_UNRELIABLE: reading->setCalibrationLevel(0.0f); break; case SENSOR_ACCURACY_LOW: reading->setCalibrationLevel(0.1f); break; diff --git a/src/plugins/sensors/dummy/main.cpp b/src/plugins/sensors/dummy/main.cpp index 89f07fc..062033d 100644 --- a/src/plugins/sensors/dummy/main.cpp +++ b/src/plugins/sensors/dummy/main.cpp @@ -55,7 +55,6 @@ class dummySensorPlugin : public QObject, public QSensorPluginInterface, public public: void registerSensors() { - qDebug() << "loaded the dummy plugin"; QSensorManager::registerBackend(QAccelerometer::type, dummyaccelerometer::id, this); QSensorManager::registerBackend(QAmbientLightSensor::type, dummylightsensor::id, this); } diff --git a/src/plugins/sensors/linux/main.cpp b/src/plugins/sensors/linux/main.cpp index 7e9ece5..0ce90f3 100644 --- a/src/plugins/sensors/linux/main.cpp +++ b/src/plugins/sensors/linux/main.cpp @@ -56,7 +56,6 @@ class LinuxSensorPlugin : public QObject, public QSensorPluginInterface, public public: void registerSensors() { - qDebug() << "loaded the Linux plugin"; QString path = QString::fromLatin1(qgetenv("QT_ACCEL_FILEPATH")); if (!path.isEmpty() && !QSensorManager::isBackendRegistered(QAccelerometer::type, LinuxSysAccelerometer::id)) QSensorManager::registerBackend(QAccelerometer::type, LinuxSysAccelerometer::id, this); diff --git a/src/sensors/doc/qtsensors.qdocconf b/src/sensors/doc/qtsensors.qdocconf index 2ede8cf..b84d3fa 100644 --- a/src/sensors/doc/qtsensors.qdocconf +++ b/src/sensors/doc/qtsensors.qdocconf @@ -46,6 +46,8 @@ sourcedirs += .. \ exampledirs += ../../../examples/sensors \ snippets/ +# Specify the install path under QT_INSTALL_EXAMPLES +examplesinstallpath = sensors imagedirs += images diff --git a/src/sensors/doc/snippets/sensors/creating.cpp b/src/sensors/doc/snippets/sensors/creating.cpp index 01e3e36..7988f7e 100644 --- a/src/sensors/doc/snippets/sensors/creating.cpp +++ b/src/sensors/doc/snippets/sensors/creating.cpp @@ -40,6 +40,7 @@ #include <QObject> #include <qaccelerometer.h> +#include <qmagnetometer.h> #include <qorientationsensor.h> class MyObject : public QObject @@ -59,5 +60,20 @@ QOrientationSensor orient_sensor; Q_UNUSED(sensor) Q_UNUSED(orient_sensor); + +{ +//! [2] +QMagnetometer *magnetometer = new QMagnetometer(this); +//! [2] +Q_UNUSED(magnetometer); +} + +{ +//! [3] +QSensor *magnetometer = new QSensor(QMagnetometer::type, this); +//! [3] +Q_UNUSED(magnetometer); +} + } diff --git a/src/sensors/make_sensor.pl b/src/sensors/make_sensor.pl index 2732251..00afa72 100755 --- a/src/sensors/make_sensor.pl +++ b/src/sensors/make_sensor.pl @@ -315,8 +315,7 @@ class Q_SENSORS_EXPORT '.$filter.' : public QSensorFilter public: virtual bool filter('.$reading.' *reading) = 0; private: - bool filter(QSensorReading *reading) Q_DECL_OVERRIDE - { return filter(static_cast<'.$reading.'*>(reading)); } + bool filter(QSensorReading *reading) Q_DECL_OVERRIDE; }; class Q_SENSORS_EXPORT '.$sensor.' : public QSensor @@ -325,7 +324,7 @@ class Q_SENSORS_EXPORT '.$sensor.' : public QSensor public: explicit '.$sensor.'(QObject *parent = 0); ~'.$sensor.'(); - '.$reading.' *reading() const { return static_cast<'.$reading.'*>(QSensor::reading()); } + '.$reading.' *reading() const; static char const * const type; private: @@ -408,6 +407,11 @@ void '.$reading.'::setMyprop(qreal myprop) \sa QSensorFilter::filter() */ +bool '.$filter.'::filter(QSensorReading *reading) +{ + return filter(static_cast<'.$reading.'*>(reading)); +} + char const * const '.$sensor.'::type("'.$sensor.'"); /*! @@ -450,6 +454,11 @@ char const * const '.$sensor.'::type("'.$sensor.'"); \sa QSensor::reading() */ +'.$reading.' *'.$sensor.'::reading() const +{ + return static_cast<'.$reading.'*>(QSensor::reading()); +} + #include "moc_'.$source.'" QT_END_NAMESPACE '; diff --git a/src/sensors/qaccelerometer.cpp b/src/sensors/qaccelerometer.cpp index 9b9bd34..dd82273 100644 --- a/src/sensors/qaccelerometer.cpp +++ b/src/sensors/qaccelerometer.cpp @@ -150,6 +150,11 @@ void QAccelerometerReading::setZ(qreal z) \sa QSensorFilter::filter() */ +bool QAccelerometerFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QAccelerometerReading*>(reading)); +} + char const * const QAccelerometer::type("QAccelerometer"); /*! @@ -257,6 +262,11 @@ void QAccelerometer::setAccelerationMode(QAccelerometer::AccelerationMode accele \sa QSensor::reading() */ +QAccelerometerReading *QAccelerometer::reading() const +{ + return static_cast<QAccelerometerReading*>(QSensor::reading()); +} + /*! \fn QAccelerometer::accelerationModeChanged(AccelerationMode accelerationMode) diff --git a/src/sensors/qaccelerometer.h b/src/sensors/qaccelerometer.h index 4478235..b9be052 100644 --- a/src/sensors/qaccelerometer.h +++ b/src/sensors/qaccelerometer.h @@ -71,7 +71,7 @@ class Q_SENSORS_EXPORT QAccelerometerFilter : public QSensorFilter public: virtual bool filter(QAccelerometerReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QAccelerometerReading*>(reading)); } + bool filter(QSensorReading *reading); }; class QAccelerometerPrivate; @@ -96,7 +96,7 @@ public: AccelerationMode accelerationMode() const; void setAccelerationMode(AccelerationMode accelerationMode); - QAccelerometerReading *reading() const { return static_cast<QAccelerometerReading*>(QSensor::reading()); } + QAccelerometerReading *reading() const; static char const * const type; Q_SIGNALS: diff --git a/src/sensors/qaltimeter.cpp b/src/sensors/qaltimeter.cpp index 6a7caa7..44c5767 100644 --- a/src/sensors/qaltimeter.cpp +++ b/src/sensors/qaltimeter.cpp @@ -102,6 +102,11 @@ void QAltimeterReading::setAltitude(qreal altitude) \sa QSensorFilter::filter() */ +bool QAltimeterFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QAltimeterReading*>(reading)); +} + char const * const QAltimeter::type("QAltimeter"); /*! @@ -144,5 +149,10 @@ QAltimeter::~QAltimeter() \sa QSensor::reading() */ +QAltimeterReading *QAltimeter::reading() const +{ + return static_cast<QAltimeterReading*>(QSensor::reading()); +} + #include "moc_qaltimeter.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qaltimeter.h b/src/sensors/qaltimeter.h index 6b7d223..7077e38 100644 --- a/src/sensors/qaltimeter.h +++ b/src/sensors/qaltimeter.h @@ -62,8 +62,7 @@ class Q_SENSORS_EXPORT QAltimeterFilter : public QSensorFilter public: virtual bool filter(QAltimeterReading *reading) = 0; private: - bool filter(QSensorReading *reading) Q_DECL_OVERRIDE - { return filter(static_cast<QAltimeterReading*>(reading)); } + bool filter(QSensorReading *reading) Q_DECL_OVERRIDE; }; class Q_SENSORS_EXPORT QAltimeter : public QSensor @@ -72,7 +71,7 @@ class Q_SENSORS_EXPORT QAltimeter : public QSensor public: explicit QAltimeter(QObject *parent = 0); ~QAltimeter(); - QAltimeterReading *reading() const { return static_cast<QAltimeterReading*>(QSensor::reading()); } + QAltimeterReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qambientlightsensor.cpp b/src/sensors/qambientlightsensor.cpp index 2c434b4..6992459 100644 --- a/src/sensors/qambientlightsensor.cpp +++ b/src/sensors/qambientlightsensor.cpp @@ -126,6 +126,11 @@ void QAmbientLightReading::setLightLevel(QAmbientLightReading::LightLevel lightL \sa QSensorFilter::filter() */ +bool QAmbientLightFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QAmbientLightReading*>(reading)); +} + char const * const QAmbientLightSensor::type("QAmbientLightSensor"); /*! @@ -167,6 +172,11 @@ QAmbientLightSensor::~QAmbientLightSensor() \sa QSensor::reading() */ +QAmbientLightReading *QAmbientLightSensor::reading() const +{ + return static_cast<QAmbientLightReading*>(QSensor::reading()); +} + #include "moc_qambientlightsensor.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qambientlightsensor.h b/src/sensors/qambientlightsensor.h index 3dae639..8f9ee50 100644 --- a/src/sensors/qambientlightsensor.h +++ b/src/sensors/qambientlightsensor.h @@ -73,7 +73,7 @@ class Q_SENSORS_EXPORT QAmbientLightFilter : public QSensorFilter public: virtual bool filter(QAmbientLightReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QAmbientLightReading*>(reading)); } + bool filter(QSensorReading *reading); }; class Q_SENSORS_EXPORT QAmbientLightSensor : public QSensor @@ -82,7 +82,7 @@ class Q_SENSORS_EXPORT QAmbientLightSensor : public QSensor public: explicit QAmbientLightSensor(QObject *parent = 0); virtual ~QAmbientLightSensor(); - QAmbientLightReading *reading() const { return static_cast<QAmbientLightReading*>(QSensor::reading()); } + QAmbientLightReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qambienttemperaturesensor.cpp b/src/sensors/qambienttemperaturesensor.cpp index 9ecde6d..7dd34dd 100644 --- a/src/sensors/qambienttemperaturesensor.cpp +++ b/src/sensors/qambienttemperaturesensor.cpp @@ -98,6 +98,11 @@ void QAmbientTemperatureReading::setTemperature(qreal temperature) \sa QSensorFilter::filter() */ +bool QAmbientTemperatureFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QAmbientTemperatureReading*>(reading)); +} + char const * const QAmbientTemperatureSensor::type("QAmbientTemperatureSensor"); /*! @@ -140,5 +145,10 @@ QAmbientTemperatureSensor::~QAmbientTemperatureSensor() \sa QSensor::reading() */ +QAmbientTemperatureReading *QAmbientTemperatureSensor::reading() const +{ + return static_cast<QAmbientTemperatureReading*>(QSensor::reading()); +} + #include "moc_qambienttemperaturesensor.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qambienttemperaturesensor.h b/src/sensors/qambienttemperaturesensor.h index 134e5a9..c91392d 100644 --- a/src/sensors/qambienttemperaturesensor.h +++ b/src/sensors/qambienttemperaturesensor.h @@ -62,8 +62,7 @@ class Q_SENSORS_EXPORT QAmbientTemperatureFilter : public QSensorFilter public: virtual bool filter(QAmbientTemperatureReading *reading) = 0; private: - bool filter(QSensorReading *reading) Q_DECL_OVERRIDE - { return filter(static_cast<QAmbientTemperatureReading*>(reading)); } + bool filter(QSensorReading *reading) Q_DECL_OVERRIDE; }; class Q_SENSORS_EXPORT QAmbientTemperatureSensor : public QSensor @@ -72,7 +71,7 @@ class Q_SENSORS_EXPORT QAmbientTemperatureSensor : public QSensor public: explicit QAmbientTemperatureSensor(QObject *parent = 0); ~QAmbientTemperatureSensor(); - QAmbientTemperatureReading *reading() const { return static_cast<QAmbientTemperatureReading*>(QSensor::reading()); } + QAmbientTemperatureReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qcompass.cpp b/src/sensors/qcompass.cpp index e0592ef..8bfca07 100644 --- a/src/sensors/qcompass.cpp +++ b/src/sensors/qcompass.cpp @@ -136,6 +136,11 @@ void QCompassReading::setCalibrationLevel(qreal calibrationLevel) \sa QSensorFilter::filter() */ +bool QCompassFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QCompassReading*>(reading)); +} + char const * const QCompass::type("QCompass"); /*! @@ -177,6 +182,11 @@ QCompass::~QCompass() \sa QSensor::reading() */ +QCompassReading *QCompass::reading() const +{ + return static_cast<QCompassReading*>(QSensor::reading()); +} + #include "moc_qcompass.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qcompass.h b/src/sensors/qcompass.h index 8b858ff..75b6869 100644 --- a/src/sensors/qcompass.h +++ b/src/sensors/qcompass.h @@ -67,7 +67,7 @@ class Q_SENSORS_EXPORT QCompassFilter : public QSensorFilter public: virtual bool filter(QCompassReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QCompassReading*>(reading)); } + bool filter(QSensorReading *reading); }; class Q_SENSORS_EXPORT QCompass : public QSensor @@ -76,7 +76,7 @@ class Q_SENSORS_EXPORT QCompass : public QSensor public: explicit QCompass(QObject *parent = 0); virtual ~QCompass(); - QCompassReading *reading() const { return static_cast<QCompassReading*>(QSensor::reading()); } + QCompassReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qgyroscope.cpp b/src/sensors/qgyroscope.cpp index a2dfff8..ca370ba 100644 --- a/src/sensors/qgyroscope.cpp +++ b/src/sensors/qgyroscope.cpp @@ -148,6 +148,11 @@ void QGyroscopeReading::setZ(qreal z) \sa QSensorFilter::filter() */ +bool QGyroscopeFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QGyroscopeReading*>(reading)); +} + char const * const QGyroscope::type("QGyroscope"); /*! @@ -189,6 +194,11 @@ QGyroscope::~QGyroscope() \sa QSensor::reading() */ +QGyroscopeReading *QGyroscope::reading() const +{ + return static_cast<QGyroscopeReading*>(QSensor::reading()); +} + #include "moc_qgyroscope.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qgyroscope.h b/src/sensors/qgyroscope.h index 32c01da..31ed23b 100644 --- a/src/sensors/qgyroscope.h +++ b/src/sensors/qgyroscope.h @@ -71,7 +71,7 @@ class Q_SENSORS_EXPORT QGyroscopeFilter : public QSensorFilter public: virtual bool filter(QGyroscopeReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QGyroscopeReading*>(reading)); } + bool filter(QSensorReading *reading); }; class Q_SENSORS_EXPORT QGyroscope : public QSensor @@ -80,7 +80,7 @@ class Q_SENSORS_EXPORT QGyroscope : public QSensor public: explicit QGyroscope(QObject *parent = 0); virtual ~QGyroscope(); - QGyroscopeReading *reading() const { return static_cast<QGyroscopeReading*>(QSensor::reading()); } + QGyroscopeReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qholstersensor.cpp b/src/sensors/qholstersensor.cpp index 761910f..648afa3 100644 --- a/src/sensors/qholstersensor.cpp +++ b/src/sensors/qholstersensor.cpp @@ -102,6 +102,11 @@ void QHolsterReading::setHolstered(bool holstered) \sa QSensorFilter::filter() */ +bool QHolsterFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QHolsterReading*>(reading)); +} + char const * const QHolsterSensor::type("QHolsterSensor"); /*! @@ -144,5 +149,10 @@ QHolsterSensor::~QHolsterSensor() \sa QSensor::reading() */ +QHolsterReading *QHolsterSensor::reading() const +{ + return static_cast<QHolsterReading*>(QSensor::reading()); +} + #include "moc_qholstersensor.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qholstersensor.h b/src/sensors/qholstersensor.h index f44b381..85faa17 100644 --- a/src/sensors/qholstersensor.h +++ b/src/sensors/qholstersensor.h @@ -62,8 +62,7 @@ class Q_SENSORS_EXPORT QHolsterFilter : public QSensorFilter public: virtual bool filter(QHolsterReading *reading) = 0; private: - bool filter(QSensorReading *reading) Q_DECL_OVERRIDE - { return filter(static_cast<QHolsterReading*>(reading)); } + bool filter(QSensorReading *reading) Q_DECL_OVERRIDE; }; class Q_SENSORS_EXPORT QHolsterSensor : public QSensor @@ -72,7 +71,7 @@ class Q_SENSORS_EXPORT QHolsterSensor : public QSensor public: explicit QHolsterSensor(QObject *parent = 0); ~QHolsterSensor(); - QHolsterReading *reading() const { return static_cast<QHolsterReading*>(QSensor::reading()); } + QHolsterReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qirproximitysensor.cpp b/src/sensors/qirproximitysensor.cpp index 6197bb9..81ef909 100644 --- a/src/sensors/qirproximitysensor.cpp +++ b/src/sensors/qirproximitysensor.cpp @@ -114,6 +114,11 @@ void QIRProximityReading::setReflectance(qreal reflectance) \sa QSensorFilter::filter() */ +bool QIRProximityFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QIRProximityReading*>(reading)); +} + char const * const QIRProximitySensor::type("QIRProximitySensor"); /*! @@ -155,5 +160,9 @@ QIRProximitySensor::~QIRProximitySensor() \sa QSensor::reading() */ +QIRProximityReading *QIRProximitySensor::reading() const +{ + return static_cast<QIRProximityReading*>(QSensor::reading()); +} #include "moc_qirproximitysensor.cpp" diff --git a/src/sensors/qirproximitysensor.h b/src/sensors/qirproximitysensor.h index 29eb49c..c4ecba4 100644 --- a/src/sensors/qirproximitysensor.h +++ b/src/sensors/qirproximitysensor.h @@ -63,7 +63,7 @@ class Q_SENSORS_EXPORT QIRProximityFilter : public QSensorFilter public: virtual bool filter(QIRProximityReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QIRProximityReading*>(reading)); } + bool filter(QSensorReading *reading); }; class Q_SENSORS_EXPORT QIRProximitySensor : public QSensor @@ -72,7 +72,7 @@ class Q_SENSORS_EXPORT QIRProximitySensor : public QSensor public: explicit QIRProximitySensor(QObject *parent = 0); virtual ~QIRProximitySensor(); - QIRProximityReading *reading() const { return static_cast<QIRProximityReading*>(QSensor::reading()); } + QIRProximityReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qlightsensor.cpp b/src/sensors/qlightsensor.cpp index 1e80ef0..7e10f0f 100644 --- a/src/sensors/qlightsensor.cpp +++ b/src/sensors/qlightsensor.cpp @@ -100,6 +100,11 @@ void QLightReading::setLux(qreal lux) \sa QSensorFilter::filter() */ +bool QLightFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QLightReading*>(reading)); +} + char const * const QLightSensor::type("QLightSensor"); /*! @@ -141,6 +146,11 @@ QLightSensor::~QLightSensor() \sa QSensor::reading() */ +QLightReading *QLightSensor::reading() const +{ + return static_cast<QLightReading*>(QSensor::reading()); +} + /*! \property QLightSensor::fieldOfView \brief a value indicating the field of view. diff --git a/src/sensors/qlightsensor.h b/src/sensors/qlightsensor.h index 1da8449..26240b4 100644 --- a/src/sensors/qlightsensor.h +++ b/src/sensors/qlightsensor.h @@ -63,7 +63,7 @@ class Q_SENSORS_EXPORT QLightFilter : public QSensorFilter public: virtual bool filter(QLightReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QLightReading*>(reading)); } + bool filter(QSensorReading *reading); }; class QLightSensorPrivate; @@ -75,7 +75,7 @@ class Q_SENSORS_EXPORT QLightSensor : public QSensor public: explicit QLightSensor(QObject *parent = 0); virtual ~QLightSensor(); - QLightReading *reading() const { return static_cast<QLightReading*>(QSensor::reading()); } + QLightReading *reading() const; static char const * const type; qreal fieldOfView() const; diff --git a/src/sensors/qmagnetometer.cpp b/src/sensors/qmagnetometer.cpp index 7c5c965..e7cc61c 100644 --- a/src/sensors/qmagnetometer.cpp +++ b/src/sensors/qmagnetometer.cpp @@ -188,6 +188,11 @@ void QMagnetometerReading::setCalibrationLevel(qreal calibrationLevel) \sa QSensorFilter::filter() */ +bool QMagnetometerFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QMagnetometerReading*>(reading)); +} + char const * const QMagnetometer::type("QMagnetometer"); /*! @@ -229,6 +234,11 @@ QMagnetometer::~QMagnetometer() \sa QSensor::reading() */ +QMagnetometerReading *QMagnetometer::reading() const +{ + return static_cast<QMagnetometerReading*>(QSensor::reading()); +} + /*! \property QMagnetometer::returnGeoValues \brief a value indicating if geomagnetic values should be returned. diff --git a/src/sensors/qmagnetometer.h b/src/sensors/qmagnetometer.h index 93b6157..9d754fc 100644 --- a/src/sensors/qmagnetometer.h +++ b/src/sensors/qmagnetometer.h @@ -75,7 +75,7 @@ class Q_SENSORS_EXPORT QMagnetometerFilter : public QSensorFilter public: virtual bool filter(QMagnetometerReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QMagnetometerReading*>(reading)); } + bool filter(QSensorReading *reading); }; class QMagnetometerPrivate; @@ -87,7 +87,7 @@ class Q_SENSORS_EXPORT QMagnetometer : public QSensor public: explicit QMagnetometer(QObject *parent = 0); virtual ~QMagnetometer(); - QMagnetometerReading *reading() const { return static_cast<QMagnetometerReading*>(QSensor::reading()); } + QMagnetometerReading *reading() const; static char const * const type; bool returnGeoValues() const; diff --git a/src/sensors/qorientationsensor.cpp b/src/sensors/qorientationsensor.cpp index 0ca545e..5f5015d 100644 --- a/src/sensors/qorientationsensor.cpp +++ b/src/sensors/qorientationsensor.cpp @@ -149,6 +149,11 @@ void QOrientationReading::setOrientation(QOrientationReading::Orientation orient \sa QSensorFilter::filter() */ +bool QOrientationFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QOrientationReading*>(reading)); +} + char const * const QOrientationSensor::type("QOrientationSensor"); /*! @@ -190,6 +195,11 @@ QOrientationSensor::~QOrientationSensor() \sa QSensor::reading() */ +QOrientationReading *QOrientationSensor::reading() const +{ + return static_cast<QOrientationReading*>(QSensor::reading()); +} + #include "moc_qorientationsensor.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qorientationsensor.h b/src/sensors/qorientationsensor.h index 082598f..a6fccb8 100644 --- a/src/sensors/qorientationsensor.h +++ b/src/sensors/qorientationsensor.h @@ -74,7 +74,7 @@ class Q_SENSORS_EXPORT QOrientationFilter : public QSensorFilter public: virtual bool filter(QOrientationReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QOrientationReading*>(reading)); } + bool filter(QSensorReading *reading); }; class Q_SENSORS_EXPORT QOrientationSensor : public QSensor @@ -83,7 +83,7 @@ class Q_SENSORS_EXPORT QOrientationSensor : public QSensor public: explicit QOrientationSensor(QObject *parent = 0); virtual ~QOrientationSensor(); - QOrientationReading *reading() const { return static_cast<QOrientationReading*>(QSensor::reading()); } + QOrientationReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qpressuresensor.cpp b/src/sensors/qpressuresensor.cpp index ca3a861..1aea843 100644 --- a/src/sensors/qpressuresensor.cpp +++ b/src/sensors/qpressuresensor.cpp @@ -128,6 +128,11 @@ void QPressureReading::setTemperature(qreal temperature) \sa QSensorFilter::filter() */ +bool QPressureFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QPressureReading*>(reading)); +} + char const * const QPressureSensor::type("QPressureSensor"); /*! @@ -170,5 +175,10 @@ QPressureSensor::~QPressureSensor() \sa QSensor::reading() */ +QPressureReading *QPressureSensor::reading() const +{ + return static_cast<QPressureReading*>(QSensor::reading()); +} + #include "moc_qpressuresensor.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qpressuresensor.h b/src/sensors/qpressuresensor.h index 4df2289..8a14d41 100644 --- a/src/sensors/qpressuresensor.h +++ b/src/sensors/qpressuresensor.h @@ -66,8 +66,7 @@ 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<QPressureReading*>(reading)); } + bool filter(QSensorReading *reading) Q_DECL_OVERRIDE; }; class Q_SENSORS_EXPORT QPressureSensor : public QSensor @@ -76,7 +75,7 @@ class Q_SENSORS_EXPORT QPressureSensor : public QSensor public: explicit QPressureSensor(QObject *parent = 0); ~QPressureSensor(); - QPressureReading *reading() const { return static_cast<QPressureReading*>(QSensor::reading()); } + QPressureReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qproximitysensor.cpp b/src/sensors/qproximitysensor.cpp index 599d290..102976d 100644 --- a/src/sensors/qproximitysensor.cpp +++ b/src/sensors/qproximitysensor.cpp @@ -105,6 +105,11 @@ void QProximityReading::setClose(bool close) \sa QSensorFilter::filter() */ +bool QProximityFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QProximityReading*>(reading)); +} + char const * const QProximitySensor::type("QProximitySensor"); /*! @@ -146,6 +151,11 @@ QProximitySensor::~QProximitySensor() \sa QSensor::reading() */ +QProximityReading *QProximitySensor::reading() const +{ + return static_cast<QProximityReading*>(QSensor::reading()); +} + #include "moc_qproximitysensor.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qproximitysensor.h b/src/sensors/qproximitysensor.h index cc8eb78..162334f 100644 --- a/src/sensors/qproximitysensor.h +++ b/src/sensors/qproximitysensor.h @@ -63,7 +63,7 @@ class Q_SENSORS_EXPORT QProximityFilter : public QSensorFilter public: virtual bool filter(QProximityReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QProximityReading*>(reading)); } + bool filter(QSensorReading *reading); }; class Q_SENSORS_EXPORT QProximitySensor : public QSensor @@ -72,7 +72,7 @@ class Q_SENSORS_EXPORT QProximitySensor : public QSensor public: explicit QProximitySensor(QObject *parent = 0); virtual ~QProximitySensor(); - QProximityReading *reading() const { return static_cast<QProximityReading*>(QSensor::reading()); } + QProximityReading *reading() const; static char const * const type; private: diff --git a/src/sensors/qrotationsensor.cpp b/src/sensors/qrotationsensor.cpp index 06ee406..135b657 100644 --- a/src/sensors/qrotationsensor.cpp +++ b/src/sensors/qrotationsensor.cpp @@ -179,6 +179,11 @@ void QRotationReading::setFromEuler(qreal x, qreal y, qreal z) \sa QSensorFilter::filter() */ +bool QRotationFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QRotationReading*>(reading)); +} + char const * const QRotationSensor::type("QRotationSensor"); /*! @@ -220,6 +225,11 @@ QRotationSensor::~QRotationSensor() \sa QSensor::reading() */ +QRotationReading *QRotationSensor::reading() const +{ + return static_cast<QRotationReading*>(QSensor::reading()); +} + /*! \property QRotationSensor::hasZ \brief a value indicating if the z angle is available. diff --git a/src/sensors/qrotationsensor.h b/src/sensors/qrotationsensor.h index 68a0d1d..e7d0e2e 100644 --- a/src/sensors/qrotationsensor.h +++ b/src/sensors/qrotationsensor.h @@ -68,7 +68,7 @@ class Q_SENSORS_EXPORT QRotationFilter : public QSensorFilter public: virtual bool filter(QRotationReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QRotationReading*>(reading)); } + bool filter(QSensorReading *reading); }; class QRotationSensorPrivate; @@ -80,7 +80,7 @@ class Q_SENSORS_EXPORT QRotationSensor : public QSensor public: explicit QRotationSensor(QObject *parent = 0); virtual ~QRotationSensor(); - QRotationReading *reading() const { return static_cast<QRotationReading*>(QSensor::reading()); } + QRotationReading *reading() const; static char const * const type; bool hasZ() const; diff --git a/src/sensors/qsensor.cpp b/src/sensors/qsensor.cpp index fad1de2..7f05189 100644 --- a/src/sensors/qsensor.cpp +++ b/src/sensors/qsensor.cpp @@ -262,6 +262,23 @@ void QSensorPrivate::init(const QByteArray &sensorType) /*! Construct the \a type sensor as a child of \a parent. + + Do not use this constructor if a derived class exists for the specific sensor type. + + The wrong way is to use the base class constructor: + \snippet sensors/creating.cpp 3 + The right way is to create an instance of the derived class: + \snippet sensors/creating.cpp 2 + + The derived classes have + additional properties and data members which are needed for certain features such as + geo value support in QMagnetometer or acceleration mode support in QAccelerometer. + These features will only work properly when creating a sensor instance from a QSensor + subclass. + + Only use this constructor if there is no derived sensor class available. Note that all + built-in sensors have a derived class, so using this constructor should only be necessary + when implementing custom sensors, like in the \l {Qt Sensors - Grue Sensor Example}{Grue sensor example}. */ QSensor::QSensor(const QByteArray &type, QObject *parent) : QObject(*new QSensorPrivate, parent) diff --git a/src/sensors/qsensorbackend.cpp b/src/sensors/qsensorbackend.cpp index 304674e..363ad87 100644 --- a/src/sensors/qsensorbackend.cpp +++ b/src/sensors/qsensorbackend.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qsensorbackend.h" +#include "qsensorbackend_p.h" #include "qsensor_p.h" #include <QDebug> @@ -59,8 +60,8 @@ QT_BEGIN_NAMESPACE /*! \internal */ -QSensorBackend::QSensorBackend(QSensor *sensor) - : m_sensor(sensor) +QSensorBackend::QSensorBackend(QSensor *sensor, QObject *parent) + : QObject(*new QSensorBackendPrivate(sensor), parent) { } @@ -91,21 +92,22 @@ bool QSensorBackend::isFeatureSupported(QSensor::Feature feature) const */ void QSensorBackend::newReadingAvailable() { - QSensorPrivate *d = m_sensor->d_func(); + Q_D(QSensorBackend); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); // Copy the values from the device reading to the filter reading - d->filter_reading->copyValuesFrom(d->device_reading); + sensorPrivate->filter_reading->copyValuesFrom(sensorPrivate->device_reading); - for (QFilterList::const_iterator it = d->filters.constBegin(); it != d->filters.constEnd(); ++it) { + for (QFilterList::const_iterator it = sensorPrivate->filters.constBegin(); it != sensorPrivate->filters.constEnd(); ++it) { QSensorFilter *filter = (*it); - if (!filter->filter(d->filter_reading)) + if (!filter->filter(sensorPrivate->filter_reading)) return; } // Copy the values from the filter reading to the cached reading - d->cache_reading->copyValuesFrom(d->filter_reading); + sensorPrivate->cache_reading->copyValuesFrom(sensorPrivate->filter_reading); - Q_EMIT m_sensor->readingChanged(); + Q_EMIT d->m_sensor->readingChanged(); } /*! @@ -131,15 +133,19 @@ void QSensorBackend::newReadingAvailable() */ QSensorReading *QSensorBackend::reading() const { - QSensorPrivate *d = m_sensor->d_func(); - return d->device_reading; + Q_D(const QSensorBackend); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); + return sensorPrivate->device_reading; } /*! - \fn QSensorBackend::sensor() const - Returns the sensor front end associated with this backend. */ +QSensor *QSensorBackend::sensor() const +{ + Q_D(const QSensorBackend); + return d->m_sensor; +} /*! \fn QSensorBackend::setReading(T *reading) @@ -210,10 +216,11 @@ QSensorReading *QSensorBackend::reading() const */ void QSensorBackend::setReadings(QSensorReading *device, QSensorReading *filter, QSensorReading *cache) { - QSensorPrivate *d = m_sensor->d_func(); - d->device_reading = device; - d->filter_reading = filter; - d->cache_reading = cache; + Q_D(QSensorBackend); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); + sensorPrivate->device_reading = device; + sensorPrivate->filter_reading = filter; + sensorPrivate->cache_reading = cache; } /*! @@ -226,8 +233,9 @@ void QSensorBackend::setReadings(QSensorReading *device, QSensorReading *filter, */ void QSensorBackend::addDataRate(qreal min, qreal max) { - QSensorPrivate *d = m_sensor->d_func(); - d->availableDataRates << qrange(min, max); + Q_D(QSensorBackend); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); + sensorPrivate->availableDataRates << qrange(min, max); } /*! @@ -245,6 +253,7 @@ void QSensorBackend::addDataRate(qreal min, qreal max) */ void QSensorBackend::setDataRates(const QSensor *otherSensor) { + Q_D(QSensorBackend); if (!otherSensor) { qWarning() << "ERROR: Cannot call QSensorBackend::setDataRates with 0"; return; @@ -253,12 +262,12 @@ void QSensorBackend::setDataRates(const QSensor *otherSensor) qWarning() << "ERROR: Cannot call QSensorBackend::setDataRates with an invalid sensor"; return; } - if (m_sensor->isConnectedToBackend()) { + if (d->m_sensor->isConnectedToBackend()) { qWarning() << "ERROR: Cannot call QSensorBackend::setDataRates outside of the constructor"; return; } - QSensorPrivate *d = m_sensor->d_func(); - d->availableDataRates = otherSensor->availableDataRates(); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); + sensorPrivate->availableDataRates = otherSensor->availableDataRates(); } /*! @@ -271,11 +280,12 @@ void QSensorBackend::setDataRates(const QSensor *otherSensor) */ void QSensorBackend::addOutputRange(qreal min, qreal max, qreal accuracy) { - QSensorPrivate *d = m_sensor->d_func(); + Q_D(QSensorBackend); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); qoutputrange details = {min, max, accuracy}; - d->outputRanges << details; + sensorPrivate->outputRanges << details; } /*! @@ -286,8 +296,9 @@ void QSensorBackend::addOutputRange(qreal min, qreal max, qreal accuracy) */ void QSensorBackend::setDescription(const QString &description) { - QSensorPrivate *d = m_sensor->d_func(); - d->description = description; + Q_D(QSensorBackend); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); + sensorPrivate->description = description; } /*! @@ -302,8 +313,9 @@ void QSensorBackend::setDescription(const QString &description) */ void QSensorBackend::sensorStopped() { - QSensorPrivate *d = m_sensor->d_func(); - d->active = false; + Q_D(QSensorBackend); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); + sensorPrivate->active = false; } /*! @@ -318,9 +330,10 @@ void QSensorBackend::sensorStopped() */ void QSensorBackend::sensorBusy() { - QSensorPrivate *d = m_sensor->d_func(); - d->active = false; - d->busy = true; + Q_D(QSensorBackend); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); + sensorPrivate->active = false; + sensorPrivate->busy = true; } /*! @@ -332,9 +345,10 @@ void QSensorBackend::sensorBusy() */ void QSensorBackend::sensorError(int error) { - QSensorPrivate *d = m_sensor->d_func(); - d->error = error; - Q_EMIT m_sensor->sensorError(error); + Q_D(QSensorBackend); + QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); + sensorPrivate->error = error; + Q_EMIT d->m_sensor->sensorError(error); } #include "moc_qsensorbackend.cpp" diff --git a/src/sensors/qsensorbackend.h b/src/sensors/qsensorbackend.h index 4c6ce8b..03a0c41 100644 --- a/src/sensors/qsensorbackend.h +++ b/src/sensors/qsensorbackend.h @@ -47,11 +47,13 @@ QT_BEGIN_NAMESPACE +class QSensorBackendPrivate; + class Q_SENSORS_EXPORT QSensorBackend : public QObject { Q_OBJECT public: - QSensorBackend(QSensor *sensor); + explicit QSensorBackend(QSensor *sensor, QObject *parent = 0); virtual ~QSensorBackend(); virtual void start() = 0; @@ -75,7 +77,7 @@ public: } QSensorReading *reading() const; - QSensor *sensor() const { return m_sensor; } + QSensor *sensor() const; // used by the backend to inform us of events void newReadingAvailable(); @@ -86,7 +88,7 @@ public: private: void setReadings(QSensorReading *device, QSensorReading *filter, QSensorReading *cache); - QSensor *m_sensor; + Q_DECLARE_PRIVATE(QSensorBackend) Q_DISABLE_COPY(QSensorBackend) }; diff --git a/src/sensors/qsensorbackend_p.h b/src/sensors/qsensorbackend_p.h new file mode 100644 index 0000000..5b98940 --- /dev/null +++ b/src/sensors/qsensorbackend_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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 QSENSORBACKEND_P_H +#define QSENSORBACKEND_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. +// + +#include "qsensorbackend.h" + +#include "private/qobject_p.h" + +QT_BEGIN_NAMESPACE + +class QSensorBackendPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QSensorBackend) +public: + explicit QSensorBackendPrivate(QSensor *sensor) + : m_sensor(sensor) + { + } + + QSensor *m_sensor; +}; + +QT_END_NAMESPACE + +#endif + diff --git a/src/sensors/qsensormanager.cpp b/src/sensors/qsensormanager.cpp index dbaf1eb..29bd4b5 100644 --- a/src/sensors/qsensormanager.cpp +++ b/src/sensors/qsensormanager.cpp @@ -496,9 +496,11 @@ void QSensor::registerInstance() */ /*! - \fn QSensorBackendFactory::~QSensorBackendFactory() \internal */ +QSensorBackendFactory::~QSensorBackendFactory() +{ +} /*! \fn QSensorBackendFactory::createBackend(QSensor *sensor) diff --git a/src/sensors/qsensormanager.h b/src/sensors/qsensormanager.h index 8fa87d1..a1611cf 100644 --- a/src/sensors/qsensormanager.h +++ b/src/sensors/qsensormanager.h @@ -70,7 +70,7 @@ class Q_SENSORS_EXPORT QSensorBackendFactory public: virtual QSensorBackend *createBackend(QSensor *sensor) = 0; protected: - ~QSensorBackendFactory() {} + virtual ~QSensorBackendFactory(); }; QT_END_NAMESPACE diff --git a/src/sensors/qsensorplugin.cpp b/src/sensors/qsensorplugin.cpp index 29498b9..ae184eb 100644 --- a/src/sensors/qsensorplugin.cpp +++ b/src/sensors/qsensorplugin.cpp @@ -54,9 +54,11 @@ */ /*! - \fn QSensorPluginInterface::~QSensorPluginInterface() \internal */ +QSensorPluginInterface::~QSensorPluginInterface() +{ +} /*! \fn QSensorPluginInterface::registerSensors() @@ -82,9 +84,12 @@ */ /*! - \fn QSensorChangesInterface::~QSensorChangesInterface() \internal */ +QSensorChangesInterface::~QSensorChangesInterface() +{ +} + /*! \fn QSensorChangesInterface::sensorsChanged() diff --git a/src/sensors/qsensorplugin.h b/src/sensors/qsensorplugin.h index 336bce6..e81d4d5 100644 --- a/src/sensors/qsensorplugin.h +++ b/src/sensors/qsensorplugin.h @@ -53,7 +53,7 @@ class Q_SENSORS_EXPORT QSensorPluginInterface public: virtual void registerSensors() = 0; protected: - ~QSensorPluginInterface() {} + virtual ~QSensorPluginInterface(); }; class Q_SENSORS_EXPORT QSensorChangesInterface @@ -61,7 +61,7 @@ class Q_SENSORS_EXPORT QSensorChangesInterface public: virtual void sensorsChanged() = 0; protected: - ~QSensorChangesInterface() {} + virtual ~QSensorChangesInterface(); }; Q_DECLARE_INTERFACE(QSensorPluginInterface, "com.qt-project.Qt.QSensorPluginInterface/1.0") diff --git a/src/sensors/qtapsensor.cpp b/src/sensors/qtapsensor.cpp index 23ec492..626268d 100644 --- a/src/sensors/qtapsensor.cpp +++ b/src/sensors/qtapsensor.cpp @@ -189,6 +189,11 @@ void QTapReading::setDoubleTap(bool doubleTap) \sa QSensorFilter::filter() */ +bool QTapFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QTapReading*>(reading)); +} + char const * const QTapSensor::type("QTapSensor"); /*! @@ -230,6 +235,11 @@ QTapSensor::~QTapSensor() \sa QSensor::reading() */ +QTapReading *QTapSensor::reading() const +{ + return static_cast<QTapReading*>(QSensor::reading()); +} + /*! \property QTapSensor::returnDoubleTapEvents \brief a value indicating if double tap events should be reported. diff --git a/src/sensors/qtapsensor.h b/src/sensors/qtapsensor.h index b870411..688781e 100644 --- a/src/sensors/qtapsensor.h +++ b/src/sensors/qtapsensor.h @@ -84,7 +84,7 @@ class Q_SENSORS_EXPORT QTapFilter : public QSensorFilter public: virtual bool filter(QTapReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QTapReading*>(reading)); } + bool filter(QSensorReading *reading); }; class QTapSensorPrivate; @@ -97,7 +97,7 @@ class Q_SENSORS_EXPORT QTapSensor : public QSensor public: explicit QTapSensor(QObject *parent = 0); virtual ~QTapSensor(); - QTapReading *reading() const { return static_cast<QTapReading*>(QSensor::reading()); } + QTapReading *reading() const; static char const * const type; bool returnDoubleTapEvents() const; diff --git a/src/sensors/qtiltsensor.cpp b/src/sensors/qtiltsensor.cpp index b78746b..220b8f9 100644 --- a/src/sensors/qtiltsensor.cpp +++ b/src/sensors/qtiltsensor.cpp @@ -118,6 +118,11 @@ void QTiltReading::setXRotation(qreal x) \sa QSensorFilter::filter() */ +bool QTiltFilter::filter(QSensorReading *reading) +{ + return filter(static_cast<QTiltReading*>(reading)); +} + char const * const QTiltSensor::type("QTiltSensor"); /*! @@ -162,6 +167,10 @@ QTiltSensor::~QTiltSensor() \sa QSensor::reading() */ +QTiltReading *QTiltSensor::reading() const +{ + return static_cast<QTiltReading*>(QSensor::reading()); +} /*! Calibrates the tilt sensor. Uses the current tilt angles as 0. diff --git a/src/sensors/qtiltsensor.h b/src/sensors/qtiltsensor.h index 246a103..4d7e4c7 100644 --- a/src/sensors/qtiltsensor.h +++ b/src/sensors/qtiltsensor.h @@ -69,7 +69,7 @@ class Q_SENSORS_EXPORT QTiltFilter : public QSensorFilter public: virtual bool filter(QTiltReading *reading) = 0; private: - bool filter(QSensorReading *reading) { return filter(static_cast<QTiltReading*>(reading)); } + bool filter(QSensorReading *reading); }; class Q_SENSORS_EXPORT QTiltSensor : public QSensor @@ -78,7 +78,7 @@ class Q_SENSORS_EXPORT QTiltSensor : public QSensor public: explicit QTiltSensor(QObject *parent = 0); ~QTiltSensor(); - QTiltReading *reading() const { return static_cast<QTiltReading*>(QSensor::reading()); } + QTiltReading *reading() const; static char const * const type; Q_INVOKABLE void calibrate(); diff --git a/src/sensors/sensors.pro b/src/sensors/sensors.pro index fe10a5e..e7ad05f 100644 --- a/src/sensors/sensors.pro +++ b/src/sensors/sensors.pro @@ -12,10 +12,15 @@ simulator { QMAKE_DOCS = $$PWD/doc/qtsensors.qdocconf +ANDROID_BUNDLED_JAR_DEPENDENCIES = \ + jar/QtSensors-bundled.jar:org.qtproject.qt5.android.sensors.QtSensors ANDROID_JAR_DEPENDENCIES = \ jar/QtSensors.jar:org.qtproject.qt5.android.sensors.QtSensors ANDROID_LIB_DEPENDENCIES = \ plugins/sensors/libqtsensors_android.so +MODULE_PLUGIN_TYPES = \ + sensors \ + sensorgestures load(qt_module) |