summaryrefslogtreecommitdiffstats
path: root/src/imports/sensors
diff options
context:
space:
mode:
authorLincoln Ramsay <lincoln.ramsay@nokia.com>2012-06-19 11:45:09 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-26 00:29:37 +0200
commitf9d52ca1c093d8997d44cd8356b43b2665fdbf20 (patch)
tree45fd29bd91c67794bf3e1aefbf232bbd1d2f7b8f /src/imports/sensors
parent1d253860f9863fd015115d728c3f1bd04c5119c6 (diff)
QtMobility.sensors has a new implementation
This implementation fixes the limitations the original code had and separates the QtSensors C++ API from the QML API so that changes to one don't need to affect the other. Change-Id: I519463f3c7cfbad3bce5c291ce166b8793d5ed4a Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/imports/sensors')
-rw-r--r--src/imports/sensors/plugins.qmltypes386
-rw-r--r--src/imports/sensors/qmlaccelerometer.cpp169
-rw-r--r--src/imports/sensors/qmlaccelerometer.h96
-rw-r--r--src/imports/sensors/qmlambientlightsensor.cpp143
-rw-r--r--src/imports/sensors/qmlambientlightsensor.h90
-rw-r--r--src/imports/sensors/qmlcompass.cpp150
-rw-r--r--src/imports/sensors/qmlcompass.h92
-rw-r--r--src/imports/sensors/qmlgyroscope.cpp166
-rw-r--r--src/imports/sensors/qmlgyroscope.h96
-rw-r--r--src/imports/sensors/qmlirproximitysensor.cpp131
-rw-r--r--src/imports/sensors/qmlirproximitysensor.h88
-rw-r--r--src/imports/sensors/qmllightsensor.cpp151
-rw-r--r--src/imports/sensors/qmllightsensor.h95
-rw-r--r--src/imports/sensors/qmlmagnetometer.cpp204
-rw-r--r--src/imports/sensors/qmlmagnetometer.h103
-rw-r--r--src/imports/sensors/qmlorientationsensor.cpp143
-rw-r--r--src/imports/sensors/qmlorientationsensor.h90
-rw-r--r--src/imports/sensors/qmlproximitysensor.cpp133
-rw-r--r--src/imports/sensors/qmlproximitysensor.h88
-rw-r--r--src/imports/sensors/qmlrotationsensor.cpp185
-rw-r--r--src/imports/sensors/qmlrotationsensor.h100
-rw-r--r--src/imports/sensors/qmlsensor.cpp426
-rw-r--r--src/imports/sensors/qmlsensor.h164
-rw-r--r--src/imports/sensors/qmlsensorglobal.cpp119
-rw-r--r--src/imports/sensors/qmlsensorglobal.h74
-rw-r--r--src/imports/sensors/qmlsensorrange.cpp90
-rw-r--r--src/imports/sensors/qmlsensorrange.h98
-rw-r--r--src/imports/sensors/qmltapsensor.cpp181
-rw-r--r--src/imports/sensors/qmltapsensor.h101
-rw-r--r--src/imports/sensors/sensors.cpp787
-rw-r--r--src/imports/sensors/sensors.pro31
31 files changed, 4141 insertions, 829 deletions
diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes
index c708a13e..49c2e748 100644
--- a/src/imports/sensors/plugins.qmltypes
+++ b/src/imports/sensors/plugins.qmltypes
@@ -9,20 +9,12 @@ Module {
Component {
name: "QAccelerometer"
prototype: "QSensor"
- exports: [
- "Accelerometer 1.1",
- "Accelerometer 1.2",
- "Accelerometer 1.3"
- ]
+ exports: ["Accelerometer 1.1", "Accelerometer 1.2"]
}
Component {
name: "QAccelerometerReading"
prototype: "QSensorReading"
- exports: [
- "AccelerometerReading 1.1",
- "AccelerometerReading 1.2",
- "AccelerometerReading 1.3"
- ]
+ exports: ["AccelerometerReading 1.1", "AccelerometerReading 1.2"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
@@ -30,11 +22,7 @@ Module {
Component {
name: "QAmbientLightReading"
prototype: "QSensorReading"
- exports: [
- "AmbientLightReading 1.1",
- "AmbientLightReading 1.2",
- "AmbientLightReading 1.3"
- ]
+ exports: ["AmbientLightReading 1.1", "AmbientLightReading 1.2"]
Enum {
name: "LightLevel"
values: {
@@ -51,76 +39,53 @@ Module {
Component {
name: "QAmbientLightSensor"
prototype: "QSensor"
- exports: [
- "AmbientLightSensor 1.1",
- "AmbientLightSensor 1.2",
- "AmbientLightSensor 1.3"
- ]
+ exports: ["AmbientLightSensor 1.1", "AmbientLightSensor 1.2"]
}
Component {
name: "QCompass"
prototype: "QSensor"
- exports: ["Compass 1.1", "Compass 1.2", "Compass 1.3"]
+ exports: ["Compass 1.1", "Compass 1.2"]
}
Component {
name: "QCompassReading"
prototype: "QSensorReading"
- exports: [
- "CompassReading 1.1",
- "CompassReading 1.2",
- "CompassReading 1.3"
- ]
+ exports: ["CompassReading 1.1", "CompassReading 1.2"]
Property { name: "azimuth"; type: "double"; isReadonly: true }
Property { name: "calibrationLevel"; type: "double"; isReadonly: true }
}
Component {
name: "QGyroscope"
prototype: "QSensor"
- exports: ["Gyroscope 1.2", "Gyroscope 1.3"]
+ exports: ["Gyroscope 1.2"]
}
Component {
name: "QGyroscopeReading"
prototype: "QSensorReading"
- exports: ["GyroscopeReading 1.2", "GyroscopeReading 1.3"]
+ exports: ["GyroscopeReading 1.2"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
}
Component {
- name: "QIRProximityReading"
- prototype: "QSensorReading"
- exports: ["IRProximityReading 1.3"]
- Property { name: "reflectance"; type: "double"; isReadonly: true }
- }
- Component {
- name: "QIRProximitySensor"
- prototype: "QSensor"
- exports: ["IRProximitySensor 1.3"]
- }
- Component {
name: "QLightReading"
prototype: "QSensorReading"
- exports: ["LightReading 1.2", "LightReading 1.3"]
+ exports: ["LightReading 1.2"]
Property { name: "lux"; type: "double"; isReadonly: true }
}
Component {
name: "QLightSensor"
prototype: "QSensor"
- exports: ["LightSensor 1.2", "LightSensor 1.3"]
+ exports: ["LightSensor 1.2"]
}
Component {
name: "QMagnetometer"
prototype: "QSensor"
- exports: ["Magnetometer 1.1", "Magnetometer 1.2", "Magnetometer 1.3"]
+ exports: ["Magnetometer 1.1", "Magnetometer 1.2"]
}
Component {
name: "QMagnetometerReading"
prototype: "QSensorReading"
- exports: [
- "MagnetometerReading 1.1",
- "MagnetometerReading 1.2",
- "MagnetometerReading 1.3"
- ]
+ exports: ["MagnetometerReading 1.1", "MagnetometerReading 1.2"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
@@ -129,11 +94,7 @@ Module {
Component {
name: "QOrientationReading"
prototype: "QSensorReading"
- exports: [
- "OrientationReading 1.1",
- "OrientationReading 1.2",
- "OrientationReading 1.3"
- ]
+ exports: ["OrientationReading 1.1", "OrientationReading 1.2"]
Enum {
name: "Orientation"
values: {
@@ -151,39 +112,23 @@ Module {
Component {
name: "QOrientationSensor"
prototype: "QSensor"
- exports: [
- "OrientationSensor 1.1",
- "OrientationSensor 1.2",
- "OrientationSensor 1.3"
- ]
+ exports: ["OrientationSensor 1.1", "OrientationSensor 1.2"]
}
Component {
name: "QProximityReading"
prototype: "QSensorReading"
- exports: [
- "ProximityReading 1.1",
- "ProximityReading 1.2",
- "ProximityReading 1.3"
- ]
+ exports: ["ProximityReading 1.1", "ProximityReading 1.2"]
Property { name: "close"; type: "bool"; isReadonly: true }
}
Component {
name: "QProximitySensor"
prototype: "QSensor"
- exports: [
- "ProximitySensor 1.1",
- "ProximitySensor 1.2",
- "ProximitySensor 1.3"
- ]
+ exports: ["ProximitySensor 1.1", "ProximitySensor 1.2"]
}
Component {
name: "QRotationReading"
prototype: "QSensorReading"
- exports: [
- "RotationReading 1.1",
- "RotationReading 1.2",
- "RotationReading 1.3"
- ]
+ exports: ["RotationReading 1.1", "RotationReading 1.2"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
@@ -191,17 +136,12 @@ Module {
Component {
name: "QRotationSensor"
prototype: "QSensor"
- exports: [
- "RotationSensor 1.1",
- "RotationSensor 1.2",
- "RotationSensor 1.3"
- ]
+ exports: ["RotationSensor 1.1", "RotationSensor 1.2"]
}
Component {
name: "QSensor"
prototype: "QObject"
- exports: ["Sensor 1.2", "Sensor 1.3"]
- exportMetaObjectRevisions: [0, 1]
+ exports: ["Sensor 1.2"]
Enum {
name: "Feature"
values: {
@@ -212,7 +152,7 @@ Module {
"Reserved": 257
}
}
- Property { name: "sensorid"; type: "QByteArray" }
+ Property { name: "identifier"; type: "QByteArray" }
Property { name: "type"; type: "QByteArray"; isReadonly: true }
Property { name: "connectedToBackend"; type: "bool"; isReadonly: true }
Property { name: "availableDataRates"; type: "qrangelist"; isReadonly: true }
@@ -247,17 +187,13 @@ Module {
Component {
name: "QSensorReading"
prototype: "QObject"
- exports: [
- "SensorReading 1.1",
- "SensorReading 1.2",
- "SensorReading 1.3"
- ]
+ exports: ["SensorReading 1.1", "SensorReading 1.2"]
Property { name: "timestamp"; type: "qulonglong"; isReadonly: true }
}
Component {
name: "QTapReading"
prototype: "QSensorReading"
- exports: ["TapReading 1.1", "TapReading 1.2", "TapReading 1.3"]
+ exports: ["TapReading 1.1", "TapReading 1.2"]
Enum {
name: "TapDirection"
values: {
@@ -282,6 +218,282 @@ Module {
Component {
name: "QTapSensor"
prototype: "QSensor"
- exports: ["TapSensor 1.1", "TapSensor 1.2", "TapSensor 1.3"]
+ exports: ["TapSensor 1.1", "TapSensor 1.2"]
+ }
+ Component {
+ name: "QmlAccelerometer"
+ prototype: "QmlSensor"
+ exports: ["Accelerometer 1.3"]
+ }
+ Component {
+ name: "QmlAccelerometerReading"
+ prototype: "QmlSensorReading"
+ exports: ["AccelerometerReading 1.3"]
+ Property { name: "x"; type: "double"; isReadonly: true }
+ Property { name: "y"; type: "double"; isReadonly: true }
+ Property { name: "z"; type: "double"; isReadonly: true }
+ Signal { name: "xChanged"; type: "void" }
+ Signal { name: "yChanged"; type: "void" }
+ Signal { name: "zChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlAmbientLightSensor"
+ prototype: "QmlSensor"
+ exports: ["AmbientLightSensor 1.3"]
+ }
+ Component {
+ name: "QmlAmbientLightSensorReading"
+ prototype: "QmlSensorReading"
+ exports: ["AmbientLightReading 1.3"]
+ Enum {
+ name: "LightLevel"
+ values: {
+ "Undefined": 0,
+ "Dark": 1,
+ "Twilight": 2,
+ "Light": 3,
+ "Bright": 4,
+ "Sunny": 5
+ }
+ }
+ Property { name: "lightLevel"; type: "LightLevel"; isReadonly: true }
+ Signal { name: "lightLevelChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlCompass"
+ prototype: "QmlSensor"
+ exports: ["Compass 1.3"]
+ }
+ Component {
+ name: "QmlCompassReading"
+ prototype: "QmlSensorReading"
+ exports: ["CompassReading 1.3"]
+ Property { name: "azimuth"; type: "double"; isReadonly: true }
+ Property { name: "calibrationLevel"; type: "double"; isReadonly: true }
+ Signal { name: "azimuthChanged"; type: "void" }
+ Signal { name: "calibrationLevelChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlGyroscope"
+ prototype: "QmlSensor"
+ exports: ["Gyroscope 1.3"]
+ }
+ Component {
+ name: "QmlGyroscopeReading"
+ prototype: "QmlSensorReading"
+ exports: ["GyroscopeReading 1.3"]
+ Property { name: "x"; type: "double"; isReadonly: true }
+ Property { name: "y"; type: "double"; isReadonly: true }
+ Property { name: "z"; type: "double"; isReadonly: true }
+ Signal { name: "xChanged"; type: "void" }
+ Signal { name: "yChanged"; type: "void" }
+ Signal { name: "zChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlIRProximitySensor"
+ prototype: "QmlSensor"
+ exports: ["IRProximitySensor 1.3"]
+ }
+ Component {
+ name: "QmlIRProximitySensorReading"
+ prototype: "QmlSensorReading"
+ exports: ["IRProximityReading 1.3"]
+ Property { name: "reflectance"; type: "double"; isReadonly: true }
+ Signal { name: "reflectanceChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlLightSensor"
+ prototype: "QmlSensor"
+ exports: ["LightSensor 1.3"]
+ Property { name: "fieldOfView"; type: "double"; isReadonly: true }
+ Signal { name: "fieldOfViewChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlLightSensorReading"
+ prototype: "QmlSensorReading"
+ exports: ["LightReading 1.3"]
+ Property { name: "lux"; type: "double"; isReadonly: true }
+ Signal { name: "luxChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlMagnetometer"
+ prototype: "QmlSensor"
+ exports: ["Magnetometer 1.3"]
+ Property { name: "returnGeoValues"; type: "bool" }
+ Signal { name: "returnGeoValuesChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlMagnetometerReading"
+ prototype: "QmlSensorReading"
+ exports: ["MagnetometerReading 1.3"]
+ Property { name: "x"; type: "double"; isReadonly: true }
+ Property { name: "y"; type: "double"; isReadonly: true }
+ Property { name: "z"; type: "double"; isReadonly: true }
+ Property { name: "calibrationLevel"; type: "double"; isReadonly: true }
+ Signal { name: "xChanged"; type: "void" }
+ Signal { name: "yChanged"; type: "void" }
+ Signal { name: "zChanged"; type: "void" }
+ Signal { name: "calibrationLevelChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlOrientationSensor"
+ prototype: "QmlSensor"
+ exports: ["OrientationSensor 1.3"]
+ }
+ Component {
+ name: "QmlOrientationSensorReading"
+ prototype: "QmlSensorReading"
+ exports: ["OrientationReading 1.3"]
+ Enum {
+ name: "Orientation"
+ values: {
+ "Undefined": 0,
+ "TopUp": 1,
+ "TopDown": 2,
+ "LeftUp": 3,
+ "RightUp": 4,
+ "FaceUp": 5,
+ "FaceDown": 6
+ }
+ }
+ Property { name: "orientation"; type: "Orientation"; isReadonly: true }
+ Signal { name: "orientationChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlProximitySensor"
+ prototype: "QmlSensor"
+ exports: ["ProximitySensor 1.3"]
+ }
+ Component {
+ name: "QmlProximitySensorReading"
+ prototype: "QmlSensorReading"
+ exports: ["ProximityReading 1.3"]
+ Property { name: "close"; type: "bool"; isReadonly: true }
+ Signal { name: "closeChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlRotationSensor"
+ prototype: "QmlSensor"
+ exports: ["RotationSensor 1.3"]
+ Property { name: "hasZ"; type: "bool"; isReadonly: true }
+ Signal { name: "hasZChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlRotationSensorReading"
+ prototype: "QmlSensorReading"
+ exports: ["RotationReading 1.3"]
+ Property { name: "x"; type: "double"; isReadonly: true }
+ Property { name: "y"; type: "double"; isReadonly: true }
+ Property { name: "z"; type: "double"; isReadonly: true }
+ Signal { name: "xChanged"; type: "void" }
+ Signal { name: "yChanged"; type: "void" }
+ Signal { name: "zChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlSensor"
+ prototype: "QObject"
+ exports: ["Sensor 1.3"]
+ exportMetaObjectRevisions: [1]
+ Property { name: "identifier"; type: "string" }
+ Property { name: "type"; type: "string"; isReadonly: true }
+ Property { name: "connectedToBackend"; type: "bool"; isReadonly: true }
+ Property { name: "availableDataRates"; type: "QmlSensorRange"; isList: true; isReadonly: true }
+ Property { name: "dataRate"; type: "int" }
+ Property { name: "reading"; type: "QmlSensorReading"; isReadonly: true; isPointer: true }
+ Property { name: "busy"; type: "bool"; isReadonly: true }
+ Property { name: "active"; type: "bool" }
+ Property { name: "outputRanges"; type: "QmlSensorOutputRange"; isList: true; isReadonly: true }
+ Property { name: "outputRange"; type: "int" }
+ Property { name: "description"; type: "string"; isReadonly: true }
+ Property { name: "error"; type: "int"; isReadonly: true }
+ Property { name: "alwaysOn"; revision: 1; type: "bool" }
+ Signal { name: "identifierChanged"; type: "void" }
+ Signal { name: "typeChanged"; type: "void" }
+ Signal { name: "connectedToBackendChanged"; type: "void" }
+ Signal { name: "availableDataRatesChanged"; type: "void" }
+ Signal { name: "dataRateChanged"; type: "void" }
+ Signal { name: "readingChanged"; type: "void" }
+ Signal { name: "busyChanged"; type: "void" }
+ Signal { name: "activeChanged"; type: "void" }
+ Signal { name: "outputRangesChanged"; type: "void" }
+ Signal { name: "outputRangeChanged"; type: "void" }
+ Signal { name: "descriptionChanged"; type: "void" }
+ Signal { name: "errorChanged"; type: "void" }
+ Signal { name: "alwaysOnChanged"; type: "void" }
+ Method { name: "start"; type: "bool" }
+ Method { name: "stop"; type: "void" }
+ }
+ Component {
+ name: "QmlSensorGlobal"
+ prototype: "QObject"
+ Signal { name: "availableSensorsChanged"; type: "void" }
+ Method { name: "sensorTypes"; type: "QStringList" }
+ Method {
+ name: "sensorsForType"
+ type: "QStringList"
+ Parameter { name: "type"; type: "string" }
+ }
+ Method {
+ name: "defaultSensorForType"
+ type: "string"
+ Parameter { name: "type"; type: "string" }
+ }
+ }
+ Component {
+ name: "QmlSensorOutputRange"
+ prototype: "QObject"
+ exports: ["OutputRange 1.3"]
+ Property { name: "minimum"; type: "double"; isReadonly: true }
+ Property { name: "maximum"; type: "double"; isReadonly: true }
+ Property { name: "accuracy"; type: "double"; isReadonly: true }
+ }
+ Component {
+ name: "QmlSensorRange"
+ prototype: "QObject"
+ exports: ["Range 1.3"]
+ Property { name: "minimum"; type: "int"; isReadonly: true }
+ Property { name: "maximum"; type: "int"; isReadonly: true }
+ }
+ Component {
+ name: "QmlSensorReading"
+ prototype: "QObject"
+ exports: ["SensorReading 1.3"]
+ Property { name: "timestamp"; type: "qulonglong"; isReadonly: true }
+ Signal { name: "timestampChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlTapSensor"
+ prototype: "QmlSensor"
+ exports: ["TapSensor 1.3"]
+ Property { name: "returnDoubleTapEvents"; type: "bool" }
+ Signal { name: "returnDoubleTapEventsChanged"; type: "void" }
+ }
+ Component {
+ name: "QmlTapSensorReading"
+ prototype: "QmlSensorReading"
+ exports: ["TapReading 1.3"]
+ Enum {
+ name: "TapDirection"
+ values: {
+ "Undefined": 0,
+ "X": 1,
+ "Y": 2,
+ "Z": 4,
+ "X_Pos": 17,
+ "Y_Pos": 34,
+ "Z_Pos": 68,
+ "X_Neg": 257,
+ "Y_Neg": 514,
+ "Z_Neg": 1028,
+ "X_Both": 273,
+ "Y_Both": 546,
+ "Z_Both": 1092
+ }
+ }
+ Property { name: "tapDirection"; type: "TapDirection"; isReadonly: true }
+ Property { name: "doubleTap"; type: "bool"; isReadonly: true }
+ Signal { name: "tapDirectionChanged"; type: "void" }
+ Signal { name: "isDoubleTapChanged"; type: "void" }
}
+ ModuleApi { version: 1.3; name: "QmlSensorGlobal" }
}
diff --git a/src/imports/sensors/qmlaccelerometer.cpp b/src/imports/sensors/qmlaccelerometer.cpp
new file mode 100644
index 00000000..8b6caacb
--- /dev/null
+++ b/src/imports/sensors/qmlaccelerometer.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlaccelerometer.h"
+#include <QAccelerometer>
+
+/*!
+ \qmltype Accelerometer
+ \instantiates QmlAccelerometer
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::Sensor
+ \brief The Accelerometer element reports on linear acceleration
+ along the X, Y and Z axes.
+
+ The Accelerometer element reports on linear acceleration
+ along the X, Y and Z axes.
+
+ This element wraps the QAccelerometer class. Please see the documentation for
+ QAccelerometer for details.
+
+ \sa AccelerometerReading
+*/
+
+QmlAccelerometer::QmlAccelerometer(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QAccelerometer(this))
+{
+}
+
+QmlAccelerometer::~QmlAccelerometer()
+{
+}
+
+QmlSensorReading *QmlAccelerometer::createReading() const
+{
+ return new QmlAccelerometerReading(m_sensor);
+}
+
+QSensor *QmlAccelerometer::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype AccelerometerReading
+ \instantiates QmlAccelerometerReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The AccelerometerReading element holds the most recent Accelerometer reading.
+
+ The AccelerometerReading element holds the most recent Accelerometer reading.
+
+ This element wraps the QAccelerometerReading class. Please see the documentation for
+ QAccelerometerReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlAccelerometerReading::QmlAccelerometerReading(QAccelerometer *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlAccelerometerReading::~QmlAccelerometerReading()
+{
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::AccelerometerReading::x
+ This property holds the acceleration on the X axis.
+
+ Please see QAccelerometerReading::x for information about this property.
+*/
+
+qreal QmlAccelerometerReading::x() const
+{
+ return m_x;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::AccelerometerReading::y
+ This property holds the acceleration on the Y axis.
+
+ Please see QAccelerometerReading::y for information about this property.
+*/
+
+qreal QmlAccelerometerReading::y() const
+{
+ return m_y;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::AccelerometerReading::z
+ This property holds the acceleration on the Z axis.
+
+ Please see QAccelerometerReading::z for information about this property.
+*/
+
+qreal QmlAccelerometerReading::z() const
+{
+ return m_z;
+}
+
+QSensorReading *QmlAccelerometerReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlAccelerometerReading::readingUpdate()
+{
+ qreal aX = m_sensor->reading()->x();
+ if (m_x != aX) {
+ m_x = aX;
+ Q_EMIT xChanged();
+ }
+ qreal aY = m_sensor->reading()->y();
+ if (m_y != aY) {
+ m_y = aY;
+ Q_EMIT yChanged();
+ }
+ qreal aZ = m_sensor->reading()->z();
+ if (m_z != aZ) {
+ m_z = aZ;
+ Q_EMIT zChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlaccelerometer.h b/src/imports/sensors/qmlaccelerometer.h
new file mode 100644
index 00000000..95785ed4
--- /dev/null
+++ b/src/imports/sensors/qmlaccelerometer.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLACCELEROMETER_H
+#define QMLACCELEROMETER_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QAccelerometer;
+
+class QmlAccelerometer : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlAccelerometer(QObject *parent = 0);
+ ~QmlAccelerometer();
+
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QAccelerometer *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlAccelerometerReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal x READ x NOTIFY xChanged)
+ Q_PROPERTY(qreal y READ y NOTIFY yChanged)
+ Q_PROPERTY(qreal z READ z NOTIFY zChanged)
+public:
+ explicit QmlAccelerometerReading(QAccelerometer *sensor);
+ ~QmlAccelerometerReading();
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+
+Q_SIGNALS:
+ void xChanged();
+ void yChanged();
+ void zChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QAccelerometer *m_sensor;
+ qreal m_x;
+ qreal m_y;
+ qreal m_z;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmlambientlightsensor.cpp b/src/imports/sensors/qmlambientlightsensor.cpp
new file mode 100644
index 00000000..784c8b1e
--- /dev/null
+++ b/src/imports/sensors/qmlambientlightsensor.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlambientlightsensor.h"
+#include <QAmbientLightSensor>
+
+/*!
+ \qmltype AmbientLightSensor
+ \instantiates QmlAmbientLightSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::Sensor
+ \brief The AmbientLightSensor element repors on ambient lighting conditions.
+
+ The AmbientLightSensor element repors on ambient lighting conditions.
+
+ This element wraps the QAmbientLightSensor class. Please see the documentation for
+ QAmbientLightSensor for details.
+
+ \sa AmbientLightReading
+*/
+
+QmlAmbientLightSensor::QmlAmbientLightSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QAmbientLightSensor(this))
+{
+}
+
+QmlAmbientLightSensor::~QmlAmbientLightSensor()
+{
+}
+
+QmlSensorReading *QmlAmbientLightSensor::createReading() const
+{
+ return new QmlAmbientLightSensorReading(m_sensor);
+}
+
+QSensor *QmlAmbientLightSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype AmbientLightReading
+ \instantiates QmlAmbientLightSensorReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The AmbientLightReading element holds the most AmbientLightSensor reading.
+
+ The AmbientLightReading element holds the most AmbientLightSensor reading.
+
+ This element wraps the QAmbientLightReading class. Please see the documentation for
+ QAmbientLightReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlAmbientLightSensorReading::QmlAmbientLightSensorReading(QAmbientLightSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlAmbientLightSensorReading::~QmlAmbientLightSensorReading()
+{
+}
+
+/*!
+ \qmlproperty LightLevel QtMobility.sensors1::AmbientLightReading::lightLevel
+ This property holds the ambient light level.
+
+ Please see QAmbientLightReading::lightLevel for information about this property.
+
+ Note that LightLevel constants are exposed through the AmbientLightReading class.
+ \code
+ AmbientLightSensor {
+ onReadingChanged: {
+ if (reading.lightLevel == AmbientLightReading.Dark)
+ // do something
+ }
+ }
+ \endcode
+*/
+
+QAmbientLightReading::LightLevel QmlAmbientLightSensorReading::lightLevel() const
+{
+ return m_lightLevel;
+}
+
+QSensorReading *QmlAmbientLightSensorReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlAmbientLightSensorReading::readingUpdate()
+{
+ QAmbientLightReading::LightLevel ll = m_sensor->reading()->lightLevel();
+ if (m_lightLevel != ll) {
+ m_lightLevel = ll;
+ Q_EMIT lightLevelChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlambientlightsensor.h b/src/imports/sensors/qmlambientlightsensor.h
new file mode 100644
index 00000000..eecb6b12
--- /dev/null
+++ b/src/imports/sensors/qmlambientlightsensor.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLAMBIENTLIGHTSENSOR_H
+#define QMLAMBIENTLIGHTSENSOR_H
+
+#include "qmlsensor.h"
+#include <QAmbientLightSensor>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QAmbientLightSensor;
+
+class QmlAmbientLightSensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlAmbientLightSensor(QObject *parent = 0);
+ ~QmlAmbientLightSensor();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QAmbientLightSensor *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+};
+
+class QmlAmbientLightSensorReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(QAmbientLightReading::LightLevel lightLevel READ lightLevel NOTIFY lightLevelChanged)
+public:
+
+ explicit QmlAmbientLightSensorReading(QAmbientLightSensor *sensor);
+ ~QmlAmbientLightSensorReading();
+
+ QAmbientLightReading::LightLevel lightLevel() const;
+
+Q_SIGNALS:
+ void lightLevelChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QAmbientLightSensor *m_sensor;
+ QAmbientLightReading::LightLevel m_lightLevel;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmlcompass.cpp b/src/imports/sensors/qmlcompass.cpp
new file mode 100644
index 00000000..886e7c74
--- /dev/null
+++ b/src/imports/sensors/qmlcompass.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlcompass.h"
+#include <QCompass>
+
+/*!
+ \qmltype Compass
+ \instantiates QmlCompass
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::Sensor
+ \brief The Compass element reports on heading using magnetic north as a reference.
+
+ The Compass element reports on heading using magnetic north as a reference.
+
+ This element wraps the QCompass class. Please see the documentation for
+ QCompass for details.
+
+ \sa CompassReading
+*/
+
+QmlCompass::QmlCompass(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QCompass(this))
+{
+}
+
+QmlCompass::~QmlCompass()
+{
+}
+
+QmlSensorReading *QmlCompass::createReading() const
+{
+ return new QmlCompassReading(m_sensor);
+}
+
+QSensor *QmlCompass::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype CompassReading
+ \instantiates QmlCompassReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The CompassReading element holds the most recent Compass reading.
+
+ The CompassReading element holds the most recent Compass reading.
+
+ This element wraps the QCompassReading class. Please see the documentation for
+ QCompassReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlCompassReading::QmlCompassReading(QCompass *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlCompassReading::~QmlCompassReading()
+{
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::CompassReading::azimuth
+ This property holds the azimuth of the device.
+
+ Please see QCompassReading::azimuth for information about this property.
+*/
+
+qreal QmlCompassReading::azimuth() const
+{
+ return m_azimuth;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::CompassReading::calibrationLevel
+ This property holds the calibration level of the reading.
+
+ Please see QCompassReading::calibrationLevel for information about this property.
+*/
+
+qreal QmlCompassReading::calibrationLevel() const
+{
+ return m_calibrationLevel;
+}
+
+QSensorReading *QmlCompassReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlCompassReading::readingUpdate()
+{
+ qreal azm = m_sensor->reading()->azimuth();
+ if (m_azimuth != azm) {
+ m_azimuth = azm;
+ Q_EMIT azimuthChanged();
+ }
+ qreal calLevel = m_sensor->reading()->calibrationLevel();
+ if (m_calibrationLevel != calLevel) {
+ m_calibrationLevel = calLevel;
+ Q_EMIT calibrationLevelChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlcompass.h b/src/imports/sensors/qmlcompass.h
new file mode 100644
index 00000000..30edbf0a
--- /dev/null
+++ b/src/imports/sensors/qmlcompass.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLCOMPASS_H
+#define QMLCOMPASS_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QCompass;
+
+class QmlCompass : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlCompass(QObject *parent = 0);
+ ~QmlCompass();
+
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QCompass *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlCompassReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal azimuth READ azimuth NOTIFY azimuthChanged)
+ Q_PROPERTY(qreal calibrationLevel READ calibrationLevel NOTIFY calibrationLevelChanged)
+public:
+ explicit QmlCompassReading(QCompass *sensor);
+ ~QmlCompassReading();
+
+ qreal azimuth() const;
+ qreal calibrationLevel() const;
+
+Q_SIGNALS:
+ void azimuthChanged();
+ void calibrationLevelChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QCompass *m_sensor;
+ qreal m_azimuth;
+ qreal m_calibrationLevel;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmlgyroscope.cpp b/src/imports/sensors/qmlgyroscope.cpp
new file mode 100644
index 00000000..b52badb3
--- /dev/null
+++ b/src/imports/sensors/qmlgyroscope.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlgyroscope.h"
+#include <QGyroscope>
+
+/*!
+ \qmltype Gyroscope
+ \instantiates QmlGyroscope
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.2
+ \inherits QtMobility.sensors1::Sensor
+ \brief The Gyroscope element reports on rotational acceleration
+ around the X, Y and Z axes.
+
+ This element wraps the QGyroscope class. Please see the documentation for
+ QGyroscope for details.
+
+ \sa GyroscopeReading
+*/
+
+QmlGyroscope::QmlGyroscope(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QGyroscope(this))
+{
+}
+
+QmlGyroscope::~QmlGyroscope()
+{
+}
+
+QmlSensorReading *QmlGyroscope::createReading() const
+{
+ return new QmlGyroscopeReading(m_sensor);
+}
+
+QSensor *QmlGyroscope::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype GyroscopeReading
+ \instantiates QmlGyroscopeReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.2
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The GyroscopeReading element holds the most recent Gyroscope reading.
+
+ The GyroscopeReading element holds the most recent Gyroscope reading.
+
+ This element wraps the QGyroscopeReading class. Please see the documentation for
+ QGyroscopeReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlGyroscopeReading::QmlGyroscopeReading(QGyroscope *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlGyroscopeReading::~QmlGyroscopeReading()
+{
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::GyroscopeReading::x
+ This property holds the angular velocity around the x axis.
+
+ Please see QGyroscopeReading::x for information about this property.
+*/
+
+qreal QmlGyroscopeReading::x() const
+{
+ return m_x;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::GyroscopeReading::y
+ This property holds the angular velocity around the y axis.
+
+ Please see QGyroscopeReading::y for information about this property.
+*/
+
+qreal QmlGyroscopeReading::y() const
+{
+ return m_y;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::GyroscopeReading::z
+ This property holds the angular velocity around the z axis.
+
+ Please see QGyroscopeReading::z for information about this property.
+*/
+
+qreal QmlGyroscopeReading::z() const
+{
+ return m_z;
+}
+
+QSensorReading *QmlGyroscopeReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlGyroscopeReading::readingUpdate()
+{
+ qreal gx = m_sensor->reading()->x();
+ if (m_x != gx) {
+ m_x = gx;
+ Q_EMIT xChanged();
+ }
+ qreal gy = m_sensor->reading()->y();
+ if (m_y != gy) {
+ m_y = gy;
+ Q_EMIT yChanged();
+ }
+ qreal gz = m_sensor->reading()->z();
+ if (m_z != gz) {
+ m_z = gz;
+ Q_EMIT zChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlgyroscope.h b/src/imports/sensors/qmlgyroscope.h
new file mode 100644
index 00000000..c5f6c902
--- /dev/null
+++ b/src/imports/sensors/qmlgyroscope.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLGYROSCOPE_H
+#define QMLGYROSCOPE_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QGyroscope;
+
+class QmlGyroscope : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlGyroscope(QObject *parent = 0);
+ ~QmlGyroscope();
+
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QGyroscope *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlGyroscopeReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal x READ x NOTIFY xChanged)
+ Q_PROPERTY(qreal y READ y NOTIFY yChanged)
+ Q_PROPERTY(qreal z READ z NOTIFY zChanged)
+public:
+ explicit QmlGyroscopeReading(QGyroscope *sensor);
+ ~QmlGyroscopeReading();
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+
+Q_SIGNALS:
+ void xChanged();
+ void yChanged();
+ void zChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QGyroscope *m_sensor;
+ qreal m_x;
+ qreal m_y;
+ qreal m_z;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmlirproximitysensor.cpp b/src/imports/sensors/qmlirproximitysensor.cpp
new file mode 100644
index 00000000..6c86872e
--- /dev/null
+++ b/src/imports/sensors/qmlirproximitysensor.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlirproximitysensor.h"
+#include <QIRProximitySensor>
+
+/*!
+ \qmltype IRProximitySensor
+ \instantiates QmlIRProximitySensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.3
+ \inherits QtMobility.sensors1::Sensor
+ \brief The IRProximitySensor element reports on infra-red reflectance values.
+
+ This element wraps the QIRProximitySensor class. Please see the documentation for
+ QIRProximitySensor for details.
+
+ \sa IRProximityReading
+*/
+
+QmlIRProximitySensor::QmlIRProximitySensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QIRProximitySensor(this))
+{
+}
+
+QmlIRProximitySensor::~QmlIRProximitySensor()
+{
+}
+
+QmlSensorReading *QmlIRProximitySensor::createReading() const
+{
+ return new QmlIRProximitySensorReading(m_sensor);
+}
+
+QSensor *QmlIRProximitySensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype IRProximityReading
+ \instantiates QmlIRProximitySensorReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.3
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The IRProximityReading element holds the most recent IR proximity reading.
+
+ The IRProximityReading element holds the most recent IR proximity reading.
+
+ This element wraps the QIRProximityReading class. Please see the documentation for
+ QIRProximityReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlIRProximitySensorReading::QmlIRProximitySensorReading(QIRProximitySensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlIRProximitySensorReading::~QmlIRProximitySensorReading()
+{
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::IRProximityReading::reflectance
+ This property holds the reflectance value.
+
+ Please see QIRProximityReading::reflectance for information about this property.
+*/
+
+qreal QmlIRProximitySensorReading::reflectance() const
+{
+ return m_reflectance;
+}
+
+QSensorReading *QmlIRProximitySensorReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlIRProximitySensorReading::readingUpdate()
+{
+ qreal fl = m_sensor->reading()->reflectance();
+ if (m_reflectance != fl) {
+ m_reflectance = fl;
+ Q_EMIT reflectanceChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlirproximitysensor.h b/src/imports/sensors/qmlirproximitysensor.h
new file mode 100644
index 00000000..bf188d2a
--- /dev/null
+++ b/src/imports/sensors/qmlirproximitysensor.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLIRPROXIMITYSENSOR_H
+#define QMLIRPROXIMITYSENSOR_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QIRProximitySensor;
+
+class QmlIRProximitySensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlIRProximitySensor(QObject *parent = 0);
+ ~QmlIRProximitySensor();
+
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QIRProximitySensor *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlIRProximitySensorReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal reflectance READ reflectance NOTIFY reflectanceChanged)
+public:
+ explicit QmlIRProximitySensorReading(QIRProximitySensor *sensor);
+ ~QmlIRProximitySensorReading();
+
+ qreal reflectance() const;
+
+Q_SIGNALS:
+ void reflectanceChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QIRProximitySensor *m_sensor;
+ qreal m_reflectance;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmllightsensor.cpp b/src/imports/sensors/qmllightsensor.cpp
new file mode 100644
index 00000000..6992ea58
--- /dev/null
+++ b/src/imports/sensors/qmllightsensor.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmllightsensor.h"
+#include <QLightSensor>
+
+/*!
+ \qmltype LightSensor
+ \instantiates QmlLightSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.2
+ \inherits QtMobility.sensors1::Sensor
+ \brief The LightSensor element reports on light levels using LUX.
+
+ The LightSensor element reports on light levels using LUX.
+
+ This element wraps the QLightSensor class. Please see the documentation for
+ QLightSensor for details.
+
+ \sa LightReading
+*/
+
+QmlLightSensor::QmlLightSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QLightSensor(this))
+{
+}
+
+QmlLightSensor::~QmlLightSensor()
+{
+}
+
+QmlSensorReading *QmlLightSensor::createReading() const
+{
+ return new QmlLightSensorReading(m_sensor);
+}
+
+QSensor *QmlLightSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::LightSensor::fieldOfView
+ This property holds a value indicating the field of view.
+
+ Please see QLightSensor::fieldOfView for information about this property.
+*/
+
+qreal QmlLightSensor::fieldOfView() const
+{
+ return m_sensor->property("fieldOfView").value<qreal>();
+}
+
+void QmlLightSensor::_update()
+{
+ if (fieldOfView() != qreal())
+ Q_EMIT fieldOfViewChanged();
+}
+
+/*!
+ \qmltype LightReading
+ \instantiates QmlLightSensorReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.2
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The LightReading element holds the most recent LightSensor reading.
+
+ The LightReading element holds the most recent LightSensor reading.
+
+ This element wraps the QLightReading class. Please see the documentation for
+ QLightReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlLightSensorReading::QmlLightSensorReading(QLightSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlLightSensorReading::~QmlLightSensorReading()
+{
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::LightReading::illuminance
+ This property holds the light level.
+
+ Please see QLightReading::illuminance for information about this property.
+*/
+
+qreal QmlLightSensorReading::illuminance() const
+{
+ return m_illuminance;
+}
+
+QSensorReading *QmlLightSensorReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlLightSensorReading::readingUpdate()
+{
+ qreal ill = m_sensor->reading()->lux();
+ if (m_illuminance != ill) {
+ m_illuminance = ill;
+ Q_EMIT illuminanceChanged();
+ }
+}
diff --git a/src/imports/sensors/qmllightsensor.h b/src/imports/sensors/qmllightsensor.h
new file mode 100644
index 00000000..90fe0b7f
--- /dev/null
+++ b/src/imports/sensors/qmllightsensor.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLLightSensor_H
+#define QMLLightSensor_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QLightSensor;
+
+class QmlLightSensor : public QmlSensor
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal fieldOfView READ fieldOfView NOTIFY fieldOfViewChanged)
+public:
+ explicit QmlLightSensor(QObject *parent = 0);
+ ~QmlLightSensor();
+
+ qreal fieldOfView() const;
+
+
+Q_SIGNALS:
+ void fieldOfViewChanged();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ void _update();
+ QLightSensor *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlLightSensorReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal illuminance READ illuminance NOTIFY illuminanceChanged)
+public:
+ explicit QmlLightSensorReading(QLightSensor *sensor);
+ ~QmlLightSensorReading();
+
+ qreal illuminance() const;
+
+Q_SIGNALS:
+ void illuminanceChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QLightSensor *m_sensor;
+ qreal m_illuminance;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmlmagnetometer.cpp b/src/imports/sensors/qmlmagnetometer.cpp
new file mode 100644
index 00000000..c266e6ac
--- /dev/null
+++ b/src/imports/sensors/qmlmagnetometer.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlmagnetometer.h"
+#include <QMagnetometer>
+
+/*!
+ \qmltype Magnetometer
+ \instantiates QmlMagnetometer
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::Sensor
+ \brief The Magnetometer element reports on magnetic field strength
+ along the Z, Y and Z axes.
+
+ The Magnetometer element reports on magnetic field strength
+ along the Z, Y and Z axes.
+
+ This element wraps the QMagnetometer class. Please see the documentation for
+ QMagnetometer for details.
+
+ \sa MagnetometerReading
+*/
+
+QmlMagnetometer::QmlMagnetometer(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QMagnetometer(this))
+{
+}
+
+QmlMagnetometer::~QmlMagnetometer()
+{
+}
+
+QmlSensorReading *QmlMagnetometer::createReading() const
+{
+ return new QmlMagnetometerReading(m_sensor);
+}
+
+QSensor *QmlMagnetometer::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmlproperty bool QtMobility.sensors1::Magnetometer::returnGeoValues
+ This property holds a value indicating if geomagnetic values should be returned.
+
+ Please see QMagnetometer::returnGeoValues for information about this property.
+*/
+
+bool QmlMagnetometer::returnGeoValues() const
+{
+ return m_sensor->property("returnGeoValues").toBool();
+}
+
+void QmlMagnetometer::setReturnGeoValues(bool geo)
+{
+ if (m_sensor->property("returnGeoValues").toBool() == geo) return;
+ m_sensor->setProperty("returnGeoValues", geo);
+}
+
+/*!
+ \qmltype MagnetometerReading
+ \instantiates QmlMagnetometerReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The MagnetometerReading element holds the most recent Magnetometer reading.
+
+ The MagnetometerReading element holds the most recent Magnetometer reading.
+
+ This element wraps the QMagnetometerReading class. Please see the documentation for
+ QMagnetometerReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlMagnetometerReading::QmlMagnetometerReading(QMagnetometer *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlMagnetometerReading::~QmlMagnetometerReading()
+{
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::x
+ This property holds the raw magnetic flux density on the X axis.
+
+ Please see QMagnetometerReading::x for information about this property.
+*/
+
+qreal QmlMagnetometerReading::x() const
+{
+ return m_x;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::y
+ This property holds the raw magnetic flux density on the Y axis.
+
+ Please see QMagnetometerReading::y for information about this property.
+*/
+
+qreal QmlMagnetometerReading::y() const
+{
+ return m_y;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::z
+ This property holds the raw magnetic flux density on the Z axis.
+
+ Please see QMagnetometerReading::z for information about this property.
+*/
+
+qreal QmlMagnetometerReading::z() const
+{
+ return m_z;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::calibrationLevel
+ This property holds the accuracy of the reading.
+
+ Please see QMagnetometerReading::calibrationLevel for information about this property.
+*/
+
+qreal QmlMagnetometerReading::calibrationLevel() const
+{
+ return m_calibrationLevel;
+}
+
+QSensorReading *QmlMagnetometerReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlMagnetometerReading::readingUpdate()
+{
+ qreal magX = m_sensor->reading()->x();
+ if (m_x != magX) {
+ m_x = magX;
+ Q_EMIT xChanged();
+ }
+ qreal magY = m_sensor->reading()->y();
+ if (m_y != magY) {
+ m_y = magY;
+ Q_EMIT yChanged();
+ }
+ qreal magZ = m_sensor->reading()->z();
+ if (m_z != magZ) {
+ m_z = magZ;
+ Q_EMIT zChanged();
+ }
+ qreal calLevel = m_sensor->reading()->calibrationLevel();
+ if (m_calibrationLevel != calLevel) {
+ m_calibrationLevel = calLevel;
+ Q_EMIT calibrationLevelChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlmagnetometer.h b/src/imports/sensors/qmlmagnetometer.h
new file mode 100644
index 00000000..d6c75c1e
--- /dev/null
+++ b/src/imports/sensors/qmlmagnetometer.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLMAGNETOMETER_H
+#define QMLMAGNETOMETER_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QMagnetometer;
+
+class QmlMagnetometer : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlMagnetometer(QObject *parent = 0);
+ ~QmlMagnetometer();
+
+ bool returnGeoValues() const;
+ void setReturnGeoValues(bool geo);
+
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QMagnetometer *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlMagnetometerReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal x READ x NOTIFY xChanged)
+ Q_PROPERTY(qreal y READ y NOTIFY yChanged)
+ Q_PROPERTY(qreal z READ z NOTIFY zChanged)
+ Q_PROPERTY(qreal calibrationLevel READ calibrationLevel NOTIFY calibrationLevelChanged)
+public:
+ explicit QmlMagnetometerReading(QMagnetometer *sensor);
+ ~QmlMagnetometerReading();
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+ qreal calibrationLevel() const;
+
+Q_SIGNALS:
+ void xChanged();
+ void yChanged();
+ void zChanged();
+ void calibrationLevelChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QMagnetometer *m_sensor;
+ qreal m_x;
+ qreal m_y;
+ qreal m_z;
+ qreal m_calibrationLevel;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmlorientationsensor.cpp b/src/imports/sensors/qmlorientationsensor.cpp
new file mode 100644
index 00000000..9db69c19
--- /dev/null
+++ b/src/imports/sensors/qmlorientationsensor.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlorientationsensor.h"
+#include <QOrientationSensor>
+
+/*!
+ \qmltype OrientationSensor
+ \instantiates QmlOrientationSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::Sensor
+ \brief The OrientationSensor element reports device orientation.
+
+ The OrientationSensor element reports device orientation.
+
+ This element wraps the QOrientationSensor class. Please see the documentation for
+ QOrientationSensor for details.
+
+ \sa OrientationReading
+*/
+
+QmlOrientationSensor::QmlOrientationSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QOrientationSensor(this))
+{
+}
+
+QmlOrientationSensor::~QmlOrientationSensor()
+{
+}
+
+QmlSensorReading *QmlOrientationSensor::createReading() const
+{
+ return new QmlOrientationSensorReading(m_sensor);
+}
+
+QSensor *QmlOrientationSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype OrientationReading
+ \instantiates QmlOrientationSensorReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The OrientationReading element holds the most recent OrientationSensor reading.
+
+ The OrientationReading element holds the most recent OrientationSensor reading.
+
+ This element wraps the QOrientationReading class. Please see the documentation for
+ QOrientationReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlOrientationSensorReading::QmlOrientationSensorReading(QOrientationSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlOrientationSensorReading::~QmlOrientationSensorReading()
+{
+}
+
+/*!
+ \qmlproperty Orientation QtMobility.sensors1::OrientationReading::orientation
+ This property holds the orientation of the device.
+
+ Please see QOrientationReading::orientation for information about this property.
+
+ Note that Orientation constants are exposed through the OrientationReading class.
+ \code
+ OrientationSensor {
+ onReadingChanged: {
+ if (reading.orientation == OrientationReading.TopUp)
+ // do something
+ }
+ }
+ \endcode
+*/
+
+QOrientationReading::Orientation QmlOrientationSensorReading::orientation() const
+{
+ return m_orientation;
+}
+
+QSensorReading *QmlOrientationSensorReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlOrientationSensorReading::readingUpdate()
+{
+ QOrientationReading::Orientation o = m_sensor->reading()->orientation();
+ if (m_orientation != o) {
+ m_orientation = o;
+ Q_EMIT orientationChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlorientationsensor.h b/src/imports/sensors/qmlorientationsensor.h
new file mode 100644
index 00000000..d14197e8
--- /dev/null
+++ b/src/imports/sensors/qmlorientationsensor.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLORIENTATIONSENSOR_H
+#define QMLORIENTATIONSENSOR_H
+
+#include "qmlsensor.h"
+#include <QOrientationSensor>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QOrientationSensor;
+
+class QmlOrientationSensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlOrientationSensor(QObject *parent = 0);
+ ~QmlOrientationSensor();
+
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QOrientationSensor *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlOrientationSensorReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(QOrientationReading::Orientation orientation READ orientation NOTIFY orientationChanged)
+public:
+
+ explicit QmlOrientationSensorReading(QOrientationSensor *sensor);
+ ~QmlOrientationSensorReading();
+
+ QOrientationReading::Orientation orientation() const;
+
+Q_SIGNALS:
+ void orientationChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QOrientationSensor *m_sensor;
+ QOrientationReading::Orientation m_orientation;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmlproximitysensor.cpp b/src/imports/sensors/qmlproximitysensor.cpp
new file mode 100644
index 00000000..fa06f80a
--- /dev/null
+++ b/src/imports/sensors/qmlproximitysensor.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlproximitysensor.h"
+#include <QProximitySensor>
+
+/*!
+ \qmltype ProximitySensor
+ \instantiates QmlProximitySensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::Sensor
+ \brief The ProximitySensor element reports on object proximity.
+
+ The ProximitySensor element reports on object proximity.
+
+ This element wraps the QProximitySensor class. Please see the documentation for
+ QProximitySensor for details.
+
+ \sa ProximityReading
+*/
+
+QmlProximitySensor::QmlProximitySensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QProximitySensor(this))
+{
+}
+
+QmlProximitySensor::~QmlProximitySensor()
+{
+}
+
+QmlSensorReading *QmlProximitySensor::createReading() const
+{
+ return new QmlProximitySensorReading(m_sensor);
+}
+
+QSensor *QmlProximitySensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype ProximityReading
+ \instantiates QmlProximitySensorReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The ProximityReading element holds the most recent ProximitySensor reading.
+
+ The ProximityReading element holds the most recent ProximitySensor reading.
+
+ This element wraps the QProximityReading class. Please see the documentation for
+ QProximityReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlProximitySensorReading::QmlProximitySensorReading(QProximitySensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlProximitySensorReading::~QmlProximitySensorReading()
+{
+}
+
+/*!
+ \qmlproperty bool QtMobility.sensors1::ProximityReading::near
+ This property holds a value indicating if something is near.
+
+ Please see QProximityReading::near for information about this property.
+*/
+
+bool QmlProximitySensorReading::near() const
+{
+ return m_near;
+}
+
+QSensorReading *QmlProximitySensorReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlProximitySensorReading::readingUpdate()
+{
+ bool pNear = m_sensor->reading()->close();
+ if (m_near != pNear) {
+ m_near = pNear;
+ Q_EMIT nearChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlproximitysensor.h b/src/imports/sensors/qmlproximitysensor.h
new file mode 100644
index 00000000..afbc3a01
--- /dev/null
+++ b/src/imports/sensors/qmlproximitysensor.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLPROXIMITYSENSOR_H
+#define QMLPROXIMITYSENSOR_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QProximitySensor;
+
+class QmlProximitySensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlProximitySensor(QObject *parent = 0);
+ ~QmlProximitySensor();
+
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QProximitySensor *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlProximitySensorReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(bool near READ near NOTIFY nearChanged)
+public:
+ explicit QmlProximitySensorReading(QProximitySensor *sensor);
+ ~QmlProximitySensorReading();
+
+ bool near() const;
+
+Q_SIGNALS:
+ void nearChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QProximitySensor *m_sensor;
+ bool m_near;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmlrotationsensor.cpp b/src/imports/sensors/qmlrotationsensor.cpp
new file mode 100644
index 00000000..745af81c
--- /dev/null
+++ b/src/imports/sensors/qmlrotationsensor.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlrotationsensor.h"
+#include <QRotationSensor>
+
+/*!
+ \qmltype RotationSensor
+ \instantiates QmlRotationSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::Sensor
+ \brief The RotationSensor element reports on device rotation
+ around the X, Y and Z axes.
+
+ The RotationSensor element reports on device rotation
+ around the X, Y and Z axes.
+
+ This element wraps the QRotationSensor class. Please see the documentation for
+ QRotationSensor for details.
+
+ \sa RotationReading
+*/
+
+QmlRotationSensor::QmlRotationSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QRotationSensor(this))
+{
+}
+
+QmlRotationSensor::~QmlRotationSensor()
+{
+}
+
+QmlSensorReading *QmlRotationSensor::createReading() const
+{
+ return new QmlRotationSensorReading(m_sensor);
+}
+
+QSensor *QmlRotationSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::RotationSensor::hasZ
+ This property holds a value indicating if the z angle is available.
+
+ Please see QRotationSensor::hasZ for information about this property.
+*/
+
+bool QmlRotationSensor::hasZ() const
+{
+ return m_sensor->property("hasZ").toBool();
+}
+
+void QmlRotationSensor::_update()
+{
+}
+
+/*!
+ \qmltype RotationReading
+ \instantiates QmlRotationSensorReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The RotationReading element holds the most recent RotationSensor reading.
+
+ The RotationReading element holds the most recent RotationSensor reading.
+
+ This element wraps the QRotationReading class. Please see the documentation for
+ QRotationReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlRotationSensorReading::QmlRotationSensorReading(QRotationSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlRotationSensorReading::~QmlRotationSensorReading()
+{
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::RotationReading::x
+ This property holds the rotation around the x axis.
+
+ Please see QRotationReading::x for information about this property.
+*/
+
+qreal QmlRotationSensorReading::x() const
+{
+ return m_x;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::RotationReading::y
+ This property holds the rotation around the y axis.
+
+ Please see QRotationReading::y for information about this property.
+*/
+
+qreal QmlRotationSensorReading::y() const
+{
+ return m_y;
+}
+
+/*!
+ \qmlproperty qreal QtMobility.sensors1::RotationReading::z
+ This property holds the rotation around the z axis.
+
+ Please see QRotationReading::z for information about this property.
+*/
+
+qreal QmlRotationSensorReading::z() const
+{
+ return m_z;
+}
+
+QSensorReading *QmlRotationSensorReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlRotationSensorReading::readingUpdate()
+{
+ qreal rX = m_sensor->reading()->x();
+ if (m_x != rX) {
+ m_x = rX;
+ Q_EMIT xChanged();
+ }
+ qreal rY = m_sensor->reading()->y();
+ if (m_y != rY) {
+ m_y = rY;
+ Q_EMIT yChanged();
+ }
+ qreal rZ = m_sensor->reading()->z();
+ if (m_z != rZ) {
+ m_z = rZ;
+ Q_EMIT zChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlrotationsensor.h b/src/imports/sensors/qmlrotationsensor.h
new file mode 100644
index 00000000..db3b62f6
--- /dev/null
+++ b/src/imports/sensors/qmlrotationsensor.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLROTATIONSENSOR_H
+#define QMLROTATIONSENSOR_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QRotationSensor;
+
+class QmlRotationSensor : public QmlSensor
+{
+ Q_OBJECT
+ Q_PROPERTY(bool hasZ READ hasZ)
+public:
+ explicit QmlRotationSensor(QObject *parent = 0);
+ ~QmlRotationSensor();
+
+ bool hasZ() const;
+
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ void _update();
+ QRotationSensor *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlRotationSensorReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal x READ x NOTIFY xChanged)
+ Q_PROPERTY(qreal y READ y NOTIFY yChanged)
+ Q_PROPERTY(qreal z READ z NOTIFY zChanged)
+public:
+ explicit QmlRotationSensorReading(QRotationSensor *sensor);
+ ~QmlRotationSensorReading();
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+
+Q_SIGNALS:
+ void xChanged();
+ void yChanged();
+ void zChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QRotationSensor *m_sensor;
+ qreal m_x;
+ qreal m_y;
+ qreal m_z;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmlsensor.cpp b/src/imports/sensors/qmlsensor.cpp
new file mode 100644
index 00000000..217b5dc2
--- /dev/null
+++ b/src/imports/sensors/qmlsensor.cpp
@@ -0,0 +1,426 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlsensor.h"
+#include <QSensor>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype Sensor
+ \instantiates QmlSensor
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \brief The Sensor element serves as a base type for sensors.
+
+ The Sensor element serves as a base type for sensors.
+
+ This element wraps the QSensor class. Please see the documentation for
+ QSensor for details.
+
+ This element cannot be directly created. Please use one of the sub-classes instead.
+*/
+
+QmlSensor::QmlSensor(QObject *parent)
+ : QObject(parent)
+ , m_parsed(false)
+ , m_active(false)
+ , m_reading(0)
+{
+}
+
+QmlSensor::~QmlSensor()
+{
+}
+
+/*!
+ \qmlproperty string QtMobility.sensors1::Sensor::identifier
+ This property holds the backend identifier for the sensor.
+
+ Please see QSensor::identifier for information about this property.
+*/
+
+QString QmlSensor::identifier() const
+{
+ return m_identifier;
+}
+
+void QmlSensor::setIdentifier(const QString &identifier)
+{
+ if (m_parsed) return;
+ m_identifier = identifier;
+ Q_EMIT identifierChanged();
+}
+
+/*!
+ \qmlproperty string QtMobility.sensors1::Sensor::type
+ This property holds the type of the sensor.
+*/
+
+QString QmlSensor::type() const
+{
+ return QString::fromLatin1(sensor()->type());
+}
+
+/*!
+ \qmlproperty bool QtMobility.sensors1::Sensor::connectedToBackend
+ This property holds a value indicating if the sensor has connected to a backend.
+
+ Please see QSensor::connectedToBackend for information about this property.
+*/
+
+bool QmlSensor::isConnectedToBackend() const
+{
+ return sensor()->isConnectedToBackend();
+}
+
+/*!
+ \qmlproperty bool QtMobility.sensors1::Sensor::busy
+ This property holds a value to indicate if the sensor is busy.
+
+ Please see QSensor::busy for information about this property.
+*/
+
+bool QmlSensor::isBusy() const
+{
+ return sensor()->isBusy();
+}
+
+/*!
+ \qmlproperty bool QtMobility.sensors1::Sensor::active
+ This property holds a value to indicate if the sensor is active.
+
+ Please see QSensor::active for information about this property.
+*/
+
+void QmlSensor::setActive(bool active)
+{
+ m_active = active;
+ if (!m_parsed) return; // delay (it'll get called again later)!
+ bool wasActive = sensor()->isActive();
+ if (wasActive == active) return;
+ if (active) {
+ sensor()->start();
+ m_active = sensor()->isActive();
+ } else {
+ sensor()->stop();
+ }
+ if (m_active != wasActive)
+ emit activeChanged();
+}
+
+bool QmlSensor::isActive() const
+{
+ return m_active;
+}
+
+/*!
+ \qmlproperty bool QtMobility.sensors1::Sensor::alwaysOn
+ This property holds a value to indicate if the sensor should remain running when the screen is off.
+
+ Please see QSensor::alwaysOn for information about this property.
+*/
+
+bool QmlSensor::isAlwaysOn() const
+{
+ return sensor()->isAlwaysOn();
+}
+
+void QmlSensor::setAlwaysOn(bool alwaysOn)
+{
+ sensor()->setAlwaysOn(alwaysOn);
+}
+
+/*!
+ \qmlproperty list<Range> QtMobility.sensors1::Sensor::availableDataRates
+ This property holds the data rates that the sensor supports.
+
+ Please see QSensor::availableDataRates for information about this property.
+*/
+
+QQmlListProperty<QmlSensorRange> QmlSensor::availableDataRates() const
+{
+ QList<QmlSensorRange*> ret;
+ ret.reserve(sensor()->availableDataRates().size());
+ foreach (const qrange &r, sensor()->availableDataRates()) {
+ QmlSensorRange *range = new QmlSensorRange;
+ //QQmlEngine::setObjectOwnership(range, QQmlEngine::JavaScriptOwnership);
+ range->setMinumum(r.first);
+ range->setMaximum(r.second);
+ ret << range;
+ }
+ return QQmlListProperty<QmlSensorRange>(const_cast<QmlSensor*>(this), ret);
+}
+
+/*!
+ \qmlproperty int QtMobility.sensors1::Sensor::dataRate
+ This property holds the data rate that the sensor should be run at.
+
+ Please see QSensor::dataRate for information about this property.
+*/
+
+int QmlSensor::dataRate() const
+{
+ return sensor()->dataRate();
+}
+
+void QmlSensor::setDataRate(int rate)
+{
+ if (rate != dataRate()) {
+ sensor()->setDataRate(rate);
+ Q_EMIT dataRateChanged();
+ }
+}
+
+/*!
+ \qmlproperty list<OutputRange> QtMobility.sensors1::Sensor::outputRanges
+ This property holds a list of output ranges the sensor supports.
+
+ Please see QSensor::outputRanges for information about this property.
+*/
+
+QQmlListProperty<QmlSensorOutputRange> QmlSensor::outputRanges() const
+{
+ QList<QmlSensorOutputRange*> ret;
+ ret.reserve(sensor()->outputRanges().size());
+ foreach (const qoutputrange &r, sensor()->outputRanges()) {
+ QmlSensorOutputRange *range = new QmlSensorOutputRange;
+ //QQmlEngine::setObjectOwnership(range, QQmlEngine::JavaScriptOwnership);
+ range->setMinimum(r.minimum);
+ range->setMaximum(r.maximum);
+ range->setAccuracy(r.accuracy);
+ ret << range;
+ }
+ return QQmlListProperty<QmlSensorOutputRange>(const_cast<QmlSensor*>(this), ret);
+}
+
+/*!
+ \qmlproperty int QtMobility.sensors1::Sensor::outputRange
+ This property holds the output range in use by the sensor.
+
+ Please see QSensor::outputRange for information about this property.
+*/
+
+int QmlSensor::outputRange() const
+{
+ return sensor()->outputRange();
+}
+
+void QmlSensor::setOutputRange(int index)
+{
+ int oldRange = outputRange();
+ if (oldRange == index) return;
+ sensor()->setOutputRange(index);
+ if (sensor()->outputRange() == index)
+ Q_EMIT outputRangeChanged();
+}
+
+/*!
+ \qmlproperty string QtMobility.sensors1::Sensor::description
+ This property holds a descriptive string for the sensor.
+*/
+
+QString QmlSensor::description() const
+{
+ return sensor()->description();
+}
+
+/*!
+ \qmlproperty int QtMobility.sensors1::Sensor::error
+ This property holds the last error code set on the sensor.
+*/
+
+int QmlSensor::error() const
+{
+ return sensor()->error();
+}
+
+/*!
+ \qmlproperty SensorReading QtMobility.sensors1::Sensor::reading
+ This property holds the reading class.
+
+ Please see QSensor::reading for information about this property.
+ \sa {QML Reading types}
+*/
+
+QmlSensorReading *QmlSensor::reading() const
+{
+ return m_reading;
+}
+
+/*!
+ \qmlmethod bool QtMobility.sensors1::Sensor::start()
+ Start retrieving values from the sensor. Returns true if the sensor was started, false otherwise.
+
+ Please see QSensor::start() for information.
+*/
+
+bool QmlSensor::start()
+{
+ setActive(true);
+ return isActive();
+}
+
+/*!
+ \qmlmethod bool QtMobility.sensors1::Sensor::stop()
+ Stop retrieving values from the sensor.
+
+ Please see QSensor::stop() for information.
+*/
+
+void QmlSensor::stop()
+{
+ setActive(false);
+}
+
+void QmlSensor::classBegin()
+{
+}
+
+void QmlSensor::componentComplete()
+{
+ m_parsed = true;
+
+ connect(sensor(), SIGNAL(sensorError(int)), this, SIGNAL(errorChanged()));
+ connect(sensor(), SIGNAL(activeChanged()), this, SIGNAL(activeChanged()));
+ connect(sensor(), SIGNAL(alwaysOnChanged()), this, SIGNAL(alwaysOnChanged()));
+
+ // We need to set this on the sensor object now
+ sensor()->setIdentifier(m_identifier.toLocal8Bit());
+
+ // These can change!
+ QByteArray oldIdentifier = sensor()->identifier();
+ int oldDataRate = dataRate();
+ int oldOutputRange = outputRange();
+
+ bool ok = sensor()->connectToBackend();
+ if (ok) {
+ Q_EMIT connectedToBackendChanged();
+ m_reading = createReading();
+ m_reading->setParent(this);
+ }
+
+ if (oldIdentifier != sensor()->identifier()) {
+ m_identifier = QString::fromLatin1(sensor()->identifier());
+ Q_EMIT identifierChanged();
+ }
+ if (oldDataRate != dataRate())
+ Q_EMIT dataRateChanged();
+ if (oldOutputRange != outputRange())
+ Q_EMIT outputRangeChanged();
+
+ // meta-data should become non-empty
+ if (!description().isEmpty())
+ Q_EMIT descriptionChanged();
+ if (sensor()->availableDataRates().count())
+ Q_EMIT availableDataRatesChanged();
+ if (sensor()->outputRanges().count())
+ Q_EMIT outputRangesChanged();
+
+ _update();
+
+ connect(sensor(), SIGNAL(readingChanged()), this, SLOT(updateReading()));
+ if (m_active) {
+ m_active = false;
+ start();
+ }
+}
+
+void QmlSensor::_update()
+{
+}
+
+void QmlSensor::updateReading()
+{
+ if (m_reading) {
+ m_reading->update();
+ Q_EMIT readingChanged();
+ }
+}
+
+/*!
+ \qmltype SensorReading
+ \instantiates QmlSensorReading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \brief The SensorReading element serves as a base type for sensor readings.
+
+ The SensorReading element serves as a base type for sensor readings.
+
+ This element wraps the QSensorReading class. Please see the documentation for
+ QSensorReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlSensorReading::QmlSensorReading(QSensor *)
+ : QObject(0)
+{
+}
+
+QmlSensorReading::~QmlSensorReading()
+{
+}
+
+/*!
+ \qmlproperty quint64 QtMobility.sensors1::SensorReading::timestamp
+ A timestamp for the reading.
+
+ Please see QSensorReading::timestamp for information about this property.
+*/
+
+quint64 QmlSensorReading::timestamp() const
+{
+ return m_timestamp;
+}
+
+void QmlSensorReading::update()
+{
+ quint64 ts = reading()->timestamp();
+ if (m_timestamp != ts) {
+ m_timestamp = ts;
+ Q_EMIT timestampChanged();
+ }
+ readingUpdate();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/sensors/qmlsensor.h b/src/imports/sensors/qmlsensor.h
new file mode 100644
index 00000000..a4ac852d
--- /dev/null
+++ b/src/imports/sensors/qmlsensor.h
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLSENSOR_H
+#define QMLSENSOR_H
+
+#include <QQmlParserStatus>
+#include <QQmlListProperty>
+#include "qmlsensorrange.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QSensor;
+class QSensorReading;
+
+class QmlSensorReading;
+
+class QmlSensor : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged)
+ Q_PROPERTY(QString type READ type NOTIFY typeChanged)
+ Q_PROPERTY(bool connectedToBackend READ isConnectedToBackend NOTIFY connectedToBackendChanged)
+ Q_PROPERTY(QQmlListProperty<QmlSensorRange> availableDataRates READ availableDataRates NOTIFY availableDataRatesChanged)
+ Q_PROPERTY(int dataRate READ dataRate WRITE setDataRate NOTIFY dataRateChanged)
+ Q_PROPERTY(QmlSensorReading* reading READ reading NOTIFY readingChanged)
+ Q_PROPERTY(bool busy READ isBusy)
+ Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
+ Q_PROPERTY(QQmlListProperty<QmlSensorOutputRange> outputRanges READ outputRanges NOTIFY outputRangesChanged)
+ Q_PROPERTY(int outputRange READ outputRange WRITE setOutputRange NOTIFY outputRangeChanged)
+ 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)
+public:
+ explicit QmlSensor(QObject *parent = 0);
+ ~QmlSensor();
+
+ QString identifier() const;
+ void setIdentifier(const QString &identifier);
+
+ QString type() const;
+
+ bool isConnectedToBackend() const;
+
+ bool isBusy() const;
+
+ void setActive(bool active);
+ bool isActive() const;
+
+ bool isAlwaysOn() const;
+ void setAlwaysOn(bool alwaysOn);
+
+ QQmlListProperty<QmlSensorRange> availableDataRates() const;
+ int dataRate() const;
+ void setDataRate(int rate);
+
+ QQmlListProperty<QmlSensorOutputRange> outputRanges() const;
+ int outputRange() const;
+ void setOutputRange(int index);
+
+ QString description() const;
+ int error() const;
+
+ QmlSensorReading *reading() const;
+
+public Q_SLOTS:
+ bool start();
+ void stop();
+
+Q_SIGNALS:
+ void identifierChanged();
+ void typeChanged();
+ void connectedToBackendChanged();
+ void availableDataRatesChanged();
+ void dataRateChanged();
+ void readingChanged();
+ void activeChanged();
+ void outputRangesChanged();
+ void outputRangeChanged();
+ void descriptionChanged();
+ void errorChanged();
+ void alwaysOnChanged();
+
+protected:
+ virtual QSensor *sensor() const = 0;
+ virtual QmlSensorReading *createReading() const = 0;
+
+private Q_SLOTS:
+ void updateReading();
+ void componentComplete();
+
+private:
+ void classBegin();
+ virtual void _update();
+ bool m_parsed;
+ bool m_active;
+ QString m_identifier;
+ QmlSensorReading *m_reading;
+};
+
+class QmlSensorReading : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(quint64 timestamp READ timestamp NOTIFY timestampChanged)
+public:
+ explicit QmlSensorReading(QSensor *sensor);
+ ~QmlSensorReading();
+
+ quint64 timestamp() const;
+ void update();
+
+Q_SIGNALS:
+ void timestampChanged();
+
+private:
+ virtual QSensorReading *reading() const = 0;
+ virtual void readingUpdate() = 0;
+ quint64 m_timestamp;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/sensors/qmlsensorglobal.cpp b/src/imports/sensors/qmlsensorglobal.cpp
new file mode 100644
index 00000000..5c9723af
--- /dev/null
+++ b/src/imports/sensors/qmlsensorglobal.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlsensorglobal.h"
+#include <QSensor>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype SensorGlobal
+ \instantiates QmlSensorGlobal
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.3
+ \brief The SensorGlobal element provides the module API.
+
+ The SensorGlobal element provides the module API.
+
+ This element cannot be directly created. It can only be accessed via a namespace import.
+
+ \code
+ import QtMobility.sensors 1.3
+ import QtMobility.sensors 1.3 as Sensors
+ ...
+ Component.onCompleted: {
+ var types = Sensors.sensorTypes();
+ console.log(types.join(", "));
+ }
+ \endcode
+*/
+
+QmlSensorGlobal::QmlSensorGlobal(QObject *parent)
+ : QObject(parent)
+ , m_sensor(new QSensor(QByteArray(), this))
+{
+ connect(m_sensor, SIGNAL(availableSensorsChanged()), this, SIGNAL(availableSensorsChanged()));
+}
+
+QmlSensorGlobal::~QmlSensorGlobal()
+{
+}
+
+/*!
+ \qmlmethod list<string> QtMobility.sensors1::SensorGlobal::sensorTypes()
+ Returns a list of the sensor types that have been registered.
+
+ Please see QSensor::sensorTypes() for information.
+*/
+QStringList QmlSensorGlobal::sensorTypes() const
+{
+ QStringList ret;
+ foreach (const QByteArray &type, QSensor::sensorTypes())
+ ret << QString::fromLocal8Bit(type);
+ return ret;
+}
+
+/*!
+ \qmlmethod list<string> QtMobility.sensors1::SensorGlobal::sensorsForType(type)
+ Returns a list of the sensor identifiers that have been registered for \a type.
+
+ Please see QSensor::sensorsForType() for information.
+*/
+QStringList QmlSensorGlobal::sensorsForType(const QString &type) const
+{
+ QStringList ret;
+ foreach (const QByteArray &identifier, QSensor::sensorsForType(type.toLocal8Bit()))
+ ret << QString::fromLocal8Bit(identifier);
+ return ret;
+}
+
+/*!
+ \qmlmethod string QtMobility.sensors1::SensorGlobal::defaultSensorForType(type)
+ Returns the default sensor identifier that has been registered for \a type.
+
+ Please see QSensor::defaultSensorForType() for information.
+*/
+QString QmlSensorGlobal::defaultSensorForType(const QString &type) const
+{
+ return QString::fromLocal8Bit(QSensor::defaultSensorForType(type.toLocal8Bit()));
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/sensors/qmlsensorglobal.h b/src/imports/sensors/qmlsensorglobal.h
new file mode 100644
index 00000000..fbbd30d7
--- /dev/null
+++ b/src/imports/sensors/qmlsensorglobal.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLSENSORGLOBAL_H
+#define QMLSENSORGLOBAL_H
+
+#include <QObject>
+#include <QStringList>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QSensor;
+
+class QmlSensorGlobal : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QmlSensorGlobal(QObject *parent = 0);
+ ~QmlSensorGlobal();
+
+ Q_INVOKABLE QStringList sensorTypes() const;
+ Q_INVOKABLE QStringList sensorsForType(const QString &type) const;
+ Q_INVOKABLE QString defaultSensorForType(const QString &type) const;
+
+Q_SIGNALS:
+ void availableSensorsChanged();
+
+private:
+ QSensor *m_sensor;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/sensors/qmlsensorrange.cpp b/src/imports/sensors/qmlsensorrange.cpp
new file mode 100644
index 00000000..b46b8613
--- /dev/null
+++ b/src/imports/sensors/qmlsensorrange.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmlsensorrange.h"
+
+QmlSensorRange::QmlSensorRange(QObject *parent)
+ : QObject(parent),
+ min(0),
+ max(0)
+{
+}
+
+QmlSensorRange::~QmlSensorRange()
+{
+}
+
+int QmlSensorRange::minimum() const
+{
+ return min;
+}
+
+int QmlSensorRange::maximum() const
+{
+ return max;
+}
+
+QmlSensorOutputRange::QmlSensorOutputRange(QObject *parent)
+ : QObject(parent),
+ min(0),
+ max(0),
+ acc(0)
+{
+}
+
+QmlSensorOutputRange::~QmlSensorOutputRange()
+{
+}
+
+qreal QmlSensorOutputRange::minimum() const
+{
+ return min;
+}
+
+qreal QmlSensorOutputRange::maximum() const
+{
+ return max;
+}
+
+qreal QmlSensorOutputRange::accuracy() const
+{
+ return acc;
+}
diff --git a/src/imports/sensors/qmlsensorrange.h b/src/imports/sensors/qmlsensorrange.h
new file mode 100644
index 00000000..261825b5
--- /dev/null
+++ b/src/imports/sensors/qmlsensorrange.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLSENSORRANGE_H
+#define QMLSENSORRANGE_H
+
+#include <QObject>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QmlSensorRange : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int minimum READ minimum)
+ Q_PROPERTY(int maximum READ maximum)
+public:
+ explicit QmlSensorRange(QObject *parent = 0);
+ ~QmlSensorRange();
+
+ int minimum() const;
+ void setMinumum(int mini) { min = mini; }
+
+ int maximum() const;
+ void setMaximum(int maxi) { max = maxi; }
+
+private:
+
+ int min;
+ int max;
+};
+
+class QmlSensorOutputRange : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal minimum READ minimum)
+ Q_PROPERTY(qreal maximum READ maximum)
+ Q_PROPERTY(qreal accuracy READ accuracy)
+public:
+ explicit QmlSensorOutputRange(QObject *parent = 0);
+ ~QmlSensorOutputRange();
+
+ qreal minimum() const;
+ void setMinimum(int mini) { min = mini; }
+
+ qreal maximum() const;
+ void setMaximum(int maxi) { max = maxi; }
+
+ qreal accuracy() const;
+ void setAccuracy(int accu) { acc = accu; }
+
+private:
+ qreal min;
+ qreal max;
+ qreal acc;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/qmltapsensor.cpp b/src/imports/sensors/qmltapsensor.cpp
new file mode 100644
index 00000000..ac17df09
--- /dev/null
+++ b/src/imports/sensors/qmltapsensor.cpp
@@ -0,0 +1,181 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 "qmltapsensor.h"
+#include <QTapSensor>
+
+/*!
+ \qmltype TapSensor
+ \instantiates QmlTapSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::Sensor
+ \brief The TapSensor element reports tap and double tap events
+ along the X, Y and Z axes.
+
+ The TapSensor element reports tap and double tap events
+ along the X, Y and Z axes.
+
+ This element wraps the QTapSensor class. Please see the documentation for
+ QTapSensor for details.
+
+ \sa TapReading
+*/
+
+QmlTapSensor::QmlTapSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QTapSensor(this))
+{
+}
+
+QmlTapSensor::~QmlTapSensor()
+{
+}
+
+QmlSensorReading *QmlTapSensor::createReading() const
+{
+ return new QmlTapSensorReading(m_sensor);
+}
+
+QSensor *QmlTapSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmlproperty bool QtMobility.sensors1::TapSensor::returnDoubleTapEvents
+ This property holds a value indicating if double tap events should be reported.
+
+ Please see QTapSensor::returnDoubleTapEvents for information about this property.
+*/
+
+bool QmlTapSensor::returnDoubleTapEvents() const
+{
+ return m_sensor->property("returnDoubleTapEvents").toBool();
+}
+
+void QmlTapSensor::setReturnDoubleTapEvents(bool ret)
+{
+ if (m_sensor->property("returnDoubleTapEvents").toBool() == ret) return;
+ m_sensor->setProperty("returnDoubleTapEvents", ret);
+ Q_EMIT returnDoubleTapEventsChanged();
+}
+
+/*!
+ \qmltype TapReading
+ \instantiates QmlTapSensorReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1.3
+ \since QtMobility.sensors 1.1
+ \inherits QtMobility.sensors1::SensorReading
+ \brief The TapReading element holds the most recent TapSensor reading.
+
+ The TapReading element holds the most recent TapSensor reading.
+
+ This element wraps the QTapReading class. Please see the documentation for
+ QTapReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlTapSensorReading::QmlTapSensorReading(QTapSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+{
+}
+
+QmlTapSensorReading::~QmlTapSensorReading()
+{
+}
+
+/*!
+ \qmlproperty TapDirection QtMobility.sensors1::TapReading::tapDirection
+ This property holds the direction of the tap.
+
+ Please see QTapReading::tapDirection for information about this property.
+
+ Note that TapDirection constants are exposed through the TapReading class.
+ \code
+ TapSensor {
+ onReadingChanged: {
+ if ((reading.tapDirection & TapReading.X_Both))
+ // do something
+ }
+ }
+ \endcode
+*/
+
+QTapReading::TapDirection QmlTapSensorReading::tapDirection() const
+{
+ return m_tapDirection;
+}
+
+/*!
+ \qmlproperty bool QtMobility.sensors1::TapReading::doubleTap
+ This property holds a value indicating if there was a single or double tap.
+
+ Please see QTapReading::doubleTap for information about this property.
+*/
+
+bool QmlTapSensorReading::isDoubleTap() const
+{
+ return m_isDoubleTap;
+}
+
+QSensorReading *QmlTapSensorReading::reading() const
+{
+ return const_cast<QTapSensor*>(m_sensor)->reading();
+}
+
+void QmlTapSensorReading::readingUpdate()
+{
+ QTapReading::TapDirection td = m_sensor->reading()->tapDirection();
+ if (m_tapDirection != td) {
+ m_tapDirection = td;
+ Q_EMIT tapDirectionChanged();
+ }
+ bool dTap = m_sensor->reading()->isDoubleTap();
+ if (m_isDoubleTap != dTap) {
+ m_isDoubleTap = dTap;
+ Q_EMIT isDoubleTapChanged();
+ }
+}
diff --git a/src/imports/sensors/qmltapsensor.h b/src/imports/sensors/qmltapsensor.h
new file mode 100644
index 00000000..f9ae94bd
--- /dev/null
+++ b/src/imports/sensors/qmltapsensor.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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 QMLTAPSENSOR_H
+#define QMLTAPSENSOR_H
+
+#include "qmlsensor.h"
+#include <QTapSensor>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QTapSensor;
+
+class QmlTapSensor : public QmlSensor
+{
+ Q_OBJECT
+ Q_PROPERTY(bool returnDoubleTapEvents READ returnDoubleTapEvents WRITE setReturnDoubleTapEvents NOTIFY returnDoubleTapEventsChanged)
+public:
+ explicit QmlTapSensor(QObject *parent = 0);
+ ~QmlTapSensor();
+
+ bool returnDoubleTapEvents() const;
+ void setReturnDoubleTapEvents(bool ret);
+
+
+Q_SIGNALS:
+ void returnDoubleTapEventsChanged();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QTapSensor *m_sensor;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+};
+
+class QmlTapSensorReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(QTapReading::TapDirection tapDirection READ tapDirection NOTIFY tapDirectionChanged)
+ Q_PROPERTY(bool doubleTap READ isDoubleTap NOTIFY isDoubleTapChanged)
+public:
+
+ explicit QmlTapSensorReading(QTapSensor *sensor);
+ ~QmlTapSensorReading();
+
+ QTapReading::TapDirection tapDirection() const;
+ bool isDoubleTap() const;
+
+Q_SIGNALS:
+ void tapDirectionChanged();
+ void isDoubleTapChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+ QTapSensor *m_sensor;
+ QTapReading::TapDirection m_tapDirection;
+ bool m_isDoubleTap;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif
diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp
index b13ec922..e5f43835 100644
--- a/src/imports/sensors/sensors.cpp
+++ b/src/imports/sensors/sensors.cpp
@@ -54,8 +54,27 @@
#include <qgyroscope.h>
#include <qirproximitysensor.h>
+#include "qmlsensorglobal.h"
+#include "qmlsensor.h"
+#include "qmlaccelerometer.h"
+#include "qmlambientlightsensor.h"
+#include "qmlcompass.h"
+#include "qmlgyroscope.h"
+#include "qmlirproximitysensor.h"
+#include "qmllightsensor.h"
+#include "qmlmagnetometer.h"
+#include "qmlorientationsensor.h"
+#include "qmlproximitysensor.h"
+#include "qmlrotationsensor.h"
+#include "qmltapsensor.h"
+
QT_BEGIN_NAMESPACE
+static QObject *global_object_13(QQmlEngine *, QJSEngine *)
+{
+ return new QmlSensorGlobal;
+}
+
class QSensorsDeclarativeModule : public QQmlExtensionPlugin
{
Q_OBJECT
@@ -118,750 +137,36 @@ public:
// Register the 1.3 interfaces
major = 1;
minor = 3;
- qmlRegisterUncreatableType<QSensor ,1>(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor"));
- qmlRegisterUncreatableType<QSensorReading >(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading"));
- qmlRegisterType <QAccelerometer >(package, major, minor, "Accelerometer");
- qmlRegisterUncreatableType<QAccelerometerReading>(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading"));
- qmlRegisterType <QAmbientLightSensor >(package, major, minor, "AmbientLightSensor");
- qmlRegisterUncreatableType<QAmbientLightReading >(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading"));
- qmlRegisterType <QCompass >(package, major, minor, "Compass");
- qmlRegisterUncreatableType<QCompassReading >(package, major, minor, "CompassReading", QLatin1String("Cannot create CompassReading"));
- qmlRegisterType <QMagnetometer >(package, major, minor, "Magnetometer");
- qmlRegisterUncreatableType<QMagnetometerReading >(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading"));
- qmlRegisterType <QOrientationSensor >(package, major, minor, "OrientationSensor");
- qmlRegisterUncreatableType<QOrientationReading >(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading"));
- qmlRegisterType <QProximitySensor >(package, major, minor, "ProximitySensor");
- qmlRegisterUncreatableType<QProximityReading >(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading"));
- qmlRegisterType <QRotationSensor >(package, major, minor, "RotationSensor");
- qmlRegisterUncreatableType<QRotationReading >(package, major, minor, "RotationReading", QLatin1String("Cannot create RotationReading"));
- qmlRegisterType <QTapSensor >(package, major, minor, "TapSensor");
- qmlRegisterUncreatableType<QTapReading >(package, major, minor, "TapReading", QLatin1String("Cannot create TapReading"));
- qmlRegisterType <QLightSensor >(package, major, minor, "LightSensor");
- qmlRegisterUncreatableType<QLightReading >(package, major, minor, "LightReading", QLatin1String("Cannot create LightReading"));
- qmlRegisterType <QGyroscope >(package, major, minor, "Gyroscope");
- qmlRegisterUncreatableType<QGyroscopeReading >(package, major, minor, "GyroscopeReading", QLatin1String("Cannot create GyroscopeReading"));
- qmlRegisterType <QIRProximitySensor >(package, major, minor, "IRProximitySensor");
- qmlRegisterUncreatableType<QIRProximityReading >(package, major, minor, "IRProximityReading", QLatin1String("Cannot create IRProximityReading"));
+ qmlRegisterSingletonType <QmlSensorGlobal >(package, major, minor, "QtSensors", global_object_13);
+ qmlRegisterUncreatableType<QmlSensorRange >(package, major, minor, "Range", QLatin1String("Cannot create Range"));
+ qmlRegisterUncreatableType<QmlSensorOutputRange >(package, major, minor, "OutputRange", QLatin1String("Cannot create OutputRange"));
+ qmlRegisterUncreatableType<QmlSensor >(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor"));
+ qmlRegisterUncreatableType<QmlSensorReading >(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading"));
+ qmlRegisterType <QmlAccelerometer >(package, major, minor, "Accelerometer");
+ qmlRegisterUncreatableType<QmlAccelerometerReading >(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading"));
+ qmlRegisterType <QmlAmbientLightSensor >(package, major, minor, "AmbientLightSensor");
+ qmlRegisterUncreatableType<QmlAmbientLightSensorReading>(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading"));
+ 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 <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 <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"));
}
};
QT_END_NAMESPACE
#include "sensors.moc"
-
-// =====================================================================
-
-/*!
- \qmltype QtMobility.sensors1::Sensor
- \instantiates QSensor
- \inqmlmodule QtMobility.sensors 1.3
- \brief The Sensor type serves as a base type for sensors.
-
- The Sensor type serves as a base type for sensors.
-
- This type wraps the QSensor class.
-
- This type cannot be directly created. Please use one of the sub-classes instead.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QSensor
-*/
-
-/*!
- \qmlproperty int QtMobility.sensors1::Sensor::dataRate
- Sets the rate at which data is returned by the sensor.
- \sa QSensor::dataRate
-*/
-
-/*!
- \qmlproperty bool QtMobility.sensors1::Sensor::active
- Starts or stops the sensor.
- \sa QSensor::active
-*/
-
-/*!
- \qmlproperty SensorReading QtMobility.sensors1::Sensor::reading
- Holds the most recent sensor reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlproperty bool QtMobility.sensors1::Sensor::alwaysOn
- Keeps the sensor running when the display turns off.
- \sa QSensor::alwaysOn
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::Sensor::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype SensorReading
- \instantiates QSensorReading
- \inqmlmodule QtMobility.sensors 1.3
- \brief The SensorReading type serves as a base type for sensor readings.
-
- The SensorReading type serves as a base type for sensor readings.
-
- This type wraps the QSensorReading class.
-
- This type cannot be directly created.
-
- \sa QSensorReading
-*/
-
-/*!
- \qmlproperty quint64 QtMobility.sensors1::SensorReading::timestamp
- A timestamp for the reading.
- \sa QSensorReading::timestamp
-*/
-
-/*!
- \qmltype QtMobility.sensors1::Accelerometer
- \instantiates QAccelerometer
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::Sensor
- \brief The Accelerometer type reports on linear acceleration
- along the X, Y and Z axes.
-
- The Accelerometer type reports on linear acceleration
- along the X, Y and Z axes.
-
- This type wraps the QAccelerometer class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QAccelerometer
-*/
-
-/*!
- \qmlproperty AccelerometerReading QtMobility.sensors1::Accelerometer::reading
- Holds the most recent accelerometer reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::Accelerometer::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype AccelerometerReading
- \instantiates QAccelerometerReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::SensorReading
- \brief The AccelerometerReading type holds the most recent Accelerometer reading.
-
- The AccelerometerReading type holds the most recent Accelerometer reading.
-
- This type wraps the QAccelerometerReading class.
-
- This type cannot be directly created.
-
- \sa QAccelerometerReading
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::AccelerometerReading::x
- \sa QAccelerometerReading::x
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::AccelerometerReading::y
- \sa QAccelerometerReading::y
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::AccelerometerReading::z
- \sa QAccelerometerReading::z
-*/
-
-/*!
- \qmltype QtMobility.sensors1::AmbientLightSensor
- \instantiates QAmbientLightSensor
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::Sensor
- \brief The AmbientLightSensor type repors on ambient lighting conditions.
-
- The AmbientLightSensor type repors on ambient lighting conditions.
-
- This type wraps the QAmbientLightSensor class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QAmbientLightSensor
-*/
-
-/*!
- \qmlproperty AmbientLightReading QtMobility.sensors1::AmbientLightSensor::reading
- Holds the most recent ambient light reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::AmbientLightSensor::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype AmbientLightReading
- \instantiates QAmbientLightReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::SensorReading
- \brief The AmbientLightReading type holds the most AmbientLightSensor reading.
-
- The AmbientLightReading type holds the most AmbientLightSensor reading.
-
- This type wraps the QAmbientLightReading class.
-
- This type cannot be directly created.
- \sa QAmbientLightReading
-*/
-
-/*!
- \qmlproperty QAmbientLightReading::LightLevel QtMobility.sensors1::AmbientLightReading::lightLevel
-
- LightLevel constants are exposed through the AmbientLightReading class.
- \code
- AmbientLightSensor {
- onReadingChanged: {
- if (reading.lightLevel == AmbientLightReading.Dark)
- // do something
- }
- }
- \endcode
-
- \sa QAmbientLightReading::lightLevel
-*/
-
-/*!
- \qmltype QtMobility.sensors1::Compass
- \instantiates QCompass
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::Sensor
- \brief The Compass type reports on heading using magnetic north as a reference.
-
- The Compass type reports on heading using magnetic north as a reference.
-
- This type wraps the QCompass class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QCompass
-*/
-
-/*!
- \qmlproperty CompassReading QtMobility.sensors1::Compass::reading
- Holds the most recent compass reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::Compass::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype CompassReading
- \instantiates QCompassReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::SensorReading
- \brief The CompassReading type holds the most recent Compass reading.
-
- The CompassReading type holds the most recent Compass reading.
-
- This type wraps the QCompassReading class.
-
- This type cannot be directly created.
-
- \sa QCompassReading
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::CompassReading::azimuth
- \sa QCompassReading::azimuth
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::CompassReading::calibrationLevel
- \sa QCompassReading::calibrationLevel
-*/
-
-/*!
- \qmltype QtMobility.sensors1::Magnetometer
- \instantiates QMagnetometer
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::Sensor
- \brief The Magnetometer type reports on magnetic field strength
- along the Z, Y and Z axes.
-
- The Magnetometer type reports on magnetic field strength
- along the Z, Y and Z axes.
-
- This type wraps the QMagnetometer class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QMagnetometer
-*/
-
-/*!
- \qmlproperty MagnetometerReading QtMobility.sensors1::Magnetometer::reading
- Holds the most recent magnetometer reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::Magnetometer::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype MagnetometerReading
- \instantiates QMagnetometerReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::SensorReading
- \brief The MagnetometerReading type holds the most recent Magnetometer reading.
-
- The MagnetometerReading type holds the most recent Magnetometer reading.
-
- This type wraps the QMagnetometerReading class.
-
- This type cannot be directly created.
-
- \sa QMagnetometerReading
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::x
- \sa QMagnetometerReading::x
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::y
- \sa QMagnetometerReading::y
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::z
- \sa QMagnetometerReading::z
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::calibrationLevel
- \sa QMagnetometerReading::calibrationLevel
-*/
-
-/*!
- \qmltype QtMobility.sensors1::OrientationSensor
- \instantiates QOrientationSensor
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::Sensor
- \brief The OrientationSensor type reports device orientation.
-
- The OrientationSensor type reports device orientation.
-
- This type wraps the QOrientationSensor class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QOrientationSensor
-*/
-
-/*!
- \qmlproperty OrientationReading QtMobility.sensors1::OrientationSensor::reading
- Holds the most recent orientation reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::OrientationSensor::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype OrientationReading
- \instantiates QOrientationReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::SensorReading
- \brief The OrientationReading type holds the most recent OrientationSensor reading.
-
- The OrientationReading type holds the most recent OrientationSensor reading.
-
- This type wraps the QOrientationReading class.
-
- This type cannot be directly created.
-
- \sa QOrientationReading
-*/
-
-/*!
- \qmlproperty QOrientationReading::Orientation QtMobility.sensors1::OrientationReading::orientation
-
- Orientation constants are exposed through the OrientationReading class.
- \code
- OrientationSensor {
- onReadingChanged: {
- if (reading.orientation == OrientationReading.TopUp)
- // do something
- }
- }
- \endcode
-
- \sa QOrientationReading::orientation
-*/
-
-/*!
- \qmltype QtMobility.sensors1::ProximitySensor
- \instantiates QProximitySensor
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::Sensor
- \brief The ProximitySensor type reports on object proximity.
-
- The ProximitySensor type reports on object proximity.
-
- This type wraps the QProximitySensor class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QProximitySensor
-*/
-
-/*!
- \qmlproperty ProximityReading QtMobility.sensors1::ProximitySensor::reading
- Holds the most recent proximity reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::ProximitySensor::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype ProximityReading
- \instantiates QProximityReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::SensorReading
- \brief The ProximityReading type holds the most recent ProximitySensor reading.
-
- The ProximityReading type holds the most recent ProximitySensor reading.
-
- This type wraps the QProximityReading class.
-
- This type cannot be directly created.
-
- \sa QProximityReading
-*/
-
-/*!
- \qmlproperty bool QtMobility.sensors1::ProximityReading::close
- \sa QProximityReading::close
-*/
-
-/*!
- \qmltype QtMobility.sensors1::RotationSensor
- \instantiates QRotationSensor
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::Sensor
- \brief The RotationSensor type reports on device rotation
- around the X, Y and Z axes.
-
- The RotationSensor type reports on device rotation
- around the X, Y and Z axes.
-
- This type wraps the QRotationSensor class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QRotationSensor
-*/
-
-/*!
- \qmlproperty RotationReading QtMobility.sensors1::RotationSensor::reading
- Holds the most recent rotation reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::RotationSensor::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype RotationReading
- \instantiates QRotationReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::SensorReading
- \brief The RotationReading type holds the most recent RotationSensor reading.
-
- The RotationReading type holds the most recent RotationSensor reading.
-
- This type wraps the QRotationReading class.
-
- This type cannot be directly created.
-
- \sa QRotationReading
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::RotationReading::x
- \sa QRotationReading::x
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::RotationReading::y
- \sa QRotationReading::y
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::RotationReading::z
- \sa QRotationReading::z
-*/
-
-/*!
- \qmltype QtMobility.sensors1::TapSensor
- \instantiates QTapSensor
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::Sensor
- \brief The TapSensor type reports tap and double tap events
- along the X, Y and Z axes.
-
- The TapSensor type reports tap and double tap events
- along the X, Y and Z axes.
-
- This type wraps the QTapSensor class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QTapSensor
-*/
-
-/*!
- \qmlproperty TapReading QtMobility.sensors1::TapSensor::reading
- Holds the most recent tap sensor reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::TapSensor::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype TapReading
- \instantiates QTapReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::SensorReading
- \brief The TapReading type holds the most recent TapSensor reading.
-
- The TapReading type holds the most recent TapSensor reading.
-
- This type wraps the QTapReading class.
-
- This type cannot be directly created.
-
- \sa QTapReading
-*/
-
-/*!
- \qmlproperty bool QtMobility.sensors1::TapReading::doubleTap
- \sa QTapReading::doubleTap
-*/
-
-/*!
- \qmlproperty QTapReading::TapDirection QtMobility.sensors1::TapReading::tapDirection
-
- TapDirection constants are exposed through the TapReading class.
- \code
- TapSensor {
- onReadingChanged: {
- if ((reading.tapDirection & TapReading.X_Both))
- // do something
- }
- }
- \endcode
-
- \sa QTapReading::tapDirection
-*/
-
-/*!
- \qmltype QtMobility.sensors1::LightSensor
- \instantiates QLightSensor
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \since QtMobility.sensors 1.2
- \inherits QtMobility.sensors1::Sensor
- \brief The LightSensor type reports on light levels using LUX.
-
- The LightSensor type reports on light levels using LUX.
-
- This type wraps the QLightSensor class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QLightSensor
-*/
-
-/*!
- \qmlproperty LightReading QtMobility.sensors1::LightSensor::reading
- Holds the most recent light sensor reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::LightSensor::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype LightReading
- \instantiates QLightReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \since QtMobility.sensors 1.2
- \inherits QtMobility.sensors1::SensorReading
- \brief The LightReading type holds the most recent LightSensor reading.
-
- The LightReading type holds the most recent LightSensor reading.
-
- This type wraps the QLightReading class.
-
- This type cannot be directly created.
- \sa QLightReading
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::LightReading::lux
- \sa QLightReading::lux
-*/
-
-/*!
- \qmltype QtMobility.sensors1::Gyroscope
- \instantiates QGyroscope
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \since QtMobility.sensors 1.2
- \inherits QtMobility.sensors1::Sensor
- \brief The Gyroscope type reports on rotational acceleration
- around the X, Y and Z axes.
-
- This type wraps the QGyroscope class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QGyroscope
-*/
-
-/*!
- \qmlproperty GyroscopeReading QtMobility.sensors1::Gyroscope::reading
- Holds the most recent gyroscope reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::Gyroscope::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype GyroscopeReading
- \instantiates QGyroscopeReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \since QtMobility.sensors 1.2
- \inherits QtMobility.sensors1::SensorReading
- \brief The GyroscopeReading type holds the most recent Gyroscope reading.
-
- The GyroscopeReading type holds the most recent Gyroscope reading.
-
- This type wraps the QGyroscopeReading class.
-
- This type cannot be directly created.
-
- \sa QGyroscopeReading
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::GyroscopeReading::x
- \sa QGyroscopeReading::x
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::GyroscopeReading::y
- \sa QGyroscopeReading::y
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::GyroscopeReading::z
- \sa QGyroscopeReading::z
-*/
-
-/*!
- \qmltype QtMobility.sensors1::IRProximitySensor
- \instantiates QIRProximitySensor
- \ingroup qml-sensors_type
- \inqmlmodule QtMobility.sensors 1.3
- \since QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::Sensor
- \brief The IRProximitySensor type reports on infra-red reflectance values.
-
- This type wraps the QIRProximitySensor class.
-
- \sa {QtMobility.sensors QML Limitations}
- \sa QIRProximitySensor
-*/
-
-/*!
- \qmlproperty IRProximityReading QtMobility.sensors1::IRProximitySensor::reading
- Holds the most recent IR proximity reading.
- \sa QSensor::reading
-*/
-
-/*!
- \qmlsignal QtMobility.sensors1::IRProximitySensor::onReadingChanged()
- Called when the reading object changes.
- \sa QSensor::readingChanged()
-*/
-
-/*!
- \qmltype IRProximityReading
- \instantiates QIRProximityReading
- \ingroup qml-sensors_reading
- \inqmlmodule QtMobility.sensors 1.3
- \since QtMobility.sensors 1.3
- \inherits QtMobility.sensors1::SensorReading
- \brief The IRProximityReading type holds the most recent IR proximity reading.
-
- The IRProximityReading type holds the most recent IR proximity reading.
-
- This type wraps the QIRProximityReading class.
-
- This type cannot be directly created.
-
- \sa QIRProximityReading
-*/
-
-/*!
- \qmlproperty qreal QtMobility.sensors1::IRProximityReading::reflectance
- \sa QIRProximityReading::reflectance
-*/
-
diff --git a/src/imports/sensors/sensors.pro b/src/imports/sensors/sensors.pro
index d533aa0c..ac59fcde 100644
--- a/src/imports/sensors/sensors.pro
+++ b/src/imports/sensors/sensors.pro
@@ -5,7 +5,36 @@ IMPORT_VERSION = 1.3 # Doesn't matter, as long as it's a valid version?!
QT += qml sensors
-SOURCES += sensors.cpp
+HEADERS += \
+ qmlsensor.h \
+ qmlsensorrange.h \
+ qmlaccelerometer.h \
+ qmlambientlightsensor.h \
+ qmlcompass.h \
+ qmlgyroscope.h \
+ qmlirproximitysensor.h \
+ qmllightsensor.h \
+ qmlmagnetometer.h \
+ qmlorientationsensor.h \
+ qmlproximitysensor.h \
+ qmltapsensor.h \
+ qmlrotationsensor.h \
+ qmlsensorglobal.h
+SOURCES += sensors.cpp \
+ qmlsensor.cpp \
+ qmlsensorrange.cpp \
+ qmlaccelerometer.cpp \
+ qmlambientlightsensor.cpp \
+ qmlcompass.cpp \
+ qmlgyroscope.cpp \
+ qmlirproximitysensor.cpp \
+ qmllightsensor.cpp \
+ qmlmagnetometer.cpp \
+ qmlorientationsensor.cpp \
+ qmlproximitysensor.cpp \
+ qmltapsensor.cpp \
+ qmlrotationsensor.cpp \
+ qmlsensorglobal.cpp
load(qml_plugin)