2017-11-23 12:33:32 +08:00
|
|
|
#ifndef QQTHTTPDOWNLOADPROTOCOL_H
|
|
|
|
#define QQTHTTPDOWNLOADPROTOCOL_H
|
|
|
|
|
|
|
|
#include <qqtwebaccessmanager.h>
|
|
|
|
|
|
|
|
class QQtHttpDownloadWebWorkSession: public QQtWebAccessSession
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-11-24 13:27:45 +08:00
|
|
|
explicit QQtHttpDownloadWebWorkSession ( QObject* parent = 0 ) :
|
|
|
|
QQtWebAccessSession ( parent ) {
|
|
|
|
filename = "tmp.download";
|
|
|
|
}
|
2017-11-23 12:33:32 +08:00
|
|
|
virtual ~QQtHttpDownloadWebWorkSession() {}
|
2017-11-24 13:27:45 +08:00
|
|
|
|
|
|
|
QString filename;
|
2017-11-25 17:55:19 +08:00
|
|
|
QString url;//?x
|
|
|
|
QString filesize;
|
|
|
|
QString filedownloaded;
|
|
|
|
QString elipsedSize;
|
|
|
|
|
|
|
|
QString downloadingTime;
|
|
|
|
QString elipsedTime;
|
|
|
|
QString wholeTime;
|
|
|
|
QString speed;
|
2017-11-23 12:33:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class QQtHttpDownloadManager : public QQtWebAccessManager
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit QQtHttpDownloadManager ( QObject* parent = nullptr );
|
|
|
|
virtual ~QQtHttpDownloadManager() {}
|
|
|
|
|
2017-11-24 13:27:45 +08:00
|
|
|
void sendRequest ( QString strUrl, QString filename );
|
2017-11-23 12:33:32 +08:00
|
|
|
signals:
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2017-11-25 17:55:19 +08:00
|
|
|
protected:
|
|
|
|
/* 字节转KB、MB、GB */
|
|
|
|
QString getSize ( qint64 bytes );
|
|
|
|
|
|
|
|
/* 速度转KB/S、MB/S、GB/S */
|
|
|
|
QString getSpeed ( double speed );
|
|
|
|
|
|
|
|
/* 秒转*d *h *m *s */
|
|
|
|
QString getElipsedTime ( int seconds );
|
2017-11-23 12:33:32 +08:00
|
|
|
private slots:
|
2017-11-23 19:12:48 +08:00
|
|
|
void replyReadyRead ( QQtWebAccessSession* session );
|
2017-11-25 17:55:19 +08:00
|
|
|
void updateDownloadProgress ( QQtWebAccessSession* session, qint64 bytesReceived, qint64 bytesTotal );
|
2017-11-23 12:33:32 +08:00
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QQTHTTPDOWNLOADPROTOCOL_H
|