diff options
author | Thomas McGuire <thomas.mcguire.qnx@kdab.com> | 2013-01-09 13:57:16 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-23 18:33:03 +0100 |
commit | 1831170d56f32530e64bbd5484a6c2cc9e1817ca (patch) | |
tree | 3499dfc2e46b97d72b17a6cfc1087add660e6e8a /src/imports | |
parent | 02285d735e7d3bd8ddfb61b7ea5e16da4ad522d1 (diff) | |
download | qtsensors-1831170d56f32530e64bbd5484a6c2cc9e1817ca.tar.gz |
Add API for duplicate skipping
Duplicate skipping enables omitting reading values
that are very similar to the previous one, thus saving
processing power.
Implement this for the Blackberry backend.
Change-Id: Ic608d8ca795b5a2e0bca5a75a62e8005c283c620
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/sensors/plugins.qmltypes | 6 | ||||
-rw-r--r-- | src/imports/sensors/qmlsensor.cpp | 20 | ||||
-rw-r--r-- | src/imports/sensors/qmlsensor.h | 5 | ||||
-rw-r--r-- | src/imports/sensors/sensors.cpp | 2 |
4 files changed, 32 insertions, 1 deletions
diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes index 1429ae7..fe9c961 100644 --- a/src/imports/sensors/plugins.qmltypes +++ b/src/imports/sensors/plugins.qmltypes @@ -157,6 +157,7 @@ Module { name: "QmlSensor" prototype: "QObject" exports: ["Sensor 5.0", "Sensor 5.1"] + exportMetaObjectRevisions: [0, 1] Property { name: "identifier"; type: "string" } Property { name: "type"; type: "string"; isReadonly: true } Property { name: "connectedToBackend"; type: "bool"; isReadonly: true } @@ -170,6 +171,11 @@ Module { Property { name: "description"; type: "string"; isReadonly: true } Property { name: "error"; type: "int"; isReadonly: true } Property { name: "alwaysOn"; type: "bool" } + Property { name: "skipDuplicates"; revision: 1; type: "bool" } + Signal { + name: "skipDuplicatesChanged" + Parameter { name: "skipDuplicates"; type: "bool" } + } Method { name: "start"; type: "bool" } Method { name: "stop" } } diff --git a/src/imports/sensors/qmlsensor.cpp b/src/imports/sensors/qmlsensor.cpp index ec1b069..40a0ebf 100644 --- a/src/imports/sensors/qmlsensor.cpp +++ b/src/imports/sensors/qmlsensor.cpp @@ -171,6 +171,25 @@ void QmlSensor::setAlwaysOn(bool alwaysOn) } /*! + \qmlproperty bool Sensor::skipDuplicates + \since QtSensors 5.1 + + This property indicates whether duplicate reading values should be omitted. + + Please see QSensor::skipDuplicates for information about this property. +*/ + +bool QmlSensor::skipDuplicates() const +{ + return sensor()->skipDuplicates(); +} + +void QmlSensor::setSkipDuplicates(bool skipDuplicates) +{ + sensor()->setSkipDuplicates(skipDuplicates); +} + +/*! \qmlproperty list<Range> Sensor::availableDataRates This property holds the data rates that the sensor supports. @@ -323,6 +342,7 @@ void QmlSensor::componentComplete() connect(sensor(), SIGNAL(sensorError(int)), this, SIGNAL(errorChanged())); connect(sensor(), SIGNAL(activeChanged()), this, SIGNAL(activeChanged())); connect(sensor(), SIGNAL(alwaysOnChanged()), this, SIGNAL(alwaysOnChanged())); + connect(sensor(), SIGNAL(skipDuplicatesChanged(bool)), this, SIGNAL(skipDuplicatesChanged(bool))); // We need to set this on the sensor object now sensor()->setIdentifier(m_identifier.toLocal8Bit()); diff --git a/src/imports/sensors/qmlsensor.h b/src/imports/sensors/qmlsensor.h index a4ac852..e287f19 100644 --- a/src/imports/sensors/qmlsensor.h +++ b/src/imports/sensors/qmlsensor.h @@ -71,6 +71,7 @@ class QmlSensor : public QObject, public QQmlParserStatus Q_PROPERTY(QString description READ description NOTIFY descriptionChanged) Q_PROPERTY(int error READ error NOTIFY errorChanged) Q_PROPERTY(bool alwaysOn READ isAlwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged) + Q_PROPERTY(bool skipDuplicates READ skipDuplicates WRITE setSkipDuplicates NOTIFY skipDuplicatesChanged REVISION 1) public: explicit QmlSensor(QObject *parent = 0); ~QmlSensor(); @@ -90,6 +91,9 @@ public: bool isAlwaysOn() const; void setAlwaysOn(bool alwaysOn); + bool skipDuplicates() const; + void setSkipDuplicates(bool skipDuplicates); + QQmlListProperty<QmlSensorRange> availableDataRates() const; int dataRate() const; void setDataRate(int rate); @@ -120,6 +124,7 @@ Q_SIGNALS: void descriptionChanged(); void errorChanged(); void alwaysOnChanged(); + void skipDuplicatesChanged(bool skipDuplicates); protected: virtual QSensor *sensor() const = 0; diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp index 9392baf..3f77431 100644 --- a/src/imports/sensors/sensors.cpp +++ b/src/imports/sensors/sensors.cpp @@ -133,7 +133,7 @@ public: qmlRegisterSingletonType <QmlSensorGlobal >(package, major, minor, "QmlSensors", global_object_50); qmlRegisterUncreatableType<QmlSensorRange >(package, major, minor, "Range", QLatin1String("Cannot create Range")); qmlRegisterUncreatableType<QmlSensorOutputRange >(package, major, minor, "OutputRange", QLatin1String("Cannot create OutputRange")); - qmlRegisterUncreatableType<QmlSensor >(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor")); + qmlRegisterUncreatableType<QmlSensor,1 >(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor")); qmlRegisterUncreatableType<QmlSensorReading >(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading")); qmlRegisterType <QmlAccelerometer,1 >(package, major, minor, "Accelerometer"); qmlRegisterUncreatableType<QmlAccelerometerReading >(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading")); |