1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 23:03:22 +02:00
GPXSee/src/map/downloader.h

54 lines
944 B
C
Raw Normal View History

2015-11-23 02:33:01 +01:00
#ifndef DOWNLOADER_H
#define DOWNLOADER_H
#include <QNetworkAccessManager>
#include <QUrl>
#include <QList>
2015-12-04 22:56:34 +01:00
#include <QSet>
2015-11-23 02:33:01 +01:00
class QNetworkReply;
2015-11-23 02:33:01 +01:00
class Download
{
public:
Download(const QUrl &url, const QString &file)
2015-11-23 02:33:01 +01:00
{_url = url; _file = file;}
const QUrl& url() const {return _url;}
2015-11-23 02:33:01 +01:00
const QString& file() const {return _file;}
private:
QUrl _url;
2015-11-23 02:33:01 +01:00
QString _file;
};
class Downloader : public QObject
{
Q_OBJECT
public:
Downloader(QObject *parent = 0);
bool get(const QList<Download> &list);
void clearErrors() {_errorDownloads.clear();}
2015-11-23 02:33:01 +01:00
signals:
void finished();
private slots:
void downloadFinished(QNetworkReply *reply);
private:
class Redirect;
class ReplyTimeout;
2017-01-16 21:45:27 +01:00
bool doDownload(const Download &dl, const Redirect *redirect = 0);
2015-11-23 02:33:01 +01:00
bool saveToDisk(const QString &filename, QIODevice *data);
2015-12-04 22:56:34 +01:00
QNetworkAccessManager _manager;
QSet<QUrl> _currentDownloads;
2015-12-04 22:56:34 +01:00
QSet<QUrl> _errorDownloads;
2015-11-23 02:33:01 +01:00
};
#endif // DOWNLOADER_H