downloadmanager.h 937 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef DOWNLOADMANAGER_H
  2. #define DOWNLOADMANAGER_H
  3. #include <QFile>
  4. #include <QObject>
  5. #include <QQueue>
  6. #include <QTime>
  7. #include <QUrl>
  8. #include <QLabel>
  9. #include <QNetworkAccessManager>
  10. //#include "textprogressbar.h"
  11. class DownloadManager: public QObject
  12. {
  13. Q_OBJECT
  14. public:
  15. DownloadManager(QObject *parent = 0);
  16. void append(const QUrl &url);
  17. void append(const QStringList &urlList);
  18. void startNextDownload();
  19. void abortDownload(QString name);
  20. signals:
  21. void finished();
  22. void cancelDownload();
  23. private slots:
  24. void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
  25. void downloadFinished();
  26. void downloadReadyRead();
  27. private:
  28. QNetworkAccessManager manager;
  29. QQueue<QUrl> downloadQueue;
  30. QNetworkReply *currentDownload;
  31. QFile output;
  32. QTime downloadTime;
  33. QString download_name;
  34. int downloadedCount;
  35. int totalCount;
  36. };
  37. #endif // DOWNLOADMANAGER_H