1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-27 03:29:16 +02:00

Added support for downloading DEM tiles

This commit is contained in:
2021-08-30 20:31:33 +02:00
parent 94a0158243
commit 2232b011a1
24 changed files with 437 additions and 87 deletions

View File

@ -77,7 +77,7 @@ QNetworkAccessManager *Downloader::_manager = 0;
int Downloader::_timeout = 30;
bool Downloader::_http2 = true;
bool Downloader::doDownload(const Download &dl, const QByteArray &authorization)
bool Downloader::doDownload(const Download &dl, const Authorization &auth)
{
const QUrl &url = dl.url();
@ -98,8 +98,8 @@ bool Downloader::doDownload(const Download &dl, const QByteArray &authorization)
QNetworkRequest::NoLessSafeRedirectPolicy);
request.setAttribute(ATTR_HTTP2_ALLOWED, QVariant(_http2));
request.setRawHeader("User-Agent", USER_AGENT);
if (!authorization.isNull())
request.setRawHeader("Authorization", authorization);
if (!auth.isNull())
request.setRawHeader("Authorization", auth.header());
QFile *file = new QFile(tmpName(dl.file()));
if (!file->open(QIODevice::WriteOnly)) {
@ -182,7 +182,7 @@ bool Downloader::get(const QList<Download> &list,
bool finishEmitted = false;
for (int i = 0; i < list.count(); i++)
finishEmitted |= doDownload(list.at(i), authorization.header());
finishEmitted |= doDownload(list.at(i), authorization);
return finishEmitted;
}

View File

@ -29,6 +29,7 @@ public:
Authorization() {}
Authorization(const QString &username, const QString &password);
bool isNull() const {return _header.isNull();}
const QByteArray &header() const {return _header;}
private:
@ -79,7 +80,7 @@ private:
class ReplyTimeout;
void insertError(const QUrl &url, QNetworkReply::NetworkError error);
bool doDownload(const Download &dl, const QByteArray &authorization);
bool doDownload(const Download &dl, const Authorization &auth);
void downloadFinished(QNetworkReply *reply);
void readData(QNetworkReply *reply);