Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef SIMPLEDOWNLOADER_H
- #define SIMPLEDOWNLOADER_H
- #include <QObject>
- #include <QNetworkAccessManager>
- #include <QNetworkReply>
- #include <QNetworkRequest>
- #include <QFile>
- #include <QStringList>
- #include <QFileInfo>
- #include <QDir>
- #include <QUrl>
- #include <QIODevice>
- #include <QTime>
- class SimpleDownloader : public QObject
- {
- Q_OBJECT
- QNetworkAccessManager manager;
- QUrl currentDownload;
- QString currentSaveDirectory;
- QTime *timer;
- QNetworkReply *reply;
- public:
- SimpleDownloader();
- void InitDownload(QString url, QString saveDirectory);
- signals:
- void Progress(int received, int total, QString message);
- void Finished(QString filename, bool success, QString message);
- private:
- QString saveFileName(QUrl url);
- bool saveReply(QString filename, QIODevice *data);
- private slots:
- void DownloadFinished(QNetworkReply *reply);
- void DownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
- void DownloadError(QNetworkReply::NetworkError);
- void ReplyDownloadFinished();
- };
- #endif // SIMPLEDOWNLOADER_H
Add Comment
Please, Sign In to add comment