filedownloadertask.h
45 lines
| 1.1 KiB
| text/x-c
|
CLexer
r4 | #ifndef FILEDOWNLOADERTASK_H | |||
#define FILEDOWNLOADERTASK_H | ||||
#include <QObject> | ||||
#include <QByteArray> | ||||
#include <QNetworkAccessManager> | ||||
#include <QNetworkRequest> | ||||
#include <QNetworkReply> | ||||
#include <QFile> | ||||
#include <QDateTime> | ||||
// TODO add download speed and remaining time. | ||||
class FileDownloaderTask : public QObject | ||||
{ | ||||
Q_OBJECT | ||||
public: | ||||
explicit FileDownloaderTask(QNetworkReply* reply,int ID,const QString& fileName,QObject *parent = 0); | ||||
~FileDownloaderTask(); | ||||
int ID(); | ||||
const QString& fileName(); | ||||
const QString& url(); | ||||
const QDateTime& startDateTime(); | ||||
bool downloadComplete(); | ||||
signals: | ||||
void updateProgress(int percent); | ||||
void updateProgress(qint64 bytesSent, qint64 bytesTotal); | ||||
public slots: | ||||
private slots: | ||||
void downloadProgress(qint64 bytesSent, qint64 bytesTotal); | ||||
void readReady(); | ||||
void downloadFinished(); | ||||
private: | ||||
int m_taskId; | ||||
QNetworkReply* m_Reply; | ||||
QByteArray m_DownloadedData; | ||||
bool m_downloadComplete; | ||||
QFile* m_file; | ||||
QString m_FileName; | ||||
QString m_URL; | ||||
QDateTime m_startDateTime; | ||||
}; | ||||
#endif // FILEDOWNLOADERTASK_H | ||||