From 9da59191388446e3105b772a98de49fa9d9aeff1 Mon Sep 17 00:00:00 2001 From: Alexander Barthel Date: Tue, 20 Jul 2021 12:17:43 +0200 Subject: [PATCH] Added progress handler for wind and HTTP downloads. 3.7.4.develop albar965/littlenavmap#737 --- src/atools.cpp | 2 +- src/fs/weather/weatherdownloadbase.cpp | 2 ++ src/fs/weather/weatherdownloadbase.h | 3 +++ src/grib/gribdownloader.cpp | 1 + src/grib/gribdownloader.h | 2 ++ src/grib/windquery.cpp | 1 + src/grib/windquery.h | 2 ++ 7 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/atools.cpp b/src/atools.cpp index 29be6373..b1b63486 100644 --- a/src/atools.cpp +++ b/src/atools.cpp @@ -34,7 +34,7 @@ const static QChar SEP(QDir::separator()); QString version() { - return "3.7.3.develop"; // VERSION_NUMBER - atools + return "3.7.4.develop"; // VERSION_NUMBER - atools } QString gitRevision() diff --git a/src/fs/weather/weatherdownloadbase.cpp b/src/fs/weather/weatherdownloadbase.cpp index ba19cafc..601bbf4e 100644 --- a/src/fs/weather/weatherdownloadbase.cpp +++ b/src/fs/weather/weatherdownloadbase.cpp @@ -34,6 +34,8 @@ WeatherDownloadBase::WeatherDownloadBase(QObject *parent, MetarFormat format, bo connect(downloader, &atools::util::HttpDownloader::downloadSslErrors, this, &WeatherDownloadBase::weatherDownloadSslErrors); + connect(downloader, &atools::util::HttpDownloader::downloadProgress, + this, &WeatherDownloadBase::weatherDownloadProgress); errorStateTimer.setSingleShot(true); errorStateTimer.setInterval(180 * 1000); diff --git a/src/fs/weather/weatherdownloadbase.h b/src/fs/weather/weatherdownloadbase.h index c0391f14..f4255c1a 100644 --- a/src/fs/weather/weatherdownloadbase.h +++ b/src/fs/weather/weatherdownloadbase.h @@ -89,6 +89,9 @@ class WeatherDownloadBase : /* Emitted on SSL errors. Call setIgnoreSslErrors to ignore future errors and continue. */ void weatherDownloadSslErrors(const QStringList& errors, const QString& downloadUrl); + /* Emitted during download */ + void weatherDownloadProgress(qint64 bytesReceived, qint64 bytesTotal, QString downloadUrl); + protected: virtual void startDownload(); diff --git a/src/grib/gribdownloader.cpp b/src/grib/gribdownloader.cpp index 84bf6df5..b98c76c5 100644 --- a/src/grib/gribdownloader.cpp +++ b/src/grib/gribdownloader.cpp @@ -42,6 +42,7 @@ GribDownloader::GribDownloader(QObject *parent, bool logVerbose = false) connect(downloader, &HttpDownloader::downloadFinished, this, &GribDownloader::downloadFinished); connect(downloader, &HttpDownloader::downloadFailed, this, &GribDownloader::downloadFailed); connect(downloader, &HttpDownloader::downloadSslErrors, this, &GribDownloader::gribDownloadSslErrors); + connect(downloader, &HttpDownloader::downloadProgress, this, &GribDownloader::gribDownloadProgress); } GribDownloader::~GribDownloader() diff --git a/src/grib/gribdownloader.h b/src/grib/gribdownloader.h index 4f2eddbe..66736983 100644 --- a/src/grib/gribdownloader.h +++ b/src/grib/gribdownloader.h @@ -113,6 +113,8 @@ class GribDownloader : /* Emitted on SSL errors. Call setIgnoreSslErrors to ignore future errors and continue. */ void gribDownloadSslErrors(const QStringList& errors, const QString& downloadUrl); + void gribDownloadProgress(qint64 bytesReceived, qint64 bytesTotal, QString downloadUrl); + private: void downloadFinished(const QByteArray& data, QString downloadUrl); void downloadFailed(const QString& error, int errorCode, QString downloadUrl); diff --git a/src/grib/windquery.cpp b/src/grib/windquery.cpp index bf2ad621..84de3092 100644 --- a/src/grib/windquery.cpp +++ b/src/grib/windquery.cpp @@ -190,6 +190,7 @@ WindQuery::WindQuery(QObject *parentObject, bool logVerbose) connect(downloader, &GribDownloader::gribDownloadFinished, this, &WindQuery::gribDownloadFinished); connect(downloader, &GribDownloader::gribDownloadFailed, this, &WindQuery::gribDownloadFailed); connect(downloader, &GribDownloader::gribDownloadSslErrors, this, &WindQuery::windDownloadSslErrors); + connect(downloader, &GribDownloader::gribDownloadProgress, this, &WindQuery::windDownloadProgress); // Set up file watcher for file based updates fileWatcher = new atools::util::FileSystemWatcher(parentObject, logVerbose); diff --git a/src/grib/windquery.h b/src/grib/windquery.h index 54431a9e..6385fc05 100644 --- a/src/grib/windquery.h +++ b/src/grib/windquery.h @@ -229,6 +229,8 @@ class WindQuery /* Emitted on SSL errors. Call setIgnoreSslErrors to ignore future errors and continue. */ void windDownloadSslErrors(const QStringList& errors, const QString& downloadUrl); + void windDownloadProgress(qint64 bytesReceived, qint64 bytesTotal, QString downloadUrl); + private: /* Wind for grid position */ WindData windForLayer(const WindAltLayer& layer, const QPoint& point) const;