diff options
author | Thomas McGuire <thomas.mcguire.qnx@kdab.com> | 2013-01-29 15:01:40 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-08 11:18:01 +0100 |
commit | 4d9edb754b3dff3331c8d8790a04548f0981f315 (patch) | |
tree | c5d96c9f8136c16b05323fb4e0841201af1c4ea4 /src/imports/sensors | |
parent | 62ce0b92ee34a1ae6b2f4e81bb0efbaa2a7d53c9 (diff) |
Use real properties for QSensor::bufferSize & co
The #ifdef Q_DOC hack is not really needed and was
confusing.
In addition, expose those properties to the QML API.
As a result, the backends can now listen to the
bufferSizeChanged() signal to update the buffering
while the sensor is running. This has been implemented
for the BlackBerry platform.
Change-Id: I5239ba2a4b791cfc9f684b44ff2bc103a7b5b0da
Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Diffstat (limited to 'src/imports/sensors')
-rw-r--r-- | src/imports/sensors/plugins.qmltypes | 15 | ||||
-rw-r--r-- | src/imports/sensors/qmlsensor.cpp | 47 | ||||
-rw-r--r-- | src/imports/sensors/qmlsensor.h | 13 |
3 files changed, 75 insertions, 0 deletions
diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes index 974f7142..2deff792 100644 --- a/src/imports/sensors/plugins.qmltypes +++ b/src/imports/sensors/plugins.qmltypes @@ -229,6 +229,9 @@ Module { Property { name: "axesOrientationMode"; revision: 1; type: "AxesOrientationMode" } Property { name: "currentOrientation"; revision: 1; type: "int"; isReadonly: true } Property { name: "userOrientation"; revision: 1; type: "int" } + Property { name: "maxBufferSize"; revision: 1; type: "int"; isReadonly: true } + Property { name: "efficientBufferSize"; revision: 1; type: "int"; isReadonly: true } + Property { name: "bufferSize"; revision: 1; type: "int" } Signal { name: "skipDuplicatesChanged" Parameter { name: "skipDuplicates"; type: "bool" } @@ -245,6 +248,18 @@ Module { name: "userOrientationChanged" Parameter { name: "userOrientation"; type: "int" } } + Signal { + name: "maxBufferSizeChanged" + Parameter { name: "maxBufferSize"; type: "int" } + } + Signal { + name: "efficientBufferSizeChanged" + Parameter { name: "efficientBufferSize"; type: "int" } + } + Signal { + name: "bufferSizeChanged" + Parameter { name: "bufferSize"; type: "int" } + } Method { name: "start"; type: "bool" } Method { name: "stop" } } diff --git a/src/imports/sensors/qmlsensor.cpp b/src/imports/sensors/qmlsensor.cpp index 727526ae..3d59a72d 100644 --- a/src/imports/sensors/qmlsensor.cpp +++ b/src/imports/sensors/qmlsensor.cpp @@ -356,6 +356,50 @@ void QmlSensor::setUserOrientation(int userOrientation) } /*! + \qmlproperty int Sensor::maxBufferSize + \since QtSensors 5.1 + This property holds the maximum buffer size. + + Please see QSensor::maxBufferSize for information about this property. +*/ + +int QmlSensor::maxBufferSize() const +{ + return sensor()->maxBufferSize(); +} + +/*! + \qmlproperty int Sensor::efficientBufferSize + \since QtSensors 5.1 + The property holds the most efficient buffer size. + + Please see QSensor::efficientBufferSize for information about this property. +*/ + +int QmlSensor::efficientBufferSize() const +{ + return sensor()->efficientBufferSize(); +} + +/*! + \qmlproperty int Sensor::bufferSize + \since QtSensors 5.1 + This property holds the size of the buffer. + + Please see QSensor::bufferSize for information about this property. +*/ + +int QmlSensor::bufferSize() const +{ + return sensor()->bufferSize(); +} + +void QmlSensor::setBufferSize(int bufferSize) +{ + sensor()->setBufferSize(bufferSize); +} + +/*! \qmlmethod bool Sensor::start() Start retrieving values from the sensor. Returns true if the sensor was started, false otherwise. @@ -396,6 +440,9 @@ void QmlSensor::componentComplete() this, SIGNAL(axesOrientationModeChanged(AxesOrientationMode))); connect(sensor(), SIGNAL(userOrientationChanged(int)), this, SIGNAL(userOrientationChanged(int))); connect(sensor(), SIGNAL(currentOrientationChanged(int)), this, SIGNAL(currentOrientationChanged(int))); + connect(sensor(), SIGNAL(bufferSizeChanged(int)), this, SIGNAL(bufferSizeChanged(int))); + connect(sensor(), SIGNAL(maxBufferSizeChanged(int)), this, SIGNAL(maxBufferSizeChanged(int))); + connect(sensor(), SIGNAL(efficientBufferSizeChanged(int)), this, SIGNAL(efficientBufferSizeChanged(int))); // We need to set this on the sensor object now sensor()->setIdentifier(m_identifier.toLocal8Bit()); diff --git a/src/imports/sensors/qmlsensor.h b/src/imports/sensors/qmlsensor.h index b68a7b9d..f72234ae 100644 --- a/src/imports/sensors/qmlsensor.h +++ b/src/imports/sensors/qmlsensor.h @@ -75,6 +75,9 @@ class QmlSensor : public QObject, public QQmlParserStatus Q_PROPERTY(AxesOrientationMode axesOrientationMode READ axesOrientationMode WRITE setAxesOrientationMode NOTIFY axesOrientationModeChanged REVISION 1) Q_PROPERTY(int currentOrientation READ currentOrientation NOTIFY currentOrientationChanged REVISION 1) Q_PROPERTY(int userOrientation READ userOrientation WRITE setUserOrientation NOTIFY userOrientationChanged REVISION 1) + Q_PROPERTY(int maxBufferSize READ maxBufferSize NOTIFY maxBufferSizeChanged REVISION 1) + Q_PROPERTY(int efficientBufferSize READ efficientBufferSize NOTIFY efficientBufferSizeChanged REVISION 1) + Q_PROPERTY(int bufferSize READ bufferSize WRITE setBufferSize NOTIFY bufferSizeChanged REVISION 1) public: // Keep in sync with QSensor::AxesOrientationMode @@ -126,6 +129,13 @@ public: int userOrientation() const; void setUserOrientation(int userOrientation); + int maxBufferSize() const; + + int efficientBufferSize() const; + + int bufferSize() const; + void setBufferSize(int bufferSize); + public Q_SLOTS: bool start(); void stop(); @@ -147,6 +157,9 @@ Q_SIGNALS: void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode); void currentOrientationChanged(int currentOrientation); void userOrientationChanged(int userOrientation); + void maxBufferSizeChanged(int maxBufferSize); + void efficientBufferSizeChanged(int efficientBufferSize); + void bufferSizeChanged(int bufferSize); protected: virtual QSensor *sensor() const = 0; |