blob: d64445f2d51d094f717309975fd4b3825be35761 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* FileDownloader.h
*
* Created on: Mar 7, 2014
* Author: nils
*/
#ifndef FILEDOWNLOADER_H_
#define FILEDOWNLOADER_H_
#include <QObject>
#include <QByteArray>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
class FileDownloader : public QObject
{
Q_OBJECT
public:
explicit FileDownloader(const QUrl& fileUrl, QObject *parent = 0);
virtual ~FileDownloader();
bool downloadFile();
signals:
/**
* Triggered when the download has finished.
* On error, downloadedData will be empty.
*/
void downloaded(const QUrl& url, const QByteArray& downloadedData);
private slots:
void fileDownloaded();
void downloadFailed(QNetworkReply::NetworkError code);
void downloadProgress(qint64 received, qint64 totalSize);
private:
void killReply(QNetworkReply *reply);
bool started;
QUrl url;
};
#endif /* FILEDOWNLOADER_H_ */
|