diff options
author | Lincoln Ramsay <lincoln.ramsay@nokia.com> | 2011-08-29 11:16:11 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-29 03:18:37 +0200 |
commit | e243c4fa9fce1ebbe1d0e625b6e2d3a07fe6b071 (patch) | |
tree | 66f546ac97016d6e50027d503c83765e2a8dea9b | |
parent | 61dc260cc409ec5303dc09f5732baa7bb142226d (diff) |
Revert the QtmSensors library.
The QtSensors API changes have been de-scoped so this library is no longer
required.
Change-Id: Iee555b69fc3f774c48c5911eeabc09aba50c13fc
Reviewed-on: http://codereview.qt.nokia.com/3686
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com>
74 files changed, 28 insertions, 8779 deletions
diff --git a/examples/accel/accel.pro b/examples/accel/accel.pro index ba114663..86303eca 100644 --- a/examples/accel/accel.pro +++ b/examples/accel/accel.pro @@ -1,7 +1,7 @@ TEMPLATE=app TARGET=accel -QT=core qtmsensors +QT=core sensors SOURCES=main.cpp diff --git a/examples/accel/main.cpp b/examples/accel/main.cpp index 9b74cc89..1fed675d 100644 --- a/examples/accel/main.cpp +++ b/examples/accel/main.cpp @@ -41,8 +41,6 @@ #include <QtCore> #include <qaccelerometer.h> -QTM_USE_NAMESPACE - QAccelerometer *accelerometer; class AccelerometerFilter : public QAccelerometerFilter diff --git a/modules/qt_sensors.pri b/modules/qt_sensors.pri index a8503a8e..a67da06a 100644 --- a/modules/qt_sensors.pri +++ b/modules/qt_sensors.pri @@ -15,21 +15,3 @@ QT.sensors.depends = core QT.sensors.DEFINES = QT_SENSORS_LIB QT_CONFIG += sensors - -QT.qtmsensors.VERSION = 5.0.0 -QT.qtmsensors.MAJOR_VERSION = 5 -QT.qtmsensors.MINOR_VERSION = 0 -QT.qtmsensors.PATCH_VERSION = 0 - -QT.qtmsensors.name = QtmSensors -QT.qtmsensors.bins = $$QT_MODULE_BIN_BASE -QT.qtmsensors.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtmSensors -QT.qtmsensors.private_includes = $$QT_MODULE_INCLUDE_BASE/QtmSensors/$$QT.qtmsensors.VERSION -QT.qtmsensors.sources = $$QT_MODULE_BASE/src/qtmsensors -QT.qtmsensors.libs = $$QT_MODULE_LIB_BASE -QT.qtmsensors.plugins = $$QT_MODULE_PLUGIN_BASE -QT.qtmsensors.imports = $$QT_MODULE_IMPORT_BASE -QT.qtmsensors.depends = sensors -QT.qtmsensors.DEFINES = QTM_SENSORS_LIB - -QT_CONFIG += qtmsensors diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 0accf3de..a68f6a5e 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs SUBDIRS += sensors -SUBDIRS += qtmsensors + diff --git a/src/imports/qtmsensors/qmldir b/src/imports/qtmsensors/qmldir deleted file mode 100644 index 77bf7cdb..00000000 --- a/src/imports/qtmsensors/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin declarative_qtmsensors diff --git a/src/imports/qtmsensors/qsensorsimport.pri b/src/imports/qtmsensors/qsensorsimport.pri deleted file mode 100644 index d5cfeffc..00000000 --- a/src/imports/qtmsensors/qsensorsimport.pri +++ /dev/null @@ -1,38 +0,0 @@ -load(qt_module) - -symbian:load(qt_plugin) -TEMPLATE = lib -CONFIG += qt plugin - -win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release - -isEmpty(TARGETPATH) { - error("qimportbase.pri: You must provide a TARGETPATH!") -} -isEmpty(TARGET) { - error("qimportbase.pri: You must provide a TARGET!") -} - -QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir -copy2build.input = QMLDIRFILE -copy2build.output = $$QT.sensors.imports/$$TARGETPATH/qmldir -!contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS -copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} -copy2build.name = COPY ${QMAKE_FILE_IN} -copy2build.CONFIG += no_link -# `clean' should leave the build in a runnable state, which means it shouldn't delete qmldir -copy2build.CONFIG += no_clean -QMAKE_EXTRA_COMPILERS += copy2build - -TARGET = $$qtLibraryTarget($$TARGET) -contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols - -load(qt_targets) - -wince*:LIBS += $$QMAKE_LIBS_GUI - -symbian: { - TARGET.EPOCALLOWDLLDATA=1 - TARGET.CAPABILITY = All -Tcb - load(armcc_warnings) -} diff --git a/src/imports/qtmsensors/qtmsensors.pro b/src/imports/qtmsensors/qtmsensors.pro deleted file mode 100644 index d09204e8..00000000 --- a/src/imports/qtmsensors/qtmsensors.pro +++ /dev/null @@ -1,29 +0,0 @@ -TARGET = declarative_qtmsensors -TARGETPATH = QtMobility/sensors - -include(qsensorsimport.pri) - -QT = declarative qtmsensors - -SOURCES += sensors.cpp - -DESTDIR = $$QT.sensors.imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -INSTALLS += target qmldir - -symbian { - # In Symbian, a library should enjoy _largest_ possible capability set. - TARGET.CAPABILITY = ALL -TCB - # Allow writable DLL data - TARGET.EPOCALLOWDLLDATA = 1 - # Target UID, makes every Symbian app unique - TARGET.UID3 = 0x20021324 - # Specifies what files shall be deployed: the plugin itself and the qmldir file. - importFiles.sources = $$DESTDIR/declarative_sensors$${QT_LIBINFIX}.dll qmldir - importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH - DEPLOYMENT = importFiles - } diff --git a/src/imports/qtmsensors/sensors.cpp b/src/imports/qtmsensors/sensors.cpp deleted file mode 100644 index a1603e41..00000000 --- a/src/imports/qtmsensors/sensors.cpp +++ /dev/null @@ -1,726 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtDeclarative/qdeclarativeextensionplugin.h> -#include <QtDeclarative/qdeclarative.h> - -#include <qaccelerometer.h> -#include <qambientlightsensor.h> -#include <qcompass.h> -#include <qmagnetometer.h> -#include <qorientationsensor.h> -#include <qproximitysensor.h> -#include <qrotationsensor.h> -#include <qtapsensor.h> -#include <qlightsensor.h> -#include <qgyroscope.h> - -QTM_USE_NAMESPACE - -QT_BEGIN_NAMESPACE - -class QtmSensorsDeclarativeModule : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - char const * const package = "QtMobility.sensors"; - if (QLatin1String(uri) != QLatin1String(package)) return; - - // Register the 1.1 interfaces - int major = 1; - int minor = 1; - qmlRegisterUncreatableType<QSensorReading >(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading")); - qmlRegisterType <QAccelerometer >(package, major, minor, "Accelerometer"); - qmlRegisterUncreatableType<QAccelerometerReading>(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading")); - qmlRegisterType <QAmbientLightSensor >(package, major, minor, "AmbientLightSensor"); - qmlRegisterUncreatableType<QAmbientLightReading >(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading")); - qmlRegisterType <QCompass >(package, major, minor, "Compass"); - qmlRegisterUncreatableType<QCompassReading >(package, major, minor, "CompassReading", QLatin1String("Cannot create CompassReading")); - qmlRegisterType <QMagnetometer >(package, major, minor, "Magnetometer"); - qmlRegisterUncreatableType<QMagnetometerReading >(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading")); - qmlRegisterType <QOrientationSensor >(package, major, minor, "OrientationSensor"); - qmlRegisterUncreatableType<QOrientationReading >(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading")); - qmlRegisterType <QProximitySensor >(package, major, minor, "ProximitySensor"); - qmlRegisterUncreatableType<QProximityReading >(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading")); - qmlRegisterType <QRotationSensor >(package, major, minor, "RotationSensor"); - qmlRegisterUncreatableType<QRotationReading >(package, major, minor, "RotationReading", QLatin1String("Cannot create RotationReading")); - qmlRegisterType <QTapSensor >(package, major, minor, "TapSensor"); - qmlRegisterUncreatableType<QTapReading >(package, major, minor, "TapReading", QLatin1String("Cannot create TapReading")); - - // Register the 1.2 interfaces - major = 1; - minor = 2; - qmlRegisterUncreatableType<QSensor >(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor")); - qmlRegisterUncreatableType<QSensorReading >(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading")); - qmlRegisterType <QAccelerometer >(package, major, minor, "Accelerometer"); - qmlRegisterUncreatableType<QAccelerometerReading>(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading")); - qmlRegisterType <QAmbientLightSensor >(package, major, minor, "AmbientLightSensor"); - qmlRegisterUncreatableType<QAmbientLightReading >(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading")); - qmlRegisterType <QCompass >(package, major, minor, "Compass"); - qmlRegisterUncreatableType<QCompassReading >(package, major, minor, "CompassReading", QLatin1String("Cannot create CompassReading")); - qmlRegisterType <QMagnetometer >(package, major, minor, "Magnetometer"); - qmlRegisterUncreatableType<QMagnetometerReading >(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading")); - qmlRegisterType <QOrientationSensor >(package, major, minor, "OrientationSensor"); - qmlRegisterUncreatableType<QOrientationReading >(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading")); - qmlRegisterType <QProximitySensor >(package, major, minor, "ProximitySensor"); - qmlRegisterUncreatableType<QProximityReading >(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading")); - qmlRegisterType <QRotationSensor >(package, major, minor, "RotationSensor"); - qmlRegisterUncreatableType<QRotationReading >(package, major, minor, "RotationReading", QLatin1String("Cannot create RotationReading")); - qmlRegisterType <QTapSensor >(package, major, minor, "TapSensor"); - qmlRegisterUncreatableType<QTapReading >(package, major, minor, "TapReading", QLatin1String("Cannot create TapReading")); - qmlRegisterType <QLightSensor >(package, major, minor, "LightSensor"); - qmlRegisterUncreatableType<QLightReading >(package, major, minor, "LightReading", QLatin1String("Cannot create LightReading")); - qmlRegisterType <QGyroscope >(package, major, minor, "Gyroscope"); - qmlRegisterUncreatableType<QGyroscopeReading >(package, major, minor, "GyroscopeReading", QLatin1String("Cannot create GyroscopeReading")); - } -}; - -QT_END_NAMESPACE - -#include "sensors.moc" - -Q_EXPORT_PLUGIN2(qtmsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QtmSensorsDeclarativeModule)); - -// ===================================================================== - -/*! - \qmlclass Sensor QSensor - \ingroup qml-sensors_type - \brief The Sensor element serves as a base type for sensors. - - The Sensor element serves as a base type for sensors. - - This element wraps the QSensor class. Please see the documentation for - QSensor for details. - - This element cannot be directly created. Please use one of the sub-classes instead. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty int Sensor::dataRate - Sets the rate at which data is returned by the sensor. - Please see QSensor::dataRate for information about this property. -*/ - -/*! - \qmlproperty bool Sensor::active - Starts or stops the sensor. - Please see QSensor::active for information about this property. -*/ - -/*! - \qmlproperty SensorReading Sensor::reading - Holds the most recent sensor reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal Sensor::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass SensorReading QSensorReading - \ingroup qml-sensors_reading - \brief The SensorReading element serves as a base type for sensor readings. - - The SensorReading element serves as a base type for sensor readings. - - This element wraps the QSensorReading class. Please see the documentation for - QSensorReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty quint64 SensorReading::timestamp - A timestamp for the reading. - Please see QSensorReading::timestamp for information about this property. -*/ - -/*! - \qmlclass Accelerometer QAccelerometer - \ingroup qml-sensors_type - \inherits Sensor - \brief The Accelerometer element reports on linear acceleration - along the X, Y and Z axes. - - The Accelerometer element reports on linear acceleration - along the X, Y and Z axes. - - This element wraps the QAccelerometer class. Please see the documentation for - QAccelerometer for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty AccelerometerReading Accelerometer::reading - Holds the most recent accelerometer reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal Accelerometer::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass AccelerometerReading QAccelerometerReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The AccelerometerReading element holds the most recent Accelerometer reading. - - The AccelerometerReading element holds the most recent Accelerometer reading. - - This element wraps the QAccelerometerReading class. Please see the documentation for - QAccelerometerReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty qreal AccelerometerReading::x - Please see QAccelerometerReading::x for information about this property. -*/ - -/*! - \qmlproperty qreal AccelerometerReading::y - Please see QAccelerometerReading::y for information about this property. -*/ - -/*! - \qmlproperty qreal AccelerometerReading::z - Please see QAccelerometerReading::z for information about this property. -*/ - -/*! - \qmlclass AmbientLightSensor QAmbientLightSensor - \ingroup qml-sensors_type - \inherits Sensor - \brief The AmbientLightSensor element repors on ambient lighting conditions. - - The AmbientLightSensor element repors on ambient lighting conditions. - - This element wraps the QAmbientLightSensor class. Please see the documentation for - QAmbientLightSensor for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty AmbientLightReading AmbientLightSensor::reading - Holds the most recent ambient light reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal AmbientLightSensor::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass AmbientLightReading QAmbientLightReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The AmbientLightReading element holds the most AmbientLightSensor reading. - - The AmbientLightReading element holds the most AmbientLightSensor reading. - - This element wraps the QAmbientLightReading class. Please see the documentation for - QAmbientLightReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty QAmbientLightReading::LightLevel AmbientLightReading::lightLevel - Please see QAmbientLightReading::lightLevel for information about this property. - - LightLevel constants are exposed through the AmbientLightReading class. - \code - AmbientLightSensor { - onReadingChanged: { - if (reading.lightLevel == AmbientLightReading.Dark) - // do something - } - } - \endcode -*/ - -/*! - \qmlclass Compass QCompass - \ingroup qml-sensors_type - \inherits Sensor - \brief The Compass element reports on heading using magnetic north as a reference. - - The Compass element reports on heading using magnetic north as a reference. - - This element wraps the QCompass class. Please see the documentation for - QCompass for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty CompassReading Compass::reading - Holds the most recent compass reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal Compass::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass CompassReading QCompassReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The CompassReading element holds the most recent Compass reading. - - The CompassReading element holds the most recent Compass reading. - - This element wraps the QCompassReading class. Please see the documentation for - QCompassReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty qreal CompassReading::azimuth - Please see QCompassReading::azimuth for information about this property. -*/ - -/*! - \qmlproperty qreal CompassReading::calibrationLevel - Please see QCompassReading::calibrationLevel for information about this property. -*/ - -/*! - \qmlclass Magnetometer QMagnetometer - \ingroup qml-sensors_type - \inherits Sensor - \brief The Magnetometer element reports on magnetic field strength - along the Z, Y and Z axes. - - The Magnetometer element reports on magnetic field strength - along the Z, Y and Z axes. - - This element wraps the QMagnetometer class. Please see the documentation for - QMagnetometer for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty MagnetometerReading Magnetometer::reading - Holds the most recent magnetometer reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal Magnetometer::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass MagnetometerReading QMagnetometerReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The MagnetometerReading element holds the most recent Magnetometer reading. - - The MagnetometerReading element holds the most recent Magnetometer reading. - - This element wraps the QMagnetometerReading class. Please see the documentation for - QMagnetometerReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty qreal MagnetometerReading::x - Please see QMagnetometerReading::x for information about this property. -*/ - -/*! - \qmlproperty qreal MagnetometerReading::y - Please see QMagnetometerReading::y for information about this property. -*/ - -/*! - \qmlproperty qreal MagnetometerReading::z - Please see QMagnetometerReading::z for information about this property. -*/ - -/*! - \qmlproperty qreal MagnetometerReading::calibrationLevel - Please see QMagnetometerReading::calibrationLevel for information about this property. -*/ - -/*! - \qmlclass OrientationSensor QOrientationSensor - \ingroup qml-sensors_type - \inherits Sensor - \brief The OrientationSensor element reports device orientation. - - The OrientationSensor element reports device orientation. - - This element wraps the QOrientationSensor class. Please see the documentation for - QOrientationSensor for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty OrientationReading OrientationSensor::reading - Holds the most recent orientation reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal OrientationSensor::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass OrientationReading QOrientationReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The OrientationReading element holds the most recent OrientationSensor reading. - - The OrientationReading element holds the most recent OrientationSensor reading. - - This element wraps the QOrientationReading class. Please see the documentation for - QOrientationReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty QOrientationReading::Orientation OrientationReading::orientation - Please see QOrientationReading::orientation for information about this property. - - Orientation constants are exposed through the OrientationReading class. - \code - OrientationSensor { - onReadingChanged: { - if (reading.orientation == OrientationReading.TopUp) - // do something - } - } - \endcode -*/ - -/*! - \qmlclass ProximitySensor QProximitySensor - \ingroup qml-sensors_type - \inherits Sensor - \brief The ProximitySensor element reports on object proximity. - - The ProximitySensor element reports on object proximity. - - This element wraps the QProximitySensor class. Please see the documentation for - QProximitySensor for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty ProximityReading ProximitySensor::reading - Holds the most recent proximity reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal ProximitySensor::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass ProximityReading QProximityReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The ProximityReading element holds the most recent ProximitySensor reading. - - The ProximityReading element holds the most recent ProximitySensor reading. - - This element wraps the QProximityReading class. Please see the documentation for - QProximityReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty bool ProximityReading::close - Please see QProximityReading::close for information about this property. -*/ - -/*! - \qmlclass RotationSensor QRotationSensor - \ingroup qml-sensors_type - \inherits Sensor - \brief The RotationSensor element reports on device rotation - around the X, Y and Z axes. - - The RotationSensor element reports on device rotation - around the X, Y and Z axes. - - This element wraps the QRotationSensor class. Please see the documentation for - QRotationSensor for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty RotationReading RotationSensor::reading - Holds the most recent rotation reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal RotationSensor::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass RotationReading QRotationReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The RotationReading element holds the most recent RotationSensor reading. - - The RotationReading element holds the most recent RotationSensor reading. - - This element wraps the QRotationReading class. Please see the documentation for - QRotationReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty qreal RotationReading::x - Please see QRotationReading::x for information about this property. -*/ - -/*! - \qmlproperty qreal RotationReading::y - Please see QRotationReading::y for information about this property. -*/ - -/*! - \qmlproperty qreal RotationReading::z - Please see QRotationReading::z for information about this property. -*/ - -/*! - \qmlclass TapSensor QTapSensor - \ingroup qml-sensors_type - \inherits Sensor - \brief The TapSensor element reports tap and double tap events - along the X, Y and Z axes. - - The TapSensor element reports tap and double tap events - along the X, Y and Z axes. - - This element wraps the QTapSensor class. Please see the documentation for - QTapSensor for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty TapReading TapSensor::reading - Holds the most recent tap sensor reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal TapSensor::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass TapReading QTapReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The TapReading element holds the most recent TapSensor reading. - - The TapReading element holds the most recent TapSensor reading. - - This element wraps the QTapReading class. Please see the documentation for - QTapReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty bool TapReading::doubleTap - Please see QTapReading::doubleTap for information about this property. -*/ - -/*! - \qmlproperty QTapReading::TapDirection TapReading::tapDirection - Please see QTapReading::tapDirection for information about this property. - - TapDirection constants are exposed through the TapReading class. - \code - TapSensor { - onReadingChanged: { - if ((reading.tapDirection & TapReading.X_Both)) - // do something - } - } - \endcode -*/ - -/*! - \qmlclass LightSensor QLightSensor - \ingroup qml-sensors_type - \inherits Sensor - \brief The LightSensor element reports on light levels using LUX. - - The LightSensor element reports on light levels using LUX. - - This element wraps the QLightSensor class. Please see the documentation for - QLightSensor for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty LightReading LightSensor::reading - Holds the most recent light sensor reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal LightSensor::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass LightReading QLightReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The LightReading element holds the most recent LightSensor reading. - - The LightReading element holds the most recent LightSensor reading. - - This element wraps the QLightReading class. Please see the documentation for - QLightReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty qreal LightReading::lux - Please see QLightReading::lux for information about this property. -*/ - -/*! - \qmlclass Gyroscope QGyroscope - \ingroup qml-sensors_type - \inherits Sensor - \brief The Gyroscope element reports on rotational acceleration - around the X, Y and Z axes. - - This element wraps the QGyroscope class. Please see the documentation for - QGyroscope for details. - - \sa {Sensors QML Limitations} -*/ - -/*! - \qmlproperty GyroscopeReading Gyroscope::reading - Holds the most recent gyroscope reading. - Please see QSensor::reading for information about this property. -*/ - -/*! - \qmlsignal Gyroscope::onReadingChanged() - Called when the reading object changes. - Please see QSensor::readingChanged() for information about this signal. -*/ - -/*! - \qmlclass GyroscopeReading QGyroscopeReading - \ingroup qml-sensors_reading - \inherits SensorReading - \brief The GyroscopeReading element holds the most recent Gyroscope reading. - - The GyroscopeReading element holds the most recent Gyroscope reading. - - This element wraps the QGyroscopeReading class. Please see the documentation for - QGyroscopeReading for details. - - This element cannot be directly created. -*/ - -/*! - \qmlproperty qreal GyroscopeReading::x - Please see QGyroscopeReading::x for information about this property. -*/ - -/*! - \qmlproperty qreal GyroscopeReading::y - Please see QGyroscopeReading::y for information about this property. -*/ - -/*! - \qmlproperty qreal GyroscopeReading::z - Please see QGyroscopeReading::z for information about this property. -*/ - - diff --git a/src/qtmsensors/backendwrapper.cpp b/src/qtmsensors/backendwrapper.cpp deleted file mode 100644 index 5bba7c4c..00000000 --- a/src/qtmsensors/backendwrapper.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#include "backendwrapper_p.h" -#include "qsensormanager_p.h" -#include <QDebug> - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class WrapperFactory : public QSensorPluginInterface, - public QSensorBackendFactory -{ -public: - void registerSensors() - { - QList<QByteArray> types; - types << QAccelerometer::type; - types << QAmbientLightSensor::type; - types << QCompass::type; - types << QGyroscope::type; - types << QLightSensor::type; - types << QMagnetometer::type; - types << QOrientationSensor::type; - types << QProximitySensor::type; - types << QRotationSensor::type; - types << QTapSensor::type; - foreach (const QByteArray &type, types) { - foreach (const QByteArray &identifier, NEW_NAMESPACE(QSensor)::sensorsForType(type)) { - QSensorManager::registerBackend(type, identifier, this); - } - } - } - - QSensorBackend *createBackend(QSensor *sensor) - { - if (sensor->type() == QAccelerometer::type) { - return new QAccelerometerWrapper(sensor); - } - if (sensor->type() == QAmbientLightSensor::type) { - return new QAmbientLightSensorWrapper(sensor); - } - if (sensor->type() == QCompass::type) { - return new QCompassWrapper(sensor); - } - if (sensor->type() == QGyroscope::type) { - return new QGyroscopeWrapper(sensor); - } - if (sensor->type() == QLightSensor::type) { - return new QLightSensorWrapper(sensor); - } - if (sensor->type() == QMagnetometer::type) { - return new QMagnetometerWrapper(sensor); - } - if (sensor->type() == QOrientationSensor::type) { - return new QOrientationSensorWrapper(sensor); - } - if (sensor->type() == QProximitySensor::type) { - return new QProximitySensorWrapper(sensor); - } - if (sensor->type() == QRotationSensor::type) { - return new QRotationSensorWrapper(sensor); - } - if (sensor->type() == QTapSensor::type) { - return new QTapSensorWrapper(sensor); - } - return 0; - } -}; - -REGISTER_STATIC_PLUGIN_V1(WrapperFactory) - -QSensorWrapper::QSensorWrapper(QSensor *sensor) - : QSensorBackend(sensor) -{ -} - -void QSensorWrapper::init(QObject *wsensor) -{ - connect(wsensor, SIGNAL(readingChanged()), this, SLOT(fetchData())); - connect(wsensor, SIGNAL(sensorError(int)), this, SLOT(reportSensorError(int))); - connect(wsensor, SIGNAL(busyChanged()), sensor(), SIGNAL(busyChanged())); - m_wsensor = wsensor; -} - -void QSensorWrapper::start() -{ - _start(); -} - -void QSensorWrapper::stop() -{ - _stop(); -} - -void QSensorWrapper::fetchData() -{ - _fetchData(); -} - -void QSensorWrapper::setProperty(const char *name, const QVariant &value) -{ - //qDebug() << "QSensorWrapper::setProperty" << name << value; - QObject::setProperty(name, value); - m_wsensor->setProperty(name, value); -} - -QVariant QSensorWrapper::property(const char *name) const -{ - //qDebug() << "QSensorWrapper::property"; - return m_wsensor->property(name); -} - -void QSensorWrapper::reportSensorError(int error) -{ - sensorError(error); -} - -IMPLEMENT_WRAPPER(QAccelerometer, QAccelerometerReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setX(sensor->reading()->x()); - m_reading.setY(sensor->reading()->y()); - m_reading.setZ(sensor->reading()->z()); - newReadingAvailable(); - }) - -IMPLEMENT_WRAPPER(QAmbientLightSensor, QAmbientLightReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setLightLevel(static_cast<QAmbientLightReading::LightLevel>(sensor->reading()->lightLevel())); - newReadingAvailable(); - }) - -IMPLEMENT_WRAPPER(QCompass, QCompassReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setAzimuth(sensor->reading()->azimuth()); - //m_reading.setCalibrationLevel(sensor->calibrationLevel()); - m_reading.setCalibrationLevel(sensor->reading()->calibrationLevel()); - newReadingAvailable(); - }) - -IMPLEMENT_WRAPPER(QGyroscope, QGyroscopeReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setX(sensor->reading()->x()); - m_reading.setY(sensor->reading()->y()); - m_reading.setZ(sensor->reading()->z()); - newReadingAvailable(); - }) - -IMPLEMENT_WRAPPER(QLightSensor, QLightReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setLux(sensor->reading()->lux()); - newReadingAvailable(); - }) - -IMPLEMENT_WRAPPER(QMagnetometer, QMagnetometerReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setX(sensor->reading()->x()); - m_reading.setY(sensor->reading()->y()); - m_reading.setZ(sensor->reading()->z()); - //m_reading.setCalibrationLevel(sensor->calibrationLevel()); - m_reading.setCalibrationLevel(sensor->reading()->calibrationLevel()); - newReadingAvailable(); - }) - -IMPLEMENT_WRAPPER(QOrientationSensor, QOrientationReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setOrientation(static_cast<QOrientationReading::Orientation>(sensor->reading()->orientation())); - newReadingAvailable(); - }) - -IMPLEMENT_WRAPPER(QProximitySensor, QProximityReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setClose(sensor->reading()->close()); - newReadingAvailable(); - }) - -IMPLEMENT_WRAPPER(QRotationSensor, QRotationReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setX(sensor->reading()->x()); - m_reading.setY(sensor->reading()->y()); - m_reading.setZ(sensor->reading()->z()); - newReadingAvailable(); - }) - -IMPLEMENT_WRAPPER(QTapSensor, QTapReading, { - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setTapDirection(static_cast<QTapReading::TapDirection>(sensor->reading()->tapDirection())); - m_reading.setDoubleTap(sensor->reading()->isDoubleTap()); - newReadingAvailable(); - }) - -#include "moc_backendwrapper_p.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE diff --git a/src/qtmsensors/backendwrapper_p.h b/src/qtmsensors/backendwrapper_p.h deleted file mode 100644 index 164cfce3..00000000 --- a/src/qtmsensors/backendwrapper_p.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef BACKENDWRAPPER_P_H -#define BACKENDWRAPPER_P_H - -#include "qsensorbackend_p.h" -#include "qaccelerometer.h" -#include <QtSensors/qaccelerometer.h> -#include "qambientlightsensor.h" -#include <QtSensors/qambientlightsensor.h> -#include "qcompass.h" -#include <QtSensors/qcompass.h> -#include "qgyroscope.h" -#include <QtSensors/qgyroscope.h> -#include "qlightsensor.h" -#include <QtSensors/qlightsensor.h> -#include "qmagnetometer.h" -#include <QtSensors/qmagnetometer.h> -#include "qorientationsensor.h" -#include <QtSensors/qorientationsensor.h> -#include "qproximitysensor.h" -#include <QtSensors/qproximitysensor.h> -#include "qrotationsensor.h" -#include <QtSensors/qrotationsensor.h> -#include "qtapsensor.h" -#include <QtSensors/qtapsensor.h> - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QTM_SENSORS_EXPORT QSensorWrapper : public QSensorBackend -{ - Q_OBJECT -public: - explicit QSensorWrapper(QSensor *sensor); - - void start(); - void stop(); - - void setProperty(const char *name, const QVariant &value); - QVariant property(const char *name) const; - - virtual bool _connect() = 0; - -public slots: - void fetchData(); - void reportSensorError(int); - -protected: - void init(QObject *wsensor); - -private: - virtual void _start() = 0; - virtual void _stop() = 0; - virtual void _fetchData() = 0; -protected: - QObject *m_wsensor; -}; - -#define DECLARE_WRAPPER(sensorclass, readingclass)\ - class sensorclass ## Wrapper : public QSensorWrapper {\ - public:\ - explicit sensorclass ## Wrapper(QSensor *sensor);\ - void _start();\ - void _stop();\ - void _fetchData();\ - bool _connect();\ - readingclass m_reading;\ - }; - -#define IMPLEMENT_WRAPPER(sensorclass, readingclass, fetchfunc)\ - sensorclass ## Wrapper::sensorclass ## Wrapper(QSensor *wsensor) : QSensorWrapper(wsensor) {\ - setReading(&m_reading);\ - NEW_NAMESPACE(sensorclass) *sensor = new NEW_NAMESPACE(sensorclass)(this);\ - init(sensor);\ - }\ - bool sensorclass ## Wrapper::_connect() {\ - QSensor *wsensor = this->sensor();\ - NEW_NAMESPACE(sensorclass) *sensor = static_cast<NEW_NAMESPACE(sensorclass)*>(m_wsensor);\ - sensor->setIdentifier(wsensor->identifier());\ - sensor->connectToBackend();\ - setDescription(sensor->description());\ - foreach (const NEW_NAMESPACE(qoutputrange) &range, sensor->outputRanges()) {\ - addOutputRange(range.minimum, range.maximum, range.accuracy);\ - }\ - foreach (const NEW_NAMESPACE(qrange) &range, sensor->availableDataRates()) {\ - addDataRate(range.first, range.second);\ - }\ - return sensor->isConnectedToBackend();\ - }\ - void sensorclass ## Wrapper::_start() {\ - NEW_NAMESPACE(sensorclass) *sensor = static_cast<NEW_NAMESPACE(sensorclass)*>(m_wsensor);\ - if (!sensor->start()) {\ - if (sensor->isBusy()) sensorBusy();\ - sensorStopped();\ - }\ - }\ - void sensorclass ## Wrapper::_stop() { NEW_NAMESPACE(sensorclass) *sensor = static_cast<NEW_NAMESPACE(sensorclass)*>(m_wsensor); sensor->stop(); }\ - void sensorclass ## Wrapper::_fetchData() { NEW_NAMESPACE(sensorclass) *sensor = static_cast<NEW_NAMESPACE(sensorclass)*>(m_wsensor); fetchfunc } - -DECLARE_WRAPPER(QAccelerometer, QAccelerometerReading) -DECLARE_WRAPPER(QAmbientLightSensor, QAmbientLightReading) -DECLARE_WRAPPER(QCompass, QCompassReading) -DECLARE_WRAPPER(QGyroscope, QGyroscopeReading) -DECLARE_WRAPPER(QLightSensor, QLightReading) -DECLARE_WRAPPER(QMagnetometer, QMagnetometerReading) -DECLARE_WRAPPER(QOrientationSensor, QOrientationReading) -DECLARE_WRAPPER(QProximitySensor, QProximityReading) -DECLARE_WRAPPER(QRotationSensor, QRotationReading) -DECLARE_WRAPPER(QTapSensor, QTapReading) - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif diff --git a/src/qtmsensors/qaccelerometer.cpp b/src/qtmsensors/qaccelerometer.cpp deleted file mode 100644 index 0f0765ec..00000000 --- a/src/qtmsensors/qaccelerometer.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccelerometer.h" -#include "qaccelerometer_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QAccelerometerReading) - -/*! - \class QAccelerometerReading - \ingroup sensors_reading - \inmodule QtSensors - \since 1.0 - - \brief The QAccelerometerReading class reports on linear acceleration - along the X, Y and Z axes. - - \section2 QAccelerometerReading Units - The scale of the values is meters per second squared. - The axes are arranged as follows. - - \image sensors-coordinates2.jpg - - A monoblock device sitting at rest, face up on a desk will experience - a force of approximately 9.8 on the Z axis (ie. towards the roof). - This is the proper acceleration the device experiences relative to - freefall. -*/ - -/*! - \property QAccelerometerReading::x - \brief the acceleration on the X axis. - - The scale of the values is meters per second squared. - \sa {QAccelerometerReading Units} -*/ - -qreal QAccelerometerReading::x() const -{ - return d->x; -} - -/*! - Sets the acceleration on the X axis to \a x. -*/ -void QAccelerometerReading::setX(qreal x) -{ - d->x = x; -} - -/*! - \property QAccelerometerReading::y - \brief the acceleration on the Y axis. - - The scale of the values is meters per second squared. - \sa {QAccelerometerReading Units} -*/ - -qreal QAccelerometerReading::y() const -{ - return d->y; -} - -/*! - Sets the acceleration on the Y axis to \a y. -*/ -void QAccelerometerReading::setY(qreal y) -{ - d->y = y; -} - -/*! - \property QAccelerometerReading::z - \brief the acceleration on the Z axis. - - The scale of the values is meters per second squared. - \sa {QAccelerometerReading Units} -*/ - -qreal QAccelerometerReading::z() const -{ - return d->z; -} - -/*! - Sets the acceleration on the Z axis to \a z. -*/ -void QAccelerometerReading::setZ(qreal z) -{ - d->z = z; -} - -// ===================================================================== - -/*! - \class QAccelerometerFilter - \ingroup sensors_filter - \inmodule QtSensors - - \brief The QAccelerometerFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QAccelerometerReading - instead of QSensorReading. -*/ - -/*! - \fn QAccelerometerFilter::filter(QAccelerometerReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QAccelerometer::type("QAccelerometer"); - -/*! - \class QAccelerometer - \ingroup sensors_type - \inmodule QtSensors - - \brief The QAccelerometer 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 QAccelerometerReading instead of a QSensorReading. - - For details about how the sensor works, see \l QAccelerometerReading. - - \sa QAccelerometerReading -*/ - -/*! - \fn QAccelerometer::QAccelerometer(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QAccelerometer::~QAccelerometer() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QAccelerometer::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -#include "moc_qaccelerometer.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qaccelerometer.h b/src/qtmsensors/qaccelerometer.h deleted file mode 100644 index 7c1c55a2..00000000 --- a/src/qtmsensors/qaccelerometer.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QACCELEROMETER_H -#define QTM_QACCELEROMETER_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QAccelerometerReadingPrivate; - -class QTM_SENSORS_EXPORT QAccelerometerReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal x READ x) - Q_PROPERTY(qreal y READ y) - Q_PROPERTY(qreal z READ z) - DECLARE_READING(QAccelerometerReading) -public: - qreal x() const; - void setX(qreal x); - - qreal y() const; - void setY(qreal y); - - qreal z() const; - void setZ(qreal z); -}; - -class QTM_SENSORS_EXPORT QAccelerometerFilter : public QSensorFilter -{ -public: - virtual bool filter(QAccelerometerReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QAccelerometerReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QAccelerometer : public QSensor -{ - Q_OBJECT -public: - explicit QAccelerometer(QObject *parent = 0) : QSensor(QAccelerometer::type, parent) {} - virtual ~QAccelerometer() {} - QAccelerometerReading *reading() const { return static_cast<QAccelerometerReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qaccelerometer_p.h b/src/qtmsensors/qaccelerometer_p.h deleted file mode 100644 index eef64396..00000000 --- a/src/qtmsensors/qaccelerometer_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QACCELEROMETER_P_H -#define QTM_QACCELEROMETER_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_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QAccelerometerReadingPrivate -{ -public: - QAccelerometerReadingPrivate() - : x(0) - , y(0) - , z(0) - { - } - - qreal x; - qreal y; - qreal z; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qambientlightsensor.cpp b/src/qtmsensors/qambientlightsensor.cpp deleted file mode 100644 index dbddc018..00000000 --- a/src/qtmsensors/qambientlightsensor.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qambientlightsensor.h" -#include "qambientlightsensor_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QAmbientLightReading) - -/*! - \class QAmbientLightReading - \ingroup sensors_reading - \inmodule QtSensors - \since 1.0 - - \brief The QAmbientLightReading class represents one reading from the - ambient light sensor. - - \section2 QAmbientLightReading Units - The ambient light sensor returns the intensity of the ambient light - using the pre-defined values found in the QAmbientLightReading::LightLevel - enum. -*/ - -/*! - \enum QAmbientLightReading::LightLevel - - This enum represents the ambient light level. - - \value Undefined The light level is unknown. - \value Dark It is dark. - \value Twilight It is moderately dark. - \value Light It is light (eg. internal lights). - \value Bright It is bright (eg. shade). - \value Sunny It is very bright (eg. direct sunlight). -*/ - -/*! - \property QAmbientLightReading::lightLevel - \brief the ambient light level. - - The value represents the ambient light and comes from QAmbientLightReading::LightLevel. - \sa {QAmbientLightReading Units} -*/ - -QAmbientLightReading::LightLevel QAmbientLightReading::lightLevel() const -{ - return static_cast<LightLevel>(d->lightLevel); -} - -/*! - Sets the ambient light level to \a lightLevel. -*/ -void QAmbientLightReading::setLightLevel(QAmbientLightReading::LightLevel lightLevel) -{ - switch (lightLevel) { - case Dark: - case Twilight: - case Light: - case Bright: - case Sunny: - d->lightLevel = lightLevel; - break; - default: - d->lightLevel = Undefined; - break; - } -} - -// ===================================================================== - -/*! - \class QAmbientLightFilter - \ingroup sensors_filter - \inmodule QtSensors - - \brief The QAmbientLightFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QAmbientLightReading - instead of QSensorReading. -*/ - -/*! - \fn QAmbientLightFilter::filter(QAmbientLightReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QAmbientLightSensor::type("QAmbientLightSensor"); - -/*! - \class QAmbientLightSensor - \ingroup sensors_type - \inmodule QtSensors - - \brief The QAmbientLightSensor 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 QAmbientLightReading instead of a QSensorReading. - - For details about how the sensor works, see \l QAmbientLightReading. - - \sa QAmbientLightReading -*/ - -/*! - \fn QAmbientLightSensor::QAmbientLightSensor(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QAmbientLightSensor::~QAmbientLightSensor() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QAmbientLightSensor::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -#include "moc_qambientlightsensor.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qambientlightsensor.h b/src/qtmsensors/qambientlightsensor.h deleted file mode 100644 index 05381bef..00000000 --- a/src/qtmsensors/qambientlightsensor.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QAMBIENTLIGHTSENSOR_H -#define QTM_QAMBIENTLIGHTSENSOR_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QAmbientLightReadingPrivate; - -class QTM_SENSORS_EXPORT QAmbientLightReading : public QSensorReading -{ - Q_OBJECT - Q_ENUMS(LightLevel) - Q_PROPERTY(LightLevel lightLevel READ lightLevel) - DECLARE_READING(QAmbientLightReading) -public: - enum LightLevel { - Undefined = 0, - Dark, - Twilight, - Light, - Bright, - Sunny - }; - - LightLevel lightLevel() const; - void setLightLevel(LightLevel lightLevel); -}; - -class QTM_SENSORS_EXPORT QAmbientLightFilter : public QSensorFilter -{ -public: - virtual bool filter(QAmbientLightReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QAmbientLightReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QAmbientLightSensor : public QSensor -{ - Q_OBJECT -public: - explicit QAmbientLightSensor(QObject *parent = 0) : QSensor(QAmbientLightSensor::type, parent) {} - virtual ~QAmbientLightSensor() {} - QAmbientLightReading *reading() const { return static_cast<QAmbientLightReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qambientlightsensor_p.h b/src/qtmsensors/qambientlightsensor_p.h deleted file mode 100644 index 85b6272e..00000000 --- a/src/qtmsensors/qambientlightsensor_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QAMBIENTLIGHTSENSOR_P_H -#define QTM_QAMBIENTLIGHTSENSOR_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_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QAmbientLightReadingPrivate -{ -public: - QAmbientLightReadingPrivate() - : lightLevel(0) - { - } - - int lightLevel; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qcompass.cpp b/src/qtmsensors/qcompass.cpp deleted file mode 100644 index 711d8238..00000000 --- a/src/qtmsensors/qcompass.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qcompass.h" -#include "qcompass_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QCompassReading) - -/*! - \class QCompassReading - \ingroup sensors_reading - \inmodule QtSensors - \since 1.0 - - \brief The QCompassReading class represents one reading from a - compass. - - \section2 QCompassReading Units - The compass returns the azimuth of the device as degrees from - magnetic north in a clockwise direction based on the top of the UI. - There is also a value to indicate the calibration status of the device. - If the device is not calibrated the azimuth may not be accurate. - - Digital compasses are susceptible to magnetic interference and may need - calibration after being placed near anything that emits a magnetic force. - Accuracy of the compass can be affected by any ferrous materials that are nearby. - - The calibration status of the device is measured as a number from 0 to 1. - A value of 1 is the highest level that the device can support and 0 is - the worst. - \sa {http://wiki.forum.nokia.com/index.php/CS001671_-_Calibrating_the_magnetometer_sensor}{CS001671 - Calibrating the magnetometer sensor} -*/ - -/*! - \property QCompassReading::azimuth - \brief the azimuth of the device. - - Measured in degrees from magnetic north in a clockwise direction based - the top of the UI. - \sa {QCompassReading Units} -*/ - -qreal QCompassReading::azimuth() const -{ - return d->azimuth; -} - -/*! - Sets the \a azimuth of the device. - - \sa {QCompassReading Units} -*/ -void QCompassReading::setAzimuth(qreal azimuth) -{ - d->azimuth = azimuth; -} - -/*! - \property QCompassReading::calibrationLevel - \brief the calibration level of the reading. - - Measured as a value from 0 to 1 with higher values being better. - \sa {QCompassReading Units}, {http://wiki.forum.nokia.com/index.php/CS001671_-_Calibrating_the_magnetometer_sensor}{CS001671 - Calibrating the magnetometer sensor} -*/ - -qreal QCompassReading::calibrationLevel() const -{ - return d->calibrationLevel; -} - -/*! - Sets the calibration level of the reading to \a calibrationLevel. -*/ -void QCompassReading::setCalibrationLevel(qreal calibrationLevel) -{ - d->calibrationLevel = calibrationLevel; -} - -// ===================================================================== - -/*! - \class QCompassFilter - \ingroup sensors_filter - \inmodule QtSensors - - \brief The QCompassFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QCompassReading - instead of QSensorReading. -*/ - -/*! - \fn QCompassFilter::filter(QCompassReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QCompass::type("QCompass"); - -/*! - \class QCompass - \ingroup sensors_type - \inmodule QtSensors - - \brief The QCompass 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 QCompassReading instead of a QSensorReading. - - For details about how the sensor works, see \l QCompassReading. - - \sa QCompassReading -*/ - -/*! - \fn QCompass::QCompass(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QCompass::~QCompass() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QCompass::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -#include "moc_qcompass.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qcompass.h b/src/qtmsensors/qcompass.h deleted file mode 100644 index 212a8b6d..00000000 --- a/src/qtmsensors/qcompass.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QCOMPASS_H -#define QTM_QCOMPASS_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QCompassReadingPrivate; - -class QTM_SENSORS_EXPORT QCompassReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal azimuth READ azimuth) - Q_PROPERTY(qreal calibrationLevel READ calibrationLevel) - DECLARE_READING(QCompassReading) -public: - qreal azimuth() const; - void setAzimuth(qreal azimuth); - - qreal calibrationLevel() const; - void setCalibrationLevel(qreal calibrationLevel); -}; - -class QTM_SENSORS_EXPORT QCompassFilter : public QSensorFilter -{ -public: - virtual bool filter(QCompassReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QCompassReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QCompass : public QSensor -{ - Q_OBJECT -public: - explicit QCompass(QObject *parent = 0) : QSensor(QCompass::type, parent) {} - virtual ~QCompass() {} - QCompassReading *reading() const { return static_cast<QCompassReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qcompass_p.h b/src/qtmsensors/qcompass_p.h deleted file mode 100644 index bf069176..00000000 --- a/src/qtmsensors/qcompass_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QCOMPASS_P_H -#define QTM_QCOMPASS_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_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QCompassReadingPrivate -{ -public: - QCompassReadingPrivate() - : azimuth(0) - , calibrationLevel(0) - { - } - - qreal azimuth; - qreal calibrationLevel; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qgyroscope.cpp b/src/qtmsensors/qgyroscope.cpp deleted file mode 100644 index c43eb4b0..00000000 --- a/src/qtmsensors/qgyroscope.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgyroscope.h" -#include "qgyroscope_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QGyroscopeReading) - -/*! - \class QGyroscopeReading - \ingroup sensors_reading - \inmodule QtSensors - \since 1.2 - - \brief The QGyroscopeReading class represents one reading from the - gyroscope sensor. - - \section2 QGyroscopeReading Units - - The reading contains 3 values, measured in degrees per second that define - the movement of the device around the x, y and z axes. Unlike QRotationReading, - the values represent the current angular velocity rather than a fixed rotation. - The measurements are in degrees per second. - - \image sensors-coordinates3.jpg -*/ - -/*! - \property QGyroscopeReading::x - \brief the angular velocity around the x axis. - - Measured as degrees per second. - \sa {QGyroscopeReading Units} -*/ - -qreal QGyroscopeReading::x() const -{ - return d->x; -} - -/*! - Sets the angular velocity around the x axis to \a x. -*/ -void QGyroscopeReading::setX(qreal x) -{ - d->x = x; -} - -/*! - \property QGyroscopeReading::y - \brief the angular velocity around the y axis. - - Measured as degrees per second. - \sa {QGyroscopeReading Units} -*/ - -qreal QGyroscopeReading::y() const -{ - return d->y; -} - -/*! - Sets the angular velocity around the y axis to \a y. -*/ -void QGyroscopeReading::setY(qreal y) -{ - d->y = y; -} - -/*! - \property QGyroscopeReading::z - \brief the angular velocity around the z axis. - - Measured as degrees per second. - \sa {QGyroscopeReading Units} -*/ - -qreal QGyroscopeReading::z() const -{ - return d->z; -} - -/*! - Sets the angular velocity around the z axis to \a z. -*/ -void QGyroscopeReading::setZ(qreal z) -{ - d->z = z; -} - -// ===================================================================== - -/*! - \class QGyroscopeFilter - \ingroup sensors_filter - \inmodule QtSensors - - \brief The QGyroscopeFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QGyroscopeReading - instead of QSensorReading. -*/ - -/*! - \fn QGyroscopeFilter::filter(QGyroscopeReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QGyroscope::type("QGyroscope"); - -/*! - \class QGyroscope - \ingroup sensors_type - \inmodule QtSensors - - \brief The QGyroscope 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 QGyroscopeReading instead of a QSensorReading. - - For details about how the sensor works, see \l QGyroscopeReading. - - \sa QGyroscopeReading -*/ - -/*! - \fn QGyroscope::QGyroscope(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QGyroscope::~QGyroscope() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QGyroscope::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -#include "moc_qgyroscope.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qgyroscope.h b/src/qtmsensors/qgyroscope.h deleted file mode 100644 index d0683dcd..00000000 --- a/src/qtmsensors/qgyroscope.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QGYROSCOPE_H -#define QTM_QGYROSCOPE_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QGyroscopeReadingPrivate; - -class QTM_SENSORS_EXPORT QGyroscopeReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal x READ x) - Q_PROPERTY(qreal y READ y) - Q_PROPERTY(qreal z READ z) - DECLARE_READING(QGyroscopeReading) -public: - qreal x() const; - void setX(qreal x); - - qreal y() const; - void setY(qreal y); - - qreal z() const; - void setZ(qreal z); -}; - -class QTM_SENSORS_EXPORT QGyroscopeFilter : public QSensorFilter -{ -public: - virtual bool filter(QGyroscopeReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QGyroscopeReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QGyroscope : public QSensor -{ - Q_OBJECT -public: - explicit QGyroscope(QObject *parent = 0) : QSensor(QGyroscope::type, parent) {} - virtual ~QGyroscope() {} - QGyroscopeReading *reading() const { return static_cast<QGyroscopeReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qgyroscope_p.h b/src/qtmsensors/qgyroscope_p.h deleted file mode 100644 index 560909f3..00000000 --- a/src/qtmsensors/qgyroscope_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QGYROSCOPE_P_H -#define QTM_QGYROSCOPE_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_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QGyroscopeReadingPrivate -{ -public: - QGyroscopeReadingPrivate() - : x(0) - , y(0) - , z(0) - { - } - - qreal x; - qreal y; - qreal z; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qlightsensor.cpp b/src/qtmsensors/qlightsensor.cpp deleted file mode 100644 index 355bbb7b..00000000 --- a/src/qtmsensors/qlightsensor.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qlightsensor.h" -#include "qlightsensor_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QLightReading) - -/*! - \class QLightReading - \ingroup sensors_reading - - \since 1.2 - - \preliminary - \brief The QLightReading class represents one reading from the - light sensor. - - \section2 QLightReading Units - The light sensor returns the intensity of the light in lux. -*/ - -/*! - \property QLightReading::lux - \brief the light level. - - Measured as lux. - \sa {QLightReading Units} -*/ - -qreal QLightReading::lux() const -{ - return d->lux; -} - -/*! - Sets the light level to \a lux. -*/ -void QLightReading::setLux(qreal lux) -{ - d->lux = lux; -} - -// ===================================================================== - -/*! - \class QLightFilter - \ingroup sensors_filter - - \preliminary - \brief The QLightFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QLightReading - instead of QSensorReading. -*/ - -/*! - \fn QLightFilter::filter(QLightReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QLightSensor::type("QLightSensor"); - -/*! - \class QLightSensor - \ingroup sensors_type - - \preliminary - \brief The QLightSensor 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 QLightReading instead of a QSensorReading. - - For details about how the sensor works, see \l QLightReading. - - \sa QLightReading -*/ - -/*! - \fn QLightSensor::QLightSensor(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QLightSensor::~QLightSensor() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QLightSensor::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -/*! - \property QLightSensor::fieldOfView - \brief a value indicating the field of view. - - This is an angle that represents the field of view of the sensor. -*/ - -#include "moc_qlightsensor.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qlightsensor.h b/src/qtmsensors/qlightsensor.h deleted file mode 100644 index 34c2e316..00000000 --- a/src/qtmsensors/qlightsensor.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QLIGHTSENSOR_H -#define QTM_QLIGHTSENSOR_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QLightReadingPrivate; - -class QTM_SENSORS_EXPORT QLightReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal lux READ lux) - DECLARE_READING(QLightReading) -public: - qreal lux() const; - void setLux(qreal lux); -}; - -class QTM_SENSORS_EXPORT QLightFilter : public QSensorFilter -{ -public: - virtual bool filter(QLightReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QLightReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QLightSensor : public QSensor -{ - Q_OBJECT -#ifdef Q_QDOC - Q_PROPERTY(qreal fieldOfView) -#endif -public: - explicit QLightSensor(QObject *parent = 0) : QSensor(QLightSensor::type, parent) {} - virtual ~QLightSensor() {} - QLightReading *reading() const { return static_cast<QLightReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qlightsensor_p.h b/src/qtmsensors/qlightsensor_p.h deleted file mode 100644 index 00e447da..00000000 --- a/src/qtmsensors/qlightsensor_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QLIGHTSENSOR_P_H -#define QTM_QLIGHTSENSOR_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 "qsensor_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QLightReadingPrivate : public QSensorReadingPrivate -{ -public: - QLightReadingPrivate() - : lux(0) - { - } - - qreal lux; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qmagnetometer.cpp b/src/qtmsensors/qmagnetometer.cpp deleted file mode 100644 index 9d18c8e6..00000000 --- a/src/qtmsensors/qmagnetometer.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmagnetometer.h" -#include "qmagnetometer_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QMagnetometerReading) - -/*! - \class QMagnetometerReading - \ingroup sensors_reading - \inmodule QtSensors - \since 1.0 - - \brief The QMagnetometerReading class represents one reading from the - magnetometer. - - \section2 QMagnetometerReading Units - The magnetometer returns magnetic flux density values along 3 axes. - The scale of the values is teslas. The axes are arranged as follows. - - \image sensors-coordinates2.jpg - - The magnetometer can report on either raw magnetic flux values or geomagnetic flux values. - By default it returns raw magnetic flux values. The QMagnetometer::returnGeoValues property - must be set to return geomagnetic flux values. - - The primary difference between raw and geomagnetic values is that extra processing - is done to eliminate local magnetic interference from the geomagnetic values so they - represent only the effect of the Earth's magnetic field. This process is not perfect - and the accuracy of each reading may change. - - The image below shows the difference between geomagnetic (on the left) and raw (on the right) - readings for a phone that is being subjected to magnetic interference. - - \image sensors-geo-vs-raw-magnetism.jpg - - The accuracy of each reading is measured as a number from 0 to 1. - A value of 1 is the highest level that the device can support and 0 is - the worst. - \sa {http://wiki.forum.nokia.com/index.php/CS001671_-_Calibrating_the_magnetometer_sensor}{CS001671 - Calibrating the magnetometer sensor} -*/ - -/*! - \property QMagnetometerReading::x - \brief the raw magnetic flux density on the X axis. - - Measured as telsas. - \sa {QMagnetometerReading Units} -*/ - -qreal QMagnetometerReading::x() const -{ - return d->x; -} - -/*! - Sets the raw magnetic flux density on the X axis to \a x. -*/ -void QMagnetometerReading::setX(qreal x) -{ - d->x = x; -} - -/*! - \property QMagnetometerReading::y - \brief the raw magnetic flux density on the Y axis. - - Measured as telsas. - \sa {QMagnetometerReading Units} -*/ - -qreal QMagnetometerReading::y() const -{ - return d->y; -} - -/*! - Sets the raw magnetic flux density on the Y axis to \a y. -*/ -void QMagnetometerReading::setY(qreal y) -{ - d->y = y; -} - -/*! - \property QMagnetometerReading::z - \brief the raw magnetic flux density on the Z axis. - - Measured as telsas. - \sa {QMagnetometerReading Units} -*/ - -qreal QMagnetometerReading::z() const -{ - return d->z; -} - -/*! - Sets the raw magnetic flux density on the Z axis to \a z. -*/ -void QMagnetometerReading::setZ(qreal z) -{ - d->z = z; -} - -/*! - \property QMagnetometerReading::calibrationLevel - \brief the accuracy of the reading. - - Measured as a value from 0 to 1 with higher values being better. - - Note that this only changes when measuring geomagnetic flux density. - Raw magnetic flux readings will always have a value of 1. - \sa {QMagnetometerReading Units}, {http://wiki.forum.nokia.com/index.php/CS001671_-_Calibrating_the_magnetometer_sensor}{CS001671 - Calibrating the magnetometer sensor} -*/ - -qreal QMagnetometerReading::calibrationLevel() const -{ - return d->calibrationLevel; -} - -/*! - Sets the accuracy of the reading to \a calibrationLevel. -*/ -void QMagnetometerReading::setCalibrationLevel(qreal calibrationLevel) -{ - d->calibrationLevel = calibrationLevel; -} - -// ===================================================================== - -/*! - \class QMagnetometerFilter - \ingroup sensors_filter - \inmodule QtSensors - - \brief The QMagnetometerFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QMagnetometerReading - instead of QSensorReading. -*/ - -/*! - \fn QMagnetometerFilter::filter(QMagnetometerReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QMagnetometer::type("QMagnetometer"); - -/*! - \class QMagnetometer - \ingroup sensors_type - \inmodule QtSensors - - \brief The QMagnetometer 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 QMagnetometerReading instead of a QSensorReading. - - For details about how the sensor works, see \l QMagnetometerReading. - - \sa QMagnetometerReading -*/ - -/*! - \fn QMagnetometer::QMagnetometer(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QMagnetometer::~QMagnetometer() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QMagnetometer::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -/*! - \property QMagnetometer::returnGeoValues - \brief a value indicating if geomagnetic values should be returned. - - Set to true to return geomagnetic flux density. - Set to false (the default) to return raw magnetic flux density. - - Note that you must access this property via QObject::property() and QObject::setProperty(). - The property must be set before calling start(). -*/ - -#include "moc_qmagnetometer.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qmagnetometer.h b/src/qtmsensors/qmagnetometer.h deleted file mode 100644 index 821da3c6..00000000 --- a/src/qtmsensors/qmagnetometer.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QMAGNETOMETER_H -#define QTM_QMAGNETOMETER_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QMagnetometerReadingPrivate; - -class QTM_SENSORS_EXPORT QMagnetometerReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal x READ x) - Q_PROPERTY(qreal y READ y) - Q_PROPERTY(qreal z READ z) - Q_PROPERTY(qreal calibrationLevel READ calibrationLevel) - DECLARE_READING(QMagnetometerReading) -public: - qreal x() const; - void setX(qreal x); - - qreal y() const; - void setY(qreal y); - - qreal z() const; - void setZ(qreal z); - - qreal calibrationLevel() const; - void setCalibrationLevel(qreal calibrationLevel); -}; - -class QTM_SENSORS_EXPORT QMagnetometerFilter : public QSensorFilter -{ -public: - virtual bool filter(QMagnetometerReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QMagnetometerReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QMagnetometer : public QSensor -{ - Q_OBJECT -#ifdef Q_QDOC - Q_PROPERTY(bool returnGeoValues) -#endif -public: - explicit QMagnetometer(QObject *parent = 0) : QSensor(QMagnetometer::type, parent) {} - virtual ~QMagnetometer() {} - QMagnetometerReading *reading() const { return static_cast<QMagnetometerReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qmagnetometer_p.h b/src/qtmsensors/qmagnetometer_p.h deleted file mode 100644 index 89938a19..00000000 --- a/src/qtmsensors/qmagnetometer_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QMAGNETOMETER_P_H -#define QTM_QMAGNETOMETER_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_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QMagnetometerReadingPrivate -{ -public: - QMagnetometerReadingPrivate() - : x(0) - , y(0) - , z(0) - , calibrationLevel(0) - { - } - - qreal x; - qreal y; - qreal z; - qreal calibrationLevel; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qorientationsensor.cpp b/src/qtmsensors/qorientationsensor.cpp deleted file mode 100644 index 6381b029..00000000 --- a/src/qtmsensors/qorientationsensor.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qorientationsensor.h" -#include "qorientationsensor_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QOrientationReading) - -/*! - \class QOrientationReading - \ingroup sensors_reading - \inmodule QtSensors - \since 1.0 - - \brief The QOrientationReading class represents one reading from the - orientation sensor. - - The orientation sensor reports the orientation of the device. As it operates below - the UI level it does not report on or even know how the UI is rotated. Most importantly - this means that this sensor cannot be used to detect if a device is in portrait or - landscape mode. - - This sensor is useful to detect that a particular side of the device is pointing up. - - \section2 QOrientationReading Units - The orientation sensor returns the orientation of the device using - the pre-defined values found in the QOrientationReading::Orientation - enum. -*/ - -/*! - \enum QOrientationReading::Orientation - - This enum represents the orientation of the device. - - To explain the meaning of each value it is helpful to refer to the following diagram. - - \image sensors-sides.jpg - - The orientations are shown here in order: TopUp, TopDown, LeftUp, RightUp, FaceUp, FaceDown. - - \image sensors-orientation.jpg - - \value Undefined The orientation is unknown. - \value TopUp The Top edge of the device is pointing up. - \value TopDown The Top edge of the device is pointing down. - \value LeftUp The Left edge of the device is pointing up. - \value RightUp The Right edge of the device is pointing up. - \value FaceUp The Face of the device is pointing up. - \value FaceDown The Face of the device is pointing down. - - It should be noted that the orientation sensor reports the orientation of the device - and not the UI. The orientation of the device will not change just because the UI is - rotated. This means this sensor cannot be used to detect if a device is in portrait - or landscape mode. -*/ - -/*! - \property QOrientationReading::orientation - \brief the orientation of the device. - - The unit is an enumeration describing the orientation of the device. - - \sa {QOrientationReading Units} -*/ - -QOrientationReading::Orientation QOrientationReading::orientation() const -{ - return static_cast<QOrientationReading::Orientation>(d->orientation); -} - -/*! - Sets the \a orientation for the reading. -*/ -void QOrientationReading::setOrientation(QOrientationReading::Orientation orientation) -{ - switch (orientation) { - case TopUp: - case TopDown: - case LeftUp: - case RightUp: - case FaceUp: - case FaceDown: - d->orientation = orientation; - break; - default: - d->orientation = Undefined; - break; - } -} - -// ===================================================================== - -/*! - \class QOrientationFilter - \ingroup sensors_filter - \inmodule QtSensors - - \brief The QOrientationFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QOrientationReading - instead of QSensorReading. -*/ - -/*! - \fn QOrientationFilter::filter(QOrientationReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QOrientationSensor::type("QOrientationSensor"); - -/*! - \class QOrientationSensor - \ingroup sensors_type - \inmodule QtSensors - - \brief The QOrientationSensor 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 QOrientationReading instead of a QSensorReading. - - For details about how the sensor works, see \l QOrientationReading. - - \sa QOrientationReading -*/ - -/*! - \fn QOrientationSensor::QOrientationSensor(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QOrientationSensor::~QOrientationSensor() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QOrientationSensor::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -#include "moc_qorientationsensor.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qorientationsensor.h b/src/qtmsensors/qorientationsensor.h deleted file mode 100644 index c3fc779a..00000000 --- a/src/qtmsensors/qorientationsensor.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QORIENTATIONSENSOR_H -#define QTM_QORIENTATIONSENSOR_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QOrientationReadingPrivate; - -class QTM_SENSORS_EXPORT QOrientationReading : public QSensorReading -{ - Q_OBJECT - Q_ENUMS(Orientation) - Q_PROPERTY(Orientation orientation READ orientation) - DECLARE_READING(QOrientationReading) -public: - enum Orientation { - Undefined = 0, - TopUp, - TopDown, - LeftUp, - RightUp, - FaceUp, - FaceDown, - }; - - Orientation orientation() const; - void setOrientation(Orientation orientation); -}; - -class QTM_SENSORS_EXPORT QOrientationFilter : public QSensorFilter -{ -public: - virtual bool filter(QOrientationReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QOrientationReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QOrientationSensor : public QSensor -{ - Q_OBJECT -public: - explicit QOrientationSensor(QObject *parent = 0) : QSensor(QOrientationSensor::type, parent) {} - virtual ~QOrientationSensor() {} - QOrientationReading *reading() const { return static_cast<QOrientationReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qorientationsensor_p.h b/src/qtmsensors/qorientationsensor_p.h deleted file mode 100644 index bace7ac4..00000000 --- a/src/qtmsensors/qorientationsensor_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QORIENTATIONSENSOR_P_H -#define QTM_QORIENTATIONSENSOR_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_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QOrientationReadingPrivate -{ -public: - QOrientationReadingPrivate() - : orientation(0) - { - } - - int orientation; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qproximitysensor.cpp b/src/qtmsensors/qproximitysensor.cpp deleted file mode 100644 index 0705a8aa..00000000 --- a/src/qtmsensors/qproximitysensor.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qproximitysensor.h" -#include "qproximitysensor_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QProximityReading) - -/*! - \class QProximityReading - \ingroup sensors_reading - \inmodule QtSensors - \since 1.0 - - \brief The QProximityReading class represents one reading from the - proximity sensor. - - \target QProximityReading_Units - The proximity sensor can only indicate if an object is close or not. - - The distance at which an object is considered close is device-specific. This - distance may be available in the QSensor::outputRanges property. -*/ - -/*! - \property QProximityReading::close - \brief a value indicating if something is close. - - Set to true if something is close. - Set to false is nothing is close. - - \sa QProximityReading_Units -*/ - -bool QProximityReading::close() const -{ - return d->close; -} - -/*! - Sets the close value to \a close. -*/ -void QProximityReading::setClose(bool close) -{ - d->close = close; -} - -// ===================================================================== - -/*! - \class QProximityFilter - \ingroup sensors_filter - \inmodule QtSensors - - \brief The QProximityFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QProximityReading - instead of QSensorReading. -*/ - -/*! - \fn QProximityFilter::filter(QProximityReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QProximitySensor::type("QProximitySensor"); - -/*! - \class QProximitySensor - \ingroup sensors_type - \inmodule QtSensors - - \brief The QProximitySensor 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 QProximityReading instead of a QSensorReading. - - For details about how the sensor works, see \l QProximityReading. - - \sa QProximityReading -*/ - -/*! - \fn QProximitySensor::QProximitySensor(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QProximitySensor::~QProximitySensor() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QProximitySensor::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -#include "moc_qproximitysensor.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qproximitysensor.h b/src/qtmsensors/qproximitysensor.h deleted file mode 100644 index 86e6bfdb..00000000 --- a/src/qtmsensors/qproximitysensor.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QPROXIMITYSENSOR_H -#define QTM_QPROXIMITYSENSOR_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QProximityReadingPrivate; - -class QTM_SENSORS_EXPORT QProximityReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(bool close READ close) - DECLARE_READING(QProximityReading) -public: - bool close() const; - void setClose(bool close); -}; - -class QTM_SENSORS_EXPORT QProximityFilter : public QSensorFilter -{ -public: - virtual bool filter(QProximityReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QProximityReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QProximitySensor : public QSensor -{ - Q_OBJECT -public: - explicit QProximitySensor(QObject *parent = 0) : QSensor(QProximitySensor::type, parent) {} - virtual ~QProximitySensor() {} - QProximityReading *reading() const { return static_cast<QProximityReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qproximitysensor_p.h b/src/qtmsensors/qproximitysensor_p.h deleted file mode 100644 index 6cb031b2..00000000 --- a/src/qtmsensors/qproximitysensor_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QPROXIMITYSENSOR_P_H -#define QTM_QPROXIMITYSENSOR_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_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QProximityReadingPrivate -{ -public: - QProximityReadingPrivate() - : close(false) - { - } - - bool close; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qrotationsensor.cpp b/src/qtmsensors/qrotationsensor.cpp deleted file mode 100644 index eba121f8..00000000 --- a/src/qtmsensors/qrotationsensor.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qrotationsensor.h" -#include "qrotationsensor_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QRotationReading) - -/*! - \class QRotationReading - \ingroup sensors_reading - \inmodule QtSensors - \since 1.0 - - \brief The QRotationReading class represents one reading from the - rotation sensor. - - \section2 QRotationReading Units - - The rotation reading contains 3 angles, measured in degrees that define - the orientation of the device in three-dimensional space. These angles - are similar to yaw, pitch and roll but are defined using only right hand - rotation with axes as defined by the right hand cartesian coordinate system. - - \image sensors-rotation.jpg - - The three angles are applied to the device in the following order. - - \list - \o Right-handed rotation z (-180, 180]. Starting from the y-axis and - incrementing in the counter-clockwise direction. - \o Right-handed rotation x [-90, 90]. Starting from the new - (once-rotated) y-axis and incrementing towards the z-axis. - \o Right-handed rotation y (-180, 180]. Starting from the new - (twice-rotated) z-axis and incrementing towards the x-axis. - \endlist - - Here is a visualization showing the order in which angles are applied. - - \image sensors-rotation-anim.gif - - The 0 point for the z angle is defined as a fixed, external entity and - is device-specific. While magnetic North is typically used as this - reference point it may not be. Do not attempt to compare values - for the z angle between devices or even on the same device if it has - moved a significant distance. - - If the device cannot detect a fixed, external entity the z angle will - always be 0 and the QRotationSensor::hasZ property will be set to false. - - The 0 point for the x and y angles are defined as when the x and y axes - of the device are oriented towards the horizon. Here is an example of - how the x value will change with device movement. - - \image sensors-rotation2.jpg - - Here is an example of how the y value will change with device movement. - - \image sensors-rotation3.jpg - - Note that when x is 90 or -90, values for z and y achieve rotation around - the same axis (due to the order of operations). In this case the y - rotation will be 0. -*/ - -/*! - \property QRotationReading::x - \brief the rotation around the x axis. - - Measured as degrees. - \sa {QRotationReading Units} -*/ - -qreal QRotationReading::x() const -{ - return d->x; -} - -/*! - Sets the rotation around the x axis to \a x. -*/ -void QRotationReading::setX(qreal x) -{ - d->x = x; -} - -/*! - \property QRotationReading::y - \brief the rotation around the y axis. - - Measured as degrees. - \sa {QRotationReading Units} -*/ - -qreal QRotationReading::y() const -{ - return d->y; -} - -/*! - Sets the rotation around the y axis to \a y. -*/ -void QRotationReading::setY(qreal y) -{ - d->y = y; -} - -/*! - \property QRotationReading::z - \brief the rotation around the z axis. - - Measured as degrees. - \sa {QRotationReading Units} -*/ - -qreal QRotationReading::z() const -{ - return d->z; -} - -/*! - Sets the rotation around the z axis to \a z. -*/ -void QRotationReading::setZ(qreal z) -{ - d->z = z; -} - -// ===================================================================== - -/*! - \class QRotationFilter - \ingroup sensors_filter - \inmodule QtSensors - - \brief The QRotationFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QRotationReading - instead of QSensorReading. -*/ - -/*! - \fn QRotationFilter::filter(QRotationReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QRotationSensor::type("QRotationSensor"); - -/*! - \class QRotationSensor - \ingroup sensors_type - \inmodule QtSensors - - \brief The QRotationSensor 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 QRotationReading instead of a QSensorReading. - - For details about how the sensor works, see \l QRotationReading. - - \sa QRotationReading -*/ - -/*! - \fn QRotationSensor::QRotationSensor(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QRotationSensor::~QRotationSensor() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QRotationSensor::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -/*! - \property QRotationSensor::hasZ - \brief a value indicating if the z angle is available. - - Returns true if z is available. - Returns false if z is not available. -*/ - -#include "moc_qrotationsensor.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qrotationsensor.h b/src/qtmsensors/qrotationsensor.h deleted file mode 100644 index c89f2b2c..00000000 --- a/src/qtmsensors/qrotationsensor.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QROTATIONSENSOR_H -#define QTM_QROTATIONSENSOR_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QRotationReadingPrivate; - -class QTM_SENSORS_EXPORT QRotationReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal x READ x) - Q_PROPERTY(qreal y READ y) - Q_PROPERTY(qreal z READ z) - DECLARE_READING(QRotationReading) -public: - qreal x() const; - void setX(qreal x); - - qreal y() const; - void setY(qreal y); - - qreal z() const; - void setZ(qreal z); -}; - -class QTM_SENSORS_EXPORT QRotationFilter : public QSensorFilter -{ -public: - virtual bool filter(QRotationReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QRotationReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QRotationSensor : public QSensor -{ - Q_OBJECT -#ifdef Q_QDOC - Q_PROPERTY(bool hasZ) -#endif -public: - explicit QRotationSensor(QObject *parent = 0) : QSensor(QRotationSensor::type, parent) {} - virtual ~QRotationSensor() {} - QRotationReading *reading() const { return static_cast<QRotationReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qrotationsensor_p.h b/src/qtmsensors/qrotationsensor_p.h deleted file mode 100644 index 23b9dcc8..00000000 --- a/src/qtmsensors/qrotationsensor_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QROTATIONSENSOR_P_H -#define QTM_QROTATIONSENSOR_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_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QRotationReadingPrivate -{ -public: - QRotationReadingPrivate() - : x(0) - , y(0) - , z(0) - { - } - - qreal x; - qreal y; - qreal z; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qsensor.cpp b/src/qtmsensors/qsensor.cpp deleted file mode 100644 index acdaec2f..00000000 --- a/src/qtmsensors/qsensor.cpp +++ /dev/null @@ -1,1017 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor.h" -#include "qsensor_p.h" -#include <QDebug> -#include <QMetaProperty> -#include <QTimer> -#include "qsensorbackend_p.h" -#include "qsensormanager_p.h" -#include "backendwrapper_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -/*! - \typedef qrange - \relates QSensor - - This type is defined as a QPair. - - \code - typedef QPair<int,int> qrange; - \endcode - - \sa QPair, qrangelist, QSensor::availableDataRates -*/ - -/*! - \typedef qrangelist - \relates QSensor - - This type is defined as a list of qrange values. - - \code - typedef QList<qrange> qrangelist; - \endcode - - \sa QList, qrange, QSensor::availableDataRates -*/ - -/*! - \class qoutputrange - \relates QSensor - \brief The qoutputrange class holds the specifics of an output range. - - The class is defined as a simple struct. - - \code - struct qoutputrange - { - qreal maximum; - qreal minimum; - qreal accuracy; - }; - \endcode - - Each output range specifies a minimum and maximum value as well as an accuracy value. - The accuracy value represents the resolution of the sensor. It is the smallest change - the sensor can detect and is expressed using the same units as the minimum and maximum. - - Sensors must often trade off range for accuracy. To allow the user to determine which of - these are more important the sensor may offer several output ranges. One output - range may have reduced minimum and maximum values and increased sensitivity. Another output - range may have higher minimum and maximum values with reduced sensitivity. Note that higher - sensitivities will be represented by smaller accuracy values. - - An example of this tradeoff can be seen by examining the LIS302DL accelerometer. It has only - 256 possible values to report with. These values are scaled so that they can represent either - -2G to +2G (with an accuracy value of 0.015G) or -8G to +8G (with an accuracy value of 0.06G). - - \sa qoutputrangelist, QSensor::outputRanges -*/ - -/*! - \variable qoutputrange::maximum - - This is the maximum value for this output range. - The units are defined by the sensor. -*/ - -/*! - \variable qoutputrange::minimum - - This is the minimum value for this output range. - The units are defined by the sensor. -*/ - -/*! - \variable qoutputrange::accuracy - - The accuracy value represents the resolution of the sensor. It is the smallest change - the sensor can detect and is expressed using the same units as the minimum and maximum. -*/ - -/*! - \typedef qoutputrangelist - \relates QSensor - - This type is defined as a list of qoutputrange values. - - \code - typedef QList<qoutputrange> qoutputrangelist; - \endcode - - \sa QList, qoutputrange, QSensor::outputRanges -*/ - -#if 0 -// A bit of a hack to call qRegisterMetaType when the library is loaded. -static int qrange_id = qRegisterMetaType<qrange>("qrange"); -static int qrangelist_id = qRegisterMetaType<qrangelist>("qrangelist"); -static int qoutputrangelist_id = qRegisterMetaType<qoutputrangelist>("qoutputrangelist"); -#endif - -// ===================================================================== - -/*! - \class QSensor - \ingroup sensors_main - \inmodule QtSensors - - \brief The QSensor class represents a single hardware sensor. - - The life cycle of a sensor is typically: - - \list - \o Create a sub-class of QSensor on the stack or heap. - \o Setup as required by the application. - \o Start receiving values. - \o Sensor data is used by the application. - \o Stop receiving values. - \endlist - - The sensor data is delivered via QSensorData and its sub-classes. - - \sa QSensorReading -*/ - -/*! - Construct the \a type sensor as a child of \a parent. -*/ -QSensor::QSensor(const QByteArray &type, QObject *parent) - : QObject(parent) - , d(new QSensorPrivate) -{ - d->type = type; - registerInstance(); // so the availableSensorsChanged() signal works -} - -/*! - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ -QSensor::~QSensor() -{ - stop(); - Q_FOREACH (QSensorFilter *filter, d->filters) - filter->setSensor(0); - delete d->backend; - d->backend = 0; - // owned by the backend - d->device_reading = 0; - d->filter_reading = 0; - d->cache_reading = 0; -} - -/*! - \property QSensor::connectedToBackend - \brief a value indicating if the sensor has connected to a backend. - - A sensor that has not been connected to a backend cannot do anything useful. - - Call the connectToBackend() method to force the sensor to connect to a backend - immediately. This is automatically called if you call start() so you only need - to do this if you need access to sensor properties (ie. to poll the sensor's - meta-data before you use it). -*/ - -bool QSensor::isConnectedToBackend() const -{ - return (d->backend != 0); -} - -/*! - \property QSensor::sensorid - \brief the backend identifier for the sensor. - - Note that the identifier is filled out automatically - when the sensor is connected to a backend. If you want - to connect a specific backend, you should call - setIdentifier() before connectToBackend(). -*/ - -QByteArray QSensor::identifier() const -{ - return d->identifier; -} - -void QSensor::setIdentifier(const QByteArray &identifier) -{ - if (isConnectedToBackend()) { - qWarning() << "ERROR: Cannot call QSensor::setIdentifier while connected to a backend!"; - return; - } - d->identifier = identifier; -} - -/*! - \property QSensor::type - \brief the type of the sensor. -*/ - -QByteArray QSensor::type() const -{ - return d->type; -} - -/*! - Try to connect to a sensor backend. - - Returns true if a suitable backend could be found, false otherwise. - - The type must be set before calling this method if you are using QSensor directly. - - \sa isConnectedToBackend() -*/ -bool QSensor::connectToBackend() -{ - if (isConnectedToBackend()) - return true; - - d->backend = QSensorManager::createBackend(this); - - // Reset the properties to their default values and re-set them now so - // that the logic we've put into the setters gets called. - if (d->dataRate != 0) { - int tmp = d->dataRate; - d->dataRate = 0; - setDataRate(tmp); - } - if (d->outputRange != -1) { - int tmp = d->outputRange; - d->outputRange = -1; - setOutputRange(tmp); - } - - QSensorWrapper *wrapper = qobject_cast<QSensorWrapper*>(d->backend); - if (wrapper) { - if (d->pendingProperties.count()) { - foreach (const PendingProperty &pair, d->pendingProperties) { - setProperty(pair.first.toLocal8Bit().constData(), pair.second); - } - d->pendingProperties.clear(); - } - bool ok = wrapper->_connect(); - Q_ASSERT(ok); - } - - return isConnectedToBackend(); -} - -/*! - \property QSensor::busy - \brief a value to indicate if the sensor is busy. - - Some sensors may be on the system but unavailable for use. - This function will return true if the sensor is busy. You - will not be able to start() the sensor. - - Note that this function does not return true if you - are using the sensor, only if another process is using - the sensor. - - \sa busyChanged() -*/ - -bool QSensor::isBusy() const -{ - return d->busy; -} - -/*! - \fn QSensor::busyChanged() - - This signal is emitted when the sensor is no longer busy. - This can be used to grab a sensor when it becomes available. - - \code - sensor.start(); - if (sensor.isBusy()) { - // need to wait for busyChanged signal and try again - } - \endcode -*/ - -/*! - \property QSensor::active - \brief a value to indicate if the sensor is active. - - This is true if the sensor is active (returning values). This is false otherwise. - - Note that setting this value to true will not have an immediate effect. Instead, - the sensor will be started once the event loop has been reached. -*/ -void QSensor::setActive(bool active) -{ - if (active == isActive()) - return; - - if (active) - QTimer::singleShot(0, this, SLOT(start())); // delay ensures all properties have been set if using QML - else - stop(); -} - -bool QSensor::isActive() const -{ - return d->active; -} - -/*! - \property QSensor::availableDataRates - \brief the data rates that the sensor supports. - - This is a list of the data rates that the sensor supports. - Measured in Hertz. - - Entries in the list can represent discrete rates or a - continuous range of rates. - A discrete rate is noted by having both values the same. - - See the sensor_explorer example for an example of how to interpret and use - this information. - - Note that this information is not mandatory as not all sensors have a rate at which - they run. In such cases, the list will be empty. - - \sa QSensor::dataRate, qrangelist -*/ - -qrangelist QSensor::availableDataRates() const -{ - return d->availableDataRates; -} - -/*! - \property QSensor::dataRate - \brief the data rate that the sensor should be run at. - - Measured in Hertz. - - The data rate is the maximum frequency at which the sensor can detect changes. - - Setting this property is not portable and can cause conflicts with other - applications. Check with the sensor backend and platform documentation for - any policy regarding multiple applications requesting a data rate. - - The default value (0) means that the app does not care what the data rate is. - Applications should consider using a timer-based poll of the current value or - ensure that the code that processes values can run very quickly as the platform - may provide updates hundreds of times each second. - - This should be set before calling start() because the sensor may not - notice changes to this value while it is running. - - Note that there is no mechanism to determine the current data rate in use by the - platform. - - \sa QSensor::availableDataRates -*/ - -int QSensor::dataRate() const -{ - return d->dataRate; -} - -void QSensor::setDataRate(int rate) -{ - if (rate == 0 || !isConnectedToBackend()) { - d->dataRate = rate; - return; - } - bool warn = true; - Q_FOREACH (const qrange &range, d->availableDataRates) { - if (rate >= range.first && rate <= range.second) { - warn = false; - d->dataRate = rate; - break; - } - } - if (warn) { - qWarning() << "setDataRate:" << rate << "is not supported by the sensor."; - } -} - -/*! - Start retrieving values from the sensor. - Returns true if the sensor was started, false otherwise. - - The sensor may fail to start for several reasons. - - Once an application has started a sensor it must wait until the sensor receives a - new value before it can query the sensor's values. This is due to how the sensor - receives values from the system. Sensors do not (in general) poll for new values, - rather new values are pushed to the sensors as they happen. - - For example, this code will not work as intended. - - \badcode - sensor->start(); - sensor->reading()->x(); // no data available - \endcode - - To work correctly, the code that accesses the reading should ensure the - readingChanged() signal has been emitted. - - \code - connect(sensor, SIGNAL(readingChanged()), this, SLOT(checkReading())); - sensor->start(); - } - void MyClass::checkReading() { - sensor->reading()->x(); - \endcode - - \sa QSensor::busy -*/ -bool QSensor::start() -{ - if (isActive()) - return true; - if (!connectToBackend()) - return false; - // Set these flags to their defaults - d->active = true; - d->busy = false; - // Backend will update the flags appropriately - d->backend->start(); - Q_EMIT activeChanged(); - return isActive(); -} - -/*! - Stop retrieving values from the sensor. - - This releases the sensor so that other processes can use it. - - \sa QSensor::busy -*/ -void QSensor::stop() -{ - if (!isConnectedToBackend() || !isActive()) - return; - d->active = false; - d->backend->stop(); - Q_EMIT activeChanged(); -} - -/*! - \property QSensor::reading - \brief the reading class. - - The reading class provides access to sensor readings. The reading object - is a volatile cache of the most recent sensor reading that has been received - so the application should process readings immediately or save the values - somewhere for later processing. - - Note that this will return 0 until a sensor backend is connected to a backend. - - Also note that readings are not immediately available after start() is called. - Applications must wait for the readingChanged() signal to be emitted. - - \sa isConnectedToBackend(), start() -*/ - -QSensorReading *QSensor::reading() const -{ - return d->cache_reading; -} - -/*! - Add a \a filter to the sensor. - - The sensor does not take ownership of the filter. - QSensorFilter will inform the sensor if it is destroyed. - - \sa QSensorFilter -*/ -void QSensor::addFilter(QSensorFilter *filter) -{ - if (!filter) { - qWarning() << "addFilter: passed a null filter!"; - return; - } - filter->setSensor(this); - d->filters << filter; -} - -/*! - Remove \a filter from the sensor. - - \sa QSensorFilter -*/ -void QSensor::removeFilter(QSensorFilter *filter) -{ - if (!filter) { - qWarning() << "removeFilter: passed a null filter!"; - return; - } - d->filters.removeOne(filter); - filter->setSensor(0); -} - -/*! - Returns the filters currently attached to the sensor. - - \sa QSensorFilter -*/ -QList<QSensorFilter*> QSensor::filters() const -{ - return d->filters; -} - -/*! - \fn QSensor::d_func() const - \internal -*/ - -/*! - \fn QSensor::readingChanged() - - This signal is emitted when a new sensor reading is received. - - The sensor reading can be found in the QSensor::reading property. Note that the - reading object is a volatile cache of the most recent sensor reading that has - been received so the application should process the reading immediately or - save the values somewhere for later processing. - - Before this signal has been emitted for the first time, the reading object will - have uninitialized data. - - \sa start() -*/ - -/*! - \fn QSensor::activeChanged() - - This signal is emitted when the QSensor::active property has changed. - - \sa QSensor::active -*/ - -/*! - \property QSensor::outputRanges - \brief a list of output ranges the sensor supports. - - A sensor may have more than one output range. Typically this is done - to give a greater measurement range at the cost of lowering accuracy. - - Note that this information is not mandatory. This information is typically only - available for sensors that have selectable output ranges (such as typical - accelerometers). - - \sa QSensor::outputRange, qoutputrangelist -*/ - -qoutputrangelist QSensor::outputRanges() const -{ - return d->outputRanges; -} - -/*! - \property QSensor::outputRange - \brief the output range in use by the sensor. - - This value represents the index in the QSensor::outputRanges list to use. - - Setting this property is not portable and can cause conflicts with other - applications. Check with the sensor backend and platform documentation for - any policy regarding multiple applications requesting an output range. - - The default value (-1) means that the app does not care what the output range is. - - Note that there is no mechanism to determine the current output range in use by the - platform. - - \sa QSensor::outputRanges -*/ - -int QSensor::outputRange() const -{ - return d->outputRange; -} - -void QSensor::setOutputRange(int index) -{ - if (index == -1 || !isConnectedToBackend()) { - d->outputRange = index; - return; - } - bool warn = true; - if (index >= 0 && index < d->outputRanges.count()) { - warn = false; - d->outputRange = index; - } - if (warn) { - qWarning() << "setOutputRange:" << index << "is not supported by the sensor."; - } -} - -/*! - \property QSensor::description - \brief a descriptive string for the sensor. -*/ - -QString QSensor::description() const -{ - return d->description; -} - -/*! - \property QSensor::error - \brief the last error code set on the sensor. - - Note that error codes are sensor-specific. -*/ - -int QSensor::error() const -{ - return d->error; -} - -/*! - \fn QSensor::sensorError(int error) - - This signal is emitted when an \a error code is set on the sensor. - Note that some errors will cause the sensor to stop working. - You should call isActive() to determine if the sensor is still running. -*/ - -/*! - \fn QSensor::availableSensorsChanged() - - This signal is emitted when the list of available sensors has changed. - The sensors available to a program will not generally change over time - however some of the avilable sensors may represent hardware that is not - permanently connected. For example, a game controller that is connected - via bluetooth would become available when it was on and would become - unavailable when it was off. - - \sa QSensor::sensorTypes(), QSensor::sensorsForType() -*/ - -/*! - \property QSensor::maxBufferSize - - The property holds the maximum buffer size. - - Note that this may be undefined, in which case the sensor does not support any form of buffering. - - \sa QSensor::bufferSize, QSensor::efficientBufferSize -*/ - -/*! - \property QSensor::efficientBufferSize - - The property holds the most efficient buffer size. Normally this is 1 (which means - no particular size is most efficient). Some sensor drivers have a FIFO buffer which - makes it more efficient to deliver the FIFO's size worth of readings at one time. - - Note that this may be undefined, in which case the sensor does not support any form of buffering. - - \sa QSensor::bufferSize, QSensor::maxBufferSize -*/ - -/*! - \property QSensor::bufferSize - - This property holds the size of the buffer. By default (and if the property - is left undefined), the buffer size is 1, which means no buffering. - If the maximum buffer size is 1 (or undefined), then buffering is not supported - by the sensor. - - Setting bufferSize greater than maxBufferSize will cause maxBufferSize to be used. - - Buffering is turned on when bufferSize is greater than 1. The sensor will collect - the requested number of samples and deliver them all to the application at one time. - They will be delivered to the application as a burst of changed readings so it is - particularly important that the application processes each reading immediately or - saves the values somewhere else. - - If stop() is called when buffering is on-going, the partial buffer is not delivered. - - When the sensor is started with buffering option, values are collected from that - moment onwards. There is no pre-existing buffer that can be utilized. - - The buffer size can only be changed while the sensor is not active. - - \sa QSensor::maxBufferSize, QSensor::efficientBufferSize -*/ - -/*! - \internal -*/ -void QSensor::setProperty(const char *name, const QVariant &value) -{ - //qDebug() << "QSensor::setProperty" << name << value; - QObject::setProperty(name, value); - QSensorWrapper *wrapper = qobject_cast<QSensorWrapper*>(d->backend); - if (wrapper) { - wrapper->setProperty(name, value); - } else if (!d->backend) { - d->pendingProperties << PendingProperty(QString::fromLocal8Bit(name), value); - } -} - -/*! - \internal -*/ -QVariant QSensor::property(const char *name) const -{ - //qDebug() << "QSensor::property"; - QSensorWrapper *wrapper = qobject_cast<QSensorWrapper*>(d->backend); - if (wrapper) { - return wrapper->property(name); - } - return QObject::property(name); -} - -// ===================================================================== - -/*! - \class QSensorFilter - \ingroup sensors_main - \inmodule QtSensors - - \brief The QSensorFilter class provides an efficient - callback facility for asynchronous notifications of - sensor changes. - - Some sensors (eg. the accelerometer) are often accessed very frequently. - This may be slowed down by the use of signals and slots. - The QSensorFilter interface provides a more efficient way for the - sensor to notify your class that the sensor has changed. - - Additionally, multiple filters can be added to a sensor. They are called - in order and each filter has the option to modify the values in the reading - or to suppress the reading altogether. - - Note that the values in the class returned by QSensor::reading() will - not be updated until after the filters have been run. - - \sa filter() -*/ - -/*! - \internal -*/ -QSensorFilter::QSensorFilter() - : m_sensor(0) -{ -} - -/*! - Notifies the attached sensor (if any) that the filter is being destroyed. -*/ -QSensorFilter::~QSensorFilter() -{ - if (m_sensor) - m_sensor->removeFilter(this); -} - -/*! - \fn QSensorFilter::filter(QSensorReading *reading) - - This function is called when the sensor \a reading changes. - - The filter can modify the reading. - - Returns true to allow the next filter to receive the value. - If this is the last filter, returning true causes the signal - to be emitted and the value is stored in the sensor. - - Returns false to drop the reading. -*/ - -/*! - \internal -*/ -void QSensorFilter::setSensor(QSensor *sensor) -{ - m_sensor = sensor; -} - -// ===================================================================== - -/*! - \class QSensorReading - \ingroup sensors_main - \inmodule QtSensors - - \brief The QSensorReading class holds the readings from the sensor. - - Note that QSensorReading is not particularly useful by itself. The interesting - data for each sensor is defined in a sub-class of QSensorReading. -*/ - -/*! - \internal -*/ -QSensorReading::QSensorReading(QObject *parent, QSensorReadingPrivate *_d) - : QObject(parent) - , d(_d?_d:new QSensorReadingPrivate) -{ -} - -/*! - \internal -*/ -QSensorReading::~QSensorReading() -{ -} - -/*! - \property QSensorReading::timestamp - \brief the timestamp of the reading. - - Timestamps values are microseconds since a fixed point. - You can use timestamps to see how far apart two sensor readings are. - - Note that sensor timestamps from different sensors may not be directly - comparable (as they may choose different fixed points for their reference). - - \bold{Note that some platforms do not deliver timestamps correctly}. - Applications should be prepared for occasional issues that cause timestamps to jump - forwards or backwards. The \l{sensors-api.html#platform-notes}{platform notes} have - more details. -*/ - -/*! - Returns the timestamp of the reading. -*/ -quint64 QSensorReading::timestamp() const -{ - return d->timestamp; -} - -/*! - Sets the \a timestamp of the reading. -*/ -void QSensorReading::setTimestamp(quint64 timestamp) -{ - d->timestamp = timestamp; -} - -/*! - Returns the number of extra properties that the reading has. - - Note that this does not count properties declared in QSensorReading. - - As an example, this returns 3 for QAccelerometerReading because - there are 3 properties defined in that class. -*/ -int QSensorReading::valueCount() const -{ - const QMetaObject *mo = metaObject(); - return mo->propertyCount() - mo->propertyOffset(); -} - -/*! - Returns the value of the property at \a index. - - Note that this function is slower than calling the data function directly. - - Here is an example of getting a property via the different mechanisms available. - - Accessing directly provides the best performance but requires compile-time knowledge - of the data you are accessing. - - \code - QAccelerometerReading *reading = ...; - qreal x = reading->x(); - \endcode - - You can also access a property by name. To do this you must call QObject::property(). - - \code - qreal x = reading->property("x").value<qreal>(); - \endcode - - Finally, you can access values via numeric index. - - \code - qreal x = reading->value(0).value<qreal>(); - \endcode - - Note that value() can only access properties declared with Q_PROPERTY() in sub-classes - of QSensorReading. - - \sa valueCount(), QObject::property() -*/ -QVariant QSensorReading::value(int index) const -{ - // get them meta-object - const QMetaObject *mo = metaObject(); - - // determine the index of the property we want - index += mo->propertyOffset(); - - // get the meta-property - QMetaProperty property = mo->property(index); - - // read the property - return property.read(this); -} - -/*! - \fn QSensorReading::copyValuesFrom(QSensorReading *other) - \internal - - Copy values from other into this reading. Implemented by sub-classes - using the DECLARE_READING() and IMPLEMENT_READING() macros. - - Note that this method should only be called by QSensorBackend. -*/ -void QSensorReading::copyValuesFrom(QSensorReading *other) -{ - QSensorReadingPrivate *my_ptr = d.data(); - QSensorReadingPrivate *other_ptr = other->d.data(); - /* Do a direct copy of the private class */ - *(my_ptr) = *(other_ptr); -} - -/*! - \fn QSensorReading::d_ptr() - \internal - No longer used. Exists to keep the winscw build happy. -*/ - -/*! - \macro DECLARE_READING(classname) - \relates QSensorReading - \brief The DECLARE_READING macro adds some required methods to a reading class. - - This macro should be used for all reading classes. Pass the \a classname of your reading class. - - \code - class MyReading : public QSensorReading - { - Q_OBJECT - Q_PROPERTY(qreal myprop READ myprop) - DECLARE_READING(MyReading) - public: - qreal myprop() const; - vod setMyprop(qreal myprop); - }; - \endcode - - \sa IMPLEMENT_READING() -*/ - -/*! - \macro IMPLEMENT_READING(classname) - \relates QSensorReading - \brief The IMPLEMENT_READING macro implements the required methods for a reading class. - - This macro should be used for all reading classes. It should be placed into a single compilation - unit (source file), not into a header file. Pass the \a classname of your reading class. - - \code - IMPLEMENT_READING(MyReading) - \endcode - - \sa DECLARE_READING() -*/ - -#include "moc_qsensor.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qsensor.h b/src/qtmsensors/qsensor.h deleted file mode 100644 index b8a0291a..00000000 --- a/src/qtmsensors/qsensor.h +++ /dev/null @@ -1,254 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QSENSOR_H -#define QTM_QSENSOR_H - -#include <QtCore/QObject> -#include <QtCore/QByteArray> -#include <QtCore/QMetaType> -#include <QtCore/QVariant> -#include <QtCore/QPair> - -#include "qtmsensorsglobal.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QSensorPrivate; -class QSensorReading; -class QSensorReadingPrivate; -class QSensorFilter; - -// This type is no longer used in the API but third party apps may be using it -typedef quint64 qtimestamp; - -typedef QPair<int,int> qrange; -typedef QList<qrange> qrangelist; -struct qoutputrange -{ - qreal minimum; - qreal maximum; - qreal accuracy; -}; -typedef QList<qoutputrange> qoutputrangelist; - -class QTM_SENSORS_EXPORT QSensor : public QObject -{ - friend class QSensorBackend; - - Q_OBJECT - Q_PROPERTY(QByteArray sensorid READ identifier WRITE setIdentifier) - Q_PROPERTY(QByteArray type READ type) - Q_PROPERTY(bool connectedToBackend READ isConnectedToBackend) - Q_PROPERTY(qrangelist availableDataRates READ availableDataRates) - Q_PROPERTY(int dataRate READ dataRate WRITE setDataRate) - Q_PROPERTY(QSensorReading* reading READ reading NOTIFY readingChanged) - Q_PROPERTY(bool busy READ isBusy) - Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) - Q_PROPERTY(qoutputrangelist outputRanges READ outputRanges) - Q_PROPERTY(int outputRange READ outputRange WRITE setOutputRange) - Q_PROPERTY(QString description READ description) - Q_PROPERTY(int error READ error NOTIFY sensorError) -#ifdef Q_QDOC - Q_PROPERTY(int maxBufferSize) - Q_PROPERTY(int efficientBufferSize) - Q_PROPERTY(int bufferSize) -#endif -public: - explicit QSensor(const QByteArray &type, QObject *parent = 0); - virtual ~QSensor(); - - QByteArray identifier() const; - void setIdentifier(const QByteArray &identifier); - - QByteArray type() const; - - Q_INVOKABLE bool connectToBackend(); - bool isConnectedToBackend() const; - - bool isBusy() const; - - void setActive(bool active); - bool isActive() const; - - qrangelist availableDataRates() const; - int dataRate() const; - void setDataRate(int rate); - - qoutputrangelist outputRanges() const; - int outputRange() const; - void setOutputRange(int index); - - QString description() const; - int error() const; - - // Filters modify the reading - void addFilter(QSensorFilter *filter); - void removeFilter(QSensorFilter *filter); - QList<QSensorFilter*> filters() const; - - // The readings are exposed via this object - QSensorReading *reading() const; - - // Information about available sensors - // These functions are implemented in qsensormanager.cpp - static QList<QByteArray> sensorTypes(); - static QList<QByteArray> sensorsForType(const QByteArray &type); - static QByteArray defaultSensorForType(const QByteArray &type); - - // These are here so we can catch dynamic properties and share - // them with the non-legacy sensor that is being wrapped - void setProperty(const char *name, const QVariant &value); - QVariant property(const char *name) const; - -public Q_SLOTS: - // Start receiving values from the sensor - bool start(); - - // Stop receiving values from the sensor - void stop(); - -Q_SIGNALS: - void busyChanged(); - void activeChanged(); - void readingChanged(); - void sensorError(int error); - void availableSensorsChanged(); - -protected: - // called by the back end - QSensorPrivate *d_func() const { return d.data(); } - -private: - void registerInstance(); - - QScopedPointer<QSensorPrivate> d; - Q_DISABLE_COPY(QSensor) -}; - -class QTM_SENSORS_EXPORT QSensorFilter -{ - friend class QSensor; -public: - virtual bool filter(QSensorReading *reading) = 0; -protected: - QSensorFilter(); - ~QSensorFilter(); - virtual void setSensor(QSensor *sensor); - QSensor *m_sensor; -}; - -class QTM_SENSORS_EXPORT QSensorReading : public QObject -{ - friend class QSensorBackend; - - Q_OBJECT - Q_PROPERTY(quint64 timestamp READ timestamp) -public: - virtual ~QSensorReading(); - - quint64 timestamp() const; - void setTimestamp(quint64 timestamp); - - // Access properties of sub-classes by numeric index - // For name-based access use QObject::property() - int valueCount() const; - QVariant value(int index) const; - -protected: - explicit QSensorReading(QObject *parent, QSensorReadingPrivate *d); - QScopedPointer<QSensorReadingPrivate> *d_ptr() { return &d; } - virtual void copyValuesFrom(QSensorReading *other); - -private: - QScopedPointer<QSensorReadingPrivate> d; - Q_DISABLE_COPY(QSensorReading) -}; - -#undef DECLARE_READING -#undef DECLARE_READING_D -#undef IMPLEMENT_READING -#undef IMPLEMENT_READING_D - -#define DECLARE_READING(classname)\ - DECLARE_READING_D(classname, classname ## Private) - -#define DECLARE_READING_D(classname, pclassname)\ - public:\ - classname(QObject *parent = 0);\ - virtual ~classname();\ - void copyValuesFrom(QSensorReading *other);\ - private:\ - QScopedPointer<pclassname> d; - -#define IMPLEMENT_READING(classname)\ - IMPLEMENT_READING_D(classname, classname ## Private) - -#define IMPLEMENT_READING_D(classname, pclassname)\ - classname::classname(QObject *parent)\ - : QSensorReading(parent, 0)\ - , d(new pclassname)\ - {}\ - classname::~classname() {}\ - void classname::copyValuesFrom(QSensorReading *_other)\ - {\ - /* No need to verify types, only called by QSensorBackend */\ - classname *other = static_cast<classname *>(_other);\ - pclassname *my_ptr = d.data();\ - pclassname *other_ptr = other->d.data();\ - /* Do a direct copy of the private class */\ - *(my_ptr) = *(other_ptr);\ - /* We need to copy the parent too */\ - QSensorReading::copyValuesFrom(_other);\ - } - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#if 0 -Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(qrange)) -Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(qrangelist)) -Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(qoutputrangelist)) -#endif - -#endif - diff --git a/src/qtmsensors/qsensor_p.h b/src/qtmsensors/qsensor_p.h deleted file mode 100644 index ec75d793..00000000 --- a/src/qtmsensors/qsensor_p.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QSENSOR_P_H -#define QTM_QSENSOR_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 "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -typedef QList<QSensorFilter*> QFilterList; -typedef QPair<QString,QVariant> PendingProperty; -class QSensorBackend; - -class QSensorPrivate -{ -public: - QSensorPrivate() - : identifier() - , type() - , outputRange(-1) - , dataRate(0) - , backend(0) - , active(false) - , busy(false) - , device_reading(0) - , filter_reading(0) - , cache_reading(0) - , error(0) - { - } - - // meta-data - QByteArray identifier; - QByteArray type; - - QString description; - - qoutputrangelist outputRanges; - int outputRange; - - // policy - qrangelist availableDataRates; - int dataRate; - - QSensorBackend *backend; - QFilterList filters; - bool active; - bool busy; - QSensorReading *device_reading; - QSensorReading *filter_reading; - QSensorReading *cache_reading; - - int error; - QList<PendingProperty> pendingProperties; -}; - -class QSensorReadingPrivate -{ -public: - QSensorReadingPrivate() - : timestamp(0) - { - } - - // sensor data cache - quint64 timestamp; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qsensorbackend.cpp b/src/qtmsensors/qsensorbackend.cpp deleted file mode 100644 index 27a3ac2f..00000000 --- a/src/qtmsensors/qsensorbackend.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensorbackend_p.h" -#include "qsensor_p.h" -#include <QDebug> - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -/*! - \class QSensorBackend - \ingroup sensors_backend - \inmodule QtSensors - \since 1.0 - - \brief The QSensorBackend class is a sensor implementation. - - Sensors on a device will be represented by sub-classes of - QSensorBackend. -*/ - -/*! - \internal -*/ -QSensorBackend::QSensorBackend(QSensor *sensor) - : m_sensor(sensor) -{ -} - -/*! - \internal -*/ -QSensorBackend::~QSensorBackend() -{ -} - -/*! - Notify the QSensor class that a new reading is available. -*/ -void QSensorBackend::newReadingAvailable() -{ - QSensorPrivate *d = m_sensor->d_func(); - - // Copy the values from the device reading to the filter reading - d->filter_reading->copyValuesFrom(d->device_reading); - - for (QFilterList::const_iterator it = d->filters.constBegin(); it != d->filters.constEnd(); ++it) { - QSensorFilter *filter = (*it); - if (!filter->filter(d->filter_reading)) - return; - } - - // Copy the values from the filter reading to the cached reading - d->cache_reading->copyValuesFrom(d->filter_reading); - - Q_EMIT m_sensor->readingChanged(); -} - -/*! - \fn QSensorBackend::start() - - Start reporting values. -*/ - -/*! - \fn QSensorBackend::stop() - - Stop reporting values. -*/ - -/*! - If the backend has lost its reference to the reading - it can call this method to get the address. - - Note that you will need to down-cast to the appropriate - type. - - \sa setReading() -*/ -QSensorReading *QSensorBackend::reading() const -{ - QSensorPrivate *d = m_sensor->d_func(); - return d->device_reading; -} - -/*! - \fn QSensorBackend::sensor() const - - Returns the sensor front end associated with this backend. -*/ - -/*! - \fn QSensorBackend::setReading(T *reading) - - This function is called to initialize the \a reading - classes used for a sensor. - - If your backend has already allocated a reading you - should pass the address of this to the function. - Otherwise you should pass 0 and the function will - return the address of the reading your backend - should use when it wants to notify the sensor API - of new readings. - - Note that this is a template function so it should - be called with the appropriate type. - - \code - class MyBackend : public QSensorBackend - { - QAccelerometerReading m_reading; - public: - MyBackend(QSensor *sensor) - : QSensorBackend(sensor) - { - setReading<QAccelerometerReading>(&m_reading); - } - - ... - \endcode - - Note that this function must be called or you will - not be able to send readings to the front end. - - If you do not wish to store the address of the reading - you may use the reading() method to get it again later. - - \code - class MyBackend : public QSensorBackend - { - public: - MyBackend(QSensor *sensor) - : QSensorBackend(sensor) - { - setReading<QAccelerometerReading>(0); - } - - void poll() - { - quint64 timestamp; - qreal x, y, z; - ... - QAccelerometerReading *reading = static_cast<QAccelerometerReading*>(reading()); - reading->setTimestamp(timestamp); - reading->setX(x); - reading->setY(y); - reading->setZ(z); - } - - ... - \endcode - - \sa reading() -*/ - -/*! - \internal -*/ -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; -} - -/*! - Add a data rate (consisting of \a min and \a max values) for the sensor. - - Note that this function should be called from the constructor so that the information - is available immediately. - - \sa QSensor::availableDataRates -*/ -void QSensorBackend::addDataRate(qreal min, qreal max) -{ - QSensorPrivate *d = m_sensor->d_func(); - d->availableDataRates << qrange(min, max); -} - -/*! - Set the data rates for the sensor based on \a otherSensor. - - This is designed for sensors that are based on other sensors. - - \code - setDataRates(otherSensor); - \endcode - - Note that this function should be called from the constructor so that the information - is available immediately. - - \sa QSensor::availableDataRates, addDataRate() -*/ -void QSensorBackend::setDataRates(const QSensor *otherSensor) -{ - if (!otherSensor) { - qWarning() << "ERROR: Cannot call QSensorBackend::setDataRates with 0"; - return; - } - if (otherSensor->identifier().isEmpty()) { - qWarning() << "ERROR: Cannot call QSensorBackend::setDataRates with an invalid sensor"; - return; - } - QSensorPrivate *d = m_sensor->d_func(); - d->availableDataRates = otherSensor->availableDataRates(); - d->dataRate = otherSensor->dataRate(); -} - -/*! - Add an output range (consisting of \a min, \a max values and \a accuracy) for the sensor. - - Note that this function should be called from the constructor so that the information - is available immediately. - - \sa QSensor::outputRange, QSensor::outputRanges -*/ -void QSensorBackend::addOutputRange(qreal min, qreal max, qreal accuracy) -{ - QSensorPrivate *d = m_sensor->d_func(); - - qoutputrange details = {min, max, accuracy}; - - d->outputRanges << details; -} - -/*! - Set the \a description for the sensor. - - Note that this function should be called from the constructor so that the information - is available immediately. -*/ -void QSensorBackend::setDescription(const QString &description) -{ - QSensorPrivate *d = m_sensor->d_func(); - d->description = description; -} - -/*! - Inform the front end that the sensor has stopped. - This can be due to start() failing or for some - unexpected reason (eg. hardware failure). - - Note that the front end must call QSensor::isActive() to see if - the sensor has stopped. If the sensor has stopped due to an error - the sensorError() function should be called to notify the class - of the error condition. -*/ -void QSensorBackend::sensorStopped() -{ - QSensorPrivate *d = m_sensor->d_func(); - d->active = false; -} - -/*! - Inform the front end that the sensor is busy. - This implicitly calls sensorStopped() and - is typically called from start(). - - Note that the front end must call QSensor::isBusy() to see if - the sensor is busy. If the sensor has stopped due to an error - the sensorError() function should be called to notify the class - of the error condition. -*/ -void QSensorBackend::sensorBusy() -{ - QSensorPrivate *d = m_sensor->d_func(); - d->active = false; - d->busy = true; -} - -/*! - Inform the front end that a sensor error occurred. - Note that this only reports an \a error code. It does - not stop the sensor. - - \sa sensorStopped() -*/ -void QSensorBackend::sensorError(int error) -{ - QSensorPrivate *d = m_sensor->d_func(); - d->error = error; - Q_EMIT m_sensor->sensorError(error); -} - -#include "moc_qsensorbackend_p.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qsensorbackend_p.h b/src/qtmsensors/qsensorbackend_p.h deleted file mode 100644 index a2d8b457..00000000 --- a/src/qtmsensors/qsensorbackend_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QSENSORBACKEND_P_H -#define QTM_QSENSORBACKEND_P_H - -#include <QObject> -#include "qtmsensorsglobal.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QSensor; -class QSensorReading; - -class QTM_SENSORS_EXPORT QSensorBackend : public QObject -{ - Q_OBJECT -public: - QSensorBackend(QSensor *sensor); - virtual ~QSensorBackend(); - - virtual void start() = 0; - virtual void stop() = 0; - - // used by the backend to set metadata properties - void addDataRate(qreal min, qreal max); - void setDataRates(const QSensor *otherSensor); - void addOutputRange(qreal min, qreal max, qreal accuracy); - void setDescription(const QString &description); - - template <typename T> - T *setReading(T *reading) - { - if (!reading) - reading = new T(this); - setReadings(reading, new T(this), new T(this)); - return reading; - } - - QSensorReading *reading() const; - QSensor *sensor() const { return m_sensor; } - - // used by the backend to inform us of events - void newReadingAvailable(); - void sensorStopped(); - void sensorBusy(); - void sensorError(int error); - -private: - void setReadings(QSensorReading *device, QSensorReading *filter, QSensorReading *cache); - - QSensor *m_sensor; - Q_DISABLE_COPY(QSensorBackend) -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qsensormanager.cpp b/src/qtmsensors/qsensormanager.cpp deleted file mode 100644 index e829d78d..00000000 --- a/src/qtmsensors/qsensormanager.cpp +++ /dev/null @@ -1,453 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensormanager_p.h" -#include <QDebug> -#include <QSettings> -#include <QTimer> -#include <private/sensorlog_p.h> -#include "backendwrapper_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -typedef QHash<QByteArray,QSensorBackendFactory*> FactoryForIdentifierMap; -typedef QHash<QByteArray,FactoryForIdentifierMap> BackendIdentifiersForTypeMap; - -class QSensorManagerPrivate : public QObject -{ - friend class QSensorManager; - - Q_OBJECT -public: - enum PluginLoadingState { - NotLoaded, - Loading, - Loaded - }; - QSensorManagerPrivate() - : pluginLoadingState(NotLoaded) - , sensorsChanged(false) - { - } - - PluginLoadingState pluginLoadingState; - void loadPlugins(); - - // Here for the unit test - QList<CreatePluginFunc> staticRegistrations; - - // Holds a mapping from type to available identifiers (and from there to the factory) - BackendIdentifiersForTypeMap backendsByType; - - // Holds the first identifier for each type - QHash<QByteArray, QByteArray> firstIdentifierForType; - - bool sensorsChanged; - -Q_SIGNALS: - void availableSensorsChanged(); - -public Q_SLOTS: - void emitSensorsChanged() - { - static bool alreadyRunning = false; - if (pluginLoadingState != QSensorManagerPrivate::Loaded || alreadyRunning) { - // We're busy. - // Just note that a registration changed and exit. - // Someone up the call stack will deal with this. - sensorsChanged = true; - return; - } - - // Notify the client of the changes - Q_EMIT availableSensorsChanged(); - } -}; - -Q_GLOBAL_STATIC(QSensorManagerPrivate, sensorManagerPrivate) - -// The unit test needs to change the behaviour of the library. It does this -// through an exported but undocumented function. -static void initPlugin(QObject *plugin); -static QSettings::Scope settings_scope = QSettings::SystemScope; -QTM_SENSORS_EXPORT void qtm_sensors_unit_test_hook(int index) -{ - QSensorManagerPrivate *d = sensorManagerPrivate(); - - switch (index) { - case 0: - Q_ASSERT(d->pluginLoadingState == QSensorManagerPrivate::NotLoaded); - settings_scope = QSettings::UserScope; - break; - default: - break; - } -} - -static void initPlugin(QObject *o) -{ - if (!o) return; - - QSensorPluginInterface *plugin = qobject_cast<QSensorPluginInterface*>(o); - if (plugin) - plugin->registerSensors(); -} - -void QSensorManagerPrivate::loadPlugins() -{ - QSensorManagerPrivate *d = this; - if (d->pluginLoadingState != QSensorManagerPrivate::NotLoaded) return; - d->pluginLoadingState = QSensorManagerPrivate::Loading; - - SENSORLOG() << "initializing legacy static plugins"; - // Legacy static plugins - Q_FOREACH (CreatePluginFunc func, d->staticRegistrations) { - QObject *plugin = func(); - initPlugin(plugin); - } - - d->pluginLoadingState = QSensorManagerPrivate::Loaded; - - if (d->sensorsChanged) { - // Notify the app that the available sensor list has changed. - // This may cause recursive calls! - d->emitSensorsChanged(); - } -} - -// ===================================================================== - -/*! - \class QSensorManager - \ingroup sensors_backend - \inmodule QtSensors - \since 1.0 - - \brief The QSensorManager class handles registration and creation of sensor backends. - - Sensor plugins register backends using the registerBackend() function. - - When QSensor::connectToBackend() is called, the createBackend() function will be called. -*/ - -/*! - Register a sensor for \a type. The \a identifier must be unique. - - The \a factory will be asked to create instances of the backend. -*/ -void QSensorManager::registerBackend(const QByteArray &type, const QByteArray &identifier, QSensorBackendFactory *factory) -{ - Q_ASSERT(type.count()); - Q_ASSERT(identifier.count()); - Q_ASSERT(factory); - QSensorManagerPrivate *d = sensorManagerPrivate(); - if (!d->backendsByType.contains(type)) { - (void)d->backendsByType[type]; - d->firstIdentifierForType[type] = identifier; - } else if (d->firstIdentifierForType[type].startsWith("generic.")) { - // Don't let a generic backend be the default when some other backend exists! - d->firstIdentifierForType[type] = identifier; - } - FactoryForIdentifierMap &factoryByIdentifier = d->backendsByType[type]; - if (factoryByIdentifier.contains(identifier)) { - qWarning() << "A backend with type" << type << "and identifier" << identifier << "has already been registered!"; - return; - } - SENSORLOG() << "registering backend for type" << type << "identifier" << identifier;// << "factory" << QString().sprintf("0x%08x", (unsigned int)factory); - factoryByIdentifier[identifier] = factory; - - // Notify the app that the available sensor list has changed. - // This may cause recursive calls! - d->emitSensorsChanged(); -} - -/*! - Unregister the backend for \a type with \a identifier. - - Note that this only prevents new instance of the backend from being created. It does not - invalidate the existing instances of the backend. The backend code should handle the - disappearance of the underlying hardware itself. -*/ -void QSensorManager::unregisterBackend(const QByteArray &type, const QByteArray &identifier) -{ - QSensorManagerPrivate *d = sensorManagerPrivate(); - if (!d->backendsByType.contains(type)) { - qWarning() << "No backends of type" << type << "are registered"; - return; - } - FactoryForIdentifierMap &factoryByIdentifier = d->backendsByType[type]; - if (!factoryByIdentifier.contains(identifier)) { - qWarning() << "Identifier" << identifier << "is not registered"; - return; - } - - (void)factoryByIdentifier.take(identifier); // we don't own this pointer anyway - if (d->firstIdentifierForType[type] == identifier) { - if (factoryByIdentifier.count()) { - d->firstIdentifierForType[type] = factoryByIdentifier.begin().key(); - if (d->firstIdentifierForType[type].startsWith("generic.")) { - // Don't let a generic backend be the default when some other backend exists! - for (FactoryForIdentifierMap::const_iterator it = factoryByIdentifier.begin()++; it != factoryByIdentifier.end(); it++) { - const QByteArray &identifier(it.key()); - if (!identifier.startsWith("generic.")) { - d->firstIdentifierForType[type] = identifier; - break; - } - } - } - } else { - (void)d->firstIdentifierForType.take(type); - } - } - if (!factoryByIdentifier.count()) - (void)d->backendsByType.take(type); - - // Notify the app that the available sensor list has changed. - // This may cause recursive calls! - d->emitSensorsChanged(); -} - -/*! - \internal -*/ -void QSensorManager::registerStaticPlugin(CreatePluginFunc func) -{ - QSensorManagerPrivate *d = sensorManagerPrivate(); - d->staticRegistrations.append(func); -} - -/*! - Create a backend for \a sensor. Returns null if no suitable backend exists. -*/ -QSensorBackend *QSensorManager::createBackend(QSensor *sensor) -{ - Q_ASSERT(sensor); - - QSensorManagerPrivate *d = sensorManagerPrivate(); - d->loadPlugins(); - - SENSORLOG() << "QSensorManager::createBackend" << "type" << sensor->type() << "identifier" << sensor->identifier(); - - if (!d->backendsByType.contains(sensor->type())) { - SENSORLOG() << "no backends of type" << sensor->type() << "have been registered."; - return 0; - } - - const FactoryForIdentifierMap &factoryByIdentifier = d->backendsByType[sensor->type()]; - QSensorBackendFactory *factory; - QSensorBackend *backend; - - if (sensor->identifier().isEmpty()) { - QByteArray defaultIdentifier = QSensor::defaultSensorForType(sensor->type()); - SENSORLOG() << "Trying the default" << defaultIdentifier; - // No identifier set, try the default - factory = factoryByIdentifier[defaultIdentifier]; - //SENSORLOG() << "factory" << QString().sprintf("0x%08x", (unsigned int)factory); - sensor->setIdentifier(defaultIdentifier); // the factory requires this - backend = factory->createBackend(sensor); - if (backend) return backend; // Got it! - - // The default failed to instantiate so try any other registered sensors for this type - Q_FOREACH (const QByteArray &identifier, factoryByIdentifier.keys()) { - SENSORLOG() << "Trying" << identifier; - if (identifier == defaultIdentifier) continue; // Don't do the default one again - factory = factoryByIdentifier[identifier]; - //SENSORLOG() << "factory" << QString().sprintf("0x%08x", (unsigned int)factory); - sensor->setIdentifier(identifier); // the factory requires this - backend = factory->createBackend(sensor); - if (backend) return backend; // Got it! - } - SENSORLOG() << "FAILED"; - sensor->setIdentifier(QByteArray()); // clear the identifier - } else { - if (!factoryByIdentifier.contains(sensor->identifier())) { - SENSORLOG() << "no backend with identifier" << sensor->identifier() << "for type" << sensor->type(); - return 0; - } - - // We were given an explicit identifier so don't substitute other backends if it fails to instantiate - factory = factoryByIdentifier[sensor->identifier()]; - //SENSORLOG() << "factory" << QString().sprintf("0x%08x", (unsigned int)factory); - backend = factory->createBackend(sensor); - if (backend) return backend; // Got it! - } - - SENSORLOG() << "no suitable backend found for requested identifier" << sensor->identifier() << "and type" << sensor->type(); - return 0; -} - -/*! - Returns true if the backend identified by \a type and \a identifier is registered. - - This is a convenience method that helps out plugins doing dynamic registration. -*/ -bool QSensorManager::isBackendRegistered(const QByteArray &type, const QByteArray &identifier) -{ - QSensorManagerPrivate *d = sensorManagerPrivate(); - d->loadPlugins(); - - if (!d->backendsByType.contains(type)) - return false; - - const FactoryForIdentifierMap &factoryByIdentifier = d->backendsByType[type]; - if (!factoryByIdentifier.contains(identifier)) - return false; - - return true; -} - -// ===================================================================== - -/*! - Returns a list of all sensor types. -*/ -QList<QByteArray> QSensor::sensorTypes() -{ - QSensorManagerPrivate *d = sensorManagerPrivate(); - d->loadPlugins(); - - return d->backendsByType.keys(); -} - -/*! - Returns a list of ids for each of the sensors for \a type. - If there are no sensors of that type available the list will be empty. -*/ -QList<QByteArray> QSensor::sensorsForType(const QByteArray &type) -{ - QSensorManagerPrivate *d = sensorManagerPrivate(); - d->loadPlugins(); - - // no sensors of that type exist - if (!d->backendsByType.contains(type)) - return QList<QByteArray>(); - - return d->backendsByType[type].keys(); -} - -/*! - Returns the default sensor identifier for \a type. - This is set in a config file and can be overridden if required. - If no default is available the system will return the first registered - sensor for \a type. - - Note that there is special case logic to prevent the generic plugin's backends from becoming the - default when another backend is registered for the same type. This logic means that a backend - identifier starting with \c{generic.} will only be the default if no other backends have been - registered for that type or if it is specified in \c{Sensors.conf}. - - \sa {Determining the default sensor for a type} -*/ -QByteArray QSensor::defaultSensorForType(const QByteArray &type) -{ - QSensorManagerPrivate *d = sensorManagerPrivate(); - d->loadPlugins(); - - // no sensors of that type exist - if (!d->backendsByType.contains(type)) - return QByteArray(); - - // The unit test needs to modify Sensors.conf but it can't access the system directory - QSettings settings(settings_scope, QLatin1String("Nokia"), QLatin1String("Sensors")); - QVariant value = settings.value(QString(QLatin1String("Default/%1")).arg(QString::fromLatin1(type))); - if (!value.isNull()) { - QByteArray defaultIdentifier = value.toByteArray(); - if (d->backendsByType[type].contains(defaultIdentifier)) // Don't return a value that we can't use! - return defaultIdentifier; - } - - // This is our fallback - return d->firstIdentifierForType[type]; -} - -void QSensor::registerInstance() -{ - QSensorManagerPrivate *d = sensorManagerPrivate(); - connect(d, SIGNAL(availableSensorsChanged()), this, SIGNAL(availableSensorsChanged())); -} - -// ===================================================================== - -/*! - \class QSensorBackendFactory - \ingroup sensors_backend - \inmodule QtSensors - - \brief The QSensorBackendFactory class instantiates instances of - QSensorBackend. - - This interface must be implemented in order to register a sensor backend. - - \sa {Creating a sensor plugin} -*/ - -/*! - \fn QSensorBackendFactory::~QSensorBackendFactory() - \internal -*/ - -/*! - \fn QSensorBackendFactory::createBackend(QSensor *sensor) - - Instantiate a backend. If the factory handles multiple identifiers - it should check with the \a sensor to see which one is requested. - - If the factory cannot create a backend it should return 0. -*/ - -/*! - \macro REGISTER_STATIC_PLUGIN(pluginname) - \relates QSensorManager - - Registers a static plugin, \a pluginname. - - Note that this macro relies on static initialization so it may not be appropriate - for use in a library and may not work on all platforms. - - \sa {Creating a sensor plugin} -*/ - -#include "qsensormanager.moc" -#include "moc_qsensormanager_p.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qsensormanager_p.h b/src/qtmsensors/qsensormanager_p.h deleted file mode 100644 index 24121412..00000000 --- a/src/qtmsensors/qsensormanager_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QSENSORMANAGER_P_H -#define QTM_QSENSORMANAGER_P_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QSensorBackend; -class QSensorBackendFactory; - -typedef QObject *(*CreatePluginFunc)(); - -class QTM_SENSORS_EXPORT QSensorManager -{ -public: - // Register a backend (call this from a plugin) - static void registerBackend(const QByteArray &type, const QByteArray &identifier, QSensorBackendFactory *factory); - static void unregisterBackend(const QByteArray &type, const QByteArray &identifier); - - static bool isBackendRegistered(const QByteArray &type, const QByteArray &identifier); - - // Create a backend (uses the type and identifier set in the sensor) - static QSensorBackend *createBackend(QSensor *sensor); - - // For the unit test - static void registerStaticPlugin(CreatePluginFunc func); -}; - -class QTM_SENSORS_EXPORT QSensorPluginInterface : public QObject -{ - Q_OBJECT -public: - virtual void registerSensors() = 0; -protected: - ~QSensorPluginInterface() {} -}; - -class QTM_SENSORS_EXPORT QSensorBackendFactory -{ -public: - virtual QSensorBackend *createBackend(QSensor *sensor) = 0; -protected: - ~QSensorBackendFactory() {} -}; - -// Legacy static plugins have their own registration methods. -// They can only register types. They cannot use the changes interface. -#define REGISTER_STATIC_PLUGIN_V1(pluginname) \ - static QObject *create_static_plugin_ ## pluginname()\ - {\ - return new pluginname;\ - }\ - static bool side_effect_sensor_backend_ ## pluginname ()\ - {\ - QSensorManager::registerStaticPlugin(create_static_plugin_ ## pluginname);\ - return false;\ - }\ - /* This assignment calls the function above */\ - static bool dummy_sensor_backend_ ## pluginname = side_effect_sensor_backend_ ## pluginname(); - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qtapsensor.cpp b/src/qtmsensors/qtapsensor.cpp deleted file mode 100644 index fded7b36..00000000 --- a/src/qtmsensors/qtapsensor.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtapsensor.h" -#include "qtapsensor_p.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(QTapReading) - -/*! - \class QTapReading - \ingroup sensors_reading - \inmodule QtSensors - \since 1.0 - - \brief The QTapReading class represents one reading from the - tap sensor. - - \section2 QTapReading Units - The tap sensor registers tap events along the 3 axes that originate from the phone. - The axes are arranged as follows. - - \image sensors-coordinates2.jpg - - By default it returns only double tap events. The QTapSensor::returnDoubleTapEvents property - must be set to false to return individual tap events. -*/ - -/*! - \enum QTapReading::TapDirection - - The tap direction is indicated using flags. Applications should check for the presence of - a particular flag as multiple flags may be set at once. - - The X, Y and Z flags allow an app to check for taps along an axis without caring about the - direction. - - \code - if (reading->tapDirection()&QTapReading::X) { - ... - } - \endcode - - The *_Pos and *_Neg flags allow checking for taps in a specific direction. Note that some - devices cannot determine the direction of a tap and will set both the _Pos and _Neg flag for - the detected axis. Previous versions of the API did not allow this. Applications that check - for the _Pos and _Neg flags as values should be updated so they can work with all devices. - - \oldcode - if (reading->tapDirection() == QTapReading::X_Pos) { - ... - } - \newcode - if (reading->tapDirection()&QTapReading::X_Pos) { - ... - } - \endcode - - \value Undefined This value means that the direction is unknown. - \value X This flag is set if the tap was along the X axis. - \value Y This flag is set if the tap was along the Y axis. - \value Z This flag is set if the tap was along the Z axis. - \value X_Pos This flag is set if the tap was towards the positive X direction. - \value Y_Pos This flag is set if the tap was towards the positive Y direction. - \value Z_Pos This flag is set if the tap was towards the positive Z direction. - \value X_Neg This flag is set if the tap was towards the negative X direction. - \value Y_Neg This flag is set if the tap was towards the negative Y direction. - \value Z_Neg This flag is set if the tap was towards the negative Z direction. - \value X_Both Equivalent to \c{X_Pos|X_Neg}. Returned by devices that cannot detect the direction of a tap. - \value Y_Both Equivalent to \c{Y_Pos|Y_Neg}. Returned by devices that cannot detect the direction of a tap. - \value Z_Both Equivalent to \c{Z_Pos|Z_Neg}. Returned by devices that cannot detect the direction of a tap. -*/ - -/*! - \property QTapReading::tapDirection - \brief the direction of the tap. - - \sa {QTapReading Units} -*/ - -QTapReading::TapDirection QTapReading::tapDirection() const -{ - return static_cast<QTapReading::TapDirection>(d->tapDirection); -} - -/*! - Sets the tap direction to \a tapDirection. -*/ -void QTapReading::setTapDirection(QTapReading::TapDirection tapDirection) -{ - switch (tapDirection) { - case X_Pos: - case Y_Pos: - case Z_Pos: - case X_Neg: - case Y_Neg: - case Z_Neg: - case X_Both: - case Y_Both: - case Z_Both: - d->tapDirection = tapDirection; - break; - default: - d->tapDirection = Undefined; - break; - } -} - -/*! - \property QTapReading::doubleTap - \brief a value indicating if there was a single or double tap. - - \list - \o true - double tap - \o false - single tap - \endlist - \sa {QTapReading Units} -*/ - -bool QTapReading::isDoubleTap() const -{ - return d->doubleTap; -} - -/*! - Sets the double tap status of the reading to \a doubleTap. -*/ -void QTapReading::setDoubleTap(bool doubleTap) -{ - d->doubleTap = doubleTap; -} - -// ===================================================================== - -/*! - \class QTapFilter - \ingroup sensors_filter - \inmodule QtSensors - - \brief The QTapFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to QTapReading - instead of QSensorReading. -*/ - -/*! - \fn QTapFilter::filter(QTapReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const QTapSensor::type("QTapSensor"); - -/*! - \class QTapSensor - \ingroup sensors_type - \inmodule QtSensors - - \brief The QTapSensor 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 QTapReading instead of a QSensorReading. - - For details about how the sensor works, see \l QTapReading. - - \sa QTapReading -*/ - -/*! - \fn QTapSensor::QTapSensor(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/*! - \fn QTapSensor::~QTapSensor() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/*! - \fn QTapSensor::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ - -/*! - \property QTapSensor::returnDoubleTapEvents - \brief a value indicating if double tap events should be reported. - - Set to true (the default) to have the sensor report only on double tap events. - Set to false to have the sensor report only on individual tap events. - - It is not possible to have the sensor report both single and double tap events. - If both are needed the app should create 2 sensor objects. - - Note that you must access this property via QObject::property() and QObject::setProperty(). - The property must be set before calling start(). -*/ - -#include "moc_qtapsensor.cpp" -QTM_END_NAMESPACE -QT_END_NAMESPACE - diff --git a/src/qtmsensors/qtapsensor.h b/src/qtmsensors/qtapsensor.h deleted file mode 100644 index 82453a40..00000000 --- a/src/qtmsensors/qtapsensor.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QTAPSENSOR_H -#define QTM_QTAPSENSOR_H - -#include "qsensor.h" - -QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QTapReadingPrivate; - -class QTM_SENSORS_EXPORT QTapReading : public QSensorReading -{ - Q_OBJECT - Q_ENUMS(TapDirection) - Q_PROPERTY(TapDirection tapDirection READ tapDirection) - Q_PROPERTY(bool doubleTap READ isDoubleTap) - DECLARE_READING(QTapReading) -public: - enum TapDirection { - Undefined = 0, - X = 0x0001, - Y = 0x0002, - Z = 0x0004, - X_Pos = 0x0011, - Y_Pos = 0x0022, - Z_Pos = 0x0044, - X_Neg = 0x0101, - Y_Neg = 0x0202, - Z_Neg = 0x0404, - X_Both = 0x0111, - Y_Both = 0x0222, - Z_Both = 0x0444 - }; - - TapDirection tapDirection() const; - void setTapDirection(TapDirection tapDirection); - - bool isDoubleTap() const; - void setDoubleTap(bool doubleTap); -}; - -class QTM_SENSORS_EXPORT QTapFilter : public QSensorFilter -{ -public: - virtual bool filter(QTapReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<QTapReading*>(reading)); } -}; - -class QTM_SENSORS_EXPORT QTapSensor : public QSensor -{ - Q_OBJECT -#ifdef Q_QDOC - Q_PROPERTY(bool returnDoubleTapEvents) -#endif -public: - explicit QTapSensor(QObject *parent = 0) : QSensor(QTapSensor::type, parent) {} - virtual ~QTapSensor() {} - QTapReading *reading() const { return static_cast<QTapReading*>(QSensor::reading()); } - static char const * const type; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qtapsensor_p.h b/src/qtmsensors/qtapsensor_p.h deleted file mode 100644 index 7296f55a..00000000 --- a/src/qtmsensors/qtapsensor_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTM_QTAPSENSOR_P_H -#define QTM_QTAPSENSOR_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_NAMESPACE -QTM_BEGIN_NAMESPACE - -class QTapReadingPrivate -{ -public: - QTapReadingPrivate() - : tapDirection(0) - , doubleTap(false) - { - } - - int tapDirection; - bool doubleTap; -}; - -QTM_END_NAMESPACE -QT_END_NAMESPACE - -#endif - diff --git a/src/qtmsensors/qtmsensors.pro b/src/qtmsensors/qtmsensors.pro deleted file mode 100644 index d8f02128..00000000 --- a/src/qtmsensors/qtmsensors.pro +++ /dev/null @@ -1,51 +0,0 @@ -load(qt_module) - -TARGET = QtmSensors -QPRO_PWD = $$PWD - -CONFIG += module -CONFIG += strict_flags -#CONFIG(debug,debug|release): -DEFINES += ENABLE_RUNTIME_SENSORLOG - -MODULE_PRI = ../../modules/qt_sensors.pri - -QT = core sensors-private - -DEFINES += QTM_BUILD_SENSORS_LIB QT_MAKEDLL - -load(qt_module_config) - -HEADERS += \ - qtmsensorsversion.h\ - qtmsensorsglobal.h\ - qsensorbackend_p.h\ - qsensormanager_p.h\ - backendwrapper_p.h - -SOURCES += \ - qsensorbackend.cpp\ - qsensormanager.cpp\ - backendwrapper.cpp - -# 3 files per sensor (including QSensor) -SENSORS=\ - qsensor\ - qaccelerometer\ - qambientlightsensor\ - qcompass\ - qlightsensor\ - qmagnetometer\ - qorientationsensor\ - qproximitysensor\ - qrotationsensor\ - qtapsensor\ - qgyroscope - -for(s,SENSORS) { - # Client API - HEADERS += $${s}.h - SOURCES += $${s}.cpp - # Private header - HEADERS += $${s}_p.h -} diff --git a/src/qtmsensors/qtmsensorsglobal.h b/src/qtmsensors/qtmsensorsglobal.h deleted file mode 100644 index 078ac897..00000000 --- a/src/qtmsensors/qtmsensorsglobal.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef QTMSENSORSGLOBAL_H -#define QTMSENSORSGLOBAL_H - -#include <QtCore/qglobal.h> - -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) -# if defined(QT_NODLL) -# undef QT_MAKEDLL -# undef QT_DLL -# elif defined(QT_MAKEDLL) /* create a Qt DLL library */ -# if defined(QT_DLL) -# undef QT_DLL -# endif -# if defined(QT_BUILD_SENSORS1_LIB) -# define QTM_SENSORS_EXPORT Q_DECL_EXPORT -# else -# define QTM_SENSORS_EXPORT Q_DECL_IMPORT -# endif -# define Q_TEMPLATEDLL -# elif defined(QT_DLL) /* use a Qt DLL library */ -# define QTM_SENSORS_EXPORT Q_DECL_IMPORT -# define Q_TEMPLATEDLL -# endif -# define Q_NO_DECLARED_NOT_DEFINED -#else -# if defined(Q_OS_LINUX) && defined(Q_CC_BOR) -# define Q_TEMPLATEDLL -# define Q_NO_DECLARED_NOT_DEFINED -# endif -# undef QT_MAKEDLL /* ignore these for other platforms */ -# undef QT_DLL -#endif - -#if !defined(QTM_SENSORS_EXPORT) -# if defined(QT_SHARED) -# define QTM_SENSORS_EXPORT Q_DECL_EXPORT -# else -# define QTM_SENSORS_EXPORT -# endif -#endif - -#define QTM_BEGIN_NAMESPACE namespace QtMobility { -#define QTM_END_NAMESPACE } -#define QTM_USE_NAMESPACE using namespace QtMobility; -#define QTM_PREPEND_NAMESPACE(x) QtMobility::x - -#if QT_PREPEND_NAMESPACE -#define NEW_NAMESPACE(x) QT_PREPEND_NAMESPACE(x) -#else -#define NEW_NAMESPACE(x) ::x -#endif - -#endif diff --git a/src/sensors/qsensorbackend.h b/src/sensors/qsensorbackend.h index b791f73f..43b2aaa9 100644 --- a/src/sensors/qsensorbackend.h +++ b/src/sensors/qsensorbackend.h @@ -42,13 +42,11 @@ #ifndef QSENSORBACKEND_H #define QSENSORBACKEND_H -#include <QObject> +#include "qsensor.h" +#include "qsensormanager.h" QT_BEGIN_NAMESPACE -class QSensor; -class QSensorReading; - class Q_SENSORS_EXPORT QSensorBackend : public QObject { Q_OBJECT diff --git a/src/sensors/qsensormanager.h b/src/sensors/qsensormanager.h index d1d611b5..3fa76987 100644 --- a/src/sensors/qsensormanager.h +++ b/src/sensors/qsensormanager.h @@ -42,7 +42,7 @@ #ifndef QSENSORMANAGER_H #define QSENSORMANAGER_H -#include <QtSensors/QSensor> +#include "qsensor.h" QT_BEGIN_NAMESPACE diff --git a/src/src.pro b/src/src.pro index 036a883b..26f89a1f 100644 --- a/src/src.pro +++ b/src/src.pro @@ -4,15 +4,10 @@ SUBDIRS += sensors sensors.subdir = sensors sensors.target = sub-sensors -SUBDIRS += qtmsensors -qtmsensors.subdir = qtmsensors -qtmsensors.target = sub-qtmsensors -qtmsensors.depends = sensors - SUBDIRS += imports imports.subdir = imports imports.target = sub-imports -imports.depends = sensors qtmsensors +imports.depends = sensors SUBDIRS += plugins plugins.subdir = plugins diff --git a/sync.profile b/sync.profile index 840ae0d7..b309f724 100644 --- a/sync.profile +++ b/sync.profile @@ -1,18 +1,15 @@ %modules = ( # path to module name map "QtSensors" => "$basedir/src/sensors", - "QtmSensors" => "$basedir/src/qtmsensors", ); %moduleheaders = ( # restrict the module headers to those found in relative path ); %classnames = ( "qtsensorsversion.h" => "QtSensorsVersion", - "qtmsensorsversion.h" => "QtmSensorsVersion", ); %mastercontent = ( ); %modulepris = ( "QtSensors" => "$basedir/modules/qt_sensors.pri", - "QtmSensors" => "$basedir/modules/qt_sensors.pri", ); %dependencies = ( "qtbase" => "refs/heads/master", diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 788e2753..b303c70b 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs SUBDIRS += qsensor -SUBDIRS += qtmsensor + diff --git a/tests/auto/qsensor/test_backends.cpp b/tests/auto/qsensor/test_backends.cpp index f8ac2622..b091d2f8 100644 --- a/tests/auto/qsensor/test_backends.cpp +++ b/tests/auto/qsensor/test_backends.cpp @@ -41,8 +41,7 @@ #include <QList> -#include <QtSensors/qsensorbackend.h> -#include <QtSensors/qsensormanager.h> +#include "qsensorbackend.h" typedef QSensorBackend* (*CreateFunc) (QSensor *sensor); class Record diff --git a/tests/auto/qsensor/test_backends.h b/tests/auto/qsensor/test_backends.h index 376d7ca5..d58793da 100644 --- a/tests/auto/qsensor/test_backends.h +++ b/tests/auto/qsensor/test_backends.h @@ -42,21 +42,21 @@ #ifndef TEST_BACKENDS_H #define TEST_BACKENDS_H -#include <QtSensors/qsensorbackend.h> +#include <qsensorbackend.h> void register_test_backends(); void unregister_test_backends(); -#include <QtSensors/qaccelerometer.h> -#include <QtSensors/qambientlightsensor.h> -#include <QtSensors/qcompass.h> -#include <QtSensors/qgyroscope.h> -#include <QtSensors/qlightsensor.h> -#include <QtSensors/qmagnetometer.h> -#include <QtSensors/qorientationsensor.h> -#include <QtSensors/qproximitysensor.h> -#include <QtSensors/qrotationsensor.h> -#include <QtSensors/qtapsensor.h> +#include <qaccelerometer.h> +#include <qambientlightsensor.h> +#include <qcompass.h> +#include <qgyroscope.h> +#include <qlightsensor.h> +#include <qmagnetometer.h> +#include <qorientationsensor.h> +#include <qproximitysensor.h> +#include <qrotationsensor.h> +#include <qtapsensor.h> #define PREPARE_SENSORINTERFACE_DECLS(SensorClass, ReadingClass, FilterClass, readingcode)\ class SensorClass ## _impl : public QSensorBackend\ diff --git a/tests/auto/qsensor/test_sensor.h b/tests/auto/qsensor/test_sensor.h index 436af251..cc7a278a 100644 --- a/tests/auto/qsensor/test_sensor.h +++ b/tests/auto/qsensor/test_sensor.h @@ -42,7 +42,7 @@ #ifndef TEST_SENSOR_H #define TEST_SENSOR_H -#include <QtSensors/qsensor.h> +#include <qsensor.h> class TestSensorReadingPrivate; diff --git a/tests/auto/qsensor/test_sensor2.h b/tests/auto/qsensor/test_sensor2.h index ba632b3e..93b20687 100644 --- a/tests/auto/qsensor/test_sensor2.h +++ b/tests/auto/qsensor/test_sensor2.h @@ -42,7 +42,7 @@ #ifndef TEST_SENSOR2_H #define TEST_SENSOR2_H -#include <QtSensors/qsensor.h> +#include "qsensor.h" #undef DECLARE_READING #undef DECLARE_READING_D diff --git a/tests/auto/qsensor/test_sensor2_p.h b/tests/auto/qsensor/test_sensor2_p.h index 87a9e637..0e84230d 100644 --- a/tests/auto/qsensor/test_sensor2_p.h +++ b/tests/auto/qsensor/test_sensor2_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include <5.0.0/QtSensors/private/qsensor_p.h> +#include "private/qsensor_p.h" class TestSensor2ReadingPrivate : public QSensorReadingPrivate { diff --git a/tests/auto/qsensor/test_sensor2impl.cpp b/tests/auto/qsensor/test_sensor2impl.cpp index fcecef29..04ee6fb0 100644 --- a/tests/auto/qsensor/test_sensor2impl.cpp +++ b/tests/auto/qsensor/test_sensor2impl.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "test_sensor2impl.h" +#include <qaccelerometer.h> #include <QDebug> char const * const testsensor2impl::id("test sensor 2 impl"); diff --git a/tests/auto/qsensor/test_sensor2impl.h b/tests/auto/qsensor/test_sensor2impl.h index ebd72192..7fb0b348 100644 --- a/tests/auto/qsensor/test_sensor2impl.h +++ b/tests/auto/qsensor/test_sensor2impl.h @@ -42,7 +42,7 @@ #ifndef TEST_SENSOR2IMPL_H #define TEST_SENSOR2IMPL_H -#include <QtSensors/qsensorbackend.h> +#include <qsensorbackend.h> #include "test_sensor2.h" class testsensor2impl : public QSensorBackend diff --git a/tests/auto/qsensor/test_sensorimpl.h b/tests/auto/qsensor/test_sensorimpl.h index d8fff884..35afb7ee 100644 --- a/tests/auto/qsensor/test_sensorimpl.h +++ b/tests/auto/qsensor/test_sensorimpl.h @@ -42,7 +42,7 @@ #ifndef TEST_SENSORIMPL_H #define TEST_SENSORIMPL_H -#include <QtSensors/qsensorbackend.h> +#include <qsensorbackend.h> #include "test_sensor.h" class testsensorimpl : public QSensorBackend diff --git a/tests/auto/qsensor/test_sensorplugin.cpp b/tests/auto/qsensor/test_sensorplugin.cpp index 9f2d69c8..c501377a 100644 --- a/tests/auto/qsensor/test_sensorplugin.cpp +++ b/tests/auto/qsensor/test_sensorplugin.cpp @@ -41,9 +41,9 @@ #include "test_sensorimpl.h" #include "test_sensor2impl.h" -#include <QtSensors/qsensorplugin.h> -#include <QtSensors/qsensorbackend.h> -#include <QtSensors/qsensormanager.h> +#include <qsensorplugin.h> +#include <qsensorbackend.h> +#include <qsensormanager.h> #include <QFile> #include <QDebug> #include <QTest> diff --git a/tests/auto/qsensor/tst_qsensor.cpp b/tests/auto/qsensor/tst_qsensor.cpp index 7807bc87..0765750d 100644 --- a/tests/auto/qsensor/tst_qsensor.cpp +++ b/tests/auto/qsensor/tst_qsensor.cpp @@ -49,7 +49,6 @@ #include <QSignalSpy> #include "qsensor.h" -#include "qsensormanager.h" #include "test_sensor.h" #include "test_sensor2.h" #include "test_sensorimpl.h" diff --git a/tests/auto/qtmsensor/main.cpp b/tests/auto/qtmsensor/main.cpp deleted file mode 100644 index 92e24755..00000000 --- a/tests/auto/qtmsensor/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "gruesensorimpl.h" -#include <qsensorplugin.h> -#include <qsensorbackend.h> -#include <qsensormanager.h> -#include <QFile> -#include <QDebug> - -class GrueSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory -{ - Q_OBJECT - Q_INTERFACES(QtMobility::QSensorPluginInterface) -public: - void registerSensors() - { - qDebug() << "loaded the grue plugin"; - QSensorManager::registerBackend(GrueSensor::type, gruesensorimpl::id, this); - } - - QSensorBackend *createBackend(QSensor *sensor) - { - if (sensor->identifier() == gruesensorimpl::id) { - // Can't make this unless we have an ambient light sensor - if (!QSensor::defaultSensorForType(QAmbientLightSensor::type).isEmpty()) - return new gruesensorimpl(sensor); - qDebug() << "can't make" << sensor->identifier() << "because no" << QAmbientLightSensor::type << "sensors exist"; - } - - return 0; - } -}; - -Q_EXPORT_PLUGIN2(libsensors_grueplugin, GrueSensorPlugin); - -#include "main.moc" - diff --git a/tests/auto/qtmsensor/qtmsensor.pro b/tests/auto/qtmsensor/qtmsensor.pro deleted file mode 100644 index 78e41c18..00000000 --- a/tests/auto/qtmsensor/qtmsensor.pro +++ /dev/null @@ -1,36 +0,0 @@ -TEMPLATE = app -TARGET = tst_qtmsensor - -CONFIG += testcase -QT = core testlib qtmsensors-private - -SOURCES += \ - tst_qtmsensor.cpp - -HEADERS += \ - ../qsensor/test_sensor.h\ - ../qsensor/test_sensor_p.h\ - ../qsensor/test_sensorimpl.h\ - ../qsensor/test_sensor2.h\ - ../qsensor/test_sensor2_p.h\ - ../qsensor/test_sensor2impl.h\ - ../qsensor/test_backends.h - -SOURCES += \ - ../qsensor/test_sensor.cpp\ - ../qsensor/test_sensorimpl.cpp\ - ../qsensor/test_sensor2.cpp\ - ../qsensor/test_sensor2impl.cpp\ - ../qsensor/test_sensorplugin.cpp\ - ../qsensor/test_backends.cpp - -HEADERS += \ - test_sensor_qtm.h \ - test_sensor_qtm_p.h \ - test_sensor_wrapper.h \ - test_backends_qtm.h - -SOURCES += \ - test_sensor_qtm.cpp \ - test_sensor_wrapper.cpp \ - test_backends_qtm.cpp diff --git a/tests/auto/qtmsensor/test_backends_qtm.cpp b/tests/auto/qtmsensor/test_backends_qtm.cpp deleted file mode 100644 index 2d98baa5..00000000 --- a/tests/auto/qtmsensor/test_backends_qtm.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QList> - -#include <private/qsensorbackend_p.h> -#include <private/qsensormanager_p.h> - -QTM_BEGIN_NAMESPACE - -typedef QSensorBackend* (*CreateFunc) (QSensor *sensor); - -class Record -{ -public: - QByteArray type; - CreateFunc func; -}; -static QList<Record> records; - -static bool registerTestBackend(const char *className, CreateFunc func) -{ - Record record; - record.type = className; - record.func = func; - records << record; - return true; -} - -QTM_END_NAMESPACE - -#define REGISTER_TOO -#include "test_backends_qtm.h" -#include <QDebug> - -QTM_BEGIN_NAMESPACE - -class BackendFactory : public QSensorBackendFactory -{ - QSensorBackend *createBackend(QSensor *sensor) - { - foreach (const Record &record, records) { - if (sensor->identifier() == record.type) { - return record.func(sensor); - } - } - return 0; - }; -}; -static BackendFactory factory; - -void register_test_backends() -{ - foreach (const Record &record, records) { - QSensorManager::registerBackend(record.type, record.type, &factory); - } -} - -void unregister_test_backends() -{ - foreach (const Record &record, records) { - QSensorManager::unregisterBackend(record.type, record.type); - } -} - -QTM_END_NAMESPACE diff --git a/tests/auto/qtmsensor/test_backends_qtm.h b/tests/auto/qtmsensor/test_backends_qtm.h deleted file mode 100644 index 9c42de5b..00000000 --- a/tests/auto/qtmsensor/test_backends_qtm.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEST_BACKENDS_H -#define TEST_BACKENDS_H - -#include <private/qsensorbackend_p.h> - -#include <qaccelerometer.h> -#include <qambientlightsensor.h> -#include <qcompass.h> -#include <qgyroscope.h> -#include <qlightsensor.h> -#include <qmagnetometer.h> -#include <qorientationsensor.h> -#include <qproximitysensor.h> -#include <qrotationsensor.h> -#include <qtapsensor.h> - -QTM_BEGIN_NAMESPACE - -void register_test_backends(); -void unregister_test_backends(); - -#define PREPARE_SENSORINTERFACE_DECLS(SensorClass, ReadingClass, FilterClass, readingcode)\ - class SensorClass ## _impl : public QSensorBackend\ - {\ - public:\ - SensorClass ## _impl(QSensor *sensor);\ - void start();\ - void stop();\ - };\ - class SensorClass ## _testfilter : public FilterClass { bool filter(ReadingClass *); }; - -#define PREPARE_SENSORINTERFACE_IMPLS(SensorClass, ReadingClass, FilterClass, readingcode)\ - SensorClass ## _impl::SensorClass ##_impl(QSensor *sensor) : QSensorBackend(sensor) {}\ - void SensorClass ## _impl::start() {\ - ReadingClass *reading = setReading<ReadingClass>(0);\ - readingcode\ - newReadingAvailable();\ - }\ - void SensorClass ##_impl::stop() {}\ - bool SensorClass ## _testfilter::filter(ReadingClass *) { return true; }\ - static QSensorBackend *create_ ## SensorClass ## _impl(QSensor *sensor) { return new SensorClass ## _impl(sensor); }\ - static bool registered_ ## SensorClass = registerTestBackend(#SensorClass, create_ ## SensorClass ## _impl); - -#ifdef REGISTER_TOO -#define PREPARE_SENSORINTERFACE(SensorClass, ReadingClass, FilterClass, readingcode)\ - PREPARE_SENSORINTERFACE_DECLS(SensorClass, ReadingClass, FilterClass, readingcode)\ - PREPARE_SENSORINTERFACE_IMPLS(SensorClass, ReadingClass, FilterClass, readingcode) -#else -#define PREPARE_SENSORINTERFACE(SensorClass, ReadingClass, FilterClass, readingcode)\ - PREPARE_SENSORINTERFACE_DECLS(SensorClass, ReadingClass, FilterClass, readingcode) -#endif - -PREPARE_SENSORINTERFACE(QAccelerometer, QAccelerometerReading, QAccelerometerFilter, { - reading->setX(1.0); - reading->setY(1.0); - reading->setZ(1.0); -}) -PREPARE_SENSORINTERFACE(QAmbientLightSensor, QAmbientLightReading, QAmbientLightFilter, { - reading->setLightLevel(QAmbientLightReading::Twilight); -}) -PREPARE_SENSORINTERFACE(QCompass, QCompassReading, QCompassFilter, { - reading->setAzimuth(1.0); - reading->setCalibrationLevel(1.0); -}) -PREPARE_SENSORINTERFACE(QGyroscope, QGyroscopeReading, QGyroscopeFilter, { - reading->setX(1.0); - reading->setY(1.0); - reading->setZ(1.0); -}) -PREPARE_SENSORINTERFACE(QLightSensor, QLightReading, QLightFilter, { - reading->setLux(1.0); -}) -PREPARE_SENSORINTERFACE(QMagnetometer, QMagnetometerReading, QMagnetometerFilter, { - reading->setX(1.0); - reading->setY(1.0); - reading->setZ(1.0); - reading->setCalibrationLevel(1.0); -}) -PREPARE_SENSORINTERFACE(QOrientationSensor, QOrientationReading, QOrientationFilter, { - reading->setOrientation(QOrientationReading::LeftUp); -}) -PREPARE_SENSORINTERFACE(QProximitySensor, QProximityReading, QProximityFilter, { - reading->setClose(true); -}) -PREPARE_SENSORINTERFACE(QRotationSensor, QRotationReading, QRotationFilter, { - reading->setX(1.0); - reading->setY(1.0); - reading->setZ(1.0); -}) -PREPARE_SENSORINTERFACE(QTapSensor, QTapReading, QTapFilter, { - reading->setTapDirection(QTapReading::Z_Both); - reading->setDoubleTap(true); -}) - -#define TEST_SENSORINTERFACE(SensorClass, ReadingClass, readingcode)\ - do {\ - SensorClass sensor;\ - SensorClass ## _testfilter filter;\ - sensor.addFilter(&filter);\ - sensor.start();\ - QVERIFY(sensor.isConnectedToBackend());\ - QVERIFY(sensor.isActive());\ - ReadingClass *reading = sensor.reading();\ - QVERIFY(reading != 0);\ - readingcode\ - } while (0); - -#endif - -QTM_END_NAMESPACE diff --git a/tests/auto/qtmsensor/test_sensor_qtm.cpp b/tests/auto/qtmsensor/test_sensor_qtm.cpp deleted file mode 100644 index ee77a7ae..00000000 --- a/tests/auto/qtmsensor/test_sensor_qtm.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "test_sensor_qtm.h" -#include "test_sensor_qtm_p.h" - -QTM_BEGIN_NAMESPACE - -IMPLEMENT_READING(TestSensorReading) - -int TestSensorReading::test() const -{ - return d->test; -} - -void TestSensorReading::setTest(int test) -{ - d->test = test; -} - -// ===================================================================== - -const char *TestSensor::type("test sensor"); - -#include "moc_test_sensor_qtm.cpp" -QTM_END_NAMESPACE diff --git a/tests/auto/qtmsensor/test_sensor_qtm.h b/tests/auto/qtmsensor/test_sensor_qtm.h deleted file mode 100644 index 1946d3b1..00000000 --- a/tests/auto/qtmsensor/test_sensor_qtm.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEST_SENSOR_QTM_H -#define TEST_SENSOR_QTM_H - -#include <qsensor.h> - -QTM_BEGIN_NAMESPACE - -class TestSensorReadingPrivate; - -class TestSensorReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(int test READ test) - DECLARE_READING(TestSensorReading) -public: - int test() const; - void setTest(int test); -}; - -class TestSensorFilter : public QSensorFilter -{ -public: - virtual bool filter(TestSensorReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast<TestSensorReading*>(reading)); } -}; - -class TestSensor : public QSensor -{ - Q_OBJECT -public: - explicit TestSensor(QObject *parent = 0) - : QSensor(TestSensor::type, parent) - , sensorsChangedEmitted(0) - { - connect(this, SIGNAL(availableSensorsChanged()), this, SLOT(s_availableSensorsChanged())); - } - virtual ~TestSensor() {} - TestSensorReading *reading() const { return static_cast<TestSensorReading*>(QSensor::reading()); } - static const char *type; - - // used by the testSensorsChangedSignal test function - int sensorsChangedEmitted; -private slots: - void s_availableSensorsChanged() - { - sensorsChangedEmitted++; - } -}; - -QTM_END_NAMESPACE - -#endif diff --git a/tests/auto/qtmsensor/test_sensor_qtm_p.h b/tests/auto/qtmsensor/test_sensor_qtm_p.h deleted file mode 100644 index 145b48eb..00000000 --- a/tests/auto/qtmsensor/test_sensor_qtm_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEST_SENSOR_QTM_P_H -#define TEST_SENSOR_QTM_P_H - -QTM_BEGIN_NAMESPACE - -// -// 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. -// - -class TestSensorReadingPrivate -{ -public: - TestSensorReadingPrivate() - : test(0) - { - } - - int test; -}; - -QTM_END_NAMESPACE - -#endif diff --git a/tests/auto/qtmsensor/test_sensor_wrapper.cpp b/tests/auto/qtmsensor/test_sensor_wrapper.cpp deleted file mode 100644 index d236cc94..00000000 --- a/tests/auto/qtmsensor/test_sensor_wrapper.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "test_sensor_wrapper.h" -#include <private/qsensormanager_p.h> -#include <QDebug> - -QTM_BEGIN_NAMESPACE - -class WrapperFactory : public QSensorPluginInterface, - public QSensorBackendFactory -{ -public: - void registerSensors() - { - QList<QByteArray> types; - types << TestSensor::type; - foreach (const QByteArray &type, types) { - foreach (const QByteArray &identifier, NEW_NAMESPACE(QSensor)::sensorsForType(type)) { - //qDebug() << "Registerbackend" << type << identifier; - QSensorManager::registerBackend(type, identifier, this); - } - } - } - - QSensorBackend *createBackend(QSensor *sensor) - { - if (sensor->identifier() == "test sensor impl") { - return new TestSensorWrapper(sensor); - } - - qWarning() << "Can't create backend" << sensor->identifier(); - return 0; - } -}; - -REGISTER_STATIC_PLUGIN_V1(WrapperFactory) - -IMPLEMENT_WRAPPER(TestSensor, TestSensorReading, { - //qDebug() << "fetchData" << sensor->reading()->timestamp(); - m_reading.setTimestamp(sensor->reading()->timestamp()); - m_reading.setTest(sensor->reading()->test()); - newReadingAvailable(); - }) - -QTM_END_NAMESPACE diff --git a/tests/auto/qtmsensor/test_sensor_wrapper.h b/tests/auto/qtmsensor/test_sensor_wrapper.h deleted file mode 100644 index adfc6c22..00000000 --- a/tests/auto/qtmsensor/test_sensor_wrapper.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TEST_SENSOR_WRAPPER_H -#define TEST_SENSOR_WRAPPER_H - -#include <private/backendwrapper_p.h> -#include "../qsensor/test_sensor.h" -#include "test_sensor_qtm.h" - -QTM_BEGIN_NAMESPACE - -DECLARE_WRAPPER(TestSensor, TestSensorReading) - -QTM_END_NAMESPACE - -#endif diff --git a/tests/auto/qtmsensor/tst_qtmsensor.cpp b/tests/auto/qtmsensor/tst_qtmsensor.cpp deleted file mode 100644 index 40f90670..00000000 --- a/tests/auto/qtmsensor/tst_qtmsensor.cpp +++ /dev/null @@ -1,766 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//TESTED_COMPONENT=src/sensors - -#include <QObject> -#include <QTest> -#include <QDebug> -#include <QSettings> -#include <QFile> -#include <QSignalSpy> - -#include <qaccelerometer.h> -#include <qambientlightsensor.h> -#include <qcompass.h> -#include <qgyroscope.h> -#include <qlightsensor.h> -#include <qmagnetometer.h> -#include <qorientationsensor.h> -#include <qproximitysensor.h> -#include <qrotationsensor.h> -#include <qtapsensor.h> - -#include "test_sensor_qtm.h" -#include "test_backends_qtm.h" -#include <private/qsensormanager_p.h> - -static char const * const testsensorimpl_id("test sensor impl"); - -Q_SENSORS_EXPORT void sensors_unit_test_hook(int); - -QTM_BEGIN_NAMESPACE -QTM_SENSORS_EXPORT void qtm_sensors_unit_test_hook(int); -QTM_END_NAMESPACE - -QTM_USE_NAMESPACE - -bool operator==(const qoutputrange &orl1, const qoutputrange &orl2) -{ - return (orl1.minimum == orl2.minimum && - orl1.maximum == orl2.maximum && - orl1.accuracy == orl2.accuracy); -} - -namespace QTest { - template<> char *toString(const qoutputrangelist &orl) - { - QStringList list; - foreach (const qoutputrange &item, orl) { - list << QString("%1-%2%3%4").arg(item.minimum).arg(item.maximum).arg(QString::fromWCharArray(L"\u00B1")).arg(item.accuracy); - } - QString ret = QString("qoutputrangelist: (%1)").arg(list.join("), (")); - return qstrdup(ret.toLatin1().data()); - } - template<> char *toString(const QList<QByteArray> &data) - { - QStringList list; - foreach (const QByteArray &str, data) { - list << QString::fromLatin1(str); - } - QString ret = QString("QList<QByteArray>: (%1)").arg(list.join("), (")); - return qstrdup(ret.toLatin1().data()); - } -} - - -class MyFilter : public TestSensorFilter { bool filter(TestSensorReading *) { return false; } }; - -class ModFilter : public TestSensorFilter -{ - bool filter(TestSensorReading *reading) - { - reading->setTest(3); - return true; - } -}; - -/* - Unit test for QtmSensor class. -*/ -class tst_QtmSensor : public QObject -{ - Q_OBJECT - -public: - tst_QtmSensor() - { - sensors_unit_test_hook(0); // change some flags the library uses - qtm_sensors_unit_test_hook(0); // change some flags the library uses - } - -private slots: - void initTestCase() - { - QSettings settings(QLatin1String("Nokia"), QLatin1String("Sensors")); - settings.clear(); - } - - void cleanupTestCase() - { - QSettings settings(QLatin1String("Nokia"), QLatin1String("Sensors")); - settings.clear(); - -#ifdef WAIT_AT_END - QFile _stdin; - _stdin.open(1, QIODevice::ReadOnly); - _stdin.readLine(); -#endif - } - - // This test MUST be first - void testRecursiveLoadPlugins() - { - TestSensor sensor; - - // This confirms that legacy static plugins can still be registered - //QTest::ignoreMessage(QtWarningMsg, "Loaded the LegacySensorPlugin "); - - // The logic for the test is in test_sensorplugin.cpp (which warns and aborts if the test fails) - (void)QSensor::sensorTypes(); - - // Checking that the availableSensorsChanged() signal was not emitted too many times while loading plugins. - QCOMPARE(sensor.sensorsChangedEmitted, 1); - } - - void testTypeRegistered() - { - QList<QByteArray> expected; - expected << TestSensor::type; - QList<QByteArray> actual = QSensor::sensorTypes(); - qSort(actual); // The actual list is not in a defined order - QCOMPARE(actual, expected); - } - - void testSensorRegistered() - { - QList<QByteArray> expected; - expected << "test sensor 2" << "test sensor 3" << testsensorimpl_id; - QList<QByteArray> actual = QSensor::sensorsForType(TestSensor::type); - qSort(actual); // The actual list is not in a defined order - QCOMPARE(actual, expected); - } - - void testSensorDefault() - { - QByteArray expected = testsensorimpl_id; - QByteArray actual = QSensor::defaultSensorForType(TestSensor::type); - QCOMPARE(actual, expected); - } - - void testBadDefaultFromConfig() - { - QSettings settings(QLatin1String("Nokia"), QLatin1String("Sensors")); - settings.setValue(QString(QLatin1String("Default/%1")).arg(QString::fromLatin1(TestSensor::type)), QByteArray("bogus id")); - settings.sync(); - - QByteArray expected = testsensorimpl_id; - QByteArray actual = QSensor::defaultSensorForType(TestSensor::type); - QCOMPARE(actual, expected); - } - - void testGoodDefaultFromConfig() - { - QSettings settings(QLatin1String("Nokia"), QLatin1String("Sensors")); - settings.setValue(QString(QLatin1String("Default/%1")).arg(QString::fromLatin1(TestSensor::type)), QByteArray(testsensorimpl_id)); - settings.sync(); - - QByteArray expected = testsensorimpl_id; - QByteArray actual = QSensor::defaultSensorForType(TestSensor::type); - QCOMPARE(actual, expected); - - settings.clear(); - } - - void testNoSensorsForType() - { - QList<QByteArray> expected; - QList<QByteArray> actual = QSensor::sensorsForType("bogus type"); - QCOMPARE(actual, expected); - } - - void testNoDefaultForType() - { - QByteArray expected; - QByteArray actual = QSensor::defaultSensorForType("bogus type"); - QCOMPARE(actual, expected); - } - - void testCreation() - { - TestSensor sensor; - sensor.connectToBackend(); - QByteArray expected = testsensorimpl_id; - QByteArray actual = sensor.identifier(); - QCOMPARE(actual, expected); - } - - void testSetIdentifierFail() - { - TestSensor sensor; - sensor.setIdentifier(testsensorimpl_id); - sensor.connectToBackend(); - QVERIFY(sensor.isConnectedToBackend()); - QByteArray expected = testsensorimpl_id; - QByteArray actual = sensor.identifier(); - QCOMPARE(actual, expected); - - QTest::ignoreMessage(QtWarningMsg, "ERROR: Cannot call QSensor::setIdentifier while connected to a backend! "); - sensor.setIdentifier("dummy.accelerometer"); - expected = testsensorimpl_id; - actual = sensor.identifier(); - QCOMPARE(actual, expected); - } - - void testBadDefaultCreation() - { - QSettings settings(QLatin1String("Nokia"), QLatin1String("Sensors")); - settings.setValue(QString(QLatin1String("Default/%1")).arg(QString::fromLatin1(TestSensor::type)), QByteArray("test sensor 2")); - settings.sync(); - - TestSensor sensor; - QTest::ignoreMessage(QtWarningMsg, "Can't create backend \"test sensor 2\" "); - sensor.connectToBackend(); - QByteArray expected = testsensorimpl_id; - QByteArray actual = sensor.identifier(); - QCOMPARE(actual, expected); - - settings.clear(); - } - - void testBadCreation() - { - QSensor sensor("bogus type"); - sensor.connectToBackend(); - QByteArray expected; // should be null - QByteArray actual = sensor.identifier(); - QCOMPARE(actual, expected); - } - - void testTimestamp() - { - TestSensor sensor; - sensor.connectToBackend(); - QVERIFY(sensor.reading() != 0); - qtimestamp timestamp = sensor.reading()->timestamp(); - QVERIFY(timestamp == qtimestamp()); - sensor.setProperty("doThis", "setOne"); - sensor.start(); - timestamp = sensor.reading()->timestamp(); - QVERIFY(timestamp == 1); - } - - void testStart() - { - TestSensor sensor; - sensor.start(); - QVERIFY(sensor.isActive()); - sensor.start(); - QVERIFY(sensor.isActive()); - } - - void testBadStart() - { - QSensor sensor("bogus type"); - sensor.start(); - QVERIFY(!sensor.isActive()); - } - - void testStop() - { - TestSensor sensor; - sensor.stop(); - QVERIFY(!sensor.isActive()); - sensor.start(); - QVERIFY(sensor.isActive()); - sensor.stop(); - QVERIFY(!sensor.isActive()); - } - - void testMetaData() - { - TestSensor sensor; - - { - bool actual = sensor.isConnectedToBackend(); - bool expected = false; - QCOMPARE(actual, expected); - } - - sensor.connectToBackend(); - - { - bool actual = sensor.isConnectedToBackend(); - bool expected = true; - QCOMPARE(actual, expected); - } - - { - QString actual = sensor.description(); - QString expected = "sensor description"; - QCOMPARE(actual, expected); - } - - { - qoutputrangelist actual = sensor.outputRanges(); - qoutputrangelist expected; - qoutputrange r; r.minimum = 0; r.maximum = 1; r.accuracy = 0.5; - expected << r; - r.minimum = 0; r.maximum = 2; r.accuracy = 1; - expected << r; - QCOMPARE(actual, expected); - } - - { - int actual = sensor.outputRange(); - int expected = -1; - QCOMPARE(actual, expected); - - sensor.setOutputRange(0); - - actual = sensor.outputRange(); - expected = 0; - QCOMPARE(actual, expected); - } - - { - qrangelist actual = sensor.availableDataRates(); - qrangelist expected = qrangelist() << qrange(100,100); - QCOMPARE(actual, expected); - } - - { - TestSensor sensor; - sensor.setProperty("doThis", "rates"); - sensor.connectToBackend(); - qrangelist actual = sensor.availableDataRates(); - qrangelist expected = qrangelist() << qrange(100,100); - QCOMPARE(actual, expected); - } - - { - TestSensor sensor; - sensor.setProperty("doThis", "rates(0)"); - QTest::ignoreMessage(QtWarningMsg, "ERROR: Cannot call QSensorBackend::setDataRates with 0 "); - sensor.connectToBackend(); - } - - { - TestSensor sensor; - sensor.setProperty("doThis", "rates(nodef)"); - QTest::ignoreMessage(QtWarningMsg, "ERROR: Cannot call QSensorBackend::setDataRates with an invalid sensor "); - sensor.connectToBackend(); - } - - { - int actual = sensor.dataRate(); - int expected = 0; - QCOMPARE(actual, expected); - - sensor.setDataRate(100); - - actual = sensor.dataRate(); - expected = 100; - QCOMPARE(actual, expected); - } - - // Test the generic accessor functions - TestSensorReading *reading = sensor.reading(); - QCOMPARE(reading->valueCount(), 1); - reading->setTest(1); - QCOMPARE(reading->test(), reading->value(0).toInt()); - } - - void testFilter() - { - TestSensor sensor; - sensor.connectToBackend(); - - QList<QSensorFilter*> actual = sensor.filters(); - QList<QSensorFilter*> expected = QList<QSensorFilter*>(); - QCOMPARE(actual, expected); - - QTest::ignoreMessage(QtWarningMsg, "addFilter: passed a null filter! "); - sensor.addFilter(0); - - QTest::ignoreMessage(QtWarningMsg, "removeFilter: passed a null filter! "); - sensor.removeFilter(0); - - MyFilter *filter = new MyFilter; - sensor.addFilter(filter); - - actual = sensor.filters(); - expected = QList<QSensorFilter*>() << filter; - QCOMPARE(actual, expected); - - MyFilter *filter2 = new MyFilter; - sensor.addFilter(filter2); - - actual = sensor.filters(); - expected = QList<QSensorFilter*>() << filter << filter2; - QCOMPARE(actual, expected); - - delete filter2; - - actual = sensor.filters(); - expected = QList<QSensorFilter*>() << filter; - QCOMPARE(actual, expected); - - sensor.removeFilter(filter); - - actual = sensor.filters(); - expected = QList<QSensorFilter*>(); - QCOMPARE(actual, expected); - - delete filter; - } - - void testFilter2() - { - TestSensor sensor; - sensor.setProperty("doThis", "setOne"); - TestSensorFilter *filter1 = new ModFilter; - TestSensorFilter *filter2 = new MyFilter; - sensor.addFilter(filter1); - sensor.start(); - QCOMPARE(sensor.reading()->test(), 3); - sensor.stop(); - sensor.reading()->setTest(1); - sensor.addFilter(filter2); - sensor.start(); - QCOMPARE(sensor.reading()->test(), 1); - sensor.stop(); - delete filter1; - delete filter2; - } - - void testFilter3() - { - TestSensor sensor; - sensor.setProperty("doThis", "setOne"); - QSignalSpy spy(&sensor, SIGNAL(readingChanged())); - sensor.start(); - QCOMPARE(spy.count(), 1); // reading changes - sensor.stop(); - - TestSensorFilter *filter2 = new MyFilter; - sensor.addFilter(filter2); - sensor.start(); - QCOMPARE(spy.count(), 1); // filter suppresses reading so it does not change - sensor.stop(); - delete filter2; - - TestSensorFilter *filter1 = new ModFilter; - sensor.addFilter(filter1); - sensor.start(); - QCOMPARE(spy.count(), 2); // filter does not suppress reading - sensor.stop(); - delete filter1; - } - - void testStart2() - { - TestSensor sensor; - sensor.connectToBackend(); - - sensor.setProperty("doThis", "stop"); - sensor.start(); - QVERIFY(!sensor.isActive()); - sensor.stop(); - - sensor.setProperty("doThis", "error"); - sensor.start(); - QVERIFY(sensor.error() == 1); - // Yes, this is non-intuitive but the sensor - // decides if an error is fatal or not. - // In this case our test sensor is reporting a - // non-fatal error so the sensor will start. - QVERIFY(sensor.isActive()); - sensor.stop(); - - sensor.setProperty("doThis", "setOne"); - sensor.start(); - QCOMPARE(sensor.reading()->timestamp(), qtimestamp(1)); - QCOMPARE(sensor.reading()->test(), 1); - sensor.stop(); - - sensor.setProperty("doThis", "setTwo"); - sensor.start(); - QCOMPARE(sensor.reading()->timestamp(), qtimestamp(2)); - QCOMPARE(sensor.reading()->test(), 2); - sensor.stop(); - } - - void testSetBadDataRate() - { - TestSensor sensor; - sensor.connectToBackend(); - - QTest::ignoreMessage(QtWarningMsg, "setDataRate: 1 is not supported by the sensor. "); - sensor.setDataRate(1); - QCOMPARE(sensor.dataRate(), 0); - - QTest::ignoreMessage(QtWarningMsg, "setDataRate: 1000 is not supported by the sensor. "); - sensor.setDataRate(1000); - QCOMPARE(sensor.dataRate(), 0); - } - - void testSetBadDataRateWhenNotConnected() - { - TestSensor sensor; - sensor.setDataRate(0); - QCOMPARE(sensor.dataRate(), 0); - sensor.setDataRate(300); - QCOMPARE(sensor.dataRate(), 300); - sensor.setDataRate(350); - QTest::ignoreMessage(QtWarningMsg, "setDataRate: 350 is not supported by the sensor. "); - sensor.connectToBackend(); - QCOMPARE(sensor.dataRate(), 0); - } - - void testSetBadOutputRange() - { - TestSensor sensor; - sensor.connectToBackend(); - - sensor.setOutputRange(-1); - QCOMPARE(sensor.outputRange(), -1); - QTest::ignoreMessage(QtWarningMsg, "setOutputRange: 300 is not supported by the sensor. "); - sensor.setOutputRange(300); - QCOMPARE(sensor.outputRange(), -1); - } - - void testSetBadOutputRangeWhenNotConnected() - { - TestSensor sensor; - sensor.setOutputRange(300); - QCOMPARE(sensor.outputRange(), 300); - sensor.setOutputRange(350); - QTest::ignoreMessage(QtWarningMsg, "setOutputRange: 350 is not supported by the sensor. "); - sensor.connectToBackend(); - QCOMPARE(sensor.outputRange(), -1); - QTest::ignoreMessage(QtWarningMsg, "setOutputRange: -2 is not supported by the sensor. "); - sensor.setOutputRange(-2); - QCOMPARE(sensor.outputRange(), -1); - } - - void testEnumHandling() - { - { - QAmbientLightReading reading; - for (int i = 0; i <= 6; i++) { - QAmbientLightReading::LightLevel setting = static_cast<QAmbientLightReading::LightLevel>(i); - QAmbientLightReading::LightLevel expected = setting; - if (i == 6) - expected = QAmbientLightReading::Undefined; - reading.setLightLevel(setting); - QCOMPARE(reading.lightLevel(), expected); - } - } - - { - QOrientationReading reading; - for (int i = 0; i <= 7; i++) { - QOrientationReading::Orientation setting = static_cast<QOrientationReading::Orientation>(i); - QOrientationReading::Orientation expected = setting; - if (i == 7) - expected = QOrientationReading::Undefined; - reading.setOrientation(setting); - QCOMPARE(reading.orientation(), expected); - } - } - - { - QTapReading reading; - reading.setTapDirection(QTapReading::Undefined); - QCOMPARE(reading.tapDirection(), QTapReading::Undefined); - reading.setTapDirection(QTapReading::X_Pos); - QCOMPARE(reading.tapDirection(), QTapReading::X_Pos); - reading.setTapDirection(QTapReading::X_Neg); - QCOMPARE(reading.tapDirection(), QTapReading::X_Neg); - reading.setTapDirection(QTapReading::Y_Pos); - QCOMPARE(reading.tapDirection(), QTapReading::Y_Pos); - reading.setTapDirection(QTapReading::Y_Neg); - QCOMPARE(reading.tapDirection(), QTapReading::Y_Neg); - reading.setTapDirection(QTapReading::Z_Pos); - QCOMPARE(reading.tapDirection(), QTapReading::Z_Pos); - reading.setTapDirection(QTapReading::Z_Neg); - QCOMPARE(reading.tapDirection(), QTapReading::Z_Neg); - // Directions can be ORed together - reading.setTapDirection(QTapReading::X_Both); - QCOMPARE(reading.tapDirection(), QTapReading::X_Both); - reading.setTapDirection(QTapReading::Y_Both); - QCOMPARE(reading.tapDirection(), QTapReading::Y_Both); - reading.setTapDirection(QTapReading::Z_Both); - QCOMPARE(reading.tapDirection(), QTapReading::Z_Both); - // You can't set just the Axis - reading.setTapDirection(QTapReading::X); - QCOMPARE(reading.tapDirection(), QTapReading::Undefined); - reading.setTapDirection(QTapReading::Y); - QCOMPARE(reading.tapDirection(), QTapReading::Undefined); - reading.setTapDirection(QTapReading::Z); - QCOMPARE(reading.tapDirection(), QTapReading::Undefined); - reading.setTapDirection(static_cast<QTapReading::TapDirection>(0x1000)); - QCOMPARE(reading.tapDirection(), QTapReading::Undefined); - } - } - - void testSetActive() - { - TestSensor sensor; - sensor.setActive(true); - // doesn't start till the event loop is hit - QVERIFY(!sensor.isActive()); - // hit the event loop - QTest::qWait(0); - QVERIFY(sensor.isActive()); - sensor.setActive(true); - QVERIFY(sensor.isActive()); - // it does stop immediately - sensor.setActive(false); - QVERIFY(!sensor.isActive()); - } - - void testIsRegistered() - { - bool expected; - bool actual; - - expected = true; - actual = QSensorManager::isBackendRegistered(TestSensor::type, testsensorimpl_id); - QCOMPARE(expected, actual); - - expected = false; - actual = QSensorManager::isBackendRegistered(TestSensor::type, "random"); - QCOMPARE(expected, actual); - - expected = false; - actual = QSensorManager::isBackendRegistered("random", "random"); - QCOMPARE(expected, actual); - } - - void testAllTheInterfaces() - { - register_test_backends(); - - TEST_SENSORINTERFACE(QAccelerometer, QAccelerometerReading, { - QCOMPARE(reading->x(), 1.0); - QCOMPARE(reading->y(), 1.0); - QCOMPARE(reading->z(), 1.0); - }) - - TEST_SENSORINTERFACE(QAmbientLightSensor, QAmbientLightReading, { - QCOMPARE(reading->lightLevel(), QAmbientLightReading::Twilight); - }) - - TEST_SENSORINTERFACE(QCompass, QCompassReading, { - QCOMPARE(reading->azimuth(), 1.0); - QCOMPARE(reading->calibrationLevel(), 1.0); - }) - - TEST_SENSORINTERFACE(QGyroscope, QGyroscopeReading, { - QCOMPARE(reading->x(), 1.0); - QCOMPARE(reading->y(), 1.0); - QCOMPARE(reading->z(), 1.0); - }) - - TEST_SENSORINTERFACE(QLightSensor, QLightReading, { - QCOMPARE(reading->lux(), 1.0); - }) - - TEST_SENSORINTERFACE(QMagnetometer, QMagnetometerReading, { - QCOMPARE(reading->x(), 1.0); - QCOMPARE(reading->y(), 1.0); - QCOMPARE(reading->z(), 1.0); - QCOMPARE(reading->calibrationLevel(), 1.0); - }) - - TEST_SENSORINTERFACE(QOrientationSensor, QOrientationReading, { - QCOMPARE(reading->orientation(), QOrientationReading::LeftUp); - }) - - TEST_SENSORINTERFACE(QProximitySensor, QProximityReading, { - QCOMPARE(reading->close(), true); - }) - - TEST_SENSORINTERFACE(QRotationSensor, QRotationReading, { - QCOMPARE(reading->x(), 1.0); - QCOMPARE(reading->y(), 1.0); - QCOMPARE(reading->z(), 1.0); - }) - - TEST_SENSORINTERFACE(QTapSensor, QTapReading, { - QCOMPARE(reading->tapDirection(), QTapReading::Z_Both); - QCOMPARE(reading->isDoubleTap(), true); - }) - - unregister_test_backends(); - } - - void testBusyChanged() - { - // Start an exclusive sensor - TestSensor sensor1; - sensor1.setProperty("exclusive", true); - sensor1.start(); - QVERIFY(sensor1.isActive()); - - // Try to start another one, sensor reports busy - TestSensor sensor2; - sensor2.setProperty("exclusive", true); - sensor2.start(); - QVERIFY(sensor2.isBusy()); - QVERIFY(!sensor2.isActive()); - - // Stopping the first instance causes the busyChanged signal to be emitted from the second instance - QSignalSpy spy(&sensor2, SIGNAL(busyChanged())); - sensor1.stop(); - QCOMPARE(spy.count(), 1); - - // Now we can start the second instance - sensor2.start(); - QVERIFY(sensor2.isActive()); - } -}; - -QTEST_MAIN(tst_QtmSensor) - -#include "tst_qtmsensor.moc" |