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/sensors/qsensor.cpp | |
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/sensors/qsensor.cpp')
-rw-r--r-- | src/sensors/qsensor.cpp | 72 |
1 files changed, 64 insertions, 8 deletions
diff --git a/src/sensors/qsensor.cpp b/src/sensors/qsensor.cpp index 125d5924..01a4f7b7 100644 --- a/src/sensors/qsensor.cpp +++ b/src/sensors/qsensor.cpp @@ -1016,11 +1016,33 @@ void QSensor::setUserOrientation(int userOrientation) 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 @@ -1028,17 +1050,36 @@ void QSensor::setUserOrientation(int userOrientation) 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. @@ -1065,11 +1106,26 @@ void QSensor::setUserOrientation(int userOrientation) 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); + } +} + // ===================================================================== /*! |