diff options
author | Carsten Bürger <carsten.burger@nokia.com> | 2012-01-04 15:21:36 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-20 17:59:09 +0100 |
commit | 54991e99ee2d1f5a883c2c5d99ced03b2c41e675 (patch) | |
tree | 935839c9892cc44c27e1f442a4b3a5e3ea747624 /src/imports/location/qdeclarativepositionsource.cpp | |
parent | 354d4c795131c4282aa98a28beab2193d5f6e540 (diff) | |
download | qtlocation-54991e99ee2d1f5a883c2c5d99ced03b2c41e675.tar.gz |
Add error handling for Position and Satellite sources
Change-Id: I160e8e4780ac755fddcb3894f31fae4d9e5618ad
Reviewed-by: Alex <alex.blasche@nokia.com>
Diffstat (limited to 'src/imports/location/qdeclarativepositionsource.cpp')
-rw-r--r-- | src/imports/location/qdeclarativepositionsource.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/imports/location/qdeclarativepositionsource.cpp b/src/imports/location/qdeclarativepositionsource.cpp index cc44a0fd..5219068b 100644 --- a/src/imports/location/qdeclarativepositionsource.cpp +++ b/src/imports/location/qdeclarativepositionsource.cpp @@ -112,12 +112,15 @@ QT_BEGIN_NAMESPACE QDeclarativePositionSource::QDeclarativePositionSource() : m_positionSource(0), m_positioningMethod(QDeclarativePositionSource::NoPositioningMethod), - m_nmeaFile(0), m_active(false), m_singleUpdate(false), m_updateInterval(0) + m_nmeaFile(0), m_active(false), m_singleUpdate(false), m_updateInterval(0), + m_sourceError(UnknownSourceError) { m_positionSource = QGeoPositionInfoSource::createDefaultSource(this); if (m_positionSource) { connect(m_positionSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdateReceived(QGeoPositionInfo))); + connect(m_positionSource, SIGNAL(error(QGeoPositionInfoSource::Error)), + this, SLOT(sourceErrorReceived(QGeoPositionInfoSource::Error))); m_positioningMethod = supportedPositioningMethods(); #if defined(Q_OS_SYMBIAN) } else { @@ -470,6 +473,39 @@ void QDeclarativePositionSource::positionUpdateReceived(const QGeoPositionInfo& } } +QDeclarativePositionSource::SourceError QDeclarativePositionSource::sourceError() const +{ + return m_sourceError; +} + +/*! + \qmlproperty enumeration PositionSource::sourceError + + This property holds the error which last occured with the PositionSource. + + \list + \o AccessError - The connection setup to the remote positioning backend failed because the + application lacked the required privileges. + \o ClosedError - The remote positioning backend closed the connection, which happens e.g. in case + the user is switching location services to off. This object becomes invalid and should be deleted. + A new source can be declared later on to check whether the positioning backend is up again. + \o UnknownSourceError - An unidentified error occurred. + \endlist + +*/ + +void QDeclarativePositionSource::sourceErrorReceived(const QGeoPositionInfoSource::Error error) +{ + if (error == QGeoPositionInfoSource::AccessError) { + m_sourceError = QDeclarativePositionSource::AccessError; + } else if (error == QGeoPositionInfoSource::ClosedError) { + m_sourceError = QDeclarativePositionSource::ClosedError; + } else { + m_sourceError = QDeclarativePositionSource::UnknownSourceError; + } + emit sourceErrorChanged(); +} + #include "moc_qdeclarativepositionsource_p.cpp" QT_END_NAMESPACE |