summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--config.tests/bbsensor_holster/bbsensor_holster.pro4
-rw-r--r--config.tests/bbsensor_holster/main.cpp57
-rw-r--r--doc/config/qt-cpp-ignore.qdocconf2
-rw-r--r--qtsensors.pro1
-rw-r--r--src/imports/sensors/plugins.qmltypes181
-rw-r--r--src/imports/sensors/qmlaccelerometer.cpp21
-rw-r--r--src/imports/sensors/qmlaccelerometer.h17
-rw-r--r--src/imports/sensors/qmlaltimeter.cpp133
-rw-r--r--src/imports/sensors/qmlaltimeter.h86
-rw-r--r--src/imports/sensors/qmlambientlightsensor.h2
-rw-r--r--src/imports/sensors/qmlambienttemperaturesensor.cpp133
-rw-r--r--src/imports/sensors/qmlambienttemperaturesensor.h86
-rw-r--r--src/imports/sensors/qmlcompass.h2
-rw-r--r--src/imports/sensors/qmlgyroscope.h2
-rw-r--r--src/imports/sensors/qmlholstersensor.cpp133
-rw-r--r--src/imports/sensors/qmlholstersensor.h86
-rw-r--r--src/imports/sensors/qmlirproximitysensor.h2
-rw-r--r--src/imports/sensors/qmllightsensor.cpp10
-rw-r--r--src/imports/sensors/qmllightsensor.h6
-rw-r--r--src/imports/sensors/qmlmagnetometer.cpp7
-rw-r--r--src/imports/sensors/qmlmagnetometer.h5
-rw-r--r--src/imports/sensors/qmlorientationsensor.h2
-rw-r--r--src/imports/sensors/qmlpressuresensor.cpp133
-rw-r--r--src/imports/sensors/qmlpressuresensor.h86
-rw-r--r--src/imports/sensors/qmlproximitysensor.h2
-rw-r--r--src/imports/sensors/qmlrotationsensor.cpp3
-rw-r--r--src/imports/sensors/qmlrotationsensor.h6
-rw-r--r--src/imports/sensors/qmlsensor.cpp120
-rw-r--r--src/imports/sensors/qmlsensor.h45
-rw-r--r--src/imports/sensors/qmlsensorglobal.h2
-rw-r--r--src/imports/sensors/qmlsensorrange.h2
-rw-r--r--src/imports/sensors/qmltapsensor.cpp8
-rw-r--r--src/imports/sensors/qmltapsensor.h5
-rw-r--r--src/imports/sensors/qmltiltsensor.h2
-rw-r--r--src/imports/sensors/sensors.cpp49
-rw-r--r--src/imports/sensors/sensors.pro10
-rw-r--r--src/plugins/sensors/blackberry/bbaccelerometer.cpp38
-rw-r--r--src/plugins/sensors/blackberry/bbaccelerometer.h4
-rw-r--r--src/plugins/sensors/blackberry/bbaltimeter.cpp27
-rw-r--r--src/plugins/sensors/blackberry/bbaltimeter.h17
-rw-r--r--src/plugins/sensors/blackberry/bbcompass.cpp15
-rw-r--r--src/plugins/sensors/blackberry/bbholstersensor.cpp58
-rw-r--r--src/plugins/sensors/blackberry/bbholstersensor.h60
-rw-r--r--src/plugins/sensors/blackberry/bbmagnetometer.cpp4
-rw-r--r--src/plugins/sensors/blackberry/bborientationsensor.cpp16
-rw-r--r--src/plugins/sensors/blackberry/bborientationsensor.h1
-rw-r--r--src/plugins/sensors/blackberry/bbpressuresensor.cpp29
-rw-r--r--src/plugins/sensors/blackberry/bbpressuresensor.h19
-rw-r--r--src/plugins/sensors/blackberry/bbproximitysensor.cpp3
-rw-r--r--src/plugins/sensors/blackberry/bbsensorbackend.cpp128
-rw-r--r--src/plugins/sensors/blackberry/bbsensorbackend.h5
-rw-r--r--src/plugins/sensors/blackberry/bbtemperaturesensor.cpp27
-rw-r--r--src/plugins/sensors/blackberry/bbtemperaturesensor.h17
-rw-r--r--src/plugins/sensors/blackberry/blackberry.pro9
-rw-r--r--src/plugins/sensors/blackberry/main.cpp20
-rw-r--r--src/plugins/sensors/dummy/dummy.pro2
-rw-r--r--src/plugins/sensors/generic/generic.pro20
-rw-r--r--src/plugins/sensors/generic/genericrotationsensor.cpp4
-rw-r--r--src/plugins/sensors/generic/genericrotationsensor.h1
-rw-r--r--src/plugins/sensors/generic/generictiltsensor.cpp33
-rw-r--r--src/plugins/sensors/generic/generictiltsensor.h4
-rw-r--r--src/plugins/sensors/generic/main.cpp18
-rw-r--r--src/plugins/sensors/linux/linux.pro2
-rw-r--r--src/plugins/sensors/sensors.pro4
-rw-r--r--src/sensors/doc/src/compatmap.qdoc26
-rw-r--r--src/sensors/gestures/qsensorgesture.h4
-rw-r--r--src/sensors/gestures/qsensorgesture_p.h2
-rw-r--r--src/sensors/gestures/qsensorgesturemanager.h4
-rw-r--r--src/sensors/gestures/qsensorgesturemanagerprivate_p.h2
-rw-r--r--src/sensors/gestures/qsensorgestureplugininterface.cpp2
-rw-r--r--src/sensors/gestures/qsensorgestureplugininterface.h4
-rw-r--r--src/sensors/gestures/qsensorgesturerecognizer.h4
-rwxr-xr-xsrc/sensors/make_sensor.pl184
-rw-r--r--src/sensors/qaccelerometer.cpp78
-rw-r--r--src/sensors/qaccelerometer.h24
-rw-r--r--src/sensors/qaccelerometer_p.h15
-rw-r--r--src/sensors/qaltimeter.cpp148
-rw-r--r--src/sensors/qaltimeter.h84
-rw-r--r--src/sensors/qaltimeter_p.h70
-rw-r--r--src/sensors/qambientlightsensor.h4
-rw-r--r--src/sensors/qambientlightsensor_p.h2
-rw-r--r--src/sensors/qambienttemperaturesensor.cpp144
-rw-r--r--src/sensors/qambienttemperaturesensor.h84
-rw-r--r--src/sensors/qambienttemperaturesensor_p.h70
-rw-r--r--src/sensors/qcompass.h4
-rw-r--r--src/sensors/qcompass_p.h2
-rw-r--r--src/sensors/qgyroscope.h4
-rw-r--r--src/sensors/qgyroscope_p.h2
-rw-r--r--src/sensors/qholstersensor.cpp148
-rw-r--r--src/sensors/qholstersensor.h84
-rw-r--r--src/sensors/qholstersensor_p.h70
-rw-r--r--src/sensors/qirproximitysensor.h4
-rw-r--r--src/sensors/qirproximitysensor_p.h2
-rw-r--r--src/sensors/qlightsensor.cpp28
-rw-r--r--src/sensors/qlightsensor.h17
-rw-r--r--src/sensors/qlightsensor_p.h13
-rw-r--r--src/sensors/qmagnetometer.cpp18
-rw-r--r--src/sensors/qmagnetometer.h17
-rw-r--r--src/sensors/qmagnetometer_p.h15
-rw-r--r--src/sensors/qorientationsensor.h4
-rw-r--r--src/sensors/qorientationsensor_p.h2
-rw-r--r--src/sensors/qpressuresensor.cpp147
-rw-r--r--src/sensors/qpressuresensor.h84
-rw-r--r--src/sensors/qpressuresensor_p.h70
-rw-r--r--src/sensors/qproximitysensor.h4
-rw-r--r--src/sensors/qproximitysensor_p.h2
-rw-r--r--src/sensors/qrotationsensor.cpp24
-rw-r--r--src/sensors/qrotationsensor.h17
-rw-r--r--src/sensors/qrotationsensor_p.h15
-rw-r--r--src/sensors/qsensor.cpp303
-rw-r--r--src/sensors/qsensor.h55
-rw-r--r--src/sensors/qsensor_p.h18
-rw-r--r--src/sensors/qsensorbackend.h4
-rw-r--r--src/sensors/qsensormanager.h4
-rw-r--r--src/sensors/qsensorplugin.h4
-rw-r--r--src/sensors/qsensorsglobal.h4
-rw-r--r--src/sensors/qtapsensor.cpp18
-rw-r--r--src/sensors/qtapsensor.h18
-rw-r--r--src/sensors/qtapsensor_p.h15
-rw-r--r--src/sensors/qtiltsensor.h4
-rw-r--r--src/sensors/qtiltsensor_p.h2
-rw-r--r--src/sensors/sensorlog_p.h2
-rw-r--r--src/sensors/sensors.pro4
-rw-r--r--sync.profile6
-rw-r--r--tests/auto/qsensor/test_backends.h16
-rw-r--r--tests/auto/qsensor/tst_qsensor.cpp18
127 files changed, 3834 insertions, 450 deletions
diff --git a/.gitignore b/.gitignore
index 11a723e1..6bbb56a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -95,6 +95,7 @@ examples/sensors/shakeit/shakeit
# Generated config test binaries
config.tests/bbsensor_compass/bbsensor_compass
config.tests/bbsensor_header/bbsensor_header
+config.tests/bbsensor_holster/bbsensor_holster
# Directories to ignore
# ---------------------
diff --git a/config.tests/bbsensor_holster/bbsensor_holster.pro b/config.tests/bbsensor_holster/bbsensor_holster.pro
new file mode 100644
index 00000000..349130a3
--- /dev/null
+++ b/config.tests/bbsensor_holster/bbsensor_holster.pro
@@ -0,0 +1,4 @@
+TEMPLATE = app
+SOURCES += main.cpp
+CONFIG += qt
+requires(blackberry)
diff --git a/config.tests/bbsensor_holster/main.cpp b/config.tests/bbsensor_holster/main.cpp
new file mode 100644
index 00000000..52dde466
--- /dev/null
+++ b/config.tests/bbsensor_holster/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/qglobal.h>
+#ifndef Q_OS_BLACKBERRY
+#error "Missing Q_OS_BLACKBERRY"
+#endif
+#include <sensor/sensor.h>
+
+int main(int argc, char** argv)
+{
+ Q_UNUSED(argc);
+ Q_UNUSED(argv);
+ sensor_event_t event;
+ const int type = SENSOR_TYPE_HOLSTER;
+ const bool holstered = event.holster_s.holstered;
+ Q_UNUSED(type);
+ Q_UNUSED(holstered);
+ return 0;
+}
diff --git a/doc/config/qt-cpp-ignore.qdocconf b/doc/config/qt-cpp-ignore.qdocconf
index 9b09a60a..28c21195 100644
--- a/doc/config/qt-cpp-ignore.qdocconf
+++ b/doc/config/qt-cpp-ignore.qdocconf
@@ -19,9 +19,7 @@ Cpp.ignoretokens = QAXFACTORY_EXPORT \
QM_EXPORT_XML \
QT_ASCII_CAST_WARN \
QT_ASCII_CAST_WARN_CONSTRUCTOR \
- QT_BEGIN_HEADER \
QT_DESIGNER_STATIC \
- QT_END_HEADER \
QT_FASTCALL \
QT_WIDGET_PLUGIN_EXPORT \
Q_COMPAT_EXPORT \
diff --git a/qtsensors.pro b/qtsensors.pro
index 0c706b21..77441730 100644
--- a/qtsensors.pro
+++ b/qtsensors.pro
@@ -2,6 +2,7 @@ load(configure)
blackberry {
qtCompileTest(bbsensor_header)
qtCompileTest(bbsensor_compass)
+ qtCompileTest(bbsensor_holster)
}
load(qt_parts)
diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes
index 687a1f25..2deff792 100644
--- a/src/imports/sensors/plugins.qmltypes
+++ b/src/imports/sensors/plugins.qmltypes
@@ -3,90 +3,146 @@ import QtQuick.tooling 1.1
// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
-// This file was auto-generated with the command 'qmlplugindump QtSensors 5.0 /home/thomas/src/qtbase/imports/'.
+// This file was auto-generated with the command 'qmlplugindump QtSensors 5.0 /home/thomas/src/qtbase/qml'.
Module {
Component {
name: "QmlAccelerometer"
prototype: "QmlSensor"
- exports: ["Accelerometer 5.0"]
+ exports: ["Accelerometer 5.0", "Accelerometer 5.1"]
+ exportMetaObjectRevisions: [0, 1]
+ Enum {
+ name: "AccelerationMode"
+ values: {
+ "Combined": 0,
+ "Gravity": 1,
+ "User": 2
+ }
+ }
+ Property { name: "accelerationMode"; revision: 1; type: "AccelerationMode" }
+ Signal {
+ name: "accelerationModeChanged"
+ Parameter { name: "accelerationMode"; type: "AccelerationMode" }
+ }
}
Component {
name: "QmlAccelerometerReading"
prototype: "QmlSensorReading"
- exports: ["AccelerometerReading 5.0"]
+ exports: ["AccelerometerReading 5.0", "AccelerometerReading 5.1"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
}
Component {
+ name: "QmlAltimeter"
+ prototype: "QmlSensor"
+ exports: ["Altimeter 5.1"]
+ }
+ Component {
+ name: "QmlAltimeterReading"
+ prototype: "QmlSensorReading"
+ exports: ["AltimeterReading 5.1"]
+ Property { name: "altitude"; type: "double"; isReadonly: true }
+ }
+ Component {
name: "QmlAmbientLightSensor"
prototype: "QmlSensor"
- exports: ["AmbientLightSensor 5.0"]
+ exports: ["AmbientLightSensor 5.0", "AmbientLightSensor 5.1"]
}
Component {
name: "QmlAmbientLightSensorReading"
prototype: "QmlSensorReading"
- exports: ["AmbientLightReading 5.0"]
+ exports: ["AmbientLightReading 5.0", "AmbientLightReading 5.1"]
Property { name: "lightLevel"; type: "QAmbientLightReading::LightLevel"; isReadonly: true }
}
Component {
+ name: "QmlAmbientTemperatureReading"
+ prototype: "QmlSensorReading"
+ exports: ["AmbientTemperatureReading 5.1"]
+ Property { name: "temperature"; type: "double"; isReadonly: true }
+ }
+ Component {
+ name: "QmlAmbientTemperatureSensor"
+ prototype: "QmlSensor"
+ exports: ["AmbientTemperatureSensor 5.1"]
+ }
+ Component {
name: "QmlCompass"
prototype: "QmlSensor"
- exports: ["Compass 5.0"]
+ exports: ["Compass 5.0", "Compass 5.1"]
}
Component {
name: "QmlCompassReading"
prototype: "QmlSensorReading"
- exports: ["CompassReading 5.0"]
+ exports: ["CompassReading 5.0", "CompassReading 5.1"]
Property { name: "azimuth"; type: "double"; isReadonly: true }
Property { name: "calibrationLevel"; type: "double"; isReadonly: true }
}
Component {
name: "QmlGyroscope"
prototype: "QmlSensor"
- exports: ["Gyroscope 5.0"]
+ exports: ["Gyroscope 5.0", "Gyroscope 5.1"]
}
Component {
name: "QmlGyroscopeReading"
prototype: "QmlSensorReading"
- exports: ["GyroscopeReading 5.0"]
+ exports: ["GyroscopeReading 5.0", "GyroscopeReading 5.1"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
}
Component {
+ name: "QmlHolsterReading"
+ prototype: "QmlSensorReading"
+ exports: ["HolsterReading 5.1"]
+ Property { name: "holstered"; type: "bool"; isReadonly: true }
+ }
+ Component {
+ name: "QmlHolsterSensor"
+ prototype: "QmlSensor"
+ exports: ["HolsterSensor 5.1"]
+ }
+ Component {
name: "QmlIRProximitySensor"
prototype: "QmlSensor"
- exports: ["IRProximitySensor 5.0"]
+ exports: ["IRProximitySensor 5.0", "IRProximitySensor 5.1"]
}
Component {
name: "QmlIRProximitySensorReading"
prototype: "QmlSensorReading"
- exports: ["IRProximityReading 5.0"]
+ exports: ["IRProximityReading 5.0", "IRProximityReading 5.1"]
Property { name: "reflectance"; type: "double"; isReadonly: true }
}
Component {
name: "QmlLightSensor"
prototype: "QmlSensor"
- exports: ["LightSensor 5.0"]
+ exports: ["LightSensor 5.0", "LightSensor 5.1"]
Property { name: "fieldOfView"; type: "double"; isReadonly: true }
+ Signal {
+ name: "fieldOfViewChanged"
+ Parameter { name: "fieldOfView"; type: "double" }
+ }
}
Component {
name: "QmlLightSensorReading"
prototype: "QmlSensorReading"
- exports: ["LightReading 5.0"]
+ exports: ["LightReading 5.0", "LightReading 5.1"]
Property { name: "illuminance"; type: "double"; isReadonly: true }
}
Component {
name: "QmlMagnetometer"
prototype: "QmlSensor"
- exports: ["Magnetometer 5.0"]
+ exports: ["Magnetometer 5.0", "Magnetometer 5.1"]
+ Property { name: "returnGeoValues"; type: "bool" }
+ Signal {
+ name: "returnGeoValuesChanged"
+ Parameter { name: "returnGeoValues"; type: "bool" }
+ }
}
Component {
name: "QmlMagnetometerReading"
prototype: "QmlSensorReading"
- exports: ["MagnetometerReading 5.0"]
+ exports: ["MagnetometerReading 5.0", "MagnetometerReading 5.1"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
@@ -95,35 +151,50 @@ Module {
Component {
name: "QmlOrientationSensor"
prototype: "QmlSensor"
- exports: ["OrientationSensor 5.0"]
+ exports: ["OrientationSensor 5.0", "OrientationSensor 5.1"]
}
Component {
name: "QmlOrientationSensorReading"
prototype: "QmlSensorReading"
- exports: ["OrientationReading 5.0"]
+ exports: ["OrientationReading 5.0", "OrientationReading 5.1"]
Property { name: "orientation"; type: "QOrientationReading::Orientation"; isReadonly: true }
}
Component {
+ name: "QmlPressureReading"
+ prototype: "QmlSensorReading"
+ exports: ["PressureReading 5.1"]
+ Property { name: "pressure"; type: "double"; isReadonly: true }
+ }
+ Component {
+ name: "QmlPressureSensor"
+ prototype: "QmlSensor"
+ exports: ["PressureSensor 5.1"]
+ }
+ Component {
name: "QmlProximitySensor"
prototype: "QmlSensor"
- exports: ["ProximitySensor 5.0"]
+ exports: ["ProximitySensor 5.0", "ProximitySensor 5.1"]
}
Component {
name: "QmlProximitySensorReading"
prototype: "QmlSensorReading"
- exports: ["ProximityReading 5.0"]
+ exports: ["ProximityReading 5.0", "ProximityReading 5.1"]
Property { name: "near"; type: "bool"; isReadonly: true }
}
Component {
name: "QmlRotationSensor"
prototype: "QmlSensor"
- exports: ["RotationSensor 5.0"]
+ exports: ["RotationSensor 5.0", "RotationSensor 5.1"]
Property { name: "hasZ"; type: "bool"; isReadonly: true }
+ Signal {
+ name: "hasZChanged"
+ Parameter { name: "hasZ"; type: "bool" }
+ }
}
Component {
name: "QmlRotationSensorReading"
prototype: "QmlSensorReading"
- exports: ["RotationReading 5.0"]
+ exports: ["RotationReading 5.0", "RotationReading 5.1"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
@@ -131,7 +202,16 @@ Module {
Component {
name: "QmlSensor"
prototype: "QObject"
- exports: ["Sensor 5.0"]
+ exports: ["Sensor 5.0", "Sensor 5.1"]
+ exportMetaObjectRevisions: [0, 1]
+ Enum {
+ name: "AxesOrientationMode"
+ values: {
+ "FixedOrientation": 0,
+ "AutomaticOrientation": 1,
+ "UserOrientation": 2
+ }
+ }
Property { name: "identifier"; type: "string" }
Property { name: "type"; type: "string"; isReadonly: true }
Property { name: "connectedToBackend"; type: "bool"; isReadonly: true }
@@ -145,13 +225,48 @@ Module {
Property { name: "description"; type: "string"; isReadonly: true }
Property { name: "error"; type: "int"; isReadonly: true }
Property { name: "alwaysOn"; type: "bool" }
+ Property { name: "skipDuplicates"; revision: 1; type: "bool" }
+ Property { name: "axesOrientationMode"; revision: 1; type: "AxesOrientationMode" }
+ Property { name: "currentOrientation"; revision: 1; type: "int"; isReadonly: true }
+ Property { name: "userOrientation"; revision: 1; type: "int" }
+ Property { name: "maxBufferSize"; revision: 1; type: "int"; isReadonly: true }
+ Property { name: "efficientBufferSize"; revision: 1; type: "int"; isReadonly: true }
+ Property { name: "bufferSize"; revision: 1; type: "int" }
+ Signal {
+ name: "skipDuplicatesChanged"
+ Parameter { name: "skipDuplicates"; type: "bool" }
+ }
+ Signal {
+ name: "axesOrientationModeChanged"
+ Parameter { name: "axesOrientationMode"; type: "AxesOrientationMode" }
+ }
+ Signal {
+ name: "currentOrientationChanged"
+ Parameter { name: "currentOrientation"; type: "int" }
+ }
+ Signal {
+ name: "userOrientationChanged"
+ Parameter { name: "userOrientation"; type: "int" }
+ }
+ Signal {
+ name: "maxBufferSizeChanged"
+ Parameter { name: "maxBufferSize"; type: "int" }
+ }
+ Signal {
+ name: "efficientBufferSizeChanged"
+ Parameter { name: "efficientBufferSize"; type: "int" }
+ }
+ Signal {
+ name: "bufferSizeChanged"
+ Parameter { name: "bufferSize"; type: "int" }
+ }
Method { name: "start"; type: "bool" }
Method { name: "stop" }
}
Component {
name: "QmlSensorGesture"
prototype: "QObject"
- exports: ["SensorGesture 5.0"]
+ exports: ["SensorGesture 5.0", "SensorGesture 5.1"]
Property { name: "availableGestures"; type: "QStringList"; isReadonly: true }
Property { name: "gestures"; type: "QStringList" }
Property { name: "validGestures"; type: "QStringList"; isReadonly: true }
@@ -165,7 +280,7 @@ Module {
Component {
name: "QmlSensorGlobal"
prototype: "QObject"
- exports: ["QmlSensors 5.0"]
+ exports: ["QmlSensors 5.0", "QmlSensors 5.1"]
Signal { name: "availableSensorsChanged" }
Method { name: "sensorTypes"; type: "QStringList" }
Method {
@@ -182,7 +297,7 @@ Module {
Component {
name: "QmlSensorOutputRange"
prototype: "QObject"
- exports: ["OutputRange 5.0"]
+ exports: ["OutputRange 5.0", "OutputRange 5.1"]
Property { name: "minimum"; type: "double"; isReadonly: true }
Property { name: "maximum"; type: "double"; isReadonly: true }
Property { name: "accuracy"; type: "double"; isReadonly: true }
@@ -190,26 +305,30 @@ Module {
Component {
name: "QmlSensorRange"
prototype: "QObject"
- exports: ["Range 5.0"]
+ exports: ["Range 5.0", "Range 5.1"]
Property { name: "minimum"; type: "int"; isReadonly: true }
Property { name: "maximum"; type: "int"; isReadonly: true }
}
Component {
name: "QmlSensorReading"
prototype: "QObject"
- exports: ["SensorReading 5.0"]
+ exports: ["SensorReading 5.0", "SensorReading 5.1"]
Property { name: "timestamp"; type: "qulonglong"; isReadonly: true }
}
Component {
name: "QmlTapSensor"
prototype: "QmlSensor"
- exports: ["TapSensor 5.0"]
+ exports: ["TapSensor 5.0", "TapSensor 5.1"]
Property { name: "returnDoubleTapEvents"; type: "bool" }
+ Signal {
+ name: "returnDoubleTapEventsChanged"
+ Parameter { name: "returnDoubleTapEvents"; type: "bool" }
+ }
}
Component {
name: "QmlTapSensorReading"
prototype: "QmlSensorReading"
- exports: ["TapReading 5.0"]
+ exports: ["TapReading 5.0", "TapReading 5.1"]
Property { name: "tapDirection"; type: "QTapReading::TapDirection"; isReadonly: true }
Property { name: "doubleTap"; type: "bool"; isReadonly: true }
Signal { name: "isDoubleTapChanged" }
@@ -217,13 +336,13 @@ Module {
Component {
name: "QmlTiltSensor"
prototype: "QmlSensor"
- exports: ["TiltSensor 5.0"]
+ exports: ["TiltSensor 5.0", "TiltSensor 5.1"]
Method { name: "calibrate" }
}
Component {
name: "QmlTiltSensorReading"
prototype: "QmlSensorReading"
- exports: ["TiltReading 5.0"]
+ exports: ["TiltReading 5.0", "TiltReading 5.1"]
Property { name: "yRotation"; type: "double"; isReadonly: true }
Property { name: "xRotation"; type: "double"; isReadonly: true }
}
diff --git a/src/imports/sensors/qmlaccelerometer.cpp b/src/imports/sensors/qmlaccelerometer.cpp
index 390f8beb..6fc82eab 100644
--- a/src/imports/sensors/qmlaccelerometer.cpp
+++ b/src/imports/sensors/qmlaccelerometer.cpp
@@ -65,12 +65,33 @@ QmlAccelerometer::QmlAccelerometer(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QAccelerometer(this))
{
+ connect(m_sensor, SIGNAL(accelerationModeChanged(AccelerationMode)),
+ this, SIGNAL(accelerationModeChanged(AccelerationMode)));
}
QmlAccelerometer::~QmlAccelerometer()
{
}
+/*!
+ \qmlproperty AccelerationMode Accelerometer::accelerationMode
+ \since QtSensors 5.1
+
+ This property holds the current acceleration mode.
+
+ Please see QAccelerometer::accelerationMode for information about this property.
+*/
+
+QmlAccelerometer::AccelerationMode QmlAccelerometer::accelerationMode() const
+{
+ return static_cast<QmlAccelerometer::AccelerationMode>(m_sensor->accelerationMode());
+}
+
+void QmlAccelerometer::setAccelerationMode(QmlAccelerometer::AccelerationMode accelerationMode)
+{
+ m_sensor->setAccelerationMode(static_cast<QAccelerometer::AccelerationMode>(accelerationMode));
+}
+
QmlSensorReading *QmlAccelerometer::createReading() const
{
return new QmlAccelerometerReading(m_sensor);
diff --git a/src/imports/sensors/qmlaccelerometer.h b/src/imports/sensors/qmlaccelerometer.h
index 95785ed4..7a9a4cd0 100644
--- a/src/imports/sensors/qmlaccelerometer.h
+++ b/src/imports/sensors/qmlaccelerometer.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QAccelerometer;
@@ -52,10 +51,25 @@ class QAccelerometer;
class QmlAccelerometer : public QmlSensor
{
Q_OBJECT
+ Q_ENUMS(AccelerationMode)
+ Q_PROPERTY(AccelerationMode accelerationMode READ accelerationMode WRITE setAccelerationMode
+ NOTIFY accelerationModeChanged REVISION 1)
public:
explicit QmlAccelerometer(QObject *parent = 0);
~QmlAccelerometer();
+ // Keep this enum in sync with QAccelerometer::AccelerationMode
+ enum AccelerationMode {
+ Combined,
+ Gravity,
+ User
+ };
+
+ AccelerationMode accelerationMode() const;
+ void setAccelerationMode(AccelerationMode accelerationMode);
+
+signals:
+ void accelerationModeChanged(AccelerationMode accelerationMode);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
@@ -92,5 +106,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlaltimeter.cpp b/src/imports/sensors/qmlaltimeter.cpp
new file mode 100644
index 00000000..abe3f922
--- /dev/null
+++ b/src/imports/sensors/qmlaltimeter.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qmlaltimeter.h"
+#include <QAltimeter>
+
+/*!
+ \qmltype Altimeter
+ \instantiates QmlAltimeter
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits Sensor
+ \brief The Altimeter element reports on altitude.
+
+ The Altimeter element reports on altitude.
+
+ This element wraps the QAltimeter class. Please see the documentation for
+ QAltimeter for details.
+
+ \sa AltimeterReading
+*/
+
+QmlAltimeter::QmlAltimeter(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QAltimeter(this))
+{
+}
+
+QmlAltimeter::~QmlAltimeter()
+{
+}
+
+QmlSensorReading *QmlAltimeter::createReading() const
+{
+ return new QmlAltimeterReading(m_sensor);
+}
+
+QSensor *QmlAltimeter::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype AltimeterReading
+ \instantiates QmlAltimeterReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits SensorReading
+ \brief The AltimeterReading element holds the most recent Altimeter reading.
+
+ The AltimeterReading element holds the most recent Altimeter reading.
+
+ This element wraps the QAltimeterReading class. Please see the documentation for
+ QAltimeterReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlAltimeterReading::QmlAltimeterReading(QAltimeter *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_altitude(0)
+{
+}
+
+QmlAltimeterReading::~QmlAltimeterReading()
+{
+}
+
+/*!
+ \qmlproperty qreal AltimeterReading::altitude
+ This property holds the altitude of the device.
+
+ Please see QAltimeterReading::altitude for information about this property.
+*/
+
+qreal QmlAltimeterReading::altitude() const
+{
+ return m_altitude;
+}
+
+QSensorReading *QmlAltimeterReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlAltimeterReading::readingUpdate()
+{
+ qreal altitude = m_sensor->reading()->altitude();
+ if (m_altitude != altitude) {
+ m_altitude = altitude;
+ Q_EMIT altitudeChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlaltimeter.h b/src/imports/sensors/qmlaltimeter.h
new file mode 100644
index 00000000..4568baaa
--- /dev/null
+++ b/src/imports/sensors/qmlaltimeter.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QMLALTIMETER_H
+#define QMLALTIMETER_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QAltimeter;
+
+class QmlAltimeter : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlAltimeter(QObject *parent = 0);
+ ~QmlAltimeter();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ QAltimeter *m_sensor;
+};
+
+class QmlAltimeterReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal altitude READ altitude NOTIFY altitudeChanged)
+public:
+ explicit QmlAltimeterReading(QAltimeter *sensor);
+ ~QmlAltimeterReading();
+
+ qreal altitude() const;
+
+Q_SIGNALS:
+ void altitudeChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ QAltimeter *m_sensor;
+ qreal m_altitude;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/imports/sensors/qmlambientlightsensor.h b/src/imports/sensors/qmlambientlightsensor.h
index eecb6b12..7715a39f 100644
--- a/src/imports/sensors/qmlambientlightsensor.h
+++ b/src/imports/sensors/qmlambientlightsensor.h
@@ -45,7 +45,6 @@
#include "qmlsensor.h"
#include <QAmbientLightSensor>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QAmbientLightSensor;
@@ -86,5 +85,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlambienttemperaturesensor.cpp b/src/imports/sensors/qmlambienttemperaturesensor.cpp
new file mode 100644
index 00000000..1190fca6
--- /dev/null
+++ b/src/imports/sensors/qmlambienttemperaturesensor.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qmlambienttemperaturesensor.h"
+#include <QAmbientTemperatureSensor>
+
+/*!
+ \qmltype AmbientTemperatureSensor
+ \instantiates QmlAmbientTemperatureSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits Sensor
+ \brief The AmbientTemperatureSensor element reports on the ambient temperature.
+
+ The AmbientTemperatureSensor element reports on the ambient temperature.
+
+ This element wraps the QAmbientTemperatureSensor class. Please see the documentation for
+ QAmbientTemperatureSensor for details.
+
+ \sa AmbientTemperatureReading
+*/
+
+QmlAmbientTemperatureSensor::QmlAmbientTemperatureSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QAmbientTemperatureSensor(this))
+{
+}
+
+QmlAmbientTemperatureSensor::~QmlAmbientTemperatureSensor()
+{
+}
+
+QmlSensorReading *QmlAmbientTemperatureSensor::createReading() const
+{
+ return new QmlAmbientTemperatureReading(m_sensor);
+}
+
+QSensor *QmlAmbientTemperatureSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype AmbientTemperatureReading
+ \instantiates QmlAmbientTemperatureReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits SensorReading
+ \brief The AmbientTemperatureReading element holds the most recent temperature reading.
+
+ The AmbientTemperatureReading element holds the most recent temperature reading.
+
+ This element wraps the QAmbientTemperatureReading class. Please see the documentation for
+ QAmbientTemperatureReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlAmbientTemperatureReading::QmlAmbientTemperatureReading(QAmbientTemperatureSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_temperature(0)
+{
+}
+
+QmlAmbientTemperatureReading::~QmlAmbientTemperatureReading()
+{
+}
+
+/*!
+ \qmlproperty qreal AmbientTemperatureReading::temperature
+ This property holds the ambient temperature in degree Celsius.
+
+ Please see QAmbientTemperatureReading::temperature for information about this property.
+*/
+
+qreal QmlAmbientTemperatureReading::temperature() const
+{
+ return m_temperature;
+}
+
+QSensorReading *QmlAmbientTemperatureReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlAmbientTemperatureReading::readingUpdate()
+{
+ const qreal temperature = m_sensor->reading()->temperature();
+ if (m_temperature != temperature) {
+ m_temperature = temperature;
+ Q_EMIT temperatureChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlambienttemperaturesensor.h b/src/imports/sensors/qmlambienttemperaturesensor.h
new file mode 100644
index 00000000..1c1d8dd6
--- /dev/null
+++ b/src/imports/sensors/qmlambienttemperaturesensor.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QMLAMBIENTTEMPERATURESENSOR_H
+#define QMLAMBIENTTEMPERATURESENSOR_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QAmbientTemperatureSensor;
+
+class QmlAmbientTemperatureSensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlAmbientTemperatureSensor(QObject *parent = 0);
+ ~QmlAmbientTemperatureSensor();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ QAmbientTemperatureSensor *m_sensor;
+};
+
+class QmlAmbientTemperatureReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal temperature READ temperature NOTIFY temperatureChanged)
+public:
+ explicit QmlAmbientTemperatureReading(QAmbientTemperatureSensor *sensor);
+ ~QmlAmbientTemperatureReading();
+
+ qreal temperature() const;
+
+Q_SIGNALS:
+ void temperatureChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ QAmbientTemperatureSensor *m_sensor;
+ qreal m_temperature;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/imports/sensors/qmlcompass.h b/src/imports/sensors/qmlcompass.h
index 30edbf0a..76294bf9 100644
--- a/src/imports/sensors/qmlcompass.h
+++ b/src/imports/sensors/qmlcompass.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QCompass;
@@ -88,5 +87,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlgyroscope.h b/src/imports/sensors/qmlgyroscope.h
index c5f6c902..f6fb6795 100644
--- a/src/imports/sensors/qmlgyroscope.h
+++ b/src/imports/sensors/qmlgyroscope.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QGyroscope;
@@ -92,5 +91,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlholstersensor.cpp b/src/imports/sensors/qmlholstersensor.cpp
new file mode 100644
index 00000000..a1eae05b
--- /dev/null
+++ b/src/imports/sensors/qmlholstersensor.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qmlholstersensor.h"
+#include <QHolsterSensor>
+
+/*!
+ \qmltype HolsterSensor
+ \instantiates QmlHolsterSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits Sensor
+ \brief The HolsterSensor element reports on whether a device is holstered.
+
+ The HolsterSensor element reports on whether a device is holstered.
+
+ This element wraps the QHolsterSensor class. Please see the documentation for
+ QHolsterSensor for details.
+
+ \sa HolsterReading
+*/
+
+QmlHolsterSensor::QmlHolsterSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QHolsterSensor(this))
+{
+}
+
+QmlHolsterSensor::~QmlHolsterSensor()
+{
+}
+
+QmlSensorReading *QmlHolsterSensor::createReading() const
+{
+ return new QmlHolsterReading(m_sensor);
+}
+
+QSensor *QmlHolsterSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype HolsterReading
+ \instantiates QmlHolsterReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits SensorReading
+ \brief The HolsterReading element holds the most recent HolsterSensor reading.
+
+ The HolsterReading element holds the most recent HolsterSensor reading.
+
+ This element wraps the QHolsterReading class. Please see the documentation for
+ QHolsterReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlHolsterReading::QmlHolsterReading(QHolsterSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_holstered(false)
+{
+}
+
+QmlHolsterReading::~QmlHolsterReading()
+{
+}
+
+/*!
+ \qmlproperty qreal HolsterReading::holstered
+ This property holds whether the device is holstered.
+
+ Please see QHolsterReading::holstered for information about this property.
+*/
+
+bool QmlHolsterReading::holstered() const
+{
+ return m_holstered;
+}
+
+QSensorReading *QmlHolsterReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlHolsterReading::readingUpdate()
+{
+ qreal holstered = m_sensor->reading()->holstered();
+ if (m_holstered != holstered) {
+ m_holstered = holstered;
+ Q_EMIT holsteredChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlholstersensor.h b/src/imports/sensors/qmlholstersensor.h
new file mode 100644
index 00000000..262ba69d
--- /dev/null
+++ b/src/imports/sensors/qmlholstersensor.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QMLHOLSTERSENSOR_H
+#define QMLHOLSTERSENSOR_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QHolsterSensor;
+
+class QmlHolsterSensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlHolsterSensor(QObject *parent = 0);
+ ~QmlHolsterSensor();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ QHolsterSensor *m_sensor;
+};
+
+class QmlHolsterReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(bool holstered READ holstered NOTIFY holsteredChanged)
+public:
+ explicit QmlHolsterReading(QHolsterSensor *sensor);
+ ~QmlHolsterReading();
+
+ bool holstered() const;
+
+Q_SIGNALS:
+ void holsteredChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ QHolsterSensor *m_sensor;
+ bool m_holstered;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/imports/sensors/qmlirproximitysensor.h b/src/imports/sensors/qmlirproximitysensor.h
index 2b2d4c49..ec39fe8b 100644
--- a/src/imports/sensors/qmlirproximitysensor.h
+++ b/src/imports/sensors/qmlirproximitysensor.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QIRProximitySensor;
@@ -83,5 +82,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmllightsensor.cpp b/src/imports/sensors/qmllightsensor.cpp
index 1c3fed2c..86126a2a 100644
--- a/src/imports/sensors/qmllightsensor.cpp
+++ b/src/imports/sensors/qmllightsensor.cpp
@@ -63,6 +63,8 @@ QmlLightSensor::QmlLightSensor(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QLightSensor(this))
{
+ connect(m_sensor, SIGNAL(fieldOfViewChanged(qreal)),
+ this, SIGNAL(fieldOfViewChanged(qreal)));
}
QmlLightSensor::~QmlLightSensor()
@@ -88,13 +90,7 @@ QSensor *QmlLightSensor::sensor() const
qreal QmlLightSensor::fieldOfView() const
{
- return m_sensor->property("fieldOfView").value<qreal>();
-}
-
-void QmlLightSensor::_update()
-{
- if (fieldOfView() != qreal())
- Q_EMIT fieldOfViewChanged();
+ return m_sensor->fieldOfView();
}
/*!
diff --git a/src/imports/sensors/qmllightsensor.h b/src/imports/sensors/qmllightsensor.h
index 90fe0b7f..e42d7818 100644
--- a/src/imports/sensors/qmllightsensor.h
+++ b/src/imports/sensors/qmllightsensor.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QLightSensor;
@@ -59,13 +58,11 @@ public:
qreal fieldOfView() const;
-
Q_SIGNALS:
- void fieldOfViewChanged();
+ void fieldOfViewChanged(qreal fieldOfView);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
- void _update();
QLightSensor *m_sensor;
QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
};
@@ -91,5 +88,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlmagnetometer.cpp b/src/imports/sensors/qmlmagnetometer.cpp
index 1f95b3f2..2c531f70 100644
--- a/src/imports/sensors/qmlmagnetometer.cpp
+++ b/src/imports/sensors/qmlmagnetometer.cpp
@@ -65,6 +65,8 @@ QmlMagnetometer::QmlMagnetometer(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QMagnetometer(this))
{
+ connect(m_sensor, SIGNAL(returnGeoValuesChanged(bool)),
+ this, SIGNAL(returnGeoValuesChanged(bool)));
}
QmlMagnetometer::~QmlMagnetometer()
@@ -90,13 +92,12 @@ QSensor *QmlMagnetometer::sensor() const
bool QmlMagnetometer::returnGeoValues() const
{
- return m_sensor->property("returnGeoValues").toBool();
+ return m_sensor->returnGeoValues();
}
void QmlMagnetometer::setReturnGeoValues(bool geo)
{
- if (m_sensor->property("returnGeoValues").toBool() == geo) return;
- m_sensor->setProperty("returnGeoValues", geo);
+ m_sensor->setReturnGeoValues(geo);
}
/*!
diff --git a/src/imports/sensors/qmlmagnetometer.h b/src/imports/sensors/qmlmagnetometer.h
index d6c75c1e..6e5facda 100644
--- a/src/imports/sensors/qmlmagnetometer.h
+++ b/src/imports/sensors/qmlmagnetometer.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QMagnetometer;
@@ -52,6 +51,7 @@ class QMagnetometer;
class QmlMagnetometer : public QmlSensor
{
Q_OBJECT
+ Q_PROPERTY(bool returnGeoValues READ returnGeoValues WRITE setReturnGeoValues NOTIFY returnGeoValuesChanged)
public:
explicit QmlMagnetometer(QObject *parent = 0);
~QmlMagnetometer();
@@ -59,6 +59,8 @@ public:
bool returnGeoValues() const;
void setReturnGeoValues(bool geo);
+Q_SIGNALS:
+ void returnGeoValuesChanged(bool returnGeoValues);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
@@ -99,5 +101,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlorientationsensor.h b/src/imports/sensors/qmlorientationsensor.h
index d14197e8..35e9d6fb 100644
--- a/src/imports/sensors/qmlorientationsensor.h
+++ b/src/imports/sensors/qmlorientationsensor.h
@@ -45,7 +45,6 @@
#include "qmlsensor.h"
#include <QOrientationSensor>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QOrientationSensor;
@@ -86,5 +85,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlpressuresensor.cpp b/src/imports/sensors/qmlpressuresensor.cpp
new file mode 100644
index 00000000..a21f7c0d
--- /dev/null
+++ b/src/imports/sensors/qmlpressuresensor.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qmlpressuresensor.h"
+#include <QPressureSensor>
+
+/*!
+ \qmltype PressureSensor
+ \instantiates QmlPressureSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits Sensor
+ \brief The PressureSensor element reports on atmospheric pressure values.
+
+ The PressureSensor element reports on atmospheric pressure values.
+
+ This element wraps the QPressureSensor class. Please see the documentation for
+ QPressureSensor for details.
+
+ \sa PressureReading
+*/
+
+QmlPressureSensor::QmlPressureSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QPressureSensor(this))
+{
+}
+
+QmlPressureSensor::~QmlPressureSensor()
+{
+}
+
+QmlSensorReading *QmlPressureSensor::createReading() const
+{
+ return new QmlPressureReading(m_sensor);
+}
+
+QSensor *QmlPressureSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype PressureReading
+ \instantiates QmlPressureReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits SensorReading
+ \brief The PressureReading element holds the most recent PressureSensor reading.
+
+ The PressureReading element holds the most recent PressureSensor reading.
+
+ This element wraps the QPressureReading class. Please see the documentation for
+ QPressureReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlPressureReading::QmlPressureReading(QPressureSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_pressure(0)
+{
+}
+
+QmlPressureReading::~QmlPressureReading()
+{
+}
+
+/*!
+ \qmlproperty qreal PressureReading::pressure
+ This property holds the atmospheric pressure value in Pascals.
+
+ Please see QPressureReading::pressure for information about this property.
+*/
+
+qreal QmlPressureReading::pressure() const
+{
+ return m_pressure;
+}
+
+QSensorReading *QmlPressureReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlPressureReading::readingUpdate()
+{
+ qreal pressure = m_sensor->reading()->pressure();
+ if (m_pressure != pressure) {
+ m_pressure = pressure;
+ Q_EMIT pressureChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlpressuresensor.h b/src/imports/sensors/qmlpressuresensor.h
new file mode 100644
index 00000000..627915a6
--- /dev/null
+++ b/src/imports/sensors/qmlpressuresensor.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QMLPRESSURESENSOR_H
+#define QMLPRESSURESENSOR_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QPressureSensor;
+
+class QmlPressureSensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlPressureSensor(QObject *parent = 0);
+ ~QmlPressureSensor();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ QPressureSensor *m_sensor;
+};
+
+class QmlPressureReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged)
+public:
+ explicit QmlPressureReading(QPressureSensor *sensor);
+ ~QmlPressureReading();
+
+ qreal pressure() const;
+
+Q_SIGNALS:
+ void pressureChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ QPressureSensor *m_sensor;
+ qreal m_pressure;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/imports/sensors/qmlproximitysensor.h b/src/imports/sensors/qmlproximitysensor.h
index afbc3a01..17cb2f9a 100644
--- a/src/imports/sensors/qmlproximitysensor.h
+++ b/src/imports/sensors/qmlproximitysensor.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QProximitySensor;
@@ -84,5 +83,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlrotationsensor.cpp b/src/imports/sensors/qmlrotationsensor.cpp
index e58a3f8c..f1821641 100644
--- a/src/imports/sensors/qmlrotationsensor.cpp
+++ b/src/imports/sensors/qmlrotationsensor.cpp
@@ -65,6 +65,7 @@ QmlRotationSensor::QmlRotationSensor(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QRotationSensor(this))
{
+ connect(m_sensor, SIGNAL(hasZChanged(bool)), this, SIGNAL(hasZChanged(bool)));
}
QmlRotationSensor::~QmlRotationSensor()
@@ -90,7 +91,7 @@ QSensor *QmlRotationSensor::sensor() const
bool QmlRotationSensor::hasZ() const
{
- return m_sensor->property("hasZ").toBool();
+ return m_sensor->hasZ();
}
void QmlRotationSensor::_update()
diff --git a/src/imports/sensors/qmlrotationsensor.h b/src/imports/sensors/qmlrotationsensor.h
index db3b62f6..4d7b543a 100644
--- a/src/imports/sensors/qmlrotationsensor.h
+++ b/src/imports/sensors/qmlrotationsensor.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QRotationSensor;
@@ -52,13 +51,15 @@ class QRotationSensor;
class QmlRotationSensor : public QmlSensor
{
Q_OBJECT
- Q_PROPERTY(bool hasZ READ hasZ)
+ Q_PROPERTY(bool hasZ READ hasZ NOTIFY hasZChanged)
public:
explicit QmlRotationSensor(QObject *parent = 0);
~QmlRotationSensor();
bool hasZ() const;
+Q_SIGNALS:
+ void hasZChanged(bool hasZ);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
@@ -96,5 +97,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlsensor.cpp b/src/imports/sensors/qmlsensor.cpp
index ec1b0691..3d59a72d 100644
--- a/src/imports/sensors/qmlsensor.cpp
+++ b/src/imports/sensors/qmlsensor.cpp
@@ -171,6 +171,25 @@ void QmlSensor::setAlwaysOn(bool alwaysOn)
}
/*!
+ \qmlproperty bool Sensor::skipDuplicates
+ \since QtSensors 5.1
+
+ This property indicates whether duplicate reading values should be omitted.
+
+ Please see QSensor::skipDuplicates for information about this property.
+*/
+
+bool QmlSensor::skipDuplicates() const
+{
+ return sensor()->skipDuplicates();
+}
+
+void QmlSensor::setSkipDuplicates(bool skipDuplicates)
+{
+ sensor()->setSkipDuplicates(skipDuplicates);
+}
+
+/*!
\qmlproperty list<Range> Sensor::availableDataRates
This property holds the data rates that the sensor supports.
@@ -288,6 +307,99 @@ QmlSensorReading *QmlSensor::reading() const
}
/*!
+ \qmlproperty Sensor::AxesOrientationMode Sensor::axesOrientationMode
+ \since QtSensors 5.1
+ This property holds the mode that affects how the screen orientation changes reading values.
+
+ Please see QSensor::axesOrientationMode for information about this property.
+*/
+
+QmlSensor::AxesOrientationMode QmlSensor::axesOrientationMode() const
+{
+ return static_cast<QmlSensor::AxesOrientationMode>(sensor()->axesOrientationMode());
+}
+
+void QmlSensor::setAxesOrientationMode(QmlSensor::AxesOrientationMode axesOrientationMode)
+{
+ sensor()->setAxesOrientationMode(static_cast<QSensor::AxesOrientationMode>(axesOrientationMode));
+}
+
+/*!
+ \qmlproperty int Sensor::currentOrientation
+ \since QtSensors 5.1
+ This property holds the current orientation that is used for rotating the reading values.
+
+ Please see QSensor::currentOrientation for information about this property.
+*/
+
+int QmlSensor::currentOrientation() const
+{
+ return sensor()->currentOrientation();
+}
+
+/*!
+ \qmlproperty int Sensor::userOrientation
+ \since QtSensors 5.1
+ This property holds the angle used for rotating the reading values in the UserOrientation mode.
+
+ Please see QSensor::userOrientation for information about this property.
+*/
+
+int QmlSensor::userOrientation() const
+{
+ return sensor()->userOrientation();
+}
+
+void QmlSensor::setUserOrientation(int userOrientation)
+{
+ sensor()->setUserOrientation(userOrientation);
+}
+
+/*!
+ \qmlproperty int Sensor::maxBufferSize
+ \since QtSensors 5.1
+ This property holds the maximum buffer size.
+
+ Please see QSensor::maxBufferSize for information about this property.
+*/
+
+int QmlSensor::maxBufferSize() const
+{
+ return sensor()->maxBufferSize();
+}
+
+/*!
+ \qmlproperty int Sensor::efficientBufferSize
+ \since QtSensors 5.1
+ The property holds the most efficient buffer size.
+
+ Please see QSensor::efficientBufferSize for information about this property.
+*/
+
+int QmlSensor::efficientBufferSize() const
+{
+ return sensor()->efficientBufferSize();
+}
+
+/*!
+ \qmlproperty int Sensor::bufferSize
+ \since QtSensors 5.1
+ This property holds the size of the buffer.
+
+ Please see QSensor::bufferSize for information about this property.
+*/
+
+int QmlSensor::bufferSize() const
+{
+ return sensor()->bufferSize();
+}
+
+void QmlSensor::setBufferSize(int bufferSize)
+{
+ sensor()->setBufferSize(bufferSize);
+}
+
+/*!
\qmlmethod bool Sensor::start()
Start retrieving values from the sensor. Returns true if the sensor was started, false otherwise.
@@ -323,6 +435,14 @@ void QmlSensor::componentComplete()
connect(sensor(), SIGNAL(sensorError(int)), this, SIGNAL(errorChanged()));
connect(sensor(), SIGNAL(activeChanged()), this, SIGNAL(activeChanged()));
connect(sensor(), SIGNAL(alwaysOnChanged()), this, SIGNAL(alwaysOnChanged()));
+ connect(sensor(), SIGNAL(skipDuplicatesChanged(bool)), this, SIGNAL(skipDuplicatesChanged(bool)));
+ connect(sensor(), SIGNAL(axesOrientationModeChanged(AxesOrientationMode)),
+ this, SIGNAL(axesOrientationModeChanged(AxesOrientationMode)));
+ connect(sensor(), SIGNAL(userOrientationChanged(int)), this, SIGNAL(userOrientationChanged(int)));
+ connect(sensor(), SIGNAL(currentOrientationChanged(int)), this, SIGNAL(currentOrientationChanged(int)));
+ connect(sensor(), SIGNAL(bufferSizeChanged(int)), this, SIGNAL(bufferSizeChanged(int)));
+ connect(sensor(), SIGNAL(maxBufferSizeChanged(int)), this, SIGNAL(maxBufferSizeChanged(int)));
+ connect(sensor(), SIGNAL(efficientBufferSizeChanged(int)), this, SIGNAL(efficientBufferSizeChanged(int)));
// We need to set this on the sensor object now
sensor()->setIdentifier(m_identifier.toLocal8Bit());
diff --git a/src/imports/sensors/qmlsensor.h b/src/imports/sensors/qmlsensor.h
index a4ac852d..f72234ae 100644
--- a/src/imports/sensors/qmlsensor.h
+++ b/src/imports/sensors/qmlsensor.h
@@ -46,7 +46,6 @@
#include <QQmlListProperty>
#include "qmlsensorrange.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QSensor;
@@ -57,6 +56,7 @@ class QmlSensorReading;
class QmlSensor : public QObject, public QQmlParserStatus
{
Q_OBJECT
+ Q_ENUMS(AxesOrientationMode)
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged)
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
@@ -71,7 +71,22 @@ class QmlSensor : public QObject, public QQmlParserStatus
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
Q_PROPERTY(int error READ error NOTIFY errorChanged)
Q_PROPERTY(bool alwaysOn READ isAlwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged)
+ Q_PROPERTY(bool skipDuplicates READ skipDuplicates WRITE setSkipDuplicates NOTIFY skipDuplicatesChanged REVISION 1)
+ Q_PROPERTY(AxesOrientationMode axesOrientationMode READ axesOrientationMode WRITE setAxesOrientationMode NOTIFY axesOrientationModeChanged REVISION 1)
+ Q_PROPERTY(int currentOrientation READ currentOrientation NOTIFY currentOrientationChanged REVISION 1)
+ Q_PROPERTY(int userOrientation READ userOrientation WRITE setUserOrientation NOTIFY userOrientationChanged REVISION 1)
+ Q_PROPERTY(int maxBufferSize READ maxBufferSize NOTIFY maxBufferSizeChanged REVISION 1)
+ Q_PROPERTY(int efficientBufferSize READ efficientBufferSize NOTIFY efficientBufferSizeChanged REVISION 1)
+ Q_PROPERTY(int bufferSize READ bufferSize WRITE setBufferSize NOTIFY bufferSizeChanged REVISION 1)
+
public:
+ // Keep in sync with QSensor::AxesOrientationMode
+ enum AxesOrientationMode {
+ FixedOrientation,
+ AutomaticOrientation,
+ UserOrientation
+ };
+
explicit QmlSensor(QObject *parent = 0);
~QmlSensor();
@@ -90,6 +105,9 @@ public:
bool isAlwaysOn() const;
void setAlwaysOn(bool alwaysOn);
+ bool skipDuplicates() const;
+ void setSkipDuplicates(bool skipDuplicates);
+
QQmlListProperty<QmlSensorRange> availableDataRates() const;
int dataRate() const;
void setDataRate(int rate);
@@ -103,6 +121,21 @@ public:
QmlSensorReading *reading() const;
+ AxesOrientationMode axesOrientationMode() const;
+ void setAxesOrientationMode(AxesOrientationMode axesOrientationMode);
+
+ int currentOrientation() const;
+
+ int userOrientation() const;
+ void setUserOrientation(int userOrientation);
+
+ int maxBufferSize() const;
+
+ int efficientBufferSize() const;
+
+ int bufferSize() const;
+ void setBufferSize(int bufferSize);
+
public Q_SLOTS:
bool start();
void stop();
@@ -120,6 +153,13 @@ Q_SIGNALS:
void descriptionChanged();
void errorChanged();
void alwaysOnChanged();
+ void skipDuplicatesChanged(bool skipDuplicates);
+ void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode);
+ void currentOrientationChanged(int currentOrientation);
+ void userOrientationChanged(int userOrientation);
+ void maxBufferSizeChanged(int maxBufferSize);
+ void efficientBufferSizeChanged(int efficientBufferSize);
+ void bufferSizeChanged(int bufferSize);
protected:
virtual QSensor *sensor() const = 0;
@@ -127,6 +167,8 @@ protected:
private Q_SLOTS:
void updateReading();
+
+protected Q_SLOTS:
void componentComplete();
private:
@@ -159,6 +201,5 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlsensorglobal.h b/src/imports/sensors/qmlsensorglobal.h
index fbbd30d7..cd28ffef 100644
--- a/src/imports/sensors/qmlsensorglobal.h
+++ b/src/imports/sensors/qmlsensorglobal.h
@@ -45,7 +45,6 @@
#include <QObject>
#include <QStringList>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QSensor;
@@ -69,6 +68,5 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlsensorrange.h b/src/imports/sensors/qmlsensorrange.h
index 261825b5..f2fcb510 100644
--- a/src/imports/sensors/qmlsensorrange.h
+++ b/src/imports/sensors/qmlsensorrange.h
@@ -44,7 +44,6 @@
#include <QObject>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QmlSensorRange : public QObject
@@ -94,5 +93,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmltapsensor.cpp b/src/imports/sensors/qmltapsensor.cpp
index 65afcb59..8877b0b0 100644
--- a/src/imports/sensors/qmltapsensor.cpp
+++ b/src/imports/sensors/qmltapsensor.cpp
@@ -65,6 +65,8 @@ QmlTapSensor::QmlTapSensor(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QTapSensor(this))
{
+ connect(m_sensor, SIGNAL(returnDoubleTapEventsChanged(bool)),
+ this, SIGNAL(returnDoubleTapEventsChanged(bool)));
}
QmlTapSensor::~QmlTapSensor()
@@ -90,14 +92,12 @@ QSensor *QmlTapSensor::sensor() const
bool QmlTapSensor::returnDoubleTapEvents() const
{
- return m_sensor->property("returnDoubleTapEvents").toBool();
+ return m_sensor->returnDoubleTapEvents();
}
void QmlTapSensor::setReturnDoubleTapEvents(bool ret)
{
- if (m_sensor->property("returnDoubleTapEvents").toBool() == ret) return;
- m_sensor->setProperty("returnDoubleTapEvents", ret);
- Q_EMIT returnDoubleTapEventsChanged();
+ m_sensor->setReturnDoubleTapEvents(ret);
}
/*!
diff --git a/src/imports/sensors/qmltapsensor.h b/src/imports/sensors/qmltapsensor.h
index f9ae94bd..b0c2fa5c 100644
--- a/src/imports/sensors/qmltapsensor.h
+++ b/src/imports/sensors/qmltapsensor.h
@@ -45,7 +45,6 @@
#include "qmlsensor.h"
#include <QTapSensor>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QTapSensor;
@@ -61,9 +60,8 @@ public:
bool returnDoubleTapEvents() const;
void setReturnDoubleTapEvents(bool ret);
-
Q_SIGNALS:
- void returnDoubleTapEventsChanged();
+ void returnDoubleTapEventsChanged(bool returnDoubleTapEvents);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
@@ -97,5 +95,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmltiltsensor.h b/src/imports/sensors/qmltiltsensor.h
index 9afed564..422c21dd 100644
--- a/src/imports/sensors/qmltiltsensor.h
+++ b/src/imports/sensors/qmltiltsensor.h
@@ -45,7 +45,6 @@
#include "qmlsensor.h"
#include <QtSensors/QTiltSensor>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QTiltSensor;
@@ -90,5 +89,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp
index 50ccdf93..77ad754a 100644
--- a/src/imports/sensors/sensors.cpp
+++ b/src/imports/sensors/sensors.cpp
@@ -44,7 +44,9 @@
#include <QtSensors/QSensorManager>
#include <QtSensors/qaccelerometer.h>
+#include <QtSensors/qaltimeter.h>
#include <QtSensors/qambientlightsensor.h>
+#include <QtSensors/qambienttemperaturesensor.h>
#include <QtSensors/qcompass.h>
#include <QtSensors/qmagnetometer.h>
#include <QtSensors/qorientationsensor.h>
@@ -59,13 +61,17 @@
#include "qmlsensorglobal.h"
#include "qmlsensor.h"
#include "qmlaccelerometer.h"
+#include "qmlaltimeter.h"
#include "qmlambientlightsensor.h"
+#include "qmlambienttemperaturesensor.h"
#include "qmlcompass.h"
#include "qmlgyroscope.h"
+#include "qmlholstersensor.h"
#include "qmlirproximitysensor.h"
#include "qmllightsensor.h"
#include "qmlmagnetometer.h"
#include "qmlorientationsensor.h"
+#include "qmlpressuresensor.h"
#include "qmlproximitysensor.h"
#include "qmlrotationsensor.h"
#include "qmltapsensor.h"
@@ -125,6 +131,49 @@ public:
qmlRegisterUncreatableType<QmlTiltSensorReading >(package, major, minor, "TiltReading", QLatin1String("Cannot create TiltReading"));
qmlRegisterType <QmlSensorGesture >(package, major, minor, "SensorGesture");
+
+ // Register the 5.1 interfaces
+ major = 5;
+ minor = 1;
+ qmlRegisterSingletonType <QmlSensorGlobal >(package, major, minor, "QmlSensors", global_object_50);
+ qmlRegisterUncreatableType<QmlSensorRange >(package, major, minor, "Range", QLatin1String("Cannot create Range"));
+ qmlRegisterUncreatableType<QmlSensorOutputRange >(package, major, minor, "OutputRange", QLatin1String("Cannot create OutputRange"));
+ qmlRegisterUncreatableType<QmlSensor,1 >(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor"));
+ qmlRegisterUncreatableType<QmlSensorReading >(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading"));
+ qmlRegisterType <QmlAccelerometer,1 >(package, major, minor, "Accelerometer");
+ qmlRegisterUncreatableType<QmlAccelerometerReading >(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading"));
+ qmlRegisterType <QmlAltimeter >(package, major, minor, "Altimeter");
+ qmlRegisterUncreatableType<QmlAltimeterReading >(package, major, minor, "AltimeterReading", QLatin1String("Cannot create AltimeterReading"));
+ qmlRegisterType <QmlAmbientLightSensor >(package, major, minor, "AmbientLightSensor");
+ qmlRegisterUncreatableType<QmlAmbientLightSensorReading>(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading"));
+ qmlRegisterType <QmlAmbientTemperatureSensor >(package, major, minor, "AmbientTemperatureSensor");
+ qmlRegisterUncreatableType<QmlAmbientTemperatureReading>(package, major, minor, "AmbientTemperatureReading", QLatin1String("Cannot create AmbientTemperatureReading"));
+ qmlRegisterType <QmlCompass >(package, major, minor, "Compass");
+ qmlRegisterUncreatableType<QmlCompassReading >(package, major, minor, "CompassReading", QLatin1String("Cannot create CompassReading"));
+ qmlRegisterType <QmlGyroscope >(package, major, minor, "Gyroscope");
+ qmlRegisterUncreatableType<QmlGyroscopeReading >(package, major, minor, "GyroscopeReading", QLatin1String("Cannot create GyroscopeReading"));
+ qmlRegisterType <QmlHolsterSensor >(package, major, minor, "HolsterSensor");
+ qmlRegisterUncreatableType<QmlHolsterReading >(package, major, minor, "HolsterReading", QLatin1String("Cannot create HolsterReading"));
+ qmlRegisterType <QmlIRProximitySensor >(package, major, minor, "IRProximitySensor");
+ qmlRegisterUncreatableType<QmlIRProximitySensorReading >(package, major, minor, "IRProximityReading", QLatin1String("Cannot create IRProximityReading"));
+ qmlRegisterType <QmlLightSensor >(package, major, minor, "LightSensor");
+ qmlRegisterUncreatableType<QmlLightSensorReading >(package, major, minor, "LightReading", QLatin1String("Cannot create LightReading"));
+ qmlRegisterType <QmlMagnetometer >(package, major, minor, "Magnetometer");
+ qmlRegisterUncreatableType<QmlMagnetometerReading >(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading"));
+ qmlRegisterType <QmlOrientationSensor >(package, major, minor, "OrientationSensor");
+ qmlRegisterUncreatableType<QmlOrientationSensorReading >(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading"));
+ qmlRegisterType <QmlPressureSensor >(package, major, minor, "PressureSensor");
+ qmlRegisterUncreatableType<QmlPressureReading >(package, major, minor, "PressureReading", QLatin1String("Cannot create PressureReading"));
+ qmlRegisterType <QmlProximitySensor >(package, major, minor, "ProximitySensor");
+ qmlRegisterUncreatableType<QmlProximitySensorReading >(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading"));
+ qmlRegisterType <QmlRotationSensor >(package, major, minor, "RotationSensor");
+ qmlRegisterUncreatableType<QmlRotationSensorReading >(package, major, minor, "RotationReading", QLatin1String("Cannot create RotationReading"));
+ qmlRegisterType <QmlTapSensor >(package, major, minor, "TapSensor");
+ qmlRegisterUncreatableType<QmlTapSensorReading >(package, major, minor, "TapReading", QLatin1String("Cannot create TapReading"));
+ qmlRegisterType <QmlTiltSensor >(package, major, minor, "TiltSensor");
+ qmlRegisterUncreatableType<QmlTiltSensorReading >(package, major, minor, "TiltReading", QLatin1String("Cannot create TiltReading"));
+
+ qmlRegisterType <QmlSensorGesture >(package, major, minor, "SensorGesture");
}
};
diff --git a/src/imports/sensors/sensors.pro b/src/imports/sensors/sensors.pro
index 210ceac1..2236ce11 100644
--- a/src/imports/sensors/sensors.pro
+++ b/src/imports/sensors/sensors.pro
@@ -1,7 +1,7 @@
CXX_MODULE = sensors
TARGET = declarative_sensors
TARGETPATH = QtSensors
-IMPORT_VERSION = 5.0 # Doesn't matter, as long as it's a valid version?!
+IMPORT_VERSION = 5.1 # Doesn't matter, as long as it's a valid version?!
QT += qml sensors sensors-private
@@ -9,13 +9,17 @@ HEADERS += \
qmlsensor.h \
qmlsensorrange.h \
qmlaccelerometer.h \
+ qmlaltimeter.h \
qmlambientlightsensor.h \
+ qmlambienttemperaturesensor.h \
qmlcompass.h \
qmlgyroscope.h \
+ qmlholstersensor.h \
qmlirproximitysensor.h \
qmllightsensor.h \
qmlmagnetometer.h \
qmlorientationsensor.h \
+ qmlpressuresensor.h\
qmlproximitysensor.h \
qmltapsensor.h \
qmlrotationsensor.h \
@@ -27,13 +31,17 @@ SOURCES += sensors.cpp \
qmlsensor.cpp \
qmlsensorrange.cpp \
qmlaccelerometer.cpp \
+ qmlaltimeter.cpp \
qmlambientlightsensor.cpp \
+ qmlambienttemperaturesensor.cpp \
qmlcompass.cpp \
qmlgyroscope.cpp \
+ qmlholstersensor.cpp \
qmlirproximitysensor.cpp \
qmllightsensor.cpp \
qmlmagnetometer.cpp \
qmlorientationsensor.cpp \
+ qmlpressuresensor.cpp\
qmlproximitysensor.cpp \
qmltapsensor.cpp \
qmlrotationsensor.cpp \
diff --git a/src/plugins/sensors/blackberry/bbaccelerometer.cpp b/src/plugins/sensors/blackberry/bbaccelerometer.cpp
index dcbd7fcc..0826cf7a 100644
--- a/src/plugins/sensors/blackberry/bbaccelerometer.cpp
+++ b/src/plugins/sensors/blackberry/bbaccelerometer.cpp
@@ -44,6 +44,12 @@ BbAccelerometer::BbAccelerometer(QSensor *sensor)
: BbSensorBackend<QAccelerometerReading>(devicePath(), SENSOR_TYPE_ACCELEROMETER, sensor)
{
setDescription(QLatin1String("X, Y, and Z axes accelerations in m/s^2"));
+
+ QAccelerometer * const accelerometer = qobject_cast<QAccelerometer *>(sensor);
+ if (accelerometer) {
+ connect(accelerometer, SIGNAL(accelerationModeChanged(AccelerationMode)),
+ this, SLOT(applyAccelerationMode()));
+ }
}
bool BbAccelerometer::updateReadingFromEvent(const sensor_event_t &event, QAccelerometerReading *reading)
@@ -58,7 +64,39 @@ bool BbAccelerometer::updateReadingFromEvent(const sensor_event_t &event, QAccel
return true;
}
+void BbAccelerometer::start()
+{
+ applyAccelerationMode();
+ BbSensorBackend<QAccelerometerReading>::start();
+}
+
QString BbAccelerometer::devicePath()
{
return QLatin1String("/dev/sensor/accel");
}
+
+void BbAccelerometer::applyAccelerationMode()
+{
+ const QAccelerometer * const accelerometer = qobject_cast<QAccelerometer *>(sensor());
+ if (accelerometer) {
+ QString fileName;
+ sensor_type_e sensorType;
+ switch (accelerometer->accelerationMode()) {
+ case QAccelerometer::Gravity:
+ fileName = QLatin1String("/dev/sensor/gravity");
+ sensorType = SENSOR_TYPE_GRAVITY;
+ break;
+ case QAccelerometer::User:
+ fileName = QLatin1String("/dev/sensor/linAccel");
+ sensorType = SENSOR_TYPE_LINEAR_ACCEL;
+ break;
+ default:
+ case QAccelerometer::Combined:
+ fileName = devicePath();
+ sensorType = SENSOR_TYPE_ACCELEROMETER;
+ break;
+ }
+
+ setDevice(fileName, sensorType);
+ }
+}
diff --git a/src/plugins/sensors/blackberry/bbaccelerometer.h b/src/plugins/sensors/blackberry/bbaccelerometer.h
index aa47873c..3071c801 100644
--- a/src/plugins/sensors/blackberry/bbaccelerometer.h
+++ b/src/plugins/sensors/blackberry/bbaccelerometer.h
@@ -51,10 +51,14 @@ class BbAccelerometer : public BbSensorBackend<QAccelerometerReading>
public:
explicit BbAccelerometer(QSensor *sensor);
+ void start() Q_DECL_OVERRIDE;
static QString devicePath();
protected:
bool updateReadingFromEvent(const sensor_event_t &event, QAccelerometerReading *reading) Q_DECL_OVERRIDE;
+
+private Q_SLOTS:
+ void applyAccelerationMode();
};
#endif
diff --git a/src/plugins/sensors/blackberry/bbaltimeter.cpp b/src/plugins/sensors/blackberry/bbaltimeter.cpp
index 07aa2646..3d21ef32 100644
--- a/src/plugins/sensors/blackberry/bbaltimeter.cpp
+++ b/src/plugins/sensors/blackberry/bbaltimeter.cpp
@@ -40,36 +40,13 @@
****************************************************************************/
#include "bbaltimeter.h"
-class BbAltimeterReadingPrivate
-{
-public:
- BbAltimeterReadingPrivate()
- : altitude(0)
- {
- }
-
- qreal altitude;
-};
-
-IMPLEMENT_READING(BbAltimeterReading)
-
-qreal BbAltimeterReading::altitude() const
-{
- return d->altitude;
-}
-
-void BbAltimeterReading::setAltitude(qreal altitude)
-{
- d->altitude = altitude;
-}
-
BbAltimeter::BbAltimeter(QSensor *sensor)
- : BbSensorBackend<BbAltimeterReading>(devicePath(), SENSOR_TYPE_ALTIMETER, sensor)
+ : BbSensorBackend<QAltimeterReading>(devicePath(), SENSOR_TYPE_ALTIMETER, sensor)
{
setDescription(QLatin1String("Altitude in meters relative to mean sea level"));
}
-bool BbAltimeter::updateReadingFromEvent(const sensor_event_t &event, BbAltimeterReading *reading)
+bool BbAltimeter::updateReadingFromEvent(const sensor_event_t &event, QAltimeterReading *reading)
{
reading->setAltitude(event.altitude_s.altitude);
return true;
diff --git a/src/plugins/sensors/blackberry/bbaltimeter.h b/src/plugins/sensors/blackberry/bbaltimeter.h
index 4744a3ff..b369c6cb 100644
--- a/src/plugins/sensors/blackberry/bbaltimeter.h
+++ b/src/plugins/sensors/blackberry/bbaltimeter.h
@@ -42,20 +42,9 @@
#define BBALTIMETER_H
#include "bbsensorbackend.h"
+#include <qaltimeter.h>
-class BbAltimeterReadingPrivate;
-
-class BbAltimeterReading : public QSensorReading
-{
- Q_OBJECT
- Q_PROPERTY(qreal altitude READ altitude)
- DECLARE_READING(BbAltimeterReading)
-public:
- qreal altitude() const;
- void setAltitude(qreal altitude);
-};
-
-class BbAltimeter : public BbSensorBackend<BbAltimeterReading>
+class BbAltimeter : public BbSensorBackend<QAltimeterReading>
{
Q_OBJECT
@@ -65,7 +54,7 @@ public:
static QString devicePath();
protected:
- bool updateReadingFromEvent(const sensor_event_t &event, BbAltimeterReading *reading) Q_DECL_OVERRIDE;
+ bool updateReadingFromEvent(const sensor_event_t &event, QAltimeterReading *reading) Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/plugins/sensors/blackberry/bbcompass.cpp b/src/plugins/sensors/blackberry/bbcompass.cpp
index 6e33d1a3..df8cc2e1 100644
--- a/src/plugins/sensors/blackberry/bbcompass.cpp
+++ b/src/plugins/sensors/blackberry/bbcompass.cpp
@@ -55,19 +55,28 @@ BbCompass::BbCompass(QSensor *sensor)
bool BbCompass::updateReadingFromEvent(const sensor_event_t &event, QCompassReading *reading)
{
+ float azimuth;
#ifdef HAVE_COMPASS_SENSOR
- reading->setAzimuth(event.compass_s.azimuth);
+ azimuth = event.compass_s.azimuth;
#else
float xRad, yRad, zRad;
matrixToEulerZXY(event.rotation_matrix, xRad, yRad, zRad);
- float azimuth = radiansToDegrees(zRad);
+ azimuth = radiansToDegrees(zRad);
if (azimuth < 0)
azimuth = -azimuth;
else
azimuth = 360.0f - azimuth;
- reading->setAzimuth(azimuth);
#endif
+ if (isAutoAxisRemappingEnabled()) {
+ azimuth += orientationForRemapping();
+ if (azimuth >= 360.0f)
+ azimuth -= 360.0f;
+ }
+
+ reading->setAzimuth(azimuth);
+
+
switch (event.accuracy) {
case SENSOR_ACCURACY_UNRELIABLE:
reading->setCalibrationLevel(0.0f);
diff --git a/src/plugins/sensors/blackberry/bbholstersensor.cpp b/src/plugins/sensors/blackberry/bbholstersensor.cpp
new file mode 100644
index 00000000..53888f58
--- /dev/null
+++ b/src/plugins/sensors/blackberry/bbholstersensor.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "bbholstersensor.h"
+
+BbHolsterSensor::BbHolsterSensor(QSensor *sensor)
+ : BbSensorBackend<QHolsterReading>(devicePath(), SENSOR_TYPE_HOLSTER, sensor)
+{
+ setDescription(QLatin1String("Whether the device is holstered or not"));
+}
+
+bool BbHolsterSensor::updateReadingFromEvent(const sensor_event_t &event, QHolsterReading *reading)
+{
+ reading->setHolstered(event.holster_s.holstered == 1);
+ return true;
+}
+
+QString BbHolsterSensor::devicePath()
+{
+ return QLatin1String("/dev/sensor/holster");
+}
diff --git a/src/plugins/sensors/blackberry/bbholstersensor.h b/src/plugins/sensors/blackberry/bbholstersensor.h
new file mode 100644
index 00000000..b33b391d
--- /dev/null
+++ b/src/plugins/sensors/blackberry/bbholstersensor.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BBHOLSTERSENSOR_H
+#define BBHOLSTERSENSOR_H
+
+#include "bbsensorbackend.h"
+#include <qholstersensor.h>
+
+class BbHolsterSensor : public BbSensorBackend<QHolsterReading>
+{
+ Q_OBJECT
+
+public:
+ explicit BbHolsterSensor(QSensor *sensor);
+
+ static QString devicePath();
+
+protected:
+ bool updateReadingFromEvent(const sensor_event_t &event, QHolsterReading *reading) Q_DECL_OVERRIDE;
+};
+
+#endif
diff --git a/src/plugins/sensors/blackberry/bbmagnetometer.cpp b/src/plugins/sensors/blackberry/bbmagnetometer.cpp
index 489a0481..5ece465e 100644
--- a/src/plugins/sensors/blackberry/bbmagnetometer.cpp
+++ b/src/plugins/sensors/blackberry/bbmagnetometer.cpp
@@ -63,7 +63,9 @@ bool BbMagnetometer::updateReadingFromEvent(const sensor_event_t &event, QMagnet
reading->setY(y);
reading->setZ(z);
- const bool returnGeoValues = sensor()->property("returnGeoValues").toBool();
+ QMagnetometer * const magnetometer = qobject_cast<QMagnetometer *>(sensor());
+ Q_ASSERT(magnetometer);
+ const bool returnGeoValues = magnetometer->returnGeoValues();
if (returnGeoValues) {
switch (event.accuracy) {
case SENSOR_ACCURACY_UNRELIABLE: reading->setCalibrationLevel(0.0f); break;
diff --git a/src/plugins/sensors/blackberry/bborientationsensor.cpp b/src/plugins/sensors/blackberry/bborientationsensor.cpp
index 68ed735b..3d9d120c 100644
--- a/src/plugins/sensors/blackberry/bborientationsensor.cpp
+++ b/src/plugins/sensors/blackberry/bborientationsensor.cpp
@@ -44,6 +44,9 @@ BbOrientationSensor::BbOrientationSensor(QSensor *sensor)
: BbSensorBackend<QOrientationReading>(devicePath(), SENSOR_TYPE_ORIENTATION, sensor)
{
setDescription(QLatin1String("Device orientation"));
+
+ // Orientation rarely changes, so enable skipping of duplicates by default
+ sensor->setSkipDuplicates(true);
}
QString BbOrientationSensor::devicePath()
@@ -51,19 +54,6 @@ QString BbOrientationSensor::devicePath()
return QLatin1String("/dev/sensor/orientation");
}
-void BbOrientationSensor::start()
-{
- BbSensorBackend<QOrientationReading>::start();
-
- // Orientation rarely changes, so enable skiping of duplicates
- sensor_devctl_skipdupevent_u deviceSkip;
- deviceSkip.tx.enable = 1;
- const int result = devctl(deviceFile().handle(), DCMD_SENSOR_SKIPDUPEVENT, &deviceSkip,
- sizeof(deviceSkip), NULL);
- if (result != EOK)
- perror("Enabling duplicate skipping for orientation sensor failed");
-}
-
void BbOrientationSensor::additionalDeviceInit()
{
// When querying the OS service for the range, it gives us the angles, which we don't need.
diff --git a/src/plugins/sensors/blackberry/bborientationsensor.h b/src/plugins/sensors/blackberry/bborientationsensor.h
index 07dc3d0f..85c7bd67 100644
--- a/src/plugins/sensors/blackberry/bborientationsensor.h
+++ b/src/plugins/sensors/blackberry/bborientationsensor.h
@@ -53,7 +53,6 @@ public:
static QString devicePath();
- void start() Q_DECL_OVERRIDE;
void additionalDeviceInit() Q_DECL_OVERRIDE;
bool addDefaultRange() Q_DECL_OVERRIDE;
diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.cpp b/src/plugins/sensors/blackberry/bbpressuresensor.cpp
index 01a2493b..8cb9b1ea 100644
--- a/src/plugins/sensors/blackberry/bbpressuresensor.cpp
+++ b/src/plugins/sensors/blackberry/bbpressuresensor.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Research In Motion
+** Copyright (C) 2013 Research In Motion
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtSensors module of the Qt Toolkit.
@@ -40,31 +40,8 @@
****************************************************************************/
#include "bbpressuresensor.h"
-class BbPressureReadingPrivate
-{
-public:
- BbPressureReadingPrivate()
- : pressure(0)
- {
- }
-
- qreal pressure;
-};
-
-IMPLEMENT_READING(BbPressureReading)
-
-qreal BbPressureReading::pressure() const
-{
- return d->pressure;
-}
-
-void BbPressureReading::setPressure(qreal pressure)
-{
- d->pressure = pressure;
-}
-
BbPressureSensor::BbPressureSensor(QSensor *sensor)
- : BbSensorBackend<BbPressureReading>(devicePath(), SENSOR_TYPE_PRESSURE, sensor)
+ : BbSensorBackend<QPressureReading>(devicePath(), SENSOR_TYPE_PRESSURE, sensor)
{
setDescription(QLatin1String("Pressure in Pascals"));
}
@@ -74,7 +51,7 @@ QString BbPressureSensor::devicePath()
return QLatin1String("/dev/sensor/pressure");
}
-bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, BbPressureReading *reading)
+bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading)
{
// TODO: I was unable to test this since the device I was testing this with did not have
// a pressure sensor. Verify that this works and check that the units are correct.
diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.h b/src/plugins/sensors/blackberry/bbpressuresensor.h
index 833832c4..7531bd68 100644
--- a/src/plugins/sensors/blackberry/bbpressuresensor.h
+++ b/src/plugins/sensors/blackberry/bbpressuresensor.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Research In Motion
+** Copyright (C) 2013 Research In Motion
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtSensors module of the Qt Toolkit.
@@ -42,20 +42,9 @@
#define BBPRESSURESENSOR_H
#include "bbsensorbackend.h"
+#include <qpressuresensor.h>
-class BbPressureReadingPrivate;
-
-class BbPressureReading : public QSensorReading
-{
- Q_OBJECT
- Q_PROPERTY(qreal pressure READ pressure)
- DECLARE_READING(BbPressureReading)
-public:
- qreal pressure() const;
- void setPressure(qreal pressure);
-};
-
-class BbPressureSensor : public BbSensorBackend<BbPressureReading>
+class BbPressureSensor : public BbSensorBackend<QPressureReading>
{
Q_OBJECT
@@ -65,7 +54,7 @@ public:
static QString devicePath();
protected:
- bool updateReadingFromEvent(const sensor_event_t &event, BbPressureReading *reading) Q_DECL_OVERRIDE;
+ bool updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading) Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/plugins/sensors/blackberry/bbproximitysensor.cpp b/src/plugins/sensors/blackberry/bbproximitysensor.cpp
index 79f3834a..1177f744 100644
--- a/src/plugins/sensors/blackberry/bbproximitysensor.cpp
+++ b/src/plugins/sensors/blackberry/bbproximitysensor.cpp
@@ -53,9 +53,6 @@ QString BbProximitySensor::devicePath()
bool BbProximitySensor::updateReadingFromEvent(const sensor_event_t &event, QProximityReading *reading)
{
- // TODO: I was unable to test this since the device I was testing this with did not have
- // a proximity sensor. Verify that this works, check that the units are correct
- // and that the threshold makes sense.
const qreal minProximity = sensor()->outputRanges().first().minimum;
reading->setClose(event.proximity_s.distance <= minProximity);
return true;
diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.cpp b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
index fa8c89be..fec40c5e 100644
--- a/src/plugins/sensors/blackberry/bbsensorbackend.cpp
+++ b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
@@ -81,15 +81,17 @@ static void remapMatrix(const float inputMatrix[3*3],
BbSensorBackendBase::BbSensorBackendBase(const QString &devicePath, sensor_type_e sensorType,
QSensor *sensor)
: QSensorBackend(sensor), m_deviceFile(devicePath), m_sensorType(sensorType), m_guiHelper(0),
- m_started(false)
+ m_started(false), m_applyingBufferSize(false)
{
m_mappingMatrix[0] = m_mappingMatrix[3] = 1;
m_mappingMatrix[1] = m_mappingMatrix[2] = 0;
connect(sensor, SIGNAL(alwaysOnChanged()), this, SLOT(applyAlwaysOnProperty()));
+ connect(sensor, SIGNAL(bufferSizeChanged(int)), this, SLOT(applyBuffering()));
+ connect(sensor, SIGNAL(userOrientationChanged(int)), this, SLOT(updateOrientation()));
// Set some sensible default values
- sensor->setProperty("efficientBufferSize", defaultBufferSize);
- sensor->setProperty("maxBufferSize", defaultBufferSize);
+ sensor->setEfficientBufferSize(defaultBufferSize);
+ sensor->setMaxBufferSize(defaultBufferSize);
}
BbGuiHelper *BbSensorBackendBase::guiHelper() const
@@ -107,6 +109,21 @@ sensor_type_e BbSensorBackendBase::sensorType() const
return m_sensorType;
}
+void BbSensorBackendBase::setDevice(const QString &deviceFile, sensor_type_e sensorType)
+{
+ if (deviceFile != m_deviceFile.fileName()) {
+ setPaused(true);
+ delete m_socketNotifier.take();
+ m_deviceFile.close();
+
+ m_sensorType = sensorType;
+ m_deviceFile.setFileName(deviceFile);
+ initSensorInfo();
+ if (m_started)
+ start(); // restart with new device file
+ }
+}
+
void BbSensorBackendBase::initSensorInfo()
{
if (!m_deviceFile.open(QFile::ReadOnly | QFile::Unbuffered)) {
@@ -168,12 +185,13 @@ qreal BbSensorBackendBase::convertValue(float bbValue)
bool BbSensorBackendBase::isAutoAxisRemappingEnabled() const
{
- return sensor()->property("automaticAxisRemapping").toBool();
+ return sensor()->isFeatureSupported(QSensor::AxesOrientation) &&
+ sensor()->axesOrientationMode() != QSensor::FixedOrientation;
}
void BbSensorBackendBase::remapMatrix(const float inputMatrix[], float outputMatrix[])
{
- if (!isAutoAxisRemappingEnabled() || m_guiHelper->currentOrientation() == 0) {
+ if (!isAutoAxisRemappingEnabled() || orientationForRemapping() == 0) {
memcpy(outputMatrix, inputMatrix, sizeof(float) * 9);
return;
}
@@ -184,10 +202,10 @@ void BbSensorBackendBase::remapMatrix(const float inputMatrix[], float outputMat
void BbSensorBackendBase::remapAxes(float *x, float *y, float *z)
{
Q_ASSERT(x && y && z);
- if (!isAutoAxisRemappingEnabled() || m_guiHelper->currentOrientation() == 0)
+ if (!isAutoAxisRemappingEnabled() || orientationForRemapping() == 0)
return;
- const int angle = m_guiHelper->currentOrientation();
+ const int angle = orientationForRemapping();
const float oldX = *x;
const float oldY = *y;
@@ -239,6 +257,16 @@ void BbSensorBackendBase::start()
}
}
+ // Enable/disable duplicate skipping
+ sensor_devctl_skipdupevent_u deviceSkip;
+ deviceSkip.tx.enable = sensor()->skipDuplicates();
+ const int result = devctl(deviceFile().handle(), DCMD_SENSOR_SKIPDUPEVENT, &deviceSkip,
+ sizeof(deviceSkip), NULL);
+ if (result != EOK) {
+ perror(QString::fromLatin1("Setting duplicate skipping for %1 failed")
+ .arg(m_deviceFile.fileName()).toLocal8Bit());
+ }
+
// Explicitly switch to non-blocking mode, otherwise read() will wait until new sensor
// data is available, and we have no way to check if there is more data or not (bytesAvailable()
// does not work for unbuffered mode)
@@ -251,24 +279,7 @@ void BbSensorBackendBase::start()
return;
}
- // Activate event queuing if needed
- bool ok = false;
- const int requestedBufferSize = sensor()->property("bufferSize").toInt(&ok);
- if (ok && requestedBufferSize > 1) {
- sensor_devctl_queue_u queueControl;
- queueControl.tx.enable = 1;
- const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_QUEUE, &queueControl, sizeof(queueControl), NULL);
- if (result != EOK) {
- perror(QString::fromLatin1("Enabling sensor queuing for %1 failed")
- .arg(m_deviceFile.fileName()).toLocal8Bit());
- }
-
- const int actualBufferSize = queueControl.rx.size;
- sensor()->setProperty("bufferSize", actualBufferSize);
- sensor()->setProperty("efficientBufferSize", actualBufferSize);
- sensor()->setProperty("maxBufferSize", actualBufferSize);
- }
-
+ applyBuffering();
applyAlwaysOnProperty();
}
@@ -281,8 +292,15 @@ void BbSensorBackendBase::stop()
bool BbSensorBackendBase::isFeatureSupported(QSensor::Feature feature) const
{
switch (feature) {
+ case QSensor::AxesOrientation:
+ return (sensorType() == SENSOR_TYPE_ACCELEROMETER || sensorType() == SENSOR_TYPE_MAGNETOMETER ||
+ sensorType() == SENSOR_TYPE_GYROSCOPE || sensorType() == SENSOR_TYPE_GRAVITY ||
+ sensorType() == SENSOR_TYPE_LINEAR_ACCEL || sensorType() == SENSOR_TYPE_ROTATION_VECTOR ||
+ sensorType() == SENSOR_TYPE_ROTATION_MATRIX || sensorType() == SENSOR_TYPE_AZIMUTH_PITCH_ROLL);
case QSensor::AlwaysOn:
case QSensor::Buffering:
+ case QSensor::AccelerationMode:
+ case QSensor::SkipDuplicates:
return true;
case QSensor::Reserved:
case QSensor::GeoValues:
@@ -331,6 +349,46 @@ void BbSensorBackendBase::applyAlwaysOnProperty()
updatePauseState();
}
+void BbSensorBackendBase::applyBuffering()
+{
+ if (!m_deviceFile.isOpen() || !m_started || m_applyingBufferSize)
+ return;
+
+ // Flag to prevent recursion. We call setBufferSize() below, and because of the changed signal,
+ // we might end up in this slot again.
+ // The call to setBufferSize() is needed since the requested buffer size is most likely different
+ // from the actual buffer size that will be used.
+ m_applyingBufferSize = true;
+
+ const bool enableBuffering = sensor()->bufferSize() > 1;
+ sensor_devctl_queue_u queueControl;
+ queueControl.tx.enable = enableBuffering ? 1 : 0;
+ const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_QUEUE, &queueControl, sizeof(queueControl), NULL);
+ if (result != EOK) {
+ perror(QString::fromLatin1("Enabling sensor queuing for %1 failed")
+ .arg(m_deviceFile.fileName()).toLocal8Bit());
+ } else {
+ if (enableBuffering) {
+ int actualBufferSize = queueControl.rx.size;
+
+ // Some firmware versions don't report the buffer size correctly. Simply pretend the
+ // buffer size is the same as the requested buffer size, as setting the buffer size to
+ // 1 here would seem as if buffering were disabled.
+ if (actualBufferSize == 1)
+ actualBufferSize = sensor()->bufferSize();
+
+ sensor()->setBufferSize(actualBufferSize);
+ sensor()->setEfficientBufferSize(actualBufferSize);
+ sensor()->setMaxBufferSize(actualBufferSize);
+ } else {
+ sensor()->setBufferSize(1);
+ sensor()->setEfficientBufferSize(defaultBufferSize);
+ sensor()->setMaxBufferSize(defaultBufferSize);
+ }
+ }
+ m_applyingBufferSize = false;
+}
+
bool BbSensorBackendBase::setPaused(bool paused)
{
if (!m_deviceFile.isOpen())
@@ -360,12 +418,26 @@ void BbSensorBackendBase::updatePauseState()
void BbSensorBackendBase::updateOrientation()
{
- // ### I can't really test this, the rotation matrix has too many glitches and drifts over time,
- // making any measurement quite hard
- const int rotationAngle = guiHelper()->currentOrientation();
+ const int rotationAngle = orientationForRemapping();
m_mappingMatrix[0] = cos(rotationAngle*M_PI/180);
m_mappingMatrix[1] = sin(rotationAngle*M_PI/180);
m_mappingMatrix[2] = -sin(rotationAngle*M_PI/180);
m_mappingMatrix[3] = cos(rotationAngle*M_PI/180);
+
+ if (sensor()->isFeatureSupported(QSensor::AxesOrientation))
+ sensor()->setCurrentOrientation(rotationAngle);
+}
+
+int BbSensorBackendBase::orientationForRemapping() const
+{
+ if (!sensor()->isFeatureSupported(QSensor::AxesOrientation))
+ return 0;
+
+ switch (sensor()->axesOrientationMode()) {
+ default:
+ case QSensor::FixedOrientation: return 0;
+ case QSensor::AutomaticOrientation: return guiHelper()->currentOrientation();
+ case QSensor::UserOrientation: return sensor()->userOrientation();
+ }
}
diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.h b/src/plugins/sensors/blackberry/bbsensorbackend.h
index 7e2ad0ec..4e7b8101 100644
--- a/src/plugins/sensors/blackberry/bbsensorbackend.h
+++ b/src/plugins/sensors/blackberry/bbsensorbackend.h
@@ -76,6 +76,9 @@ protected:
BbGuiHelper *guiHelper() const;
QFile& deviceFile();
sensor_type_e sensorType() const;
+ int orientationForRemapping() const;
+
+ void setDevice(const QString &deviceFile, sensor_type_e sensorType);
// This is called while the device file is open during initalization and gives a subclass
// an opportunity to do additional initalization.
@@ -104,6 +107,7 @@ protected:
private slots:
void dataAvailable();
void applyAlwaysOnProperty();
+ void applyBuffering();
bool setPaused(bool paused);
void updatePauseState();
void updateOrientation();
@@ -115,6 +119,7 @@ private:
BbGuiHelper *m_guiHelper;
float m_mappingMatrix[4];
bool m_started;
+ bool m_applyingBufferSize;
};
template<class SensorReading>
diff --git a/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp b/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp
index f3ec6342..b38fba4d 100644
--- a/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp
+++ b/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp
@@ -40,31 +40,8 @@
****************************************************************************/
#include "bbtemperaturesensor.h"
-class BbTemperatureReadingPrivate
-{
-public:
- BbTemperatureReadingPrivate()
- : temperature(0)
- {
- }
-
- qreal temperature;
-};
-
-IMPLEMENT_READING(BbTemperatureReading)
-
-qreal BbTemperatureReading::temperature() const
-{
- return d->temperature;
-}
-
-void BbTemperatureReading::setTemperature(qreal temperature)
-{
- d->temperature = temperature;
-}
-
BbTemperatureSensor::BbTemperatureSensor(QSensor *sensor)
- : BbSensorBackend<BbTemperatureReading>(devicePath(), SENSOR_TYPE_TEMPERATURE, sensor)
+ : BbSensorBackend<QAmbientTemperatureReading>(devicePath(), SENSOR_TYPE_TEMPERATURE, sensor)
{
setDescription(QLatin1String("Temperature in degrees Celsius"));
}
@@ -74,7 +51,7 @@ QString BbTemperatureSensor::devicePath()
return QLatin1String("/dev/sensor/temp");
}
-bool BbTemperatureSensor::updateReadingFromEvent(const sensor_event_t &event, BbTemperatureReading *reading)
+bool BbTemperatureSensor::updateReadingFromEvent(const sensor_event_t &event, QAmbientTemperatureReading *reading)
{
// TODO: I was unable to test this since the device I was testing this with did not have
// a temperature sensor. Verify that this works and check that the units are correct.
diff --git a/src/plugins/sensors/blackberry/bbtemperaturesensor.h b/src/plugins/sensors/blackberry/bbtemperaturesensor.h
index 1b9ea1bf..a24c67e7 100644
--- a/src/plugins/sensors/blackberry/bbtemperaturesensor.h
+++ b/src/plugins/sensors/blackberry/bbtemperaturesensor.h
@@ -42,20 +42,9 @@
#define BBTEMPERATURESENSOR_H
#include "bbsensorbackend.h"
+#include <qambienttemperaturesensor.h>
-class BbTemperatureReadingPrivate;
-
-class BbTemperatureReading : public QSensorReading
-{
- Q_OBJECT
- Q_PROPERTY(qreal temperature READ temperature)
- DECLARE_READING(BbTemperatureReading)
-public:
- qreal temperature() const;
- void setTemperature(qreal temperature);
-};
-
-class BbTemperatureSensor : public BbSensorBackend<BbTemperatureReading>
+class BbTemperatureSensor : public BbSensorBackend<QAmbientTemperatureReading>
{
Q_OBJECT
@@ -65,7 +54,7 @@ public:
static QString devicePath();
protected:
- bool updateReadingFromEvent(const sensor_event_t &event, BbTemperatureReading *reading);
+ bool updateReadingFromEvent(const sensor_event_t &event, QAmbientTemperatureReading *reading);
};
#endif
diff --git a/src/plugins/sensors/blackberry/blackberry.pro b/src/plugins/sensors/blackberry/blackberry.pro
index 73027c20..902239c4 100644
--- a/src/plugins/sensors/blackberry/blackberry.pro
+++ b/src/plugins/sensors/blackberry/blackberry.pro
@@ -12,6 +12,10 @@ config_bbsensor_compass {
DEFINES += HAVE_COMPASS_SENSOR
}
+config_bbsensor_holster {
+ DEFINES += HAVE_HOLSTER_SENSOR
+}
+
HEADERS += bbsensorbackend.h \
bbaccelerometer.h \
bbaltimeter.h \
@@ -47,4 +51,9 @@ SOURCES += bbsensorbackend.cpp \
bbutil.cpp \
main.cpp
+config_bbsensor_holster {
+ HEADERS += bbholstersensor.h
+ SOURCES += bbholstersensor.cpp
+}
+
OTHER_FILES = plugin.json
diff --git a/src/plugins/sensors/blackberry/main.cpp b/src/plugins/sensors/blackberry/main.cpp
index 7c2d5dbc..61f9aa08 100644
--- a/src/plugins/sensors/blackberry/main.cpp
+++ b/src/plugins/sensors/blackberry/main.cpp
@@ -43,6 +43,9 @@
#include "bbambientlightsensor.h"
#include "bbcompass.h"
#include "bbgyroscope.h"
+#ifdef HAVE_HOLSTER_SENSOR
+#include "bbholstersensor.h"
+#endif
#include "bbirproximitysensor.h"
#include "bblightsensor.h"
#include "bbmagnetometer.h"
@@ -61,6 +64,9 @@ static const char *bbAltitmeterId = "bbAltimeter";
static const char *bbAmbientLightSensorId = "bbAmbientLightSensor";
static const char *bbCompassId = "bbCompass";
static const char *bbGyroscopeId = "bbGyroscope";
+#ifdef HAVE_HOLSTER_SENSOR
+static const char *bbHolsterSensorId = "bbHolsterSensor";
+#endif
static const char *bbIRProximitySensorId = "bbIRProximitySensor";
static const char *bbLightSensorId = "bbLightSensor";
static const char *bbMagnetometerId = "bbMagnetometer";
@@ -82,13 +88,17 @@ public:
if (sensorSupported(BbAccelerometer::devicePath()))
QSensorManager::registerBackend(QAccelerometer::type, bbAccelerometerId, this);
if (sensorSupported(BbAltimeter::devicePath()))
- QSensorManager::registerBackend("BbAltimeter", bbAltitmeterId, this);
+ QSensorManager::registerBackend(QAltimeter::type, bbAltitmeterId, this);
if (sensorSupported(BbAmbientLightSensor::devicePath()))
QSensorManager::registerBackend(QAmbientLightSensor::type, bbAmbientLightSensorId, this);
if (sensorSupported(BbCompass::devicePath()))
QSensorManager::registerBackend(QCompass::type, bbCompassId, this);
if (sensorSupported(BbGyroscope::devicePath()))
QSensorManager::registerBackend(QGyroscope::type, bbGyroscopeId, this);
+#ifdef HAVE_HOLSTER_SENSOR
+ if (sensorSupported(BbHolsterSensor::devicePath()))
+ QSensorManager::registerBackend(QHolsterSensor::type, bbHolsterSensorId, this);
+#endif
if (sensorSupported(BbIRProximitySensor::devicePath()))
QSensorManager::registerBackend(QIRProximitySensor::type, bbIRProximitySensorId, this);
if (sensorSupported(BbLightSensor::devicePath()))
@@ -98,13 +108,13 @@ public:
if (sensorSupported(BbOrientationSensor::devicePath()))
QSensorManager::registerBackend(QOrientationSensor::type, bbOrientationSensorId, this);
if (sensorSupported(BbPressureSensor::devicePath()))
- QSensorManager::registerBackend("BbPressureSensor", bbPressureSensorId, this);
+ QSensorManager::registerBackend(QPressureSensor::type, bbPressureSensorId, this);
if (sensorSupported(BbProximitySensor::devicePath()))
QSensorManager::registerBackend(QProximitySensor::type, bbProximitySensorId, this);
if (sensorSupported(BbRotationSensor::devicePath()))
QSensorManager::registerBackend(QRotationSensor::type, bbRotationSensorId, this);
if (sensorSupported(BbTemperatureSensor::devicePath()))
- QSensorManager::registerBackend("BbTemperatureSensor", bbTemperatureSensorId, this);
+ QSensorManager::registerBackend(QAmbientTemperatureSensor::type, bbTemperatureSensorId, this);
}
QSensorBackend *createBackend(QSensor *sensor) Q_DECL_OVERRIDE
@@ -120,6 +130,10 @@ public:
backend = new BbCompass(sensor);
if (sensor->identifier() == bbGyroscopeId)
backend = new BbGyroscope(sensor);
+#ifdef HAVE_HOLSTER_SENSOR
+ if (sensor->identifier() == bbHolsterSensorId)
+ backend = new BbHolsterSensor(sensor);
+#endif
if (sensor->identifier() == bbIRProximitySensorId)
backend = new BbIRProximitySensor(sensor);
if (sensor->identifier() == bbLightSensorId)
diff --git a/src/plugins/sensors/dummy/dummy.pro b/src/plugins/sensors/dummy/dummy.pro
index b97bd9ce..f54588af 100644
--- a/src/plugins/sensors/dummy/dummy.pro
+++ b/src/plugins/sensors/dummy/dummy.pro
@@ -15,4 +15,4 @@ SOURCES += dummycommon.cpp\
OTHER_FILES = plugin.json
-unix:!mac:!qnx:LIBS+=-lrt
+unix:!mac:!qnx:!android:LIBS+=-lrt
diff --git a/src/plugins/sensors/generic/generic.pro b/src/plugins/sensors/generic/generic.pro
index 2d4f9f9f..5bfeff64 100644
--- a/src/plugins/sensors/generic/generic.pro
+++ b/src/plugins/sensors/generic/generic.pro
@@ -4,15 +4,19 @@ QT = core sensors
PLUGIN_TYPE = sensors
load(qt_plugin)
-HEADERS += genericorientationsensor.h\
- genericrotationsensor.h\
- genericalssensor.h\
- generictiltsensor.h
+HEADERS += generictiltsensor.h
-SOURCES += genericorientationsensor.cpp\
- main.cpp\
- genericrotationsensor.cpp\
- genericalssensor.cpp\
+SOURCES += main.cpp\
generictiltsensor.cpp
+!blackberry {
+ HEADERS += genericorientationsensor.h\
+ genericrotationsensor.h\
+ genericalssensor.h
+
+ SOURCES += genericorientationsensor.cpp\
+ genericrotationsensor.cpp\
+ genericalssensor.cpp
+}
+
OTHER_FILES = plugin.json
diff --git a/src/plugins/sensors/generic/genericrotationsensor.cpp b/src/plugins/sensors/generic/genericrotationsensor.cpp
index b5f80cb3..0548adc0 100644
--- a/src/plugins/sensors/generic/genericrotationsensor.cpp
+++ b/src/plugins/sensors/generic/genericrotationsensor.cpp
@@ -57,7 +57,9 @@ genericrotationsensor::genericrotationsensor(QSensor *sensor)
setReading<QRotationReading>(&m_reading);
setDataRates(accelerometer);
- sensor->setProperty("hasZ", false);
+ QRotationSensor * const rotationSensor = qobject_cast<QRotationSensor *>(sensor);
+ if (rotationSensor)
+ rotationSensor->setHasZ(false);
}
void genericrotationsensor::start()
diff --git a/src/plugins/sensors/generic/genericrotationsensor.h b/src/plugins/sensors/generic/genericrotationsensor.h
index 3475cafe..ffa48ea3 100644
--- a/src/plugins/sensors/generic/genericrotationsensor.h
+++ b/src/plugins/sensors/generic/genericrotationsensor.h
@@ -62,7 +62,6 @@ public:
private:
QRotationReading m_reading;
QAccelerometer *accelerometer;
- QMagnetometer *magnetometer;
};
#endif
diff --git a/src/plugins/sensors/generic/generictiltsensor.cpp b/src/plugins/sensors/generic/generictiltsensor.cpp
index 6aefb576..dc118bf7 100644
--- a/src/plugins/sensors/generic/generictiltsensor.cpp
+++ b/src/plugins/sensors/generic/generictiltsensor.cpp
@@ -106,6 +106,11 @@ void GenericTiltSensor::calibrate()
calibratedRoll = roll;
}
+static qreal rad2deg(qreal rad)
+{
+ return rad / (2 * M_PI) * 360;
+}
+
bool GenericTiltSensor::filter(QAccelerometerReading *reading)
{
/*
@@ -154,23 +159,22 @@ bool GenericTiltSensor::filter(QAccelerometerReading *reading)
qDebug() << "new yrot: " << yrot;
qDebug() << "----------------------------------";
#endif
- qreal dxrot = xrot - xRotation;
- qreal dyrot = yrot - yRotation;
+ qreal dxrot = rad2deg(xrot) - xRotation;
+ qreal dyrot = rad2deg(yrot) - yRotation;
if (dxrot < 0) dxrot = -dxrot;
if (dyrot < 0) dyrot = -dyrot;
- bool change = false;
- if (dxrot >= radAccuracy) {
- xRotation = xrot;
- change = true;
+ bool setNewReading = false;
+ if (dxrot >= rad2deg(radAccuracy) || !sensor()->skipDuplicates()) {
+ xRotation = rad2deg(xrot);
+ setNewReading = true;
}
- if (dyrot >= radAccuracy) {
- yRotation = yrot;
- change = true;
+ if (dyrot >= rad2deg(radAccuracy) || !sensor()->skipDuplicates()) {
+ yRotation = rad2deg(yrot);
+ setNewReading = true;
}
- if (xRotation != m_reading.xRotation()
- || yRotation != m_reading.yRotation()
- || m_reading.timestamp() == 0) {
+
+ if (setNewReading || m_reading.timestamp() == 0) {
m_reading.setTimestamp(reading->timestamp());
m_reading.setXRotation(xRotation);
m_reading.setYRotation(yRotation);
@@ -179,3 +183,8 @@ bool GenericTiltSensor::filter(QAccelerometerReading *reading)
return false;
}
+
+bool GenericTiltSensor::isFeatureSupported(QSensor::Feature feature) const
+{
+ return (feature == QSensor::SkipDuplicates);
+}
diff --git a/src/plugins/sensors/generic/generictiltsensor.h b/src/plugins/sensors/generic/generictiltsensor.h
index 0633662c..0f84ca6f 100644
--- a/src/plugins/sensors/generic/generictiltsensor.h
+++ b/src/plugins/sensors/generic/generictiltsensor.h
@@ -46,7 +46,6 @@
#include <qtiltsensor.h>
#include <qaccelerometer.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class GenericTiltSensor : public QSensorBackend, public QAccelerometerFilter
@@ -64,6 +63,8 @@ public:
bool filter(QAccelerometerReading *reading);
+ bool isFeatureSupported(QSensor::Feature feature) const Q_DECL_OVERRIDE;
+
private:
QTiltReading m_reading;
QAccelerometer *accelerometer;
@@ -77,7 +78,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/plugins/sensors/generic/main.cpp b/src/plugins/sensors/generic/main.cpp
index 15507b63..4b348b19 100644
--- a/src/plugins/sensors/generic/main.cpp
+++ b/src/plugins/sensors/generic/main.cpp
@@ -39,9 +39,12 @@
**
****************************************************************************/
+#ifndef Q_OS_BLACKBERRY
#include "genericorientationsensor.h"
#include "genericrotationsensor.h"
#include "genericalssensor.h"
+#endif
+#include "generictiltsensor.h"
#include <qsensorplugin.h>
#include <qsensorbackend.h>
#include <qsensormanager.h>
@@ -56,7 +59,6 @@ class genericSensorPlugin : public QObject, public QSensorPluginInterface, publi
public:
void registerSensors()
{
- qDebug() << "loaded the Generic plugin";
// Nothing to register here
}
@@ -64,26 +66,33 @@ public:
{
if (!QSensor::defaultSensorForType(QAccelerometer::type).isEmpty()) {
// There is an accelerometer available. Register the backends
+#ifndef Q_OS_BLACKBERRY
if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, genericorientationsensor::id))
QSensorManager::registerBackend(QOrientationSensor::type, genericorientationsensor::id, this);
if (!QSensorManager::isBackendRegistered(QRotationSensor::type, genericrotationsensor::id))
QSensorManager::registerBackend(QRotationSensor::type, genericrotationsensor::id, this);
if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id))
QSensorManager::registerBackend(QAmbientLightSensor::type, genericalssensor::id, this);
- if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id))
- QSensorManager::registerBackend(QAmbientLightSensor::type, genericalssensor::id, this);
+#endif
+ if (!QSensorManager::isBackendRegistered(QTiltSensor::type, GenericTiltSensor::id))
+ QSensorManager::registerBackend(QTiltSensor::type, GenericTiltSensor::id, this);
} else {
+#ifndef Q_OS_BLACKBERRY
if (QSensorManager::isBackendRegistered(QOrientationSensor::type, genericorientationsensor::id))
QSensorManager::unregisterBackend(QOrientationSensor::type, genericorientationsensor::id);
if (QSensorManager::isBackendRegistered(QRotationSensor::type, genericrotationsensor::id))
QSensorManager::unregisterBackend(QRotationSensor::type, genericrotationsensor::id);
if (QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id))
QSensorManager::unregisterBackend(QAmbientLightSensor::type, genericalssensor::id);
+#endif
+ if (QSensorManager::isBackendRegistered(QTiltSensor::type, GenericTiltSensor::id))
+ QSensorManager::unregisterBackend(QTiltSensor::type, GenericTiltSensor::id);
}
}
QSensorBackend *createBackend(QSensor *sensor)
{
+#ifndef Q_OS_BLACKBERRY
if (sensor->identifier() == genericorientationsensor::id)
return new genericorientationsensor(sensor);
@@ -92,6 +101,9 @@ public:
if (sensor->identifier() == genericalssensor::id)
return new genericalssensor(sensor);
+#endif
+ if (sensor->identifier() == GenericTiltSensor::id)
+ return new GenericTiltSensor(sensor);
return 0;
}
diff --git a/src/plugins/sensors/linux/linux.pro b/src/plugins/sensors/linux/linux.pro
index 7546728f..25c4f2d9 100644
--- a/src/plugins/sensors/linux/linux.pro
+++ b/src/plugins/sensors/linux/linux.pro
@@ -6,7 +6,7 @@ load(qt_plugin)
OTHER_FILES = plugin.json
-LIBS += -lrt
+!android:LIBS += -lrt
HEADERS += linuxsysaccelerometer.h
SOURCES += linuxsysaccelerometer.cpp \
main.cpp
diff --git a/src/plugins/sensors/sensors.pro b/src/plugins/sensors/sensors.pro
index df63f36d..a8b59b0d 100644
--- a/src/plugins/sensors/sensors.pro
+++ b/src/plugins/sensors/sensors.pro
@@ -1,9 +1,9 @@
TEMPLATE = subdirs
-# Don't build dummy and generic plugins by default, the Blackberry backend has real implementations
+# Don't build dummy plugins, the Blackberry backend has real implementations
# of these. This reduces compile time and plugin loading time.
blackberry {
- isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = blackberry
+ isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = blackberry generic
}
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, dummy):SUBDIRS += dummy
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, generic):SUBDIRS += generic
diff --git a/src/sensors/doc/src/compatmap.qdoc b/src/sensors/doc/src/compatmap.qdoc
index 0fd4951c..abb71a15 100644
--- a/src/sensors/doc/src/compatmap.qdoc
+++ b/src/sensors/doc/src/compatmap.qdoc
@@ -64,10 +64,22 @@
<td bgcolor="gray"></td>
</tr>
<tr>
- <td nowrap="nowrap">Ambient Light Sensor</td>
+ <td nowrap="nowrap">Altimeter</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap">Ambient Light Sensor</td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap">Ambient Temperature Sensor</td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Compass</td>
@@ -82,6 +94,12 @@
<td bgcolor="gray"></td>
</tr>
<tr>
+ <td nowrap="nowrap">Holster Sensor</td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
<td nowrap="nowrap">IR Proximity Sensor</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
@@ -106,6 +124,12 @@
<td bgcolor="green"></td>
</tr>
<tr>
+ <td nowrap="nowrap">Pressure Sensor</td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
<td nowrap="nowrap">Proximity Sensor</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
diff --git a/src/sensors/gestures/qsensorgesture.h b/src/sensors/gestures/qsensorgesture.h
index 2d7e9018..5ae7bb22 100644
--- a/src/sensors/gestures/qsensorgesture.h
+++ b/src/sensors/gestures/qsensorgesture.h
@@ -52,11 +52,8 @@
#include <QtCore/qmetatype.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGesturePrivate;
class Q_SENSORS_EXPORT QSensorGesture : public QObject
@@ -93,7 +90,6 @@ Q_SIGNALS:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTURE_H
diff --git a/src/sensors/gestures/qsensorgesture_p.h b/src/sensors/gestures/qsensorgesture_p.h
index 5bad75b5..4ee19b9c 100644
--- a/src/sensors/gestures/qsensorgesture_p.h
+++ b/src/sensors/gestures/qsensorgesture_p.h
@@ -61,7 +61,6 @@
#include "qsensorgesturemanager.h"
#include <QtCore/private/qmetaobjectbuilder_p.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QSensorGesturePrivate : public QObject
@@ -84,6 +83,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTURE_P_H
diff --git a/src/sensors/gestures/qsensorgesturemanager.h b/src/sensors/gestures/qsensorgesturemanager.h
index da5048a0..96ea9718 100644
--- a/src/sensors/gestures/qsensorgesturemanager.h
+++ b/src/sensors/gestures/qsensorgesturemanager.h
@@ -48,11 +48,8 @@
#include <QtSensors/qsensorgesture.h>
#include <QtSensors/qsensorgesturerecognizer.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGestureManagerPrivate;
class Q_SENSORS_EXPORT QSensorGestureManager : public QObject
{
@@ -78,6 +75,5 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTUREMANAGER_P_H
diff --git a/src/sensors/gestures/qsensorgesturemanagerprivate_p.h b/src/sensors/gestures/qsensorgesturemanagerprivate_p.h
index 50770c77..0994b2ab 100644
--- a/src/sensors/gestures/qsensorgesturemanagerprivate_p.h
+++ b/src/sensors/gestures/qsensorgesturemanagerprivate_p.h
@@ -52,7 +52,6 @@
#include "qsensorgesture.h"
#include "qsensorgesturerecognizer.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QFactoryLoader;
@@ -99,6 +98,5 @@ private slots:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTUREMANAGERPRIVATE_P_H
diff --git a/src/sensors/gestures/qsensorgestureplugininterface.cpp b/src/sensors/gestures/qsensorgestureplugininterface.cpp
index add34c0e..de02f890 100644
--- a/src/sensors/gestures/qsensorgestureplugininterface.cpp
+++ b/src/sensors/gestures/qsensorgestureplugininterface.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
\brief The QSensorGesturePluginInterface class is the pure virtual interface to sensor gesture
plugins.
- \since QtSensors 5.0
+ \since 5.0
The QSensorGesturePluginInterface class is implemented in sensor gesture plugins to register
sensor gesture recognizers with QSensorGestureManager.
diff --git a/src/sensors/gestures/qsensorgestureplugininterface.h b/src/sensors/gestures/qsensorgestureplugininterface.h
index da933c92..330d880c 100644
--- a/src/sensors/gestures/qsensorgestureplugininterface.h
+++ b/src/sensors/gestures/qsensorgestureplugininterface.h
@@ -48,11 +48,8 @@
#include <QtSensors/qsensorgesture.h>
#include <QtSensors/qsensorgesturerecognizer.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGestureRecognizer;
class Q_SENSORS_EXPORT QSensorGesturePluginInterface
@@ -68,6 +65,5 @@ public:
Q_DECLARE_INTERFACE(QSensorGesturePluginInterface, "org.qt-project.QSensorGesturePluginInterface")
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTUREPLUGININTERFACE_H
diff --git a/src/sensors/gestures/qsensorgesturerecognizer.h b/src/sensors/gestures/qsensorgesturerecognizer.h
index bebc5ce6..c35c25be 100644
--- a/src/sensors/gestures/qsensorgesturerecognizer.h
+++ b/src/sensors/gestures/qsensorgesturerecognizer.h
@@ -48,11 +48,8 @@
#include <QtSensors/qsensorgesture.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGestureRecognizerPrivate;
class Q_SENSORS_EXPORT QSensorGestureRecognizer : public QObject
{
@@ -84,6 +81,5 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTURERECOGNIZER_H
diff --git a/src/sensors/make_sensor.pl b/src/sensors/make_sensor.pl
index 4d78a312..27322517 100755
--- a/src/sensors/make_sensor.pl
+++ b/src/sensors/make_sensor.pl
@@ -52,6 +52,15 @@ $sensorbase =~ s/Sensor$//;
my $reading = $sensorbase.'Reading';
my $reading_private = $reading.'Private';
my $filter = $sensorbase.'Filter';
+my $no_q_sensor = $sensor;
+$no_q_sensor =~ s/^.//;
+my $qmlsensor = "Qml".$no_q_sensor;
+my $qmlsensorbase = $qmlsensor;
+$qmlsensorbase =~ s/Sensor$//;
+my $qmlreading = $qmlsensorbase."Reading";
+my $no_q_reading = $no_q_sensor;
+$no_q_reading =~ s/Sensor$//;
+$no_q_reading = $no_q_reading."Reading";
my $filebase;
eval {
@@ -61,9 +70,15 @@ if ($@) {
$filebase = lc($sensor);
}
+my $qmlfilebase = $filebase;
+$qmlfilebase =~ s/^.//;
+$qmlfilebase = "qml".$qmlfilebase;
+
my $pheader = $filebase."_p.h";
my $header = $filebase.".h";
my $source = $filebase.".cpp";
+my $qmlsource = "../imports/sensors/".$qmlfilebase.".cpp";
+my $qmlheader = "../imports/sensors/".$qmlfilebase.".h";
my $pguard = uc($pheader);
$pguard =~ s/\./_/g;
@@ -71,6 +86,163 @@ $pguard =~ s/\./_/g;
my $guard = uc($header);
$guard =~ s/\./_/g;
+my $qmlguard = "QML".uc($no_q_sensor)."_H";
+
+if (! -e $qmlheader) {
+ print "Creating $qmlheader\n";
+ open OUT, ">$qmlheader" or die $!;
+ print OUT '
+#ifndef '.$qmlguard.'
+#define '.$qmlguard.'
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class '.$sensor.';
+
+class '.$qmlsensor.' : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit '.$qmlsensor.'(QObject *parent = 0);
+ ~'.$qmlsensor.'();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ '.$sensor.' *m_sensor;
+};
+
+class '.$qmlreading.' : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop1 READ prop1 NOTIFY prop1Changed)
+public:
+ explicit '.$qmlreading.'('.$sensor.' *sensor);
+ ~'.$qmlreading.'();
+
+ qreal prop1() const;
+
+Q_SIGNALS:
+ void prop1Changed();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ '.$sensor.' *m_sensor;
+ qreal m_prop1;
+};
+
+QT_END_NAMESPACE
+#endif
+';
+ close OUT;
+}
+
+if (! -e $qmlsource) {
+ print "Creating $qmlsource\n";
+ open OUT, ">$qmlsource" or die $!;
+ print OUT '
+#include "qml'.lc($no_q_sensor).'.h"
+#include <'.$sensor.'>
+
+/*!
+ \qmltype '.$no_q_sensor.'
+ \instantiates '.$qmlsensor.'
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.[INSERT VERSION HERE]
+ \inherits Sensor
+ \brief The '.$no_q_sensor.' element reports on fubbleness.
+
+ The '.$no_q_sensor.' element reports on fubbleness.
+
+ This element wraps the '.$sensor.' class. Please see the documentation for
+ '.$sensor.' for details.
+
+ \sa '.$no_q_reading.'
+*/
+
+'.$qmlsensor.'::'.$qmlsensor.'(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new '.$sensor.'(this))
+{
+}
+
+'.$qmlsensor.'::~'.$qmlsensor.'()
+{
+}
+
+QmlSensorReading *'.$qmlsensor.'::createReading() const
+{
+ return new '.$qmlreading.'(m_sensor);
+}
+
+QSensor *'.$qmlsensor.'::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype '.$no_q_reading.'
+ \instantiates '.$qmlreading.'
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.[INSERT VERSION HERE]
+ \inherits SensorReading
+ \brief The '.$no_q_reading.' element holds the most recent '.$no_q_sensor.' reading.
+
+ The '.$no_q_reading.' element holds the most recent '.$no_q_sensor.' reading.
+
+ This element wraps the '.$reading.' class. Please see the documentation for
+ '.$reading.' for details.
+
+ This element cannot be directly created.
+*/
+
+'.$qmlreading.'::'.$qmlreading.'('.$sensor.' *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_prop1(0)
+{
+}
+
+'.$qmlreading.'::~'.$qmlreading.'()
+{
+}
+
+/*!
+ \qmlproperty qreal '.$no_q_reading.'::prop1
+ This property holds the fubble of the device.
+
+ Please see '.$reading.'::prop1 for information about this property.
+*/
+
+qreal '.$qmlreading.'::prop1() const
+{
+ return m_prop1;
+}
+
+QSensorReading *'.$qmlreading.'::reading() const
+{
+ return m_sensor->reading();
+}
+
+void '.$qmlreading.'::readingUpdate()
+{
+ qreal prop1 = m_sensor->reading()->prop1();
+ if (m_prop1 != prop1) {
+ m_prop1 = prop1;
+ Q_EMIT prop1Changed();
+ }
+}
+';
+ close OUT;
+}
+
if (! -e $pheader) {
print "Creating $pheader\n";
open OUT, ">$pheader" or die $!;
@@ -89,7 +261,6 @@ if (! -e $pheader) {
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class '.$reading_private.'
@@ -110,7 +281,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
';
@@ -126,11 +296,8 @@ if (! -e $header) {
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class '.$reading_private.';
class Q_SENSORS_EXPORT '.$reading.' : public QSensorReading
@@ -166,7 +333,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
';
@@ -188,7 +354,7 @@ IMPLEMENT_READING('.$reading.')
\class '.$reading.'
\ingroup sensors_reading
\inmodule QtSensors
- \since QtSensors 5.[INSERT VERSION HERE]
+ \since 5.[INSERT VERSION HERE]
\brief The '.$reading.' class holds readings from the [X] sensor.
@@ -226,7 +392,7 @@ void '.$reading.'::setMyprop(qreal myprop)
\class '.$filter.'
\ingroup sensors_filter
\inmodule QtSensors
- \since QtSensors 5.[INSERT VERSION HERE]
+ \since 5.[INSERT VERSION HERE]
\brief The '.$filter.' class is a convenience wrapper around QSensorFilter.
@@ -248,7 +414,7 @@ char const * const '.$sensor.'::type("'.$sensor.'");
\class '.$sensor.'
\ingroup sensors_type
\inmodule QtSensors
- \since QtSensors 5.[INSERT VERSION HERE]
+ \since 5.[INSERT VERSION HERE]
\brief The '.$sensor.' class is a convenience wrapper around QSensor.
diff --git a/src/sensors/qaccelerometer.cpp b/src/sensors/qaccelerometer.cpp
index 4aeedf42..9b9bd346 100644
--- a/src/sensors/qaccelerometer.cpp
+++ b/src/sensors/qaccelerometer.cpp
@@ -153,6 +153,29 @@ void QAccelerometerReading::setZ(qreal z)
char const * const QAccelerometer::type("QAccelerometer");
/*!
+ \enum QAccelerometer::AccelerationMode
+
+ \brief This enum represents the acceleration mode of an acceleration sensor.
+
+ The acceleration mode controls how the sensor reports acceleration. QAccelerometer::Combined
+ is the only mode in which the values can be directly physically measured, the others are an
+ approximation.
+
+ \value Combined Both the acceleration caused by gravity and the acceleration caused by the
+ user moving the device is reported combined.
+ \value Gravity Only the acceleration caused by gravity is reported. Movements of the device
+ caused by the user have no effect other than changing the direction when the
+ device is rotated.
+ \value User Only the acceleration caused by the user moving the device is reported, the
+ effect of gravity is canceled out. A device at rest therefore should report
+ values of, or close to, zero.
+ In other APIs, this mode might be known as \e {linear acceleration}.
+
+ \sa QAccelerometer::accelerationMode
+ \since 5.1
+*/
+
+/*!
\class QAccelerometer
\ingroup sensors_type
\inmodule QtSensors
@@ -161,7 +184,11 @@ char const * const QAccelerometer::type("QAccelerometer");
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.
+ It also supports changing the acceleration mode, which controls whether the force of gravity
+ is included in the accelerometer values or not.
+
+ Furthermore, this class features a reading() function that returns a QAccelerometerReading
+ instead of a QSensorReading.
For details about how the sensor works, see \l QAccelerometerReading.
@@ -172,7 +199,7 @@ char const * const QAccelerometer::type("QAccelerometer");
Construct the sensor as a child of \a parent.
*/
QAccelerometer::QAccelerometer(QObject *parent)
- : QSensor(QAccelerometer::type, parent)
+ : QSensor(QAccelerometer::type, *new QAccelerometerPrivate, parent)
{
}
@@ -184,6 +211,45 @@ QAccelerometer::~QAccelerometer()
}
/*!
+ \property QAccelerometer::accelerationMode
+ \brief The acceleration mode controls how acceleration values are reported.
+ \since 5.1
+
+ The acceleration mode controls how the acceleration sensor reports its values.
+ The default mode is QAccelerometer::Combined, which means the acceleration caused
+ by gravity is included in the reported values.
+
+ Acceleration caused by gravity and acceleration caused by the user moving the device
+ are physically impossible to distinguish because of general relativity. Most devices use
+ sensor fusion to figure out which parts of the acceleration is caused by gravity, for example
+ by using a rotation sensor to calculate the gravity direction and assuming a fixed magnitude
+ for gravity. Therefore the result is only an approximation and may be inaccurate.
+ The QAccelerometer::Combined mode is the most accurate one, as it does not involve approximating
+ the gravity.
+
+ Not all backends and devices might support setting the acceleration mode. For those cases, the
+ default mode QAccelerometer::Combined is used, changing it has no effect.
+*/
+QAccelerometer::AccelerationMode QAccelerometer::accelerationMode() const
+{
+ Q_D(const QAccelerometer);
+ return d->accelerationMode;
+}
+
+/*!
+ Sets the acceleration mode to \a accelerationMode.
+ \since 5.1
+*/
+void QAccelerometer::setAccelerationMode(QAccelerometer::AccelerationMode accelerationMode)
+{
+ Q_D(QAccelerometer);
+ if (d->accelerationMode != accelerationMode) {
+ d->accelerationMode = accelerationMode;
+ emit accelerationModeChanged(d->accelerationMode);
+ }
+}
+
+/*!
\fn QAccelerometer::reading() const
Returns the reading class for this sensor.
@@ -191,6 +257,14 @@ QAccelerometer::~QAccelerometer()
\sa QSensor::reading()
*/
+/*!
+ \fn QAccelerometer::accelerationModeChanged(AccelerationMode accelerationMode)
+
+ Emitted when the acceleration mode was changed.
+
+ \since 5.1
+*/
+
#include "moc_qaccelerometer.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qaccelerometer.h b/src/sensors/qaccelerometer.h
index 734ce97e..4478235c 100644
--- a/src/sensors/qaccelerometer.h
+++ b/src/sensors/qaccelerometer.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QAccelerometerReadingPrivate;
class Q_SENSORS_EXPORT QAccelerometerReading : public QSensorReading
@@ -77,21 +74,40 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QAccelerometerReading*>(reading)); }
};
+class QAccelerometerPrivate;
+
class Q_SENSORS_EXPORT QAccelerometer : public QSensor
{
Q_OBJECT
+ Q_ENUMS(AccelerationMode)
+ Q_PROPERTY(AccelerationMode accelerationMode READ accelerationMode WRITE setAccelerationMode
+ NOTIFY accelerationModeChanged)
public:
explicit QAccelerometer(QObject *parent = 0);
virtual ~QAccelerometer();
+
+ // Keep this enum in sync with QmlAccelerometer::AccelerationMode
+ enum AccelerationMode {
+ Combined,
+ Gravity,
+ User
+ };
+
+ AccelerationMode accelerationMode() const;
+ void setAccelerationMode(AccelerationMode accelerationMode);
+
QAccelerometerReading *reading() const { return static_cast<QAccelerometerReading*>(QSensor::reading()); }
static char const * const type;
+Q_SIGNALS:
+ void accelerationModeChanged(AccelerationMode accelerationMode);
+
private:
+ Q_DECLARE_PRIVATE(QAccelerometer)
Q_DISABLE_COPY(QAccelerometer)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qaccelerometer_p.h b/src/sensors/qaccelerometer_p.h
index dd60fd19..e8023db2 100644
--- a/src/sensors/qaccelerometer_p.h
+++ b/src/sensors/qaccelerometer_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
class QAccelerometerReadingPrivate
@@ -71,8 +72,18 @@ public:
qreal z;
};
+class QAccelerometerPrivate : public QSensorPrivate
+{
+public:
+ QAccelerometerPrivate()
+ : accelerationMode(QAccelerometer::Combined)
+ {
+ }
+
+ QAccelerometer::AccelerationMode accelerationMode;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qaltimeter.cpp b/src/sensors/qaltimeter.cpp
new file mode 100644
index 00000000..6a7caa7b
--- /dev/null
+++ b/src/sensors/qaltimeter.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qaltimeter.h>
+#include "qaltimeter_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QAltimeterReading)
+
+/*!
+ \class QAltimeterReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAltimeterReading class holds readings from the altimeter sensor.
+
+ The altitude is reported in meters relative to mean sea level.
+
+ On BlackBerry, the altimeter uses a combination of pressure and location to determine
+ the altitude, as using pressure alone would yield to inaccurate results due to changes
+ in air pressure caused by the weather. The location information is used to compensate for
+ the weather. This requires that the user has enabled location services in the global
+ settings.
+*/
+
+/*!
+ \property QAltimeterReading::altitude
+ \brief The altitude in meters relative to mean sea level.
+*/
+
+qreal QAltimeterReading::altitude() const
+{
+ return d->altitude;
+}
+
+/*!
+ Sets the altitude to \a altitude.
+*/
+void QAltimeterReading::setAltitude(qreal altitude)
+{
+ d->altitude = altitude;
+}
+
+// =====================================================================
+
+/*!
+ \class QAltimeterFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAltimeterFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QAltimeterReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QAltimeterFilter::filter(QAltimeterReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QAltimeter::type("QAltimeter");
+
+/*!
+ \class QAltimeter
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAltimeter 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 QAltimeterReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QAltimeterReading.
+
+ \sa QAltimeterReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QAltimeter::QAltimeter(QObject *parent)
+ : QSensor(QAltimeter::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QAltimeter::~QAltimeter()
+{
+}
+
+/*!
+ \fn QAltimeter::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qaltimeter.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qaltimeter.h b/src/sensors/qaltimeter.h
new file mode 100644
index 00000000..6b7d2232
--- /dev/null
+++ b/src/sensors/qaltimeter.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QALTIMETER_H
+#define QALTIMETER_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAltimeterReadingPrivate;
+
+class Q_SENSORS_EXPORT QAltimeterReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal altitude READ altitude)
+ DECLARE_READING(QAltimeterReading)
+public:
+ qreal altitude() const;
+ void setAltitude(qreal altitude);
+};
+
+class Q_SENSORS_EXPORT QAltimeterFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QAltimeterReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QAltimeterReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QAltimeter : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QAltimeter(QObject *parent = 0);
+ ~QAltimeter();
+ QAltimeterReading *reading() const { return static_cast<QAltimeterReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QAltimeter)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qaltimeter_p.h b/src/sensors/qaltimeter_p.h
new file mode 100644
index 00000000..dfc3ebd3
--- /dev/null
+++ b/src/sensors/qaltimeter_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QALTIMETER_P_H
+#define QALTIMETER_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
+
+class QAltimeterReadingPrivate
+{
+public:
+ QAltimeterReadingPrivate()
+ : altitude(0)
+ {
+ }
+
+ qreal altitude;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qambientlightsensor.h b/src/sensors/qambientlightsensor.h
index 8b69fc2c..3dae639c 100644
--- a/src/sensors/qambientlightsensor.h
+++ b/src/sensors/qambientlightsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QAmbientLightReadingPrivate;
class Q_SENSORS_EXPORT QAmbientLightReading : public QSensorReading
@@ -93,7 +90,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qambientlightsensor_p.h b/src/sensors/qambientlightsensor_p.h
index 5faf8530..c921c6bf 100644
--- a/src/sensors/qambientlightsensor_p.h
+++ b/src/sensors/qambientlightsensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QAmbientLightReadingPrivate
@@ -68,7 +67,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qambienttemperaturesensor.cpp b/src/sensors/qambienttemperaturesensor.cpp
new file mode 100644
index 00000000..9ecde6df
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qambienttemperaturesensor.h>
+#include "qambienttemperaturesensor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QAmbientTemperatureReading)
+
+/*!
+ \class QAmbientTemperatureReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAmbientTemperatureReading class holds readings of the ambient temperature.
+
+ The ambient (room) temperature is the temperature in degree Celsius.
+*/
+
+/*!
+ \property QAmbientTemperatureReading::temperature
+ \brief The ambient temperature
+
+ Measured in degree Celsius.
+*/
+
+qreal QAmbientTemperatureReading::temperature() const
+{
+ return d->temperature;
+}
+
+/*!
+ Sets ambient temperature to \a temperature.
+*/
+void QAmbientTemperatureReading::setTemperature(qreal temperature)
+{
+ d->temperature = temperature;
+}
+
+// =====================================================================
+
+/*!
+ \class QAmbientTemperatureFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAmbientTemperatureFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QAmbientTemperatureReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QAmbientTemperatureFilter::filter(QAmbientTemperatureReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QAmbientTemperatureSensor::type("QAmbientTemperatureSensor");
+
+/*!
+ \class QAmbientTemperatureSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAmbientTemperatureSensor 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 QAmbientTemperatureReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QAmbientTemperatureReading.
+
+ \sa QAmbientTemperatureReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QAmbientTemperatureSensor::QAmbientTemperatureSensor(QObject *parent)
+ : QSensor(QAmbientTemperatureSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QAmbientTemperatureSensor::~QAmbientTemperatureSensor()
+{
+}
+
+/*!
+ \fn QAmbientTemperatureSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qambienttemperaturesensor.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qambienttemperaturesensor.h b/src/sensors/qambienttemperaturesensor.h
new file mode 100644
index 00000000..134e5a92
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QAMBIENTTEMPERATURESENSOR_H
+#define QAMBIENTTEMPERATURESENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAmbientTemperatureReadingPrivate;
+
+class Q_SENSORS_EXPORT QAmbientTemperatureReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal temperature READ temperature)
+ DECLARE_READING(QAmbientTemperatureReading)
+public:
+ qreal temperature() const;
+ void setTemperature(qreal temperature);
+};
+
+class Q_SENSORS_EXPORT QAmbientTemperatureFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QAmbientTemperatureReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QAmbientTemperatureReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QAmbientTemperatureSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QAmbientTemperatureSensor(QObject *parent = 0);
+ ~QAmbientTemperatureSensor();
+ QAmbientTemperatureReading *reading() const { return static_cast<QAmbientTemperatureReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QAmbientTemperatureSensor)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qambienttemperaturesensor_p.h b/src/sensors/qambienttemperaturesensor_p.h
new file mode 100644
index 00000000..63fe1452
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QAMBIENTTEMPERATURESENSOR_P_H
+#define QAMBIENTTEMPERATURESENSOR_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
+
+class QAmbientTemperatureReadingPrivate
+{
+public:
+ QAmbientTemperatureReadingPrivate()
+ : temperature(0)
+ {
+ }
+
+ qreal temperature;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qcompass.h b/src/sensors/qcompass.h
index 17b06584..8b858ff7 100644
--- a/src/sensors/qcompass.h
+++ b/src/sensors/qcompass.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QCompassReadingPrivate;
class Q_SENSORS_EXPORT QCompassReading : public QSensorReading
@@ -87,7 +84,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qcompass_p.h b/src/sensors/qcompass_p.h
index 04a3b798..49da19b2 100644
--- a/src/sensors/qcompass_p.h
+++ b/src/sensors/qcompass_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QCompassReadingPrivate
@@ -70,7 +69,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qgyroscope.h b/src/sensors/qgyroscope.h
index 7589c6ce..32c01da8 100644
--- a/src/sensors/qgyroscope.h
+++ b/src/sensors/qgyroscope.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QGyroscopeReadingPrivate;
class Q_SENSORS_EXPORT QGyroscopeReading : public QSensorReading
@@ -91,7 +88,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qgyroscope_p.h b/src/sensors/qgyroscope_p.h
index 21bcde41..a5e42766 100644
--- a/src/sensors/qgyroscope_p.h
+++ b/src/sensors/qgyroscope_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QGyroscopeReadingPrivate
@@ -72,7 +71,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qholstersensor.cpp b/src/sensors/qholstersensor.cpp
new file mode 100644
index 00000000..761910f2
--- /dev/null
+++ b/src/sensors/qholstersensor.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qholstersensor.h>
+#include "qholstersensor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QHolsterReading)
+
+/*!
+ \class QHolsterReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QHolsterReading class holds readings from the holster sensor.
+
+ \section2 QHolsterReading Units
+ The holster sensor can detect if a device is holstered or not. A holster is a pocket,
+ similar to a gun holster, specifically made for the device. If the device is inside of this
+ pocket, it is holstered. The holster supports the device in detecting whether the device is
+ holstered or not.
+*/
+
+/*!
+ \property QHolsterReading::holstered
+ \brief A value indicating whether the device is holstered.
+
+ \sa {QHolsterReading Units}
+*/
+
+bool QHolsterReading::holstered() const
+{
+ return d->holstered;
+}
+
+/*!
+ Sets the holstered value to \a holstered.
+*/
+void QHolsterReading::setHolstered(bool holstered)
+{
+ d->holstered = holstered;
+}
+
+// =====================================================================
+
+/*!
+ \class QHolsterFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QHolsterFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QHolsterReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QHolsterFilter::filter(QHolsterReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QHolsterSensor::type("QHolsterSensor");
+
+/*!
+ \class QHolsterSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QHolsterSensor 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 QHolsterReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QHolsterReading.
+
+ \sa QHolsterReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QHolsterSensor::QHolsterSensor(QObject *parent)
+ : QSensor(QHolsterSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QHolsterSensor::~QHolsterSensor()
+{
+}
+
+/*!
+ \fn QHolsterSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qholstersensor.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qholstersensor.h b/src/sensors/qholstersensor.h
new file mode 100644
index 00000000..f44b381e
--- /dev/null
+++ b/src/sensors/qholstersensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QHOLSTERSENSOR_H
+#define QHOLSTERSENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QHolsterReadingPrivate;
+
+class Q_SENSORS_EXPORT QHolsterReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(bool holstered READ holstered)
+ DECLARE_READING(QHolsterReading)
+public:
+ bool holstered() const;
+ void setHolstered(bool holstered);
+};
+
+class Q_SENSORS_EXPORT QHolsterFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QHolsterReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QHolsterReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QHolsterSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QHolsterSensor(QObject *parent = 0);
+ ~QHolsterSensor();
+ QHolsterReading *reading() const { return static_cast<QHolsterReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QHolsterSensor)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qholstersensor_p.h b/src/sensors/qholstersensor_p.h
new file mode 100644
index 00000000..a90613f0
--- /dev/null
+++ b/src/sensors/qholstersensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QHOLSTERSENSOR_P_H
+#define QHOLSTERSENSOR_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
+
+class QHolsterReadingPrivate
+{
+public:
+ QHolsterReadingPrivate()
+ : holstered(false)
+ {
+ }
+
+ bool holstered;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qirproximitysensor.h b/src/sensors/qirproximitysensor.h
index c6b8925b..29eb49cd 100644
--- a/src/sensors/qirproximitysensor.h
+++ b/src/sensors/qirproximitysensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QIRProximityReadingPrivate;
class Q_SENSORS_EXPORT QIRProximityReading : public QSensorReading
@@ -83,7 +80,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qirproximitysensor_p.h b/src/sensors/qirproximitysensor_p.h
index 6241b629..9b16af56 100644
--- a/src/sensors/qirproximitysensor_p.h
+++ b/src/sensors/qirproximitysensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QIRProximityReadingPrivate
@@ -68,6 +67,5 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qlightsensor.cpp b/src/sensors/qlightsensor.cpp
index b712bb6e..f02f6b10 100644
--- a/src/sensors/qlightsensor.cpp
+++ b/src/sensors/qlightsensor.cpp
@@ -120,7 +120,7 @@ char const * const QLightSensor::type("QLightSensor");
Construct the sensor as a child of \a parent.
*/
QLightSensor::QLightSensor(QObject *parent)
- : QSensor(QLightSensor::type, parent)
+ : QSensor(QLightSensor::type, *new QLightSensorPrivate, parent)
{
}
@@ -144,7 +144,33 @@ QLightSensor::~QLightSensor()
\brief a value indicating the field of view.
This is an angle that represents the field of view of the sensor.
+
+ Not all light sensor support retrieving their field of view. For sensors
+ that don't support this property, the value will be 0. Whether the field of
+ view is supported can be checked with QSensor::isFeatureSupported() and the
+ QSensor::FieldOfView flag.
+*/
+
+qreal QLightSensor::fieldOfView() const
+{
+ Q_D(const QLightSensor);
+ return d->fieldOfView;
+}
+
+/*!
+ \since 5.1
+
+ Sets the field of view. This is to be called from the
+ backend.
*/
+void QLightSensor::setFieldOfView(qreal fieldOfView)
+{
+ Q_D(QLightSensor);
+ if (d->fieldOfView != fieldOfView) {
+ d->fieldOfView = fieldOfView;
+ emit fieldOfViewChanged(fieldOfView);
+ }
+}
#include "moc_qlightsensor.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qlightsensor.h b/src/sensors/qlightsensor.h
index 096df931..1da84498 100644
--- a/src/sensors/qlightsensor.h
+++ b/src/sensors/qlightsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QLightReadingPrivate;
class Q_SENSORS_EXPORT QLightReading : public QSensorReading
@@ -69,24 +66,30 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QLightReading*>(reading)); }
};
+class QLightSensorPrivate;
+
class Q_SENSORS_EXPORT QLightSensor : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(qreal fieldOfView)
-#endif
+ Q_PROPERTY(qreal fieldOfView READ fieldOfView NOTIFY fieldOfViewChanged)
public:
explicit QLightSensor(QObject *parent = 0);
virtual ~QLightSensor();
QLightReading *reading() const { return static_cast<QLightReading*>(QSensor::reading()); }
static char const * const type;
+ qreal fieldOfView() const;
+ void setFieldOfView(qreal fieldOfView);
+
+Q_SIGNALS:
+ void fieldOfViewChanged(qreal fieldOfView);
+
private:
+ Q_DECLARE_PRIVATE(QLightSensor)
Q_DISABLE_COPY(QLightSensor)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qlightsensor_p.h b/src/sensors/qlightsensor_p.h
index da84463e..a9df63e4 100644
--- a/src/sensors/qlightsensor_p.h
+++ b/src/sensors/qlightsensor_p.h
@@ -55,7 +55,6 @@
#include "qsensor_p.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QLightReadingPrivate : public QSensorReadingPrivate
@@ -69,8 +68,18 @@ public:
qreal lux;
};
+class QLightSensorPrivate : public QSensorPrivate
+{
+public:
+ QLightSensorPrivate()
+ : fieldOfView(0)
+ {
+ }
+
+ qreal fieldOfView;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qmagnetometer.cpp b/src/sensors/qmagnetometer.cpp
index 60b2df83..f5f563aa 100644
--- a/src/sensors/qmagnetometer.cpp
+++ b/src/sensors/qmagnetometer.cpp
@@ -210,7 +210,7 @@ char const * const QMagnetometer::type("QMagnetometer");
Construct the sensor as a child of \a parent.
*/
QMagnetometer::QMagnetometer(QObject *parent)
- : QSensor(QMagnetometer::type, parent)
+ : QSensor(QMagnetometer::type, *new QMagnetometerPrivate, parent)
{
}
@@ -236,10 +236,24 @@ QMagnetometer::~QMagnetometer()
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().
*/
+bool QMagnetometer::returnGeoValues() const
+{
+ Q_D(const QMagnetometer);
+ return d->returnGeoValues;
+}
+
+void QMagnetometer::setReturnGeoValues(bool returnGeoValues)
+{
+ Q_D(QMagnetometer);
+ if (d->returnGeoValues != returnGeoValues) {
+ d->returnGeoValues = returnGeoValues;
+ emit returnGeoValuesChanged(returnGeoValues);
+ }
+}
+
#include "moc_qmagnetometer.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qmagnetometer.h b/src/sensors/qmagnetometer.h
index 60e142d4..93b6157f 100644
--- a/src/sensors/qmagnetometer.h
+++ b/src/sensors/qmagnetometer.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QMagnetometerReadingPrivate;
class Q_SENSORS_EXPORT QMagnetometerReading : public QSensorReading
@@ -81,24 +78,30 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QMagnetometerReading*>(reading)); }
};
+class QMagnetometerPrivate;
+
class Q_SENSORS_EXPORT QMagnetometer : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(bool returnGeoValues)
-#endif
+ Q_PROPERTY(bool returnGeoValues READ returnGeoValues WRITE setReturnGeoValues NOTIFY returnGeoValuesChanged)
public:
explicit QMagnetometer(QObject *parent = 0);
virtual ~QMagnetometer();
QMagnetometerReading *reading() const { return static_cast<QMagnetometerReading*>(QSensor::reading()); }
static char const * const type;
+ bool returnGeoValues() const;
+ void setReturnGeoValues(bool returnGeoValues);
+
+Q_SIGNALS:
+ void returnGeoValuesChanged(bool returnGeoValues);
+
private:
+ Q_DECLARE_PRIVATE(QMagnetometer)
Q_DISABLE_COPY(QMagnetometer)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qmagnetometer_p.h b/src/sensors/qmagnetometer_p.h
index 2b42cfd7..3c38e6c8 100644
--- a/src/sensors/qmagnetometer_p.h
+++ b/src/sensors/qmagnetometer_p.h
@@ -53,9 +53,21 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
+class QMagnetometerPrivate : public QSensorPrivate
+{
+public:
+ QMagnetometerPrivate()
+ : returnGeoValues(false)
+ {
+ }
+
+ bool returnGeoValues;
+};
+
class QMagnetometerReadingPrivate
{
public:
@@ -74,7 +86,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qorientationsensor.h b/src/sensors/qorientationsensor.h
index f577df7a..082598fb 100644
--- a/src/sensors/qorientationsensor.h
+++ b/src/sensors/qorientationsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QOrientationReadingPrivate;
class Q_SENSORS_EXPORT QOrientationReading : public QSensorReading
@@ -94,7 +91,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qorientationsensor_p.h b/src/sensors/qorientationsensor_p.h
index 09a65a71..433f3dd9 100644
--- a/src/sensors/qorientationsensor_p.h
+++ b/src/sensors/qorientationsensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QOrientationReadingPrivate
@@ -68,7 +67,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qpressuresensor.cpp b/src/sensors/qpressuresensor.cpp
new file mode 100644
index 00000000..ea8a79bb
--- /dev/null
+++ b/src/sensors/qpressuresensor.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qpressuresensor.h>
+#include "qpressuresensor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QPressureReading)
+
+/*!
+ \class QPressureReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QPressureReading class holds readings from the pressure sensor.
+
+ \section2 QPressureReading Units
+
+ The pressure sensor returns atmospheric pressure values in Pascals.
+*/
+
+/*!
+ \property QPressureReading::pressure
+ \brief The measured atmospheric pressure.
+
+ Returned as Pascals.
+ \sa {QPressureReading Units}
+*/
+
+qreal QPressureReading::pressure() const
+{
+ return d->pressure;
+}
+
+/*!
+ Sets the pressure to \a pressure.
+*/
+void QPressureReading::setPressure(qreal pressure)
+{
+ d->pressure = pressure;
+}
+
+// =====================================================================
+
+/*!
+ \class QPressureFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QPressureFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QPressureReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QPressureFilter::filter(QPressureReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QPressureSensor::type("QPressureSensor");
+
+/*!
+ \class QPressureSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QPressureSensor class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QPressureReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QPressureReading.
+
+ \sa QPressureReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QPressureSensor::QPressureSensor(QObject *parent)
+ : QSensor(QPressureSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QPressureSensor::~QPressureSensor()
+{
+}
+
+/*!
+ \fn QPressureSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qpressuresensor.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qpressuresensor.h b/src/sensors/qpressuresensor.h
new file mode 100644
index 00000000..50379b52
--- /dev/null
+++ b/src/sensors/qpressuresensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QPRESSURESENSOR_H
+#define QPRESSURESENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPressureReadingPrivate;
+
+class Q_SENSORS_EXPORT QPressureReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal pressure READ pressure)
+ DECLARE_READING(QPressureReading)
+public:
+ qreal pressure() const;
+ void setPressure(qreal pressure);
+};
+
+class Q_SENSORS_EXPORT QPressureFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QPressureReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QPressureReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QPressureSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QPressureSensor(QObject *parent = 0);
+ ~QPressureSensor();
+ QPressureReading *reading() const { return static_cast<QPressureReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QPressureSensor)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qpressuresensor_p.h b/src/sensors/qpressuresensor_p.h
new file mode 100644
index 00000000..1c74e7f1
--- /dev/null
+++ b/src/sensors/qpressuresensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QPRESSURESENSOR_P_H
+#define QPRESSURESENSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QPressureReadingPrivate
+{
+public:
+ QPressureReadingPrivate()
+ : pressure(0)
+ {
+ }
+
+ qreal pressure;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qproximitysensor.h b/src/sensors/qproximitysensor.h
index efabead9..cc8eb78b 100644
--- a/src/sensors/qproximitysensor.h
+++ b/src/sensors/qproximitysensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QProximityReadingPrivate;
class Q_SENSORS_EXPORT QProximityReading : public QSensorReading
@@ -83,7 +80,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qproximitysensor_p.h b/src/sensors/qproximitysensor_p.h
index 57125d50..8f951e6a 100644
--- a/src/sensors/qproximitysensor_p.h
+++ b/src/sensors/qproximitysensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QProximityReadingPrivate
@@ -68,7 +67,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qrotationsensor.cpp b/src/sensors/qrotationsensor.cpp
index 9acc1cd8..ea0515ca 100644
--- a/src/sensors/qrotationsensor.cpp
+++ b/src/sensors/qrotationsensor.cpp
@@ -201,7 +201,7 @@ char const * const QRotationSensor::type("QRotationSensor");
Construct the sensor as a child of \a parent.
*/
QRotationSensor::QRotationSensor(QObject *parent)
- : QSensor(QRotationSensor::type, parent)
+ : QSensor(QRotationSensor::type, *new QRotationSensorPrivate, parent)
{
}
@@ -228,6 +228,28 @@ QRotationSensor::~QRotationSensor()
Returns false if z is not available.
*/
+bool QRotationSensor::hasZ() const
+{
+ Q_D(const QRotationSensor);
+ return (d->hasZ);
+}
+
+/*!
+ \since 5.1
+
+ Sets whether the z angle is available. This is to be called from the
+ backend. By default the hasZ property is true, so a backend only has to
+ call this if its rotation sensor can not report z angles.
+*/
+void QRotationSensor::setHasZ(bool hasZ)
+{
+ Q_D(QRotationSensor);
+ if (d->hasZ != hasZ) {
+ d->hasZ = hasZ;
+ emit hasZChanged(hasZ);
+ }
+}
+
#include "moc_qrotationsensor.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qrotationsensor.h b/src/sensors/qrotationsensor.h
index c049238c..68a0d1d3 100644
--- a/src/sensors/qrotationsensor.h
+++ b/src/sensors/qrotationsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QRotationReadingPrivate;
class Q_SENSORS_EXPORT QRotationReading : public QSensorReading
@@ -74,24 +71,30 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QRotationReading*>(reading)); }
};
+class QRotationSensorPrivate;
+
class Q_SENSORS_EXPORT QRotationSensor : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(bool hasZ)
-#endif
+ Q_PROPERTY(bool hasZ READ hasZ NOTIFY hasZChanged)
public:
explicit QRotationSensor(QObject *parent = 0);
virtual ~QRotationSensor();
QRotationReading *reading() const { return static_cast<QRotationReading*>(QSensor::reading()); }
static char const * const type;
+ bool hasZ() const;
+ void setHasZ(bool hasZ);
+
+Q_SIGNALS:
+ void hasZChanged(bool hasZ);
+
private:
+ Q_DECLARE_PRIVATE(QRotationSensor)
Q_DISABLE_COPY(QRotationSensor)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qrotationsensor_p.h b/src/sensors/qrotationsensor_p.h
index f6ce13ff..401c2143 100644
--- a/src/sensors/qrotationsensor_p.h
+++ b/src/sensors/qrotationsensor_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
class QRotationReadingPrivate
@@ -71,8 +72,18 @@ public:
qreal z;
};
+class QRotationSensorPrivate : public QSensorPrivate
+{
+public:
+ QRotationSensorPrivate()
+ : hasZ(true)
+ {
+ }
+
+ bool hasZ;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensor.cpp b/src/sensors/qsensor.cpp
index 81cb6530..01a4f7b7 100644
--- a/src/sensors/qsensor.cpp
+++ b/src/sensors/qsensor.cpp
@@ -176,6 +176,40 @@ void QSensorPrivate::init(const QByteArray &sensorType)
The sensor data is delivered via QSensorReading and its sub-classes.
+ \section1 Orientation
+
+ Some sensors react to screen orientation changes, such as QAccelerometer, QMagnetometer and
+ QRotationSensor. These are so called \e orientable sensors. For orientable sensors,
+ QSensor supports changing the reporting of the reading values based on the orientation of the
+ screen.
+
+ For orientable sensors, the axesOrientationMode property controls how the orientation affects
+ the reading values.
+
+ In the default mode, QSensor::FixedOrientation, the reading values remain
+ unaffected by the orientation. In the QSensor::AutomaticOrientation mode, the reading
+ values are automatically rotated by taking the current screen orientation into account. And
+ finally, in the QSensor::UserOrientation mode, the reading values are rotated
+ according to a user-specified orientation.
+
+ The functionality of this is only available if it is supported by the backend and if the sensor
+ is orientable, which can be checked by calling QSensor::isFeatureSupported()
+ with the QSensor::AxesOrientation flag.
+
+ The orientation values here are always of the screen orientation, not the device orientation.
+ The screen orientation is the orientation of the GUI. For example when rotating a device by 90
+ degrees counter-clockwise, the screen orientation compensates for that by rotating 90 degrees
+ clockwise, to the effect that the GUI is still facing upright after the device has been rotated.
+ Note that applications can lock the screen orientation, for example to force portrait or landscape
+ mode. For locked orientations, orientable sensors will not react with reading changes if the device
+ orientation is changed, as orientable sensors react to screen orientation changes only. This makes
+ sense, as the purpose of orientable sensors is to keep the sensor orientation in sync with the screen
+ orientation.
+
+ The orientation values range from 0 to 270 degrees. The orientation is applied in clockwise direction,
+ e.g. an orientation value of 90 degrees means that the screen has been rotated 90 degress to the right
+ from its origin position, to compensate a device rotation of 90 degrees to the left.
+
\sa QSensorReading
*/
@@ -189,6 +223,9 @@ void QSensorPrivate::init(const QByteArray &sensorType)
QSensor::bufferSize property.
\value AlwaysOn The backend supports changing the policy on whether to suspend when idle,
controlled by the QSensor::alwaysOn property.
+ \value SkipDuplicates The backend supports skipping of same or very similar successive
+ readings. This can be enabled by setting the QSensor::skipDuplicates
+ property to true.
The features of QMagnetometer are:
@@ -200,6 +237,16 @@ void QSensorPrivate::init(const QByteArray &sensorType)
\value FieldOfView The backend specifies its field of view, which can be
read from the QLightSensor::fieldOfView property.
+ The features of QAccelerometer are:
+
+ \value AccelerationMode The backend supports switching the acceleration mode
+ of the acceleromter with the QAccelerometer::accelerationMode property.
+
+ The features of all orientable sensors are:
+
+ \value AxesOrientation The backend supports changing the axes orientation from the default of
+ QSensor::FixedOrientation to something else.
+
\omitvalue Reserved
\sa QSensor::isFeatureSupported()
@@ -429,6 +476,54 @@ bool QSensor::isAlwaysOn() const
}
/*!
+ \property QSensor::skipDuplicates
+ \brief Indicates whether duplicate reading values should be omitted.
+ \since 5.1
+
+ When duplicate skipping is enabled, successive readings with the same or very
+ similar values are omitted. This helps reducing the amount of processing done, as less sensor
+ readings are made available. As a consequence, readings arrive at an irregular interval.
+
+ Duplicate skipping is not just enabled for readings that are exactly the same, but also for
+ readings that are quite similar, as each sensor has a bit of jitter even if the device is
+ not moved.
+
+ Support for this property depends on the backend. Use isFeatureSupported() to check if it is
+ supported on the current platform.
+
+ Duplicate skipping is disabled by default.
+
+ Duplicate skipping takes effect when the sensor is started, changing the property while the
+ sensor is active has no immediate effect.
+*/
+bool QSensor::skipDuplicates() const
+{
+ Q_D(const QSensor);
+ return d->skipDuplicates;
+}
+
+/*!
+ Sets the duplicate skipping to \a skipDuplicates.
+
+ \since 5.1
+*/
+void QSensor::setSkipDuplicates(bool skipDuplicates)
+{
+ Q_D(QSensor);
+ if (d->skipDuplicates != skipDuplicates) {
+ d->skipDuplicates = skipDuplicates;
+ emit skipDuplicatesChanged(skipDuplicates);
+ }
+}
+
+/*!
+ \fn QSensor::skipDuplicatesChanged(bool skipDuplicates)
+ \since 5.1
+
+ This signal is emitted when the skipDuplicates property changes.
+*/
+
+/*!
\property QSensor::availableDataRates
\brief the data rates that the sensor supports.
@@ -760,6 +855,142 @@ int QSensor::error() const
}
/*!
+ \enum QSensor::AxesOrientationMode
+ \since 5.1
+
+ Describes how reading values are affected by the screen orientation.
+
+ \value FixedOrientation No automatic rotation is applied to the reading values.
+
+ \value AutomaticOrientation The reading values are automatically rotated based on the screen
+ orientation.
+
+ \value UserOrientation The reading values are rotated based on the angle of the userOrientation property.
+
+ \sa QSensor::axesOrientationMode
+*/
+
+/*!
+ \property QSensor::axesOrientationMode
+ \since 5.1
+ \brief The mode that affects how the screen orientation changes reading values.
+
+ When set to FixedOrientation, which is the default mode, no automatic rotation is applied to
+ the reading. This is the only mode available for backends that do not support the
+ QSensor::AxesOrientation feature.
+
+ When set to AutomaticOrientation, the reading values are automatically rotated when the
+ screen orientation changes. In effect, the screen orientation is canceled out.
+
+ As an example, assume the device is rotated by 180 degrees and therefore the screen orientation
+ also is rotated by 180 degrees from the native orientation. Without automatic axes orientation,
+ the reading values would now be changed: Both the X and the Y values would be negated, forcing
+ an application developer to manually cancel out the negation in application code. Automatic
+ axes orientation does this automatically, in this mode the X and Y values would be the same as
+ with the default screen orientation.
+
+ This automatic rotation of the axes is handy is some usecases, for example in a bubble level
+ application that measures how level a surface is by looking at the X axis value of an
+ accelerometer. When the device and screen orientation change by 90 degrees, an application
+ developer does not need to change anything, he can continue using the X axis value even though
+ the device is rotated. Without automatic axes orientation, the application developer would need
+ to look at the Y values instead, thereby adding code to the application that reads from a
+ different axis depending on the screen orientation.
+
+ The UserOrientation mode is quite similar to AutomaticOrientation, only that the screen orientation
+ is manually controlled instead of automatically determined. The angle of the userOrientation
+ property is then used for rotating the reading values.
+
+ Since the rotation of the reading values is based on the screen orientation, Z values will never
+ change, as the Z axis is perpendicular to the screen.
+ As screen orientation changes in 90 degree steps, rotating the reading values is also done in
+ steps of 90 degrees.
+
+ This property is only used for orientable sensors.
+*/
+
+QSensor::AxesOrientationMode QSensor::axesOrientationMode() const
+{
+ Q_D(const QSensor);
+ return d->axesOrientationMode;
+}
+
+void QSensor::setAxesOrientationMode(QSensor::AxesOrientationMode axesOrientationMode)
+{
+ Q_D(QSensor);
+ if (d->axesOrientationMode != axesOrientationMode) {
+ d->axesOrientationMode = axesOrientationMode;
+ emit axesOrientationModeChanged(axesOrientationMode);
+ }
+}
+
+/*!
+ \property QSensor::currentOrientation
+ \since 5.1
+ \brief The current orientation that is used for rotating the reading values.
+
+ This might not be the same as the screen orientation. For example, in the FixedOrientation mode,
+ the reading values are not rotated, and therefore the property is 0.
+
+ In the UserOrientation mode, the readings are rotated based on the userOrientation property,
+ and therefore this property is equal to the userOrientation property.
+
+ In the AutomaticOrientation mode, the readings are rotated based on the screen orientation,
+ and therefore this property will be equal to the current screen orientation.
+
+ This property is set by the backend and only valid for orientable sensors.
+*/
+
+int QSensor::currentOrientation() const
+{
+ Q_D(const QSensor);
+ return d->currentOrientation;
+}
+
+/*!
+ \since 5.1
+ Sets the current screen orientation to \a currentOrientation. This is to be called from the
+ backend whenever the screen orientation or the userOrientation property changes.
+*/
+void QSensor::setCurrentOrientation(int currentOrientation)
+{
+ Q_D(QSensor);
+ if (d->currentOrientation != currentOrientation) {
+ d->currentOrientation = currentOrientation;
+ emit currentOrientationChanged(currentOrientation);
+ }
+}
+
+/*!
+ \property QSensor::userOrientation
+ \since 5.1
+ \brief The angle used for rotating the reading values in the UserOrientation mode.
+
+ When the axesOrientationMode property is set to UserOrientation, the angle for rotating the
+ reading values is taken from this property. In other modes, the property has no effect.
+
+ The default is 0. The only valid values are 0, 90, 180 and 270, as those are the only possible
+ screen orientations.
+
+ This property is only valid for orientable sensors.
+*/
+
+int QSensor::userOrientation() const
+{
+ Q_D(const QSensor);
+ return d->userOrientation;
+}
+
+void QSensor::setUserOrientation(int userOrientation)
+{
+ Q_D(QSensor);
+ if (d->userOrientation != userOrientation) {
+ d->userOrientation = userOrientation;
+ emit userOrientationChanged(userOrientation);
+ }
+}
+
+/*!
\fn QSensor::sensorError(int error)
This signal is emitted when an \a error code is set on the sensor.
@@ -785,11 +1016,33 @@ int QSensor::error() const
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.
+ Note that this may be 1, in which case the sensor does not support any form of buffering.
+ In that case, isFeatureSupported(QSensor::Buffering) will also return false.
\sa QSensor::bufferSize, QSensor::efficientBufferSize
*/
+int QSensor::maxBufferSize() const
+{
+ Q_D(const QSensor);
+ return d->maxBufferSize;
+}
+
+/*!
+ \since 5.1
+ Sets the maximum buffer size to \a maxBufferSize. This is to be called from the
+ backend.
+*/
+void QSensor::setMaxBufferSize(int maxBufferSize)
+{
+ // ### Qt 6: Remove the entire maxBufferSize property, no backend really uses it
+ Q_D(QSensor);
+ if (d->maxBufferSize != maxBufferSize) {
+ d->maxBufferSize = maxBufferSize;
+ emit maxBufferSizeChanged(maxBufferSize);
+ }
+}
+
/*!
\property QSensor::efficientBufferSize
@@ -797,17 +1050,36 @@ int QSensor::error() const
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
*/
+int QSensor::efficientBufferSize() const
+{
+ Q_D(const QSensor);
+ return d->efficientBufferSize;
+}
+
+/*!
+ \since 5.1
+ Sets the efficient buffer size to \a efficientBufferSize. This is to be called from the
+ backend.
+*/
+void QSensor::setEfficientBufferSize(int efficientBufferSize)
+{
+ // ### Qt 6: Remove the entire efficientBufferSize property, no backend really uses it
+ Q_D(QSensor);
+ if (d->efficientBufferSize != efficientBufferSize) {
+ d->efficientBufferSize = efficientBufferSize;
+ emit efficientBufferSizeChanged(efficientBufferSize);
+ }
+}
+
/*!
\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
+ This property holds the size of the buffer. By default, the buffer size is 1,
+ which means no buffering.
+ If the maximum buffer size is 1, then buffering is not supported
by the sensor.
Setting bufferSize greater than maxBufferSize will cause maxBufferSize to be used.
@@ -834,11 +1106,26 @@ int QSensor::error() const
in time, for example when the event loop is blocked for too long. Without a buffer, these readings
would simply be dropped.
- The buffer size can only be changed while the sensor is not active.
-
\sa QSensor::maxBufferSize, QSensor::efficientBufferSize
*/
+int QSensor::bufferSize() const
+{
+ Q_D(const QSensor);
+ return d->bufferSize;
+}
+
+void QSensor::setBufferSize(int bufferSize)
+{
+ // ### Qt 6: Currently only the Blackberry backend supports this, but only as an on/off switch.
+ // We should consider changing this to a more appropriate API.
+ Q_D(QSensor);
+ if (d->bufferSize != bufferSize) {
+ d->bufferSize = bufferSize;
+ emit bufferSizeChanged(bufferSize);
+ }
+}
+
// =====================================================================
/*!
diff --git a/src/sensors/qsensor.h b/src/sensors/qsensor.h
index 46d011d3..2314fb94 100644
--- a/src/sensors/qsensor.h
+++ b/src/sensors/qsensor.h
@@ -50,11 +50,8 @@
#include <QtCore/QVariant>
#include <QtCore/QPair>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorPrivate;
class QSensorBackend;
class QSensorReading;
@@ -80,6 +77,7 @@ class Q_SENSORS_EXPORT QSensor : public QObject
Q_OBJECT
Q_ENUMS(Feature)
+ Q_ENUMS(AxesOrientationMode)
Q_PROPERTY(QByteArray identifier READ identifier WRITE setIdentifier)
Q_PROPERTY(QByteArray type READ type)
Q_PROPERTY(bool connectedToBackend READ isConnectedToBackend)
@@ -93,20 +91,32 @@ class Q_SENSORS_EXPORT QSensor : public QObject
Q_PROPERTY(QString description READ description)
Q_PROPERTY(int error READ error NOTIFY sensorError)
Q_PROPERTY(bool alwaysOn READ isAlwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged REVISION 1)
-#ifdef Q_QDOC
- Q_PROPERTY(int maxBufferSize)
- Q_PROPERTY(int efficientBufferSize)
- Q_PROPERTY(int bufferSize)
-#endif
+ Q_PROPERTY(bool skipDuplicates READ skipDuplicates WRITE setSkipDuplicates NOTIFY skipDuplicatesChanged)
+ Q_PROPERTY(AxesOrientationMode axesOrientationMode READ axesOrientationMode WRITE setAxesOrientationMode NOTIFY axesOrientationModeChanged)
+ Q_PROPERTY(int currentOrientation READ currentOrientation NOTIFY currentOrientationChanged)
+ Q_PROPERTY(int userOrientation READ userOrientation WRITE setUserOrientation NOTIFY userOrientationChanged)
+ Q_PROPERTY(int maxBufferSize READ maxBufferSize NOTIFY maxBufferSizeChanged)
+ Q_PROPERTY(int efficientBufferSize READ efficientBufferSize NOTIFY efficientBufferSizeChanged)
+ Q_PROPERTY(int bufferSize READ bufferSize WRITE setBufferSize NOTIFY bufferSizeChanged)
public:
enum Feature {
Buffering,
AlwaysOn,
GeoValues,
FieldOfView,
+ AccelerationMode,
+ SkipDuplicates,
+ AxesOrientation,
Reserved = 257 // Make sure at least 2 bytes are used for the enum to avoid breaking BC later
};
+ // Keep in sync with QmlSensor::AxesOrientationMode
+ enum AxesOrientationMode {
+ FixedOrientation,
+ AutomaticOrientation,
+ UserOrientation
+ };
+
explicit QSensor(const QByteArray &type, QObject *parent = 0);
virtual ~QSensor();
@@ -126,6 +136,9 @@ public:
bool isAlwaysOn() const;
void setAlwaysOn(bool alwaysOn);
+ bool skipDuplicates() const;
+ void setSkipDuplicates(bool skipDuplicates);
+
qrangelist availableDataRates() const;
int dataRate() const;
void setDataRate(int rate);
@@ -153,6 +166,24 @@ public:
Q_INVOKABLE bool isFeatureSupported(Feature feature) const;
+ AxesOrientationMode axesOrientationMode() const;
+ void setAxesOrientationMode(AxesOrientationMode axesOrientationMode);
+
+ int currentOrientation() const;
+ void setCurrentOrientation(int currentOrientation);
+
+ int userOrientation() const;
+ void setUserOrientation(int userOrientation);
+
+ int maxBufferSize() const;
+ void setMaxBufferSize(int maxBufferSize);
+
+ int efficientBufferSize() const;
+ void setEfficientBufferSize(int efficientBufferSize);
+
+ int bufferSize() const;
+ void setBufferSize(int bufferSize);
+
public Q_SLOTS:
// Start receiving values from the sensor
bool start();
@@ -168,6 +199,13 @@ Q_SIGNALS:
void availableSensorsChanged();
void alwaysOnChanged();
void dataRateChanged();
+ void skipDuplicatesChanged(bool skipDuplicates);
+ void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode);
+ void currentOrientationChanged(int currentOrientation);
+ void userOrientationChanged(int userOrientation);
+ void maxBufferSizeChanged(int maxBufferSize);
+ void efficientBufferSizeChanged(int efficientBufferSize);
+ void bufferSizeChanged(int bufferSize);
protected:
explicit QSensor(const QByteArray &type, QSensorPrivate &dd, QObject* parent = 0);
@@ -253,7 +291,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
Q_DECLARE_METATYPE(qrange)
Q_DECLARE_METATYPE(qrangelist)
diff --git a/src/sensors/qsensor_p.h b/src/sensors/qsensor_p.h
index 80312b65..71a5b6eb 100644
--- a/src/sensors/qsensor_p.h
+++ b/src/sensors/qsensor_p.h
@@ -57,7 +57,6 @@
#include "private/qobject_p.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
typedef QList<QSensorFilter*> QFilterList;
@@ -79,6 +78,13 @@ public:
, cache_reading(0)
, error(0)
, alwaysOn(false)
+ , skipDuplicates(false)
+ , axesOrientationMode(QSensor::FixedOrientation)
+ , currentOrientation(0)
+ , userOrientation(0)
+ , bufferSize(1)
+ , maxBufferSize(1)
+ , efficientBufferSize(1)
{
}
@@ -108,6 +114,15 @@ public:
int error;
bool alwaysOn;
+ bool skipDuplicates;
+
+ QSensor::AxesOrientationMode axesOrientationMode;
+ int currentOrientation;
+ int userOrientation;
+
+ int bufferSize;
+ int maxBufferSize;
+ int efficientBufferSize;
};
class QSensorReadingPrivate
@@ -123,7 +138,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensorbackend.h b/src/sensors/qsensorbackend.h
index 92dc9e91..4c6ce8b5 100644
--- a/src/sensors/qsensorbackend.h
+++ b/src/sensors/qsensorbackend.h
@@ -45,11 +45,8 @@
#include <QtSensors/qsensor.h>
#include <QtSensors/qsensormanager.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class Q_SENSORS_EXPORT QSensorBackend : public QObject
{
Q_OBJECT
@@ -94,7 +91,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensormanager.h b/src/sensors/qsensormanager.h
index c2037f75..8fa87d1f 100644
--- a/src/sensors/qsensormanager.h
+++ b/src/sensors/qsensormanager.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorBackend;
class QSensorBackendFactory;
class QSensorPluginInterface;
@@ -77,7 +74,6 @@ protected:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensorplugin.h b/src/sensors/qsensorplugin.h
index 5caef6f1..336bce6b 100644
--- a/src/sensors/qsensorplugin.h
+++ b/src/sensors/qsensorplugin.h
@@ -46,11 +46,8 @@
#include <QtCore/qplugin.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class Q_SENSORS_EXPORT QSensorPluginInterface
{
public:
@@ -71,7 +68,6 @@ Q_DECLARE_INTERFACE(QSensorPluginInterface, "com.qt-project.Qt.QSensorPluginInte
Q_DECLARE_INTERFACE(QSensorChangesInterface, "com.qt-project.Qt.QSensorChangesInterface/5.0")
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensorsglobal.h b/src/sensors/qsensorsglobal.h
index bdd016ff..496ff4ac 100644
--- a/src/sensors/qsensorsglobal.h
+++ b/src/sensors/qsensorsglobal.h
@@ -44,11 +44,8 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
#ifndef QT_STATIC
# if defined(QT_BUILD_SENSORS_LIB)
# define Q_SENSORS_EXPORT Q_DECL_EXPORT
@@ -60,7 +57,6 @@ QT_MODULE(QtSensors)
#endif
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORSGLOBAL_H
diff --git a/src/sensors/qtapsensor.cpp b/src/sensors/qtapsensor.cpp
index bd65196b..23ec492f 100644
--- a/src/sensors/qtapsensor.cpp
+++ b/src/sensors/qtapsensor.cpp
@@ -211,7 +211,7 @@ char const * const QTapSensor::type("QTapSensor");
Construct the sensor as a child of \a parent.
*/
QTapSensor::QTapSensor(QObject *parent)
- : QSensor(QTapSensor::type, parent)
+ : QSensor(QTapSensor::type, *new QTapSensorPrivate, parent)
{
}
@@ -240,10 +240,24 @@ QTapSensor::~QTapSensor()
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().
*/
+bool QTapSensor::returnDoubleTapEvents() const
+{
+ Q_D(const QTapSensor);
+ return d->returnDoubleTapEvents;
+}
+
+void QTapSensor::setReturnDoubleTapEvents(bool returnDoubleTapEvents)
+{
+ Q_D(QTapSensor);
+ if (d->returnDoubleTapEvents != returnDoubleTapEvents) {
+ d->returnDoubleTapEvents = returnDoubleTapEvents;
+ emit returnDoubleTapEventsChanged(returnDoubleTapEvents);
+ }
+}
+
#include "moc_qtapsensor.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qtapsensor.h b/src/sensors/qtapsensor.h
index da71e965..74ca40c2 100644
--- a/src/sensors/qtapsensor.h
+++ b/src/sensors/qtapsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QTapReadingPrivate;
class Q_SENSORS_EXPORT QTapReading : public QSensorReading
@@ -90,24 +87,31 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QTapReading*>(reading)); }
};
+class QTapSensorPrivate;
+
class Q_SENSORS_EXPORT QTapSensor : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(bool returnDoubleTapEvents)
-#endif
+ Q_PROPERTY(bool returnDoubleTapEvents READ returnDoubleTapEvents WRITE setReturnDoubleTapEvents
+ NOTIFY returnDoubleTapEventsChanged)
public:
explicit QTapSensor(QObject *parent = 0);
virtual ~QTapSensor();
QTapReading *reading() const { return static_cast<QTapReading*>(QSensor::reading()); }
static char const * const type;
+ bool returnDoubleTapEvents() const;
+ void setReturnDoubleTapEvents(bool returnDoubleTapEvents);
+
+Q_SIGNALS:
+ void returnDoubleTapEventsChanged(bool returnDoubleTapEvents);
+
private:
+ Q_DECLARE_PRIVATE(QTapSensor);
Q_DISABLE_COPY(QTapSensor)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qtapsensor_p.h b/src/sensors/qtapsensor_p.h
index 68270e87..6bf81473 100644
--- a/src/sensors/qtapsensor_p.h
+++ b/src/sensors/qtapsensor_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
class QTapReadingPrivate
@@ -69,8 +70,18 @@ public:
bool doubleTap;
};
+class QTapSensorPrivate : public QSensorPrivate
+{
+public:
+ QTapSensorPrivate()
+ : returnDoubleTapEvents(true)
+ {
+ }
+
+ bool returnDoubleTapEvents;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qtiltsensor.h b/src/sensors/qtiltsensor.h
index 68dcdfea..246a103e 100644
--- a/src/sensors/qtiltsensor.h
+++ b/src/sensors/qtiltsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QTiltReadingPrivate;
class Q_SENSORS_EXPORT QTiltReading : public QSensorReading
@@ -91,5 +88,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qtiltsensor_p.h b/src/sensors/qtiltsensor_p.h
index 14946243..e8cce136 100644
--- a/src/sensors/qtiltsensor_p.h
+++ b/src/sensors/qtiltsensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QTiltReadingPrivate
@@ -70,5 +69,4 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/sensorlog_p.h b/src/sensors/sensorlog_p.h
index d1cde707..f808ab2d 100644
--- a/src/sensors/sensorlog_p.h
+++ b/src/sensors/sensorlog_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#ifdef ENABLE_RUNTIME_SENSORLOG
@@ -83,7 +82,6 @@ static bool logEnabled()
#endif
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/sensors.pro b/src/sensors/sensors.pro
index 2cb33468..b70c17c6 100644
--- a/src/sensors/sensors.pro
+++ b/src/sensors/sensors.pro
@@ -51,8 +51,11 @@ simulator {
SENSORS=\
qsensor\
qaccelerometer\
+ qaltimeter\
qambientlightsensor\
+ qambienttemperaturesensor\
qcompass\
+ qholstersensor\
qlightsensor\
qmagnetometer\
qorientationsensor\
@@ -62,6 +65,7 @@ SENSORS=\
qtapsensor\
qtiltsensor\
qgyroscope\
+ qpressuresensor\
for(s,SENSORS) {
# Client API
diff --git a/sync.profile b/sync.profile
index 913c0e90..9e398bde 100644
--- a/sync.profile
+++ b/sync.profile
@@ -4,7 +4,7 @@
%moduleheaders = ( # restrict the module headers to those found in relative path
);
%dependencies = (
- "qtbase" => "refs/heads/stable",
- "qtdeclarative" => "refs/heads/stable",
- "qtjsbackend" => "refs/heads/stable",
+ "qtbase" => "refs/heads/dev",
+ "qtdeclarative" => "refs/heads/dev",
+ "qtjsbackend" => "refs/heads/dev",
);
diff --git a/tests/auto/qsensor/test_backends.h b/tests/auto/qsensor/test_backends.h
index a36a8586..b76d4128 100644
--- a/tests/auto/qsensor/test_backends.h
+++ b/tests/auto/qsensor/test_backends.h
@@ -48,12 +48,16 @@ void register_test_backends();
void unregister_test_backends();
#include <qaccelerometer.h>
+#include <qaltimeter.h>
#include <qambientlightsensor.h>
+#include <qambienttemperaturesensor.h>
#include <qcompass.h>
#include <qgyroscope.h>
+#include <qholstersensor.h>
#include <qlightsensor.h>
#include <qmagnetometer.h>
#include <qorientationsensor.h>
+#include <qpressuresensor.h>
#include <qproximitysensor.h>
#include <qrotationsensor.h>
#include <qtapsensor.h>
@@ -96,9 +100,15 @@ PREPARE_SENSORINTERFACE(QAccelerometer, QAccelerometerReading, QAccelerometerFil
reading->setY(1.0);
reading->setZ(1.0);
})
+PREPARE_SENSORINTERFACE(QAltimeter, QAltimeterReading, QAltimeterFilter, {
+ reading->setAltitude(8848);
+})
PREPARE_SENSORINTERFACE(QAmbientLightSensor, QAmbientLightReading, QAmbientLightFilter, {
reading->setLightLevel(QAmbientLightReading::Twilight);
})
+PREPARE_SENSORINTERFACE(QAmbientTemperatureSensor, QAmbientTemperatureReading, QAmbientTemperatureFilter, {
+ reading->setTemperature(30);
+})
PREPARE_SENSORINTERFACE(QCompass, QCompassReading, QCompassFilter, {
reading->setAzimuth(1.0);
reading->setCalibrationLevel(1.0);
@@ -108,6 +118,9 @@ PREPARE_SENSORINTERFACE(QGyroscope, QGyroscopeReading, QGyroscopeFilter, {
reading->setY(1.0);
reading->setZ(1.0);
})
+PREPARE_SENSORINTERFACE(QHolsterSensor, QHolsterReading, QHolsterFilter, {
+ reading->setHolstered(true);
+})
PREPARE_SENSORINTERFACE(QLightSensor, QLightReading, QLightFilter, {
reading->setLux(1.0);
})
@@ -120,6 +133,9 @@ PREPARE_SENSORINTERFACE(QMagnetometer, QMagnetometerReading, QMagnetometerFilter
PREPARE_SENSORINTERFACE(QOrientationSensor, QOrientationReading, QOrientationFilter, {
reading->setOrientation(QOrientationReading::LeftUp);
})
+PREPARE_SENSORINTERFACE(QPressureSensor, QPressureReading, QPressureFilter, {
+ reading->setPressure(1.0);
+})
PREPARE_SENSORINTERFACE(QProximitySensor, QProximityReading, QProximityFilter, {
reading->setClose(true);
})
diff --git a/tests/auto/qsensor/tst_qsensor.cpp b/tests/auto/qsensor/tst_qsensor.cpp
index a4591aa4..a410f711 100644
--- a/tests/auto/qsensor/tst_qsensor.cpp
+++ b/tests/auto/qsensor/tst_qsensor.cpp
@@ -847,10 +847,18 @@ private slots:
QCOMPARE(reading->z(), 1.0);
})
+ TEST_SENSORINTERFACE(QAltimeter, QAltimeterReading, {
+ QCOMPARE(reading->altitude(), 8848.0);
+ })
+
TEST_SENSORINTERFACE(QAmbientLightSensor, QAmbientLightReading, {
QCOMPARE(reading->lightLevel(), QAmbientLightReading::Twilight);
})
+ TEST_SENSORINTERFACE(QAmbientTemperatureSensor, QAmbientTemperatureReading, {
+ QCOMPARE(reading->temperature(), 30.0);
+ })
+
TEST_SENSORINTERFACE(QCompass, QCompassReading, {
QCOMPARE(reading->azimuth(), 1.0);
QCOMPARE(reading->calibrationLevel(), 1.0);
@@ -862,6 +870,10 @@ private slots:
QCOMPARE(reading->z(), 1.0);
})
+ TEST_SENSORINTERFACE(QHolsterSensor, QHolsterReading, {
+ QCOMPARE(reading->holstered(), true);
+ })
+
TEST_SENSORINTERFACE(QLightSensor, QLightReading, {
QCOMPARE(reading->lux(), 1.0);
})
@@ -877,6 +889,10 @@ private slots:
QCOMPARE(reading->orientation(), QOrientationReading::LeftUp);
})
+ TEST_SENSORINTERFACE(QPressureSensor, QPressureReading, {
+ QCOMPARE(reading->pressure(), 1.0);
+ })
+
TEST_SENSORINTERFACE(QProximitySensor, QProximityReading, {
QCOMPARE(reading->close(), true);
})
@@ -959,6 +975,7 @@ private slots:
QVERIFY(!sensor.isFeatureSupported(QSensor::Buffering));
QVERIFY(!sensor.isFeatureSupported(QSensor::GeoValues));
QVERIFY(!sensor.isFeatureSupported(QSensor::FieldOfView));
+ QVERIFY(!sensor.isFeatureSupported(QSensor::AccelerationMode));
// Connect to backend - according to the testsensorimpl implementation, AlwaysOn and
// GeoValues should be supported afterwards
@@ -968,6 +985,7 @@ private slots:
QVERIFY(!sensor.isFeatureSupported(QSensor::Buffering));
QVERIFY(sensor.isFeatureSupported(QSensor::GeoValues));
QVERIFY(!sensor.isFeatureSupported(QSensor::FieldOfView));
+ QVERIFY(!sensor.isFeatureSupported(QSensor::AccelerationMode));
}
};