RabbitCommon v2.2.6
Loading...
Searching...
No Matches
Download.h
1#ifndef CDOWNLOADFILE_H
2#define CDOWNLOADFILE_H
3
4#include <QUrl>
5#include <QFile>
6#include <QNetworkAccessManager>
7#include <QNetworkReply>
8
9#include "rabbitcommon_export.h"
10
11namespace RabbitCommon {
12
44class RABBITCOMMON_EXPORT CDownload : public QObject
45{
46 Q_OBJECT
47
48public:
49 explicit CDownload(QObject *parent = nullptr);
50 ~CDownload();
51
68 int Start(QVector<QUrl> urls, QString szFileName = QString(), bool bSequence = false);
69
70signals:
74 void sigFinished(const QString szFile);
75 void sigError(int nErr, const QString szErr);
76 void sigDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
77
78private:
86 int DownloadFile(int nIndex, const QUrl &url, bool bRedirection = false);
87 int CloseReply(QNetworkReply* pReply, bool bAbort = false);
88
89private Q_SLOTS:
90 void slotReadyRead();
91 void slotError(QNetworkReply::NetworkError e);
92 void slotSslError(const QList<QSslError> e);
93 void slotDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
94 void slotFinished();
95
96private:
97 bool m_bSequence;
98 QString m_szFileName;
99 QVector<QUrl> m_Url;
100 QVector<QSharedPointer<QFile> > m_DownloadFile;
101 bool m_bDownload;
102 QNetworkAccessManager m_NetManager;
103 QMap<QNetworkReply*, int> m_Reply;
104 qint64 m_nBytesReceived;
105 QString m_szError;
106};
107
108} // namespace RabbitCommon
109
110#endif // CDOWNLOADFILE_H
Download the same file from multiple URLs.
Definition Download.h:45
void sigFinished(const QString szFile)