summaryrefslogtreecommitdiff
path: root/examples/positioning/weatherinfo
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-08-14 13:04:42 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-08-14 13:04:58 +0200
commitd34d3e421bb998777c11265ec9db1f239bd9bdb1 (patch)
tree6e5156243d048c9a7a31982b1a562d1a87bc7123 /examples/positioning/weatherinfo
parentf55ae20fa3216e0fcaa7973b047ac5688e2c50bc (diff)
parenta36d9e67e3b8168cb4d1eb76eda96ebb8242fd20 (diff)
downloadqtlocation-d34d3e421bb998777c11265ec9db1f239bd9bdb1.tar.gz
Merge branch '5.3' into 5.4
Change-Id: I02ab19530354f656823e59bb43a6fc4786b2f189
Diffstat (limited to 'examples/positioning/weatherinfo')
-rw-r--r--examples/positioning/weatherinfo/appmodel.cpp17
-rw-r--r--examples/positioning/weatherinfo/appmodel.h3
2 files changed, 19 insertions, 1 deletions
diff --git a/examples/positioning/weatherinfo/appmodel.cpp b/examples/positioning/weatherinfo/appmodel.cpp
index d0a37265..30d990d4 100644
--- a/examples/positioning/weatherinfo/appmodel.cpp
+++ b/examples/positioning/weatherinfo/appmodel.cpp
@@ -233,6 +233,8 @@ void AppModel::networkSessionOpened()
d->useGps = true;
connect(d->src, SIGNAL(positionUpdated(QGeoPositionInfo)),
this, SLOT(positionUpdated(QGeoPositionInfo)));
+ connect(d->src, SIGNAL(error(QGeoPositionInfoSource::Error)),
+ this, SLOT(positionError(QGeoPositionInfoSource::Error)));
d->src->startUpdates();
} else {
d->useGps = false;
@@ -277,6 +279,21 @@ void AppModel::positionUpdated(QGeoPositionInfo gpsPos)
d->geoReplyMapper, SLOT(map()));
}
+void AppModel::positionError(QGeoPositionInfoSource::Error e)
+{
+ qWarning() << "Position source error. Falling back to simulation mode.";
+ // cleanup insufficient QGeoPositionInfoSource instance
+ d->src->stopUpdates();
+ d->src->deleteLater();
+ d->src = 0;
+
+ // activate simulation mode
+ d->useGps = false;
+ d->city = "Brisbane";
+ emit cityChanged();
+ this->refreshWeather();
+}
+
void AppModel::handleGeoNetworkData(QObject *replyObj)
{
QNetworkReply *networkReply = qobject_cast<QNetworkReply*>(replyObj);
diff --git a/examples/positioning/weatherinfo/appmodel.h b/examples/positioning/weatherinfo/appmodel.h
index e0d32148..16297236 100644
--- a/examples/positioning/weatherinfo/appmodel.h
+++ b/examples/positioning/weatherinfo/appmodel.h
@@ -46,7 +46,7 @@
#include <QtNetwork/QNetworkReply>
#include <QtQml/QQmlListProperty>
-#include <qgeopositioninfo.h>
+#include <QtPositioning/QGeoPositionInfoSource>
//! [0]
class WeatherData : public QObject {
@@ -146,6 +146,7 @@ public slots:
private slots:
void networkSessionOpened();
void positionUpdated(QGeoPositionInfo gpsPos);
+ void positionError(QGeoPositionInfoSource::Error e);
// these would have QNetworkReply* params but for the signalmapper
void handleGeoNetworkData(QObject *networkReply);
void handleWeatherNetworkData(QObject *networkReply);