summaryrefslogtreecommitdiffstats
path: root/src/sensors
diff options
context:
space:
mode:
Diffstat (limited to 'src/sensors')
-rw-r--r--src/sensors/doc/src/compatmap.qdoc26
-rw-r--r--src/sensors/gestures/qsensorgesture.h4
-rw-r--r--src/sensors/gestures/qsensorgesture_p.h2
-rw-r--r--src/sensors/gestures/qsensorgesturemanager.h4
-rw-r--r--src/sensors/gestures/qsensorgesturemanagerprivate_p.h2
-rw-r--r--src/sensors/gestures/qsensorgestureplugininterface.cpp2
-rw-r--r--src/sensors/gestures/qsensorgestureplugininterface.h4
-rw-r--r--src/sensors/gestures/qsensorgesturerecognizer.h4
-rwxr-xr-xsrc/sensors/make_sensor.pl184
-rw-r--r--src/sensors/qaccelerometer.cpp78
-rw-r--r--src/sensors/qaccelerometer.h24
-rw-r--r--src/sensors/qaccelerometer_p.h15
-rw-r--r--src/sensors/qaltimeter.cpp148
-rw-r--r--src/sensors/qaltimeter.h84
-rw-r--r--src/sensors/qaltimeter_p.h70
-rw-r--r--src/sensors/qambientlightsensor.h4
-rw-r--r--src/sensors/qambientlightsensor_p.h2
-rw-r--r--src/sensors/qambienttemperaturesensor.cpp144
-rw-r--r--src/sensors/qambienttemperaturesensor.h84
-rw-r--r--src/sensors/qambienttemperaturesensor_p.h70
-rw-r--r--src/sensors/qcompass.h4
-rw-r--r--src/sensors/qcompass_p.h2
-rw-r--r--src/sensors/qgyroscope.h4
-rw-r--r--src/sensors/qgyroscope_p.h2
-rw-r--r--src/sensors/qholstersensor.cpp148
-rw-r--r--src/sensors/qholstersensor.h84
-rw-r--r--src/sensors/qholstersensor_p.h70
-rw-r--r--src/sensors/qirproximitysensor.h4
-rw-r--r--src/sensors/qirproximitysensor_p.h2
-rw-r--r--src/sensors/qlightsensor.cpp28
-rw-r--r--src/sensors/qlightsensor.h17
-rw-r--r--src/sensors/qlightsensor_p.h13
-rw-r--r--src/sensors/qmagnetometer.cpp18
-rw-r--r--src/sensors/qmagnetometer.h17
-rw-r--r--src/sensors/qmagnetometer_p.h15
-rw-r--r--src/sensors/qorientationsensor.h4
-rw-r--r--src/sensors/qorientationsensor_p.h2
-rw-r--r--src/sensors/qpressuresensor.cpp147
-rw-r--r--src/sensors/qpressuresensor.h84
-rw-r--r--src/sensors/qpressuresensor_p.h70
-rw-r--r--src/sensors/qproximitysensor.h4
-rw-r--r--src/sensors/qproximitysensor_p.h2
-rw-r--r--src/sensors/qrotationsensor.cpp24
-rw-r--r--src/sensors/qrotationsensor.h17
-rw-r--r--src/sensors/qrotationsensor_p.h15
-rw-r--r--src/sensors/qsensor.cpp303
-rw-r--r--src/sensors/qsensor.h55
-rw-r--r--src/sensors/qsensor_p.h18
-rw-r--r--src/sensors/qsensorbackend.h4
-rw-r--r--src/sensors/qsensormanager.h4
-rw-r--r--src/sensors/qsensorplugin.h4
-rw-r--r--src/sensors/qsensorsglobal.h4
-rw-r--r--src/sensors/qtapsensor.cpp18
-rw-r--r--src/sensors/qtapsensor.h18
-rw-r--r--src/sensors/qtapsensor_p.h15
-rw-r--r--src/sensors/qtiltsensor.h4
-rw-r--r--src/sensors/qtiltsensor_p.h2
-rw-r--r--src/sensors/sensorlog_p.h2
-rw-r--r--src/sensors/sensors.pro4
59 files changed, 2047 insertions, 160 deletions
diff --git a/src/sensors/doc/src/compatmap.qdoc b/src/sensors/doc/src/compatmap.qdoc
index 0fd4951c..abb71a15 100644
--- a/src/sensors/doc/src/compatmap.qdoc
+++ b/src/sensors/doc/src/compatmap.qdoc
@@ -64,10 +64,22 @@
<td bgcolor="gray"></td>
</tr>
<tr>
- <td nowrap="nowrap">Ambient Light Sensor</td>
+ <td nowrap="nowrap">Altimeter</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap">Ambient Light Sensor</td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap">Ambient Temperature Sensor</td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Compass</td>
@@ -82,6 +94,12 @@
<td bgcolor="gray"></td>
</tr>
<tr>
+ <td nowrap="nowrap">Holster Sensor</td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
<td nowrap="nowrap">IR Proximity Sensor</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
@@ -106,6 +124,12 @@
<td bgcolor="green"></td>
</tr>
<tr>
+ <td nowrap="nowrap">Pressure Sensor</td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
<td nowrap="nowrap">Proximity Sensor</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
diff --git a/src/sensors/gestures/qsensorgesture.h b/src/sensors/gestures/qsensorgesture.h
index 2d7e9018..5ae7bb22 100644
--- a/src/sensors/gestures/qsensorgesture.h
+++ b/src/sensors/gestures/qsensorgesture.h
@@ -52,11 +52,8 @@
#include <QtCore/qmetatype.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGesturePrivate;
class Q_SENSORS_EXPORT QSensorGesture : public QObject
@@ -93,7 +90,6 @@ Q_SIGNALS:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTURE_H
diff --git a/src/sensors/gestures/qsensorgesture_p.h b/src/sensors/gestures/qsensorgesture_p.h
index 5bad75b5..4ee19b9c 100644
--- a/src/sensors/gestures/qsensorgesture_p.h
+++ b/src/sensors/gestures/qsensorgesture_p.h
@@ -61,7 +61,6 @@
#include "qsensorgesturemanager.h"
#include <QtCore/private/qmetaobjectbuilder_p.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QSensorGesturePrivate : public QObject
@@ -84,6 +83,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTURE_P_H
diff --git a/src/sensors/gestures/qsensorgesturemanager.h b/src/sensors/gestures/qsensorgesturemanager.h
index da5048a0..96ea9718 100644
--- a/src/sensors/gestures/qsensorgesturemanager.h
+++ b/src/sensors/gestures/qsensorgesturemanager.h
@@ -48,11 +48,8 @@
#include <QtSensors/qsensorgesture.h>
#include <QtSensors/qsensorgesturerecognizer.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGestureManagerPrivate;
class Q_SENSORS_EXPORT QSensorGestureManager : public QObject
{
@@ -78,6 +75,5 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTUREMANAGER_P_H
diff --git a/src/sensors/gestures/qsensorgesturemanagerprivate_p.h b/src/sensors/gestures/qsensorgesturemanagerprivate_p.h
index 50770c77..0994b2ab 100644
--- a/src/sensors/gestures/qsensorgesturemanagerprivate_p.h
+++ b/src/sensors/gestures/qsensorgesturemanagerprivate_p.h
@@ -52,7 +52,6 @@
#include "qsensorgesture.h"
#include "qsensorgesturerecognizer.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QFactoryLoader;
@@ -99,6 +98,5 @@ private slots:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTUREMANAGERPRIVATE_P_H
diff --git a/src/sensors/gestures/qsensorgestureplugininterface.cpp b/src/sensors/gestures/qsensorgestureplugininterface.cpp
index add34c0e..de02f890 100644
--- a/src/sensors/gestures/qsensorgestureplugininterface.cpp
+++ b/src/sensors/gestures/qsensorgestureplugininterface.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
\brief The QSensorGesturePluginInterface class is the pure virtual interface to sensor gesture
plugins.
- \since QtSensors 5.0
+ \since 5.0
The QSensorGesturePluginInterface class is implemented in sensor gesture plugins to register
sensor gesture recognizers with QSensorGestureManager.
diff --git a/src/sensors/gestures/qsensorgestureplugininterface.h b/src/sensors/gestures/qsensorgestureplugininterface.h
index da933c92..330d880c 100644
--- a/src/sensors/gestures/qsensorgestureplugininterface.h
+++ b/src/sensors/gestures/qsensorgestureplugininterface.h
@@ -48,11 +48,8 @@
#include <QtSensors/qsensorgesture.h>
#include <QtSensors/qsensorgesturerecognizer.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGestureRecognizer;
class Q_SENSORS_EXPORT QSensorGesturePluginInterface
@@ -68,6 +65,5 @@ public:
Q_DECLARE_INTERFACE(QSensorGesturePluginInterface, "org.qt-project.QSensorGesturePluginInterface")
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTUREPLUGININTERFACE_H
diff --git a/src/sensors/gestures/qsensorgesturerecognizer.h b/src/sensors/gestures/qsensorgesturerecognizer.h
index bebc5ce6..c35c25be 100644
--- a/src/sensors/gestures/qsensorgesturerecognizer.h
+++ b/src/sensors/gestures/qsensorgesturerecognizer.h
@@ -48,11 +48,8 @@
#include <QtSensors/qsensorgesture.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGestureRecognizerPrivate;
class Q_SENSORS_EXPORT QSensorGestureRecognizer : public QObject
{
@@ -84,6 +81,5 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTURERECOGNIZER_H
diff --git a/src/sensors/make_sensor.pl b/src/sensors/make_sensor.pl
index 4d78a312..27322517 100755
--- a/src/sensors/make_sensor.pl
+++ b/src/sensors/make_sensor.pl
@@ -52,6 +52,15 @@ $sensorbase =~ s/Sensor$//;
my $reading = $sensorbase.'Reading';
my $reading_private = $reading.'Private';
my $filter = $sensorbase.'Filter';
+my $no_q_sensor = $sensor;
+$no_q_sensor =~ s/^.//;
+my $qmlsensor = "Qml".$no_q_sensor;
+my $qmlsensorbase = $qmlsensor;
+$qmlsensorbase =~ s/Sensor$//;
+my $qmlreading = $qmlsensorbase."Reading";
+my $no_q_reading = $no_q_sensor;
+$no_q_reading =~ s/Sensor$//;
+$no_q_reading = $no_q_reading."Reading";
my $filebase;
eval {
@@ -61,9 +70,15 @@ if ($@) {
$filebase = lc($sensor);
}
+my $qmlfilebase = $filebase;
+$qmlfilebase =~ s/^.//;
+$qmlfilebase = "qml".$qmlfilebase;
+
my $pheader = $filebase."_p.h";
my $header = $filebase.".h";
my $source = $filebase.".cpp";
+my $qmlsource = "../imports/sensors/".$qmlfilebase.".cpp";
+my $qmlheader = "../imports/sensors/".$qmlfilebase.".h";
my $pguard = uc($pheader);
$pguard =~ s/\./_/g;
@@ -71,6 +86,163 @@ $pguard =~ s/\./_/g;
my $guard = uc($header);
$guard =~ s/\./_/g;
+my $qmlguard = "QML".uc($no_q_sensor)."_H";
+
+if (! -e $qmlheader) {
+ print "Creating $qmlheader\n";
+ open OUT, ">$qmlheader" or die $!;
+ print OUT '
+#ifndef '.$qmlguard.'
+#define '.$qmlguard.'
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class '.$sensor.';
+
+class '.$qmlsensor.' : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit '.$qmlsensor.'(QObject *parent = 0);
+ ~'.$qmlsensor.'();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ '.$sensor.' *m_sensor;
+};
+
+class '.$qmlreading.' : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop1 READ prop1 NOTIFY prop1Changed)
+public:
+ explicit '.$qmlreading.'('.$sensor.' *sensor);
+ ~'.$qmlreading.'();
+
+ qreal prop1() const;
+
+Q_SIGNALS:
+ void prop1Changed();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ '.$sensor.' *m_sensor;
+ qreal m_prop1;
+};
+
+QT_END_NAMESPACE
+#endif
+';
+ close OUT;
+}
+
+if (! -e $qmlsource) {
+ print "Creating $qmlsource\n";
+ open OUT, ">$qmlsource" or die $!;
+ print OUT '
+#include "qml'.lc($no_q_sensor).'.h"
+#include <'.$sensor.'>
+
+/*!
+ \qmltype '.$no_q_sensor.'
+ \instantiates '.$qmlsensor.'
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.[INSERT VERSION HERE]
+ \inherits Sensor
+ \brief The '.$no_q_sensor.' element reports on fubbleness.
+
+ The '.$no_q_sensor.' element reports on fubbleness.
+
+ This element wraps the '.$sensor.' class. Please see the documentation for
+ '.$sensor.' for details.
+
+ \sa '.$no_q_reading.'
+*/
+
+'.$qmlsensor.'::'.$qmlsensor.'(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new '.$sensor.'(this))
+{
+}
+
+'.$qmlsensor.'::~'.$qmlsensor.'()
+{
+}
+
+QmlSensorReading *'.$qmlsensor.'::createReading() const
+{
+ return new '.$qmlreading.'(m_sensor);
+}
+
+QSensor *'.$qmlsensor.'::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype '.$no_q_reading.'
+ \instantiates '.$qmlreading.'
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.[INSERT VERSION HERE]
+ \inherits SensorReading
+ \brief The '.$no_q_reading.' element holds the most recent '.$no_q_sensor.' reading.
+
+ The '.$no_q_reading.' element holds the most recent '.$no_q_sensor.' reading.
+
+ This element wraps the '.$reading.' class. Please see the documentation for
+ '.$reading.' for details.
+
+ This element cannot be directly created.
+*/
+
+'.$qmlreading.'::'.$qmlreading.'('.$sensor.' *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_prop1(0)
+{
+}
+
+'.$qmlreading.'::~'.$qmlreading.'()
+{
+}
+
+/*!
+ \qmlproperty qreal '.$no_q_reading.'::prop1
+ This property holds the fubble of the device.
+
+ Please see '.$reading.'::prop1 for information about this property.
+*/
+
+qreal '.$qmlreading.'::prop1() const
+{
+ return m_prop1;
+}
+
+QSensorReading *'.$qmlreading.'::reading() const
+{
+ return m_sensor->reading();
+}
+
+void '.$qmlreading.'::readingUpdate()
+{
+ qreal prop1 = m_sensor->reading()->prop1();
+ if (m_prop1 != prop1) {
+ m_prop1 = prop1;
+ Q_EMIT prop1Changed();
+ }
+}
+';
+ close OUT;
+}
+
if (! -e $pheader) {
print "Creating $pheader\n";
open OUT, ">$pheader" or die $!;
@@ -89,7 +261,6 @@ if (! -e $pheader) {
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class '.$reading_private.'
@@ -110,7 +281,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
';
@@ -126,11 +296,8 @@ if (! -e $header) {
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class '.$reading_private.';
class Q_SENSORS_EXPORT '.$reading.' : public QSensorReading
@@ -166,7 +333,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
';
@@ -188,7 +354,7 @@ IMPLEMENT_READING('.$reading.')
\class '.$reading.'
\ingroup sensors_reading
\inmodule QtSensors
- \since QtSensors 5.[INSERT VERSION HERE]
+ \since 5.[INSERT VERSION HERE]
\brief The '.$reading.' class holds readings from the [X] sensor.
@@ -226,7 +392,7 @@ void '.$reading.'::setMyprop(qreal myprop)
\class '.$filter.'
\ingroup sensors_filter
\inmodule QtSensors
- \since QtSensors 5.[INSERT VERSION HERE]
+ \since 5.[INSERT VERSION HERE]
\brief The '.$filter.' class is a convenience wrapper around QSensorFilter.
@@ -248,7 +414,7 @@ char const * const '.$sensor.'::type("'.$sensor.'");
\class '.$sensor.'
\ingroup sensors_type
\inmodule QtSensors
- \since QtSensors 5.[INSERT VERSION HERE]
+ \since 5.[INSERT VERSION HERE]
\brief The '.$sensor.' class is a convenience wrapper around QSensor.
diff --git a/src/sensors/qaccelerometer.cpp b/src/sensors/qaccelerometer.cpp
index 4aeedf42..9b9bd346 100644
--- a/src/sensors/qaccelerometer.cpp
+++ b/src/sensors/qaccelerometer.cpp
@@ -153,6 +153,29 @@ void QAccelerometerReading::setZ(qreal z)
char const * const QAccelerometer::type("QAccelerometer");
/*!
+ \enum QAccelerometer::AccelerationMode
+
+ \brief This enum represents the acceleration mode of an acceleration sensor.
+
+ The acceleration mode controls how the sensor reports acceleration. QAccelerometer::Combined
+ is the only mode in which the values can be directly physically measured, the others are an
+ approximation.
+
+ \value Combined Both the acceleration caused by gravity and the acceleration caused by the
+ user moving the device is reported combined.
+ \value Gravity Only the acceleration caused by gravity is reported. Movements of the device
+ caused by the user have no effect other than changing the direction when the
+ device is rotated.
+ \value User Only the acceleration caused by the user moving the device is reported, the
+ effect of gravity is canceled out. A device at rest therefore should report
+ values of, or close to, zero.
+ In other APIs, this mode might be known as \e {linear acceleration}.
+
+ \sa QAccelerometer::accelerationMode
+ \since 5.1
+*/
+
+/*!
\class QAccelerometer
\ingroup sensors_type
\inmodule QtSensors
@@ -161,7 +184,11 @@ char const * const QAccelerometer::type("QAccelerometer");
The only behavioural difference is that this class sets the type properly.
- This class also features a reading() function that returns a QAccelerometerReading instead of a QSensorReading.
+ It also supports changing the acceleration mode, which controls whether the force of gravity
+ is included in the accelerometer values or not.
+
+ Furthermore, this class features a reading() function that returns a QAccelerometerReading
+ instead of a QSensorReading.
For details about how the sensor works, see \l QAccelerometerReading.
@@ -172,7 +199,7 @@ char const * const QAccelerometer::type("QAccelerometer");
Construct the sensor as a child of \a parent.
*/
QAccelerometer::QAccelerometer(QObject *parent)
- : QSensor(QAccelerometer::type, parent)
+ : QSensor(QAccelerometer::type, *new QAccelerometerPrivate, parent)
{
}
@@ -184,6 +211,45 @@ QAccelerometer::~QAccelerometer()
}
/*!
+ \property QAccelerometer::accelerationMode
+ \brief The acceleration mode controls how acceleration values are reported.
+ \since 5.1
+
+ The acceleration mode controls how the acceleration sensor reports its values.
+ The default mode is QAccelerometer::Combined, which means the acceleration caused
+ by gravity is included in the reported values.
+
+ Acceleration caused by gravity and acceleration caused by the user moving the device
+ are physically impossible to distinguish because of general relativity. Most devices use
+ sensor fusion to figure out which parts of the acceleration is caused by gravity, for example
+ by using a rotation sensor to calculate the gravity direction and assuming a fixed magnitude
+ for gravity. Therefore the result is only an approximation and may be inaccurate.
+ The QAccelerometer::Combined mode is the most accurate one, as it does not involve approximating
+ the gravity.
+
+ Not all backends and devices might support setting the acceleration mode. For those cases, the
+ default mode QAccelerometer::Combined is used, changing it has no effect.
+*/
+QAccelerometer::AccelerationMode QAccelerometer::accelerationMode() const
+{
+ Q_D(const QAccelerometer);
+ return d->accelerationMode;
+}
+
+/*!
+ Sets the acceleration mode to \a accelerationMode.
+ \since 5.1
+*/
+void QAccelerometer::setAccelerationMode(QAccelerometer::AccelerationMode accelerationMode)
+{
+ Q_D(QAccelerometer);
+ if (d->accelerationMode != accelerationMode) {
+ d->accelerationMode = accelerationMode;
+ emit accelerationModeChanged(d->accelerationMode);
+ }
+}
+
+/*!
\fn QAccelerometer::reading() const
Returns the reading class for this sensor.
@@ -191,6 +257,14 @@ QAccelerometer::~QAccelerometer()
\sa QSensor::reading()
*/
+/*!
+ \fn QAccelerometer::accelerationModeChanged(AccelerationMode accelerationMode)
+
+ Emitted when the acceleration mode was changed.
+
+ \since 5.1
+*/
+
#include "moc_qaccelerometer.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qaccelerometer.h b/src/sensors/qaccelerometer.h
index 734ce97e..4478235c 100644
--- a/src/sensors/qaccelerometer.h
+++ b/src/sensors/qaccelerometer.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QAccelerometerReadingPrivate;
class Q_SENSORS_EXPORT QAccelerometerReading : public QSensorReading
@@ -77,21 +74,40 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QAccelerometerReading*>(reading)); }
};
+class QAccelerometerPrivate;
+
class Q_SENSORS_EXPORT QAccelerometer : public QSensor
{
Q_OBJECT
+ Q_ENUMS(AccelerationMode)
+ Q_PROPERTY(AccelerationMode accelerationMode READ accelerationMode WRITE setAccelerationMode
+ NOTIFY accelerationModeChanged)
public:
explicit QAccelerometer(QObject *parent = 0);
virtual ~QAccelerometer();
+
+ // Keep this enum in sync with QmlAccelerometer::AccelerationMode
+ enum AccelerationMode {
+ Combined,
+ Gravity,
+ User
+ };
+
+ AccelerationMode accelerationMode() const;
+ void setAccelerationMode(AccelerationMode accelerationMode);
+
QAccelerometerReading *reading() const { return static_cast<QAccelerometerReading*>(QSensor::reading()); }
static char const * const type;
+Q_SIGNALS:
+ void accelerationModeChanged(AccelerationMode accelerationMode);
+
private:
+ Q_DECLARE_PRIVATE(QAccelerometer)
Q_DISABLE_COPY(QAccelerometer)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qaccelerometer_p.h b/src/sensors/qaccelerometer_p.h
index dd60fd19..e8023db2 100644
--- a/src/sensors/qaccelerometer_p.h
+++ b/src/sensors/qaccelerometer_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
class QAccelerometerReadingPrivate
@@ -71,8 +72,18 @@ public:
qreal z;
};
+class QAccelerometerPrivate : public QSensorPrivate
+{
+public:
+ QAccelerometerPrivate()
+ : accelerationMode(QAccelerometer::Combined)
+ {
+ }
+
+ QAccelerometer::AccelerationMode accelerationMode;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qaltimeter.cpp b/src/sensors/qaltimeter.cpp
new file mode 100644
index 00000000..6a7caa7b
--- /dev/null
+++ b/src/sensors/qaltimeter.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qaltimeter.h>
+#include "qaltimeter_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QAltimeterReading)
+
+/*!
+ \class QAltimeterReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAltimeterReading class holds readings from the altimeter sensor.
+
+ The altitude is reported in meters relative to mean sea level.
+
+ On BlackBerry, the altimeter uses a combination of pressure and location to determine
+ the altitude, as using pressure alone would yield to inaccurate results due to changes
+ in air pressure caused by the weather. The location information is used to compensate for
+ the weather. This requires that the user has enabled location services in the global
+ settings.
+*/
+
+/*!
+ \property QAltimeterReading::altitude
+ \brief The altitude in meters relative to mean sea level.
+*/
+
+qreal QAltimeterReading::altitude() const
+{
+ return d->altitude;
+}
+
+/*!
+ Sets the altitude to \a altitude.
+*/
+void QAltimeterReading::setAltitude(qreal altitude)
+{
+ d->altitude = altitude;
+}
+
+// =====================================================================
+
+/*!
+ \class QAltimeterFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAltimeterFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QAltimeterReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QAltimeterFilter::filter(QAltimeterReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QAltimeter::type("QAltimeter");
+
+/*!
+ \class QAltimeter
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAltimeter class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QAltimeterReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QAltimeterReading.
+
+ \sa QAltimeterReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QAltimeter::QAltimeter(QObject *parent)
+ : QSensor(QAltimeter::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QAltimeter::~QAltimeter()
+{
+}
+
+/*!
+ \fn QAltimeter::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qaltimeter.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qaltimeter.h b/src/sensors/qaltimeter.h
new file mode 100644
index 00000000..6b7d2232
--- /dev/null
+++ b/src/sensors/qaltimeter.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QALTIMETER_H
+#define QALTIMETER_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAltimeterReadingPrivate;
+
+class Q_SENSORS_EXPORT QAltimeterReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal altitude READ altitude)
+ DECLARE_READING(QAltimeterReading)
+public:
+ qreal altitude() const;
+ void setAltitude(qreal altitude);
+};
+
+class Q_SENSORS_EXPORT QAltimeterFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QAltimeterReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QAltimeterReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QAltimeter : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QAltimeter(QObject *parent = 0);
+ ~QAltimeter();
+ QAltimeterReading *reading() const { return static_cast<QAltimeterReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QAltimeter)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qaltimeter_p.h b/src/sensors/qaltimeter_p.h
new file mode 100644
index 00000000..dfc3ebd3
--- /dev/null
+++ b/src/sensors/qaltimeter_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QALTIMETER_P_H
+#define QALTIMETER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QAltimeterReadingPrivate
+{
+public:
+ QAltimeterReadingPrivate()
+ : altitude(0)
+ {
+ }
+
+ qreal altitude;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qambientlightsensor.h b/src/sensors/qambientlightsensor.h
index 8b69fc2c..3dae639c 100644
--- a/src/sensors/qambientlightsensor.h
+++ b/src/sensors/qambientlightsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QAmbientLightReadingPrivate;
class Q_SENSORS_EXPORT QAmbientLightReading : public QSensorReading
@@ -93,7 +90,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qambientlightsensor_p.h b/src/sensors/qambientlightsensor_p.h
index 5faf8530..c921c6bf 100644
--- a/src/sensors/qambientlightsensor_p.h
+++ b/src/sensors/qambientlightsensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QAmbientLightReadingPrivate
@@ -68,7 +67,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qambienttemperaturesensor.cpp b/src/sensors/qambienttemperaturesensor.cpp
new file mode 100644
index 00000000..9ecde6df
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qambienttemperaturesensor.h>
+#include "qambienttemperaturesensor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QAmbientTemperatureReading)
+
+/*!
+ \class QAmbientTemperatureReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAmbientTemperatureReading class holds readings of the ambient temperature.
+
+ The ambient (room) temperature is the temperature in degree Celsius.
+*/
+
+/*!
+ \property QAmbientTemperatureReading::temperature
+ \brief The ambient temperature
+
+ Measured in degree Celsius.
+*/
+
+qreal QAmbientTemperatureReading::temperature() const
+{
+ return d->temperature;
+}
+
+/*!
+ Sets ambient temperature to \a temperature.
+*/
+void QAmbientTemperatureReading::setTemperature(qreal temperature)
+{
+ d->temperature = temperature;
+}
+
+// =====================================================================
+
+/*!
+ \class QAmbientTemperatureFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAmbientTemperatureFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QAmbientTemperatureReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QAmbientTemperatureFilter::filter(QAmbientTemperatureReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QAmbientTemperatureSensor::type("QAmbientTemperatureSensor");
+
+/*!
+ \class QAmbientTemperatureSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAmbientTemperatureSensor class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QAmbientTemperatureReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QAmbientTemperatureReading.
+
+ \sa QAmbientTemperatureReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QAmbientTemperatureSensor::QAmbientTemperatureSensor(QObject *parent)
+ : QSensor(QAmbientTemperatureSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QAmbientTemperatureSensor::~QAmbientTemperatureSensor()
+{
+}
+
+/*!
+ \fn QAmbientTemperatureSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qambienttemperaturesensor.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qambienttemperaturesensor.h b/src/sensors/qambienttemperaturesensor.h
new file mode 100644
index 00000000..134e5a92
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QAMBIENTTEMPERATURESENSOR_H
+#define QAMBIENTTEMPERATURESENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAmbientTemperatureReadingPrivate;
+
+class Q_SENSORS_EXPORT QAmbientTemperatureReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal temperature READ temperature)
+ DECLARE_READING(QAmbientTemperatureReading)
+public:
+ qreal temperature() const;
+ void setTemperature(qreal temperature);
+};
+
+class Q_SENSORS_EXPORT QAmbientTemperatureFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QAmbientTemperatureReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QAmbientTemperatureReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QAmbientTemperatureSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QAmbientTemperatureSensor(QObject *parent = 0);
+ ~QAmbientTemperatureSensor();
+ QAmbientTemperatureReading *reading() const { return static_cast<QAmbientTemperatureReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QAmbientTemperatureSensor)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qambienttemperaturesensor_p.h b/src/sensors/qambienttemperaturesensor_p.h
new file mode 100644
index 00000000..63fe1452
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QAMBIENTTEMPERATURESENSOR_P_H
+#define QAMBIENTTEMPERATURESENSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QAmbientTemperatureReadingPrivate
+{
+public:
+ QAmbientTemperatureReadingPrivate()
+ : temperature(0)
+ {
+ }
+
+ qreal temperature;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qcompass.h b/src/sensors/qcompass.h
index 17b06584..8b858ff7 100644
--- a/src/sensors/qcompass.h
+++ b/src/sensors/qcompass.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QCompassReadingPrivate;
class Q_SENSORS_EXPORT QCompassReading : public QSensorReading
@@ -87,7 +84,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qcompass_p.h b/src/sensors/qcompass_p.h
index 04a3b798..49da19b2 100644
--- a/src/sensors/qcompass_p.h
+++ b/src/sensors/qcompass_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QCompassReadingPrivate
@@ -70,7 +69,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qgyroscope.h b/src/sensors/qgyroscope.h
index 7589c6ce..32c01da8 100644
--- a/src/sensors/qgyroscope.h
+++ b/src/sensors/qgyroscope.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QGyroscopeReadingPrivate;
class Q_SENSORS_EXPORT QGyroscopeReading : public QSensorReading
@@ -91,7 +88,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qgyroscope_p.h b/src/sensors/qgyroscope_p.h
index 21bcde41..a5e42766 100644
--- a/src/sensors/qgyroscope_p.h
+++ b/src/sensors/qgyroscope_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QGyroscopeReadingPrivate
@@ -72,7 +71,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qholstersensor.cpp b/src/sensors/qholstersensor.cpp
new file mode 100644
index 00000000..761910f2
--- /dev/null
+++ b/src/sensors/qholstersensor.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qholstersensor.h>
+#include "qholstersensor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QHolsterReading)
+
+/*!
+ \class QHolsterReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QHolsterReading class holds readings from the holster sensor.
+
+ \section2 QHolsterReading Units
+ The holster sensor can detect if a device is holstered or not. A holster is a pocket,
+ similar to a gun holster, specifically made for the device. If the device is inside of this
+ pocket, it is holstered. The holster supports the device in detecting whether the device is
+ holstered or not.
+*/
+
+/*!
+ \property QHolsterReading::holstered
+ \brief A value indicating whether the device is holstered.
+
+ \sa {QHolsterReading Units}
+*/
+
+bool QHolsterReading::holstered() const
+{
+ return d->holstered;
+}
+
+/*!
+ Sets the holstered value to \a holstered.
+*/
+void QHolsterReading::setHolstered(bool holstered)
+{
+ d->holstered = holstered;
+}
+
+// =====================================================================
+
+/*!
+ \class QHolsterFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QHolsterFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QHolsterReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QHolsterFilter::filter(QHolsterReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QHolsterSensor::type("QHolsterSensor");
+
+/*!
+ \class QHolsterSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QHolsterSensor class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QHolsterReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QHolsterReading.
+
+ \sa QHolsterReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QHolsterSensor::QHolsterSensor(QObject *parent)
+ : QSensor(QHolsterSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QHolsterSensor::~QHolsterSensor()
+{
+}
+
+/*!
+ \fn QHolsterSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qholstersensor.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qholstersensor.h b/src/sensors/qholstersensor.h
new file mode 100644
index 00000000..f44b381e
--- /dev/null
+++ b/src/sensors/qholstersensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QHOLSTERSENSOR_H
+#define QHOLSTERSENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QHolsterReadingPrivate;
+
+class Q_SENSORS_EXPORT QHolsterReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(bool holstered READ holstered)
+ DECLARE_READING(QHolsterReading)
+public:
+ bool holstered() const;
+ void setHolstered(bool holstered);
+};
+
+class Q_SENSORS_EXPORT QHolsterFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QHolsterReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QHolsterReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QHolsterSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QHolsterSensor(QObject *parent = 0);
+ ~QHolsterSensor();
+ QHolsterReading *reading() const { return static_cast<QHolsterReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QHolsterSensor)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qholstersensor_p.h b/src/sensors/qholstersensor_p.h
new file mode 100644
index 00000000..a90613f0
--- /dev/null
+++ b/src/sensors/qholstersensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QHOLSTERSENSOR_P_H
+#define QHOLSTERSENSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QHolsterReadingPrivate
+{
+public:
+ QHolsterReadingPrivate()
+ : holstered(false)
+ {
+ }
+
+ bool holstered;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qirproximitysensor.h b/src/sensors/qirproximitysensor.h
index c6b8925b..29eb49cd 100644
--- a/src/sensors/qirproximitysensor.h
+++ b/src/sensors/qirproximitysensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QIRProximityReadingPrivate;
class Q_SENSORS_EXPORT QIRProximityReading : public QSensorReading
@@ -83,7 +80,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qirproximitysensor_p.h b/src/sensors/qirproximitysensor_p.h
index 6241b629..9b16af56 100644
--- a/src/sensors/qirproximitysensor_p.h
+++ b/src/sensors/qirproximitysensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QIRProximityReadingPrivate
@@ -68,6 +67,5 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qlightsensor.cpp b/src/sensors/qlightsensor.cpp
index b712bb6e..f02f6b10 100644
--- a/src/sensors/qlightsensor.cpp
+++ b/src/sensors/qlightsensor.cpp
@@ -120,7 +120,7 @@ char const * const QLightSensor::type("QLightSensor");
Construct the sensor as a child of \a parent.
*/
QLightSensor::QLightSensor(QObject *parent)
- : QSensor(QLightSensor::type, parent)
+ : QSensor(QLightSensor::type, *new QLightSensorPrivate, parent)
{
}
@@ -144,7 +144,33 @@ QLightSensor::~QLightSensor()
\brief a value indicating the field of view.
This is an angle that represents the field of view of the sensor.
+
+ Not all light sensor support retrieving their field of view. For sensors
+ that don't support this property, the value will be 0. Whether the field of
+ view is supported can be checked with QSensor::isFeatureSupported() and the
+ QSensor::FieldOfView flag.
+*/
+
+qreal QLightSensor::fieldOfView() const
+{
+ Q_D(const QLightSensor);
+ return d->fieldOfView;
+}
+
+/*!
+ \since 5.1
+
+ Sets the field of view. This is to be called from the
+ backend.
*/
+void QLightSensor::setFieldOfView(qreal fieldOfView)
+{
+ Q_D(QLightSensor);
+ if (d->fieldOfView != fieldOfView) {
+ d->fieldOfView = fieldOfView;
+ emit fieldOfViewChanged(fieldOfView);
+ }
+}
#include "moc_qlightsensor.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qlightsensor.h b/src/sensors/qlightsensor.h
index 096df931..1da84498 100644
--- a/src/sensors/qlightsensor.h
+++ b/src/sensors/qlightsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QLightReadingPrivate;
class Q_SENSORS_EXPORT QLightReading : public QSensorReading
@@ -69,24 +66,30 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QLightReading*>(reading)); }
};
+class QLightSensorPrivate;
+
class Q_SENSORS_EXPORT QLightSensor : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(qreal fieldOfView)
-#endif
+ Q_PROPERTY(qreal fieldOfView READ fieldOfView NOTIFY fieldOfViewChanged)
public:
explicit QLightSensor(QObject *parent = 0);
virtual ~QLightSensor();
QLightReading *reading() const { return static_cast<QLightReading*>(QSensor::reading()); }
static char const * const type;
+ qreal fieldOfView() const;
+ void setFieldOfView(qreal fieldOfView);
+
+Q_SIGNALS:
+ void fieldOfViewChanged(qreal fieldOfView);
+
private:
+ Q_DECLARE_PRIVATE(QLightSensor)
Q_DISABLE_COPY(QLightSensor)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qlightsensor_p.h b/src/sensors/qlightsensor_p.h
index da84463e..a9df63e4 100644
--- a/src/sensors/qlightsensor_p.h
+++ b/src/sensors/qlightsensor_p.h
@@ -55,7 +55,6 @@
#include "qsensor_p.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QLightReadingPrivate : public QSensorReadingPrivate
@@ -69,8 +68,18 @@ public:
qreal lux;
};
+class QLightSensorPrivate : public QSensorPrivate
+{
+public:
+ QLightSensorPrivate()
+ : fieldOfView(0)
+ {
+ }
+
+ qreal fieldOfView;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qmagnetometer.cpp b/src/sensors/qmagnetometer.cpp
index 60b2df83..f5f563aa 100644
--- a/src/sensors/qmagnetometer.cpp
+++ b/src/sensors/qmagnetometer.cpp
@@ -210,7 +210,7 @@ char const * const QMagnetometer::type("QMagnetometer");
Construct the sensor as a child of \a parent.
*/
QMagnetometer::QMagnetometer(QObject *parent)
- : QSensor(QMagnetometer::type, parent)
+ : QSensor(QMagnetometer::type, *new QMagnetometerPrivate, parent)
{
}
@@ -236,10 +236,24 @@ QMagnetometer::~QMagnetometer()
Set to true to return geomagnetic flux density.
Set to false (the default) to return raw magnetic flux density.
- Note that you must access this property via QObject::property() and QObject::setProperty().
The property must be set before calling start().
*/
+bool QMagnetometer::returnGeoValues() const
+{
+ Q_D(const QMagnetometer);
+ return d->returnGeoValues;
+}
+
+void QMagnetometer::setReturnGeoValues(bool returnGeoValues)
+{
+ Q_D(QMagnetometer);
+ if (d->returnGeoValues != returnGeoValues) {
+ d->returnGeoValues = returnGeoValues;
+ emit returnGeoValuesChanged(returnGeoValues);
+ }
+}
+
#include "moc_qmagnetometer.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qmagnetometer.h b/src/sensors/qmagnetometer.h
index 60e142d4..93b6157f 100644
--- a/src/sensors/qmagnetometer.h
+++ b/src/sensors/qmagnetometer.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QMagnetometerReadingPrivate;
class Q_SENSORS_EXPORT QMagnetometerReading : public QSensorReading
@@ -81,24 +78,30 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QMagnetometerReading*>(reading)); }
};
+class QMagnetometerPrivate;
+
class Q_SENSORS_EXPORT QMagnetometer : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(bool returnGeoValues)
-#endif
+ Q_PROPERTY(bool returnGeoValues READ returnGeoValues WRITE setReturnGeoValues NOTIFY returnGeoValuesChanged)
public:
explicit QMagnetometer(QObject *parent = 0);
virtual ~QMagnetometer();
QMagnetometerReading *reading() const { return static_cast<QMagnetometerReading*>(QSensor::reading()); }
static char const * const type;
+ bool returnGeoValues() const;
+ void setReturnGeoValues(bool returnGeoValues);
+
+Q_SIGNALS:
+ void returnGeoValuesChanged(bool returnGeoValues);
+
private:
+ Q_DECLARE_PRIVATE(QMagnetometer)
Q_DISABLE_COPY(QMagnetometer)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qmagnetometer_p.h b/src/sensors/qmagnetometer_p.h
index 2b42cfd7..3c38e6c8 100644
--- a/src/sensors/qmagnetometer_p.h
+++ b/src/sensors/qmagnetometer_p.h
@@ -53,9 +53,21 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
+class QMagnetometerPrivate : public QSensorPrivate
+{
+public:
+ QMagnetometerPrivate()
+ : returnGeoValues(false)
+ {
+ }
+
+ bool returnGeoValues;
+};
+
class QMagnetometerReadingPrivate
{
public:
@@ -74,7 +86,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qorientationsensor.h b/src/sensors/qorientationsensor.h
index f577df7a..082598fb 100644
--- a/src/sensors/qorientationsensor.h
+++ b/src/sensors/qorientationsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QOrientationReadingPrivate;
class Q_SENSORS_EXPORT QOrientationReading : public QSensorReading
@@ -94,7 +91,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qorientationsensor_p.h b/src/sensors/qorientationsensor_p.h
index 09a65a71..433f3dd9 100644
--- a/src/sensors/qorientationsensor_p.h
+++ b/src/sensors/qorientationsensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QOrientationReadingPrivate
@@ -68,7 +67,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qpressuresensor.cpp b/src/sensors/qpressuresensor.cpp
new file mode 100644
index 00000000..ea8a79bb
--- /dev/null
+++ b/src/sensors/qpressuresensor.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qpressuresensor.h>
+#include "qpressuresensor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QPressureReading)
+
+/*!
+ \class QPressureReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QPressureReading class holds readings from the pressure sensor.
+
+ \section2 QPressureReading Units
+
+ The pressure sensor returns atmospheric pressure values in Pascals.
+*/
+
+/*!
+ \property QPressureReading::pressure
+ \brief The measured atmospheric pressure.
+
+ Returned as Pascals.
+ \sa {QPressureReading Units}
+*/
+
+qreal QPressureReading::pressure() const
+{
+ return d->pressure;
+}
+
+/*!
+ Sets the pressure to \a pressure.
+*/
+void QPressureReading::setPressure(qreal pressure)
+{
+ d->pressure = pressure;
+}
+
+// =====================================================================
+
+/*!
+ \class QPressureFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QPressureFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QPressureReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QPressureFilter::filter(QPressureReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QPressureSensor::type("QPressureSensor");
+
+/*!
+ \class QPressureSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QPressureSensor class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QPressureReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QPressureReading.
+
+ \sa QPressureReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QPressureSensor::QPressureSensor(QObject *parent)
+ : QSensor(QPressureSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QPressureSensor::~QPressureSensor()
+{
+}
+
+/*!
+ \fn QPressureSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qpressuresensor.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qpressuresensor.h b/src/sensors/qpressuresensor.h
new file mode 100644
index 00000000..50379b52
--- /dev/null
+++ b/src/sensors/qpressuresensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QPRESSURESENSOR_H
+#define QPRESSURESENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPressureReadingPrivate;
+
+class Q_SENSORS_EXPORT QPressureReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal pressure READ pressure)
+ DECLARE_READING(QPressureReading)
+public:
+ qreal pressure() const;
+ void setPressure(qreal pressure);
+};
+
+class Q_SENSORS_EXPORT QPressureFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QPressureReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QPressureReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QPressureSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QPressureSensor(QObject *parent = 0);
+ ~QPressureSensor();
+ QPressureReading *reading() const { return static_cast<QPressureReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QPressureSensor)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qpressuresensor_p.h b/src/sensors/qpressuresensor_p.h
new file mode 100644
index 00000000..1c74e7f1
--- /dev/null
+++ b/src/sensors/qpressuresensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QPRESSURESENSOR_P_H
+#define QPRESSURESENSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QPressureReadingPrivate
+{
+public:
+ QPressureReadingPrivate()
+ : pressure(0)
+ {
+ }
+
+ qreal pressure;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qproximitysensor.h b/src/sensors/qproximitysensor.h
index efabead9..cc8eb78b 100644
--- a/src/sensors/qproximitysensor.h
+++ b/src/sensors/qproximitysensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QProximityReadingPrivate;
class Q_SENSORS_EXPORT QProximityReading : public QSensorReading
@@ -83,7 +80,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qproximitysensor_p.h b/src/sensors/qproximitysensor_p.h
index 57125d50..8f951e6a 100644
--- a/src/sensors/qproximitysensor_p.h
+++ b/src/sensors/qproximitysensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QProximityReadingPrivate
@@ -68,7 +67,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qrotationsensor.cpp b/src/sensors/qrotationsensor.cpp
index 9acc1cd8..ea0515ca 100644
--- a/src/sensors/qrotationsensor.cpp
+++ b/src/sensors/qrotationsensor.cpp
@@ -201,7 +201,7 @@ char const * const QRotationSensor::type("QRotationSensor");
Construct the sensor as a child of \a parent.
*/
QRotationSensor::QRotationSensor(QObject *parent)
- : QSensor(QRotationSensor::type, parent)
+ : QSensor(QRotationSensor::type, *new QRotationSensorPrivate, parent)
{
}
@@ -228,6 +228,28 @@ QRotationSensor::~QRotationSensor()
Returns false if z is not available.
*/
+bool QRotationSensor::hasZ() const
+{
+ Q_D(const QRotationSensor);
+ return (d->hasZ);
+}
+
+/*!
+ \since 5.1
+
+ Sets whether the z angle is available. This is to be called from the
+ backend. By default the hasZ property is true, so a backend only has to
+ call this if its rotation sensor can not report z angles.
+*/
+void QRotationSensor::setHasZ(bool hasZ)
+{
+ Q_D(QRotationSensor);
+ if (d->hasZ != hasZ) {
+ d->hasZ = hasZ;
+ emit hasZChanged(hasZ);
+ }
+}
+
#include "moc_qrotationsensor.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qrotationsensor.h b/src/sensors/qrotationsensor.h
index c049238c..68a0d1d3 100644
--- a/src/sensors/qrotationsensor.h
+++ b/src/sensors/qrotationsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QRotationReadingPrivate;
class Q_SENSORS_EXPORT QRotationReading : public QSensorReading
@@ -74,24 +71,30 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QRotationReading*>(reading)); }
};
+class QRotationSensorPrivate;
+
class Q_SENSORS_EXPORT QRotationSensor : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(bool hasZ)
-#endif
+ Q_PROPERTY(bool hasZ READ hasZ NOTIFY hasZChanged)
public:
explicit QRotationSensor(QObject *parent = 0);
virtual ~QRotationSensor();
QRotationReading *reading() const { return static_cast<QRotationReading*>(QSensor::reading()); }
static char const * const type;
+ bool hasZ() const;
+ void setHasZ(bool hasZ);
+
+Q_SIGNALS:
+ void hasZChanged(bool hasZ);
+
private:
+ Q_DECLARE_PRIVATE(QRotationSensor)
Q_DISABLE_COPY(QRotationSensor)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qrotationsensor_p.h b/src/sensors/qrotationsensor_p.h
index f6ce13ff..401c2143 100644
--- a/src/sensors/qrotationsensor_p.h
+++ b/src/sensors/qrotationsensor_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
class QRotationReadingPrivate
@@ -71,8 +72,18 @@ public:
qreal z;
};
+class QRotationSensorPrivate : public QSensorPrivate
+{
+public:
+ QRotationSensorPrivate()
+ : hasZ(true)
+ {
+ }
+
+ bool hasZ;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensor.cpp b/src/sensors/qsensor.cpp
index 81cb6530..01a4f7b7 100644
--- a/src/sensors/qsensor.cpp
+++ b/src/sensors/qsensor.cpp
@@ -176,6 +176,40 @@ void QSensorPrivate::init(const QByteArray &sensorType)
The sensor data is delivered via QSensorReading and its sub-classes.
+ \section1 Orientation
+
+ Some sensors react to screen orientation changes, such as QAccelerometer, QMagnetometer and
+ QRotationSensor. These are so called \e orientable sensors. For orientable sensors,
+ QSensor supports changing the reporting of the reading values based on the orientation of the
+ screen.
+
+ For orientable sensors, the axesOrientationMode property controls how the orientation affects
+ the reading values.
+
+ In the default mode, QSensor::FixedOrientation, the reading values remain
+ unaffected by the orientation. In the QSensor::AutomaticOrientation mode, the reading
+ values are automatically rotated by taking the current screen orientation into account. And
+ finally, in the QSensor::UserOrientation mode, the reading values are rotated
+ according to a user-specified orientation.
+
+ The functionality of this is only available if it is supported by the backend and if the sensor
+ is orientable, which can be checked by calling QSensor::isFeatureSupported()
+ with the QSensor::AxesOrientation flag.
+
+ The orientation values here are always of the screen orientation, not the device orientation.
+ The screen orientation is the orientation of the GUI. For example when rotating a device by 90
+ degrees counter-clockwise, the screen orientation compensates for that by rotating 90 degrees
+ clockwise, to the effect that the GUI is still facing upright after the device has been rotated.
+ Note that applications can lock the screen orientation, for example to force portrait or landscape
+ mode. For locked orientations, orientable sensors will not react with reading changes if the device
+ orientation is changed, as orientable sensors react to screen orientation changes only. This makes
+ sense, as the purpose of orientable sensors is to keep the sensor orientation in sync with the screen
+ orientation.
+
+ The orientation values range from 0 to 270 degrees. The orientation is applied in clockwise direction,
+ e.g. an orientation value of 90 degrees means that the screen has been rotated 90 degress to the right
+ from its origin position, to compensate a device rotation of 90 degrees to the left.
+
\sa QSensorReading
*/
@@ -189,6 +223,9 @@ void QSensorPrivate::init(const QByteArray &sensorType)
QSensor::bufferSize property.
\value AlwaysOn The backend supports changing the policy on whether to suspend when idle,
controlled by the QSensor::alwaysOn property.
+ \value SkipDuplicates The backend supports skipping of same or very similar successive
+ readings. This can be enabled by setting the QSensor::skipDuplicates
+ property to true.
The features of QMagnetometer are:
@@ -200,6 +237,16 @@ void QSensorPrivate::init(const QByteArray &sensorType)
\value FieldOfView The backend specifies its field of view, which can be
read from the QLightSensor::fieldOfView property.
+ The features of QAccelerometer are:
+
+ \value AccelerationMode The backend supports switching the acceleration mode
+ of the acceleromter with the QAccelerometer::accelerationMode property.
+
+ The features of all orientable sensors are:
+
+ \value AxesOrientation The backend supports changing the axes orientation from the default of
+ QSensor::FixedOrientation to something else.
+
\omitvalue Reserved
\sa QSensor::isFeatureSupported()
@@ -429,6 +476,54 @@ bool QSensor::isAlwaysOn() const
}
/*!
+ \property QSensor::skipDuplicates
+ \brief Indicates whether duplicate reading values should be omitted.
+ \since 5.1
+
+ When duplicate skipping is enabled, successive readings with the same or very
+ similar values are omitted. This helps reducing the amount of processing done, as less sensor
+ readings are made available. As a consequence, readings arrive at an irregular interval.
+
+ Duplicate skipping is not just enabled for readings that are exactly the same, but also for
+ readings that are quite similar, as each sensor has a bit of jitter even if the device is
+ not moved.
+
+ Support for this property depends on the backend. Use isFeatureSupported() to check if it is
+ supported on the current platform.
+
+ Duplicate skipping is disabled by default.
+
+ Duplicate skipping takes effect when the sensor is started, changing the property while the
+ sensor is active has no immediate effect.
+*/
+bool QSensor::skipDuplicates() const
+{
+ Q_D(const QSensor);
+ return d->skipDuplicates;
+}
+
+/*!
+ Sets the duplicate skipping to \a skipDuplicates.
+
+ \since 5.1
+*/
+void QSensor::setSkipDuplicates(bool skipDuplicates)
+{
+ Q_D(QSensor);
+ if (d->skipDuplicates != skipDuplicates) {
+ d->skipDuplicates = skipDuplicates;
+ emit skipDuplicatesChanged(skipDuplicates);
+ }
+}
+
+/*!
+ \fn QSensor::skipDuplicatesChanged(bool skipDuplicates)
+ \since 5.1
+
+ This signal is emitted when the skipDuplicates property changes.
+*/
+
+/*!
\property QSensor::availableDataRates
\brief the data rates that the sensor supports.
@@ -760,6 +855,142 @@ int QSensor::error() const
}
/*!
+ \enum QSensor::AxesOrientationMode
+ \since 5.1
+
+ Describes how reading values are affected by the screen orientation.
+
+ \value FixedOrientation No automatic rotation is applied to the reading values.
+
+ \value AutomaticOrientation The reading values are automatically rotated based on the screen
+ orientation.
+
+ \value UserOrientation The reading values are rotated based on the angle of the userOrientation property.
+
+ \sa QSensor::axesOrientationMode
+*/
+
+/*!
+ \property QSensor::axesOrientationMode
+ \since 5.1
+ \brief The mode that affects how the screen orientation changes reading values.
+
+ When set to FixedOrientation, which is the default mode, no automatic rotation is applied to
+ the reading. This is the only mode available for backends that do not support the
+ QSensor::AxesOrientation feature.
+
+ When set to AutomaticOrientation, the reading values are automatically rotated when the
+ screen orientation changes. In effect, the screen orientation is canceled out.
+
+ As an example, assume the device is rotated by 180 degrees and therefore the screen orientation
+ also is rotated by 180 degrees from the native orientation. Without automatic axes orientation,
+ the reading values would now be changed: Both the X and the Y values would be negated, forcing
+ an application developer to manually cancel out the negation in application code. Automatic
+ axes orientation does this automatically, in this mode the X and Y values would be the same as
+ with the default screen orientation.
+
+ This automatic rotation of the axes is handy is some usecases, for example in a bubble level
+ application that measures how level a surface is by looking at the X axis value of an
+ accelerometer. When the device and screen orientation change by 90 degrees, an application
+ developer does not need to change anything, he can continue using the X axis value even though
+ the device is rotated. Without automatic axes orientation, the application developer would need
+ to look at the Y values instead, thereby adding code to the application that reads from a
+ different axis depending on the screen orientation.
+
+ The UserOrientation mode is quite similar to AutomaticOrientation, only that the screen orientation
+ is manually controlled instead of automatically determined. The angle of the userOrientation
+ property is then used for rotating the reading values.
+
+ Since the rotation of the reading values is based on the screen orientation, Z values will never
+ change, as the Z axis is perpendicular to the screen.
+ As screen orientation changes in 90 degree steps, rotating the reading values is also done in
+ steps of 90 degrees.
+
+ This property is only used for orientable sensors.
+*/
+
+QSensor::AxesOrientationMode QSensor::axesOrientationMode() const
+{
+ Q_D(const QSensor);
+ return d->axesOrientationMode;
+}
+
+void QSensor::setAxesOrientationMode(QSensor::AxesOrientationMode axesOrientationMode)
+{
+ Q_D(QSensor);
+ if (d->axesOrientationMode != axesOrientationMode) {
+ d->axesOrientationMode = axesOrientationMode;
+ emit axesOrientationModeChanged(axesOrientationMode);
+ }
+}
+
+/*!
+ \property QSensor::currentOrientation
+ \since 5.1
+ \brief The current orientation that is used for rotating the reading values.
+
+ This might not be the same as the screen orientation. For example, in the FixedOrientation mode,
+ the reading values are not rotated, and therefore the property is 0.
+
+ In the UserOrientation mode, the readings are rotated based on the userOrientation property,
+ and therefore this property is equal to the userOrientation property.
+
+ In the AutomaticOrientation mode, the readings are rotated based on the screen orientation,
+ and therefore this property will be equal to the current screen orientation.
+
+ This property is set by the backend and only valid for orientable sensors.
+*/
+
+int QSensor::currentOrientation() const
+{
+ Q_D(const QSensor);
+ return d->currentOrientation;
+}
+
+/*!
+ \since 5.1
+ Sets the current screen orientation to \a currentOrientation. This is to be called from the
+ backend whenever the screen orientation or the userOrientation property changes.
+*/
+void QSensor::setCurrentOrientation(int currentOrientation)
+{
+ Q_D(QSensor);
+ if (d->currentOrientation != currentOrientation) {
+ d->currentOrientation = currentOrientation;
+ emit currentOrientationChanged(currentOrientation);
+ }
+}
+
+/*!
+ \property QSensor::userOrientation
+ \since 5.1
+ \brief The angle used for rotating the reading values in the UserOrientation mode.
+
+ When the axesOrientationMode property is set to UserOrientation, the angle for rotating the
+ reading values is taken from this property. In other modes, the property has no effect.
+
+ The default is 0. The only valid values are 0, 90, 180 and 270, as those are the only possible
+ screen orientations.
+
+ This property is only valid for orientable sensors.
+*/
+
+int QSensor::userOrientation() const
+{
+ Q_D(const QSensor);
+ return d->userOrientation;
+}
+
+void QSensor::setUserOrientation(int userOrientation)
+{
+ Q_D(QSensor);
+ if (d->userOrientation != userOrientation) {
+ d->userOrientation = userOrientation;
+ emit userOrientationChanged(userOrientation);
+ }
+}
+
+/*!
\fn QSensor::sensorError(int error)
This signal is emitted when an \a error code is set on the sensor.
@@ -785,11 +1016,33 @@ int QSensor::error() const
The property holds the maximum buffer size.
- Note that this may be undefined, in which case the sensor does not support any form of buffering.
+ Note that this may be 1, in which case the sensor does not support any form of buffering.
+ In that case, isFeatureSupported(QSensor::Buffering) will also return false.
\sa QSensor::bufferSize, QSensor::efficientBufferSize
*/
+int QSensor::maxBufferSize() const
+{
+ Q_D(const QSensor);
+ return d->maxBufferSize;
+}
+
+/*!
+ \since 5.1
+ Sets the maximum buffer size to \a maxBufferSize. This is to be called from the
+ backend.
+*/
+void QSensor::setMaxBufferSize(int maxBufferSize)
+{
+ // ### Qt 6: Remove the entire maxBufferSize property, no backend really uses it
+ Q_D(QSensor);
+ if (d->maxBufferSize != maxBufferSize) {
+ d->maxBufferSize = maxBufferSize;
+ emit maxBufferSizeChanged(maxBufferSize);
+ }
+}
+
/*!
\property QSensor::efficientBufferSize
@@ -797,17 +1050,36 @@ int QSensor::error() const
no particular size is most efficient). Some sensor drivers have a FIFO buffer which
makes it more efficient to deliver the FIFO's size worth of readings at one time.
- Note that this may be undefined, in which case the sensor does not support any form of buffering.
-
\sa QSensor::bufferSize, QSensor::maxBufferSize
*/
+int QSensor::efficientBufferSize() const
+{
+ Q_D(const QSensor);
+ return d->efficientBufferSize;
+}
+
+/*!
+ \since 5.1
+ Sets the efficient buffer size to \a efficientBufferSize. This is to be called from the
+ backend.
+*/
+void QSensor::setEfficientBufferSize(int efficientBufferSize)
+{
+ // ### Qt 6: Remove the entire efficientBufferSize property, no backend really uses it
+ Q_D(QSensor);
+ if (d->efficientBufferSize != efficientBufferSize) {
+ d->efficientBufferSize = efficientBufferSize;
+ emit efficientBufferSizeChanged(efficientBufferSize);
+ }
+}
+
/*!
\property QSensor::bufferSize
- This property holds the size of the buffer. By default (and if the property
- is left undefined), the buffer size is 1, which means no buffering.
- If the maximum buffer size is 1 (or undefined), then buffering is not supported
+ This property holds the size of the buffer. By default, the buffer size is 1,
+ which means no buffering.
+ If the maximum buffer size is 1, then buffering is not supported
by the sensor.
Setting bufferSize greater than maxBufferSize will cause maxBufferSize to be used.
@@ -834,11 +1106,26 @@ int QSensor::error() const
in time, for example when the event loop is blocked for too long. Without a buffer, these readings
would simply be dropped.
- The buffer size can only be changed while the sensor is not active.
-
\sa QSensor::maxBufferSize, QSensor::efficientBufferSize
*/
+int QSensor::bufferSize() const
+{
+ Q_D(const QSensor);
+ return d->bufferSize;
+}
+
+void QSensor::setBufferSize(int bufferSize)
+{
+ // ### Qt 6: Currently only the Blackberry backend supports this, but only as an on/off switch.
+ // We should consider changing this to a more appropriate API.
+ Q_D(QSensor);
+ if (d->bufferSize != bufferSize) {
+ d->bufferSize = bufferSize;
+ emit bufferSizeChanged(bufferSize);
+ }
+}
+
// =====================================================================
/*!
diff --git a/src/sensors/qsensor.h b/src/sensors/qsensor.h
index 46d011d3..2314fb94 100644
--- a/src/sensors/qsensor.h
+++ b/src/sensors/qsensor.h
@@ -50,11 +50,8 @@
#include <QtCore/QVariant>
#include <QtCore/QPair>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorPrivate;
class QSensorBackend;
class QSensorReading;
@@ -80,6 +77,7 @@ class Q_SENSORS_EXPORT QSensor : public QObject
Q_OBJECT
Q_ENUMS(Feature)
+ Q_ENUMS(AxesOrientationMode)
Q_PROPERTY(QByteArray identifier READ identifier WRITE setIdentifier)
Q_PROPERTY(QByteArray type READ type)
Q_PROPERTY(bool connectedToBackend READ isConnectedToBackend)
@@ -93,20 +91,32 @@ class Q_SENSORS_EXPORT QSensor : public QObject
Q_PROPERTY(QString description READ description)
Q_PROPERTY(int error READ error NOTIFY sensorError)
Q_PROPERTY(bool alwaysOn READ isAlwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged REVISION 1)
-#ifdef Q_QDOC
- Q_PROPERTY(int maxBufferSize)
- Q_PROPERTY(int efficientBufferSize)
- Q_PROPERTY(int bufferSize)
-#endif
+ Q_PROPERTY(bool skipDuplicates READ skipDuplicates WRITE setSkipDuplicates NOTIFY skipDuplicatesChanged)
+ Q_PROPERTY(AxesOrientationMode axesOrientationMode READ axesOrientationMode WRITE setAxesOrientationMode NOTIFY axesOrientationModeChanged)
+ Q_PROPERTY(int currentOrientation READ currentOrientation NOTIFY currentOrientationChanged)
+ Q_PROPERTY(int userOrientation READ userOrientation WRITE setUserOrientation NOTIFY userOrientationChanged)
+ Q_PROPERTY(int maxBufferSize READ maxBufferSize NOTIFY maxBufferSizeChanged)
+ Q_PROPERTY(int efficientBufferSize READ efficientBufferSize NOTIFY efficientBufferSizeChanged)
+ Q_PROPERTY(int bufferSize READ bufferSize WRITE setBufferSize NOTIFY bufferSizeChanged)
public:
enum Feature {
Buffering,
AlwaysOn,
GeoValues,
FieldOfView,
+ AccelerationMode,
+ SkipDuplicates,
+ AxesOrientation,
Reserved = 257 // Make sure at least 2 bytes are used for the enum to avoid breaking BC later
};
+ // Keep in sync with QmlSensor::AxesOrientationMode
+ enum AxesOrientationMode {
+ FixedOrientation,
+ AutomaticOrientation,
+ UserOrientation
+ };
+
explicit QSensor(const QByteArray &type, QObject *parent = 0);
virtual ~QSensor();
@@ -126,6 +136,9 @@ public:
bool isAlwaysOn() const;
void setAlwaysOn(bool alwaysOn);
+ bool skipDuplicates() const;
+ void setSkipDuplicates(bool skipDuplicates);
+
qrangelist availableDataRates() const;
int dataRate() const;
void setDataRate(int rate);
@@ -153,6 +166,24 @@ public:
Q_INVOKABLE bool isFeatureSupported(Feature feature) const;
+ AxesOrientationMode axesOrientationMode() const;
+ void setAxesOrientationMode(AxesOrientationMode axesOrientationMode);
+
+ int currentOrientation() const;
+ void setCurrentOrientation(int currentOrientation);
+
+ int userOrientation() const;
+ void setUserOrientation(int userOrientation);
+
+ int maxBufferSize() const;
+ void setMaxBufferSize(int maxBufferSize);
+
+ int efficientBufferSize() const;
+ void setEfficientBufferSize(int efficientBufferSize);
+
+ int bufferSize() const;
+ void setBufferSize(int bufferSize);
+
public Q_SLOTS:
// Start receiving values from the sensor
bool start();
@@ -168,6 +199,13 @@ Q_SIGNALS:
void availableSensorsChanged();
void alwaysOnChanged();
void dataRateChanged();
+ void skipDuplicatesChanged(bool skipDuplicates);
+ void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode);
+ void currentOrientationChanged(int currentOrientation);
+ void userOrientationChanged(int userOrientation);
+ void maxBufferSizeChanged(int maxBufferSize);
+ void efficientBufferSizeChanged(int efficientBufferSize);
+ void bufferSizeChanged(int bufferSize);
protected:
explicit QSensor(const QByteArray &type, QSensorPrivate &dd, QObject* parent = 0);
@@ -253,7 +291,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
Q_DECLARE_METATYPE(qrange)
Q_DECLARE_METATYPE(qrangelist)
diff --git a/src/sensors/qsensor_p.h b/src/sensors/qsensor_p.h
index 80312b65..71a5b6eb 100644
--- a/src/sensors/qsensor_p.h
+++ b/src/sensors/qsensor_p.h
@@ -57,7 +57,6 @@
#include "private/qobject_p.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
typedef QList<QSensorFilter*> QFilterList;
@@ -79,6 +78,13 @@ public:
, cache_reading(0)
, error(0)
, alwaysOn(false)
+ , skipDuplicates(false)
+ , axesOrientationMode(QSensor::FixedOrientation)
+ , currentOrientation(0)
+ , userOrientation(0)
+ , bufferSize(1)
+ , maxBufferSize(1)
+ , efficientBufferSize(1)
{
}
@@ -108,6 +114,15 @@ public:
int error;
bool alwaysOn;
+ bool skipDuplicates;
+
+ QSensor::AxesOrientationMode axesOrientationMode;
+ int currentOrientation;
+ int userOrientation;
+
+ int bufferSize;
+ int maxBufferSize;
+ int efficientBufferSize;
};
class QSensorReadingPrivate
@@ -123,7 +138,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensorbackend.h b/src/sensors/qsensorbackend.h
index 92dc9e91..4c6ce8b5 100644
--- a/src/sensors/qsensorbackend.h
+++ b/src/sensors/qsensorbackend.h
@@ -45,11 +45,8 @@
#include <QtSensors/qsensor.h>
#include <QtSensors/qsensormanager.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class Q_SENSORS_EXPORT QSensorBackend : public QObject
{
Q_OBJECT
@@ -94,7 +91,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensormanager.h b/src/sensors/qsensormanager.h
index c2037f75..8fa87d1f 100644
--- a/src/sensors/qsensormanager.h
+++ b/src/sensors/qsensormanager.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorBackend;
class QSensorBackendFactory;
class QSensorPluginInterface;
@@ -77,7 +74,6 @@ protected:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensorplugin.h b/src/sensors/qsensorplugin.h
index 5caef6f1..336bce6b 100644
--- a/src/sensors/qsensorplugin.h
+++ b/src/sensors/qsensorplugin.h
@@ -46,11 +46,8 @@
#include <QtCore/qplugin.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class Q_SENSORS_EXPORT QSensorPluginInterface
{
public:
@@ -71,7 +68,6 @@ Q_DECLARE_INTERFACE(QSensorPluginInterface, "com.qt-project.Qt.QSensorPluginInte
Q_DECLARE_INTERFACE(QSensorChangesInterface, "com.qt-project.Qt.QSensorChangesInterface/5.0")
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensorsglobal.h b/src/sensors/qsensorsglobal.h
index bdd016ff..496ff4ac 100644
--- a/src/sensors/qsensorsglobal.h
+++ b/src/sensors/qsensorsglobal.h
@@ -44,11 +44,8 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
#ifndef QT_STATIC
# if defined(QT_BUILD_SENSORS_LIB)
# define Q_SENSORS_EXPORT Q_DECL_EXPORT
@@ -60,7 +57,6 @@ QT_MODULE(QtSensors)
#endif
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORSGLOBAL_H
diff --git a/src/sensors/qtapsensor.cpp b/src/sensors/qtapsensor.cpp
index bd65196b..23ec492f 100644
--- a/src/sensors/qtapsensor.cpp
+++ b/src/sensors/qtapsensor.cpp
@@ -211,7 +211,7 @@ char const * const QTapSensor::type("QTapSensor");
Construct the sensor as a child of \a parent.
*/
QTapSensor::QTapSensor(QObject *parent)
- : QSensor(QTapSensor::type, parent)
+ : QSensor(QTapSensor::type, *new QTapSensorPrivate, parent)
{
}
@@ -240,10 +240,24 @@ QTapSensor::~QTapSensor()
It is not possible to have the sensor report both single and double tap events.
If both are needed the app should create 2 sensor objects.
- Note that you must access this property via QObject::property() and QObject::setProperty().
The property must be set before calling start().
*/
+bool QTapSensor::returnDoubleTapEvents() const
+{
+ Q_D(const QTapSensor);
+ return d->returnDoubleTapEvents;
+}
+
+void QTapSensor::setReturnDoubleTapEvents(bool returnDoubleTapEvents)
+{
+ Q_D(QTapSensor);
+ if (d->returnDoubleTapEvents != returnDoubleTapEvents) {
+ d->returnDoubleTapEvents = returnDoubleTapEvents;
+ emit returnDoubleTapEventsChanged(returnDoubleTapEvents);
+ }
+}
+
#include "moc_qtapsensor.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qtapsensor.h b/src/sensors/qtapsensor.h
index da71e965..74ca40c2 100644
--- a/src/sensors/qtapsensor.h
+++ b/src/sensors/qtapsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QTapReadingPrivate;
class Q_SENSORS_EXPORT QTapReading : public QSensorReading
@@ -90,24 +87,31 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QTapReading*>(reading)); }
};
+class QTapSensorPrivate;
+
class Q_SENSORS_EXPORT QTapSensor : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(bool returnDoubleTapEvents)
-#endif
+ Q_PROPERTY(bool returnDoubleTapEvents READ returnDoubleTapEvents WRITE setReturnDoubleTapEvents
+ NOTIFY returnDoubleTapEventsChanged)
public:
explicit QTapSensor(QObject *parent = 0);
virtual ~QTapSensor();
QTapReading *reading() const { return static_cast<QTapReading*>(QSensor::reading()); }
static char const * const type;
+ bool returnDoubleTapEvents() const;
+ void setReturnDoubleTapEvents(bool returnDoubleTapEvents);
+
+Q_SIGNALS:
+ void returnDoubleTapEventsChanged(bool returnDoubleTapEvents);
+
private:
+ Q_DECLARE_PRIVATE(QTapSensor);
Q_DISABLE_COPY(QTapSensor)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qtapsensor_p.h b/src/sensors/qtapsensor_p.h
index 68270e87..6bf81473 100644
--- a/src/sensors/qtapsensor_p.h
+++ b/src/sensors/qtapsensor_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
class QTapReadingPrivate
@@ -69,8 +70,18 @@ public:
bool doubleTap;
};
+class QTapSensorPrivate : public QSensorPrivate
+{
+public:
+ QTapSensorPrivate()
+ : returnDoubleTapEvents(true)
+ {
+ }
+
+ bool returnDoubleTapEvents;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qtiltsensor.h b/src/sensors/qtiltsensor.h
index 68dcdfea..246a103e 100644
--- a/src/sensors/qtiltsensor.h
+++ b/src/sensors/qtiltsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QTiltReadingPrivate;
class Q_SENSORS_EXPORT QTiltReading : public QSensorReading
@@ -91,5 +88,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qtiltsensor_p.h b/src/sensors/qtiltsensor_p.h
index 14946243..e8cce136 100644
--- a/src/sensors/qtiltsensor_p.h
+++ b/src/sensors/qtiltsensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QTiltReadingPrivate
@@ -70,5 +69,4 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/sensorlog_p.h b/src/sensors/sensorlog_p.h
index d1cde707..f808ab2d 100644
--- a/src/sensors/sensorlog_p.h
+++ b/src/sensors/sensorlog_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#ifdef ENABLE_RUNTIME_SENSORLOG
@@ -83,7 +82,6 @@ static bool logEnabled()
#endif
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/sensors.pro b/src/sensors/sensors.pro
index 2cb33468..b70c17c6 100644
--- a/src/sensors/sensors.pro
+++ b/src/sensors/sensors.pro
@@ -51,8 +51,11 @@ simulator {
SENSORS=\
qsensor\
qaccelerometer\
+ qaltimeter\
qambientlightsensor\
+ qambienttemperaturesensor\
qcompass\
+ qholstersensor\
qlightsensor\
qmagnetometer\
qorientationsensor\
@@ -62,6 +65,7 @@ SENSORS=\
qtapsensor\
qtiltsensor\
qgyroscope\
+ qpressuresensor\
for(s,SENSORS) {
# Client API