diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2020-02-14 16:25:01 +0100 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2020-02-17 15:28:42 +0100 |
commit | a95c1e3a7cf55a43ba1a8b963aa0c0df02655747 (patch) | |
tree | 89cc15a59b5c03074dcab041e2bc0a6abfce7591 /examples/positioning/weatherinfo/appmodel.cpp | |
parent | 0b81e828add7e77fd3aecaf46955f7d1a84321ae (diff) | |
download | qtlocation-a95c1e3a7cf55a43ba1a8b963aa0c0df02655747.tar.gz |
Remove use of bearer management from weatherinfo example
Change-Id: I8740a008b43b8a5476bdb3506e763acb4bd1b454
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/positioning/weatherinfo/appmodel.cpp')
-rw-r--r-- | examples/positioning/weatherinfo/appmodel.cpp | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/examples/positioning/weatherinfo/appmodel.cpp b/examples/positioning/weatherinfo/appmodel.cpp index 93186aea..bace7510 100644 --- a/examples/positioning/weatherinfo/appmodel.cpp +++ b/examples/positioning/weatherinfo/appmodel.cpp @@ -55,7 +55,6 @@ #include <qnmeapositioninfosource.h> #include <qgeopositioninfo.h> #include <qnetworkconfigmanager.h> -#include <qnetworksession.h> #include <QJsonDocument> #include <QJsonObject> @@ -150,7 +149,6 @@ public: QString longitude, latitude; QString city; QNetworkAccessManager *nam; - QNetworkSession *ns; WeatherData now; QList<WeatherData*> forecast; QQmlListProperty<WeatherData> *fcProp; @@ -166,7 +164,6 @@ public: AppModelPrivate() : src(NULL), nam(NULL), - ns(NULL), fcProp(NULL), ready(false), useGps(true), @@ -225,31 +222,7 @@ AppModel::AppModel(QObject *parent) : //! [1] - // make sure we have an active network session d->nam = new QNetworkAccessManager(this); - - QNetworkConfigurationManager ncm; - d->ns = new QNetworkSession(ncm.defaultConfiguration(), this); - connect(d->ns, SIGNAL(opened()), this, SLOT(networkSessionOpened())); - // the session may be already open. if it is, run the slot directly - if (d->ns->isOpen()) - this->networkSessionOpened(); - // tell the system we want network - d->ns->open(); -} -//! [1] - -AppModel::~AppModel() -{ - d->ns->close(); - if (d->src) - d->src->stopUpdates(); - delete d; -} - -//! [2] -void AppModel::networkSessionOpened() -{ d->src = QGeoPositionInfoSource::createDefaultSource(this); if (d->src) { @@ -266,9 +239,16 @@ void AppModel::networkSessionOpened() this->refreshWeather(); } } -//! [2] +//! [1] + +AppModel::~AppModel() +{ + if (d->src) + d->src->stopUpdates(); + delete d; +} -//! [3] +//! [2] void AppModel::positionUpdated(QGeoPositionInfo gpsPos) { d->coord = gpsPos.coordinate(); @@ -278,7 +258,7 @@ void AppModel::positionUpdated(QGeoPositionInfo gpsPos) queryCity(); } -//! [3] +//! [2] void AppModel::queryCity() { |