diff options
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/positioning/plugins.qmltypes | 1 | ||||
-rw-r--r-- | src/imports/positioning/qdeclarativepositionsource.cpp | 46 | ||||
-rw-r--r-- | src/imports/positioning/qdeclarativepositionsource_p.h | 5 |
3 files changed, 50 insertions, 2 deletions
diff --git a/src/imports/positioning/plugins.qmltypes b/src/imports/positioning/plugins.qmltypes index 952d6830..9ea738f4 100644 --- a/src/imports/positioning/plugins.qmltypes +++ b/src/imports/positioning/plugins.qmltypes @@ -173,6 +173,7 @@ Module { Property { name: "sourceError"; type: "SourceError"; isReadonly: true } Property { name: "name"; type: "string" } Signal { name: "validityChanged" } + Signal { name: "updateTimeout" } Method { name: "update" } Method { name: "start" } Method { name: "stop" } diff --git a/src/imports/positioning/qdeclarativepositionsource.cpp b/src/imports/positioning/qdeclarativepositionsource.cpp index ae5d916e..c5090fe2 100644 --- a/src/imports/positioning/qdeclarativepositionsource.cpp +++ b/src/imports/positioning/qdeclarativepositionsource.cpp @@ -107,6 +107,21 @@ QT_BEGIN_NAMESPACE */ +/*! + \qmlsignal PositionSource::updateTimeout() + + If \l update() was called, this signal is emitted if the current position could not be + retrieved within a certain amount of time. + + If \l start() was called, this signal is emitted if the position engine determines that + it is not able to provide further regular updates. + + \since Qt Positioning 5.5 + + \sa QGeoPositionInfoSource::updateTimeout() +*/ + + QDeclarativePositionSource::QDeclarativePositionSource() : m_positionSource(0), m_preferredPositioningMethods(NoPositioningMethods), m_nmeaFile(0), m_nmeaSocket(0), m_active(false), m_singleUpdate(false), m_updateInterval(0), @@ -167,6 +182,8 @@ void QDeclarativePositionSource::setName(const QString &newName) this, SLOT(positionUpdateReceived(QGeoPositionInfo))); connect(m_positionSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(sourceErrorReceived(QGeoPositionInfoSource::Error))); + connect(m_positionSource, SIGNAL(updateTimeout()), + this, SLOT(updateTimeoutReceived())); m_positionSource->setUpdateInterval(m_updateInterval); m_positionSource->setPreferredPositioningMethods( @@ -277,6 +294,11 @@ void QDeclarativePositionSource::setNmeaSource(const QUrl &nmeaSource) (qobject_cast<QNmeaPositionInfoSource *>(m_positionSource))->setDevice(m_nmeaFile); connect(m_positionSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdateReceived(QGeoPositionInfo))); + connect(m_positionSource, SIGNAL(error(QGeoPositionInfoSource::Error)), + this, SLOT(sourceErrorReceived(QGeoPositionInfoSource::Error))); + connect(m_positionSource, SIGNAL(updateTimeout()), + this, SLOT(updateTimeoutReceived())); + setPosition(m_positionSource->lastKnownPosition()); if (m_active && !m_singleUpdate) { // Keep on updating even though source changed @@ -323,6 +345,10 @@ void QDeclarativePositionSource::socketConnected() connect(m_positionSource, &QNmeaPositionInfoSource::positionUpdated, this, &QDeclarativePositionSource::positionUpdateReceived); + connect(m_positionSource, SIGNAL(error(QGeoPositionInfoSource::Error)), + this, SLOT(sourceErrorReceived(QGeoPositionInfoSource::Error))); + connect(m_positionSource, SIGNAL(updateTimeout()), + this, SLOT(updateTimeoutReceived())); setPosition(m_positionSource->lastKnownPosition()); @@ -362,6 +388,24 @@ void QDeclarativePositionSource::socketError(QAbstractSocket::SocketError error) emit sourceErrorChanged(); } + +void QDeclarativePositionSource::updateTimeoutReceived() +{ + if (!m_active) + return; + + if (m_singleUpdate) { + m_singleUpdate = false; + + // only singleUpdate based timeouts change activity + // continuous updates may resume again (see QGeoPositionInfoSource::startUpdates()) + m_active = false; + emit activeChanged(); + } + + emit updateTimeout(); +} + void QDeclarativePositionSource::setPosition(const QGeoPositionInfo &pi) { m_position.setPosition(pi); @@ -663,6 +707,8 @@ void QDeclarativePositionSource::componentComplete() this, SLOT(positionUpdateReceived(QGeoPositionInfo))); connect(m_positionSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(sourceErrorReceived(QGeoPositionInfoSource::Error))); + connect(m_positionSource, SIGNAL(updateTimeout()), + this, SLOT(updateTimeoutReceived())); m_positionSource->setUpdateInterval(m_updateInterval); m_positionSource->setPreferredPositioningMethods( diff --git a/src/imports/positioning/qdeclarativepositionsource_p.h b/src/imports/positioning/qdeclarativepositionsource_p.h index 7a27b952..376014e4 100644 --- a/src/imports/positioning/qdeclarativepositionsource_p.h +++ b/src/imports/positioning/qdeclarativepositionsource_p.h @@ -109,7 +109,7 @@ public: void componentComplete(); public Q_SLOTS: - void update(); + void update(); // TODO Qt 6 change to void update(int) void start(); void stop(); @@ -123,13 +123,14 @@ Q_SIGNALS: void sourceErrorChanged(); void nameChanged(); void validityChanged(); - + void updateTimeout(); private Q_SLOTS: void positionUpdateReceived(const QGeoPositionInfo &update); void sourceErrorReceived(const QGeoPositionInfoSource::Error error); void socketConnected(); void socketError(QAbstractSocket::SocketError error); + void updateTimeoutReceived(); private: void setPosition(const QGeoPositionInfo &pi); |