RabbitCommon v2.3.3
Loading...
Searching...
No Matches
Download.h
1// Copyright Copyright (c) Kang Lin studio, All Rights Reserved
2// Author Kang Lin <kl222@126.com>
3
4#ifndef CDOWNLOADFILE_H
5#define CDOWNLOADFILE_H
6
7#include <QUrl>
8#include <QFile>
9#include <QNetworkAccessManager>
10#include <QNetworkReply>
11
12#include "rabbitcommon_export.h"
13
14namespace RabbitCommon {
15
47class RABBITCOMMON_EXPORT CDownload : public QObject
48{
49 Q_OBJECT
50
51public:
52 explicit CDownload(QObject *parent = nullptr);
53 ~CDownload();
54
71 int Start(QVector<QUrl> urls, QString szFileName = QString(), bool bSequence = false);
72
73signals:
77 void sigFinished(const QString szFile);
78 void sigError(int nErr, const QString szErr);
79 void sigDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
80
81private:
89 int DownloadFile(int nIndex, const QUrl &url, bool bRedirection = false);
90 int CloseReply(QNetworkReply* pReply, bool bAbort = false);
91
92private Q_SLOTS:
93 void slotReadyRead();
94 void slotError(QNetworkReply::NetworkError e);
95 void slotSslError(const QList<QSslError> e);
96 void slotDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
97 void slotFinished();
98
99private:
100 bool m_bSequence;
101 QString m_szFileName;
102 QVector<QUrl> m_Url;
103 QVector<QSharedPointer<QFile> > m_DownloadFile;
104 bool m_bDownload;
105 QNetworkAccessManager m_NetManager;
106 QMap<QNetworkReply*, int> m_Reply;
107 qint64 m_nBytesReceived;
108 QString m_szError;
109};
110
111} // namespace RabbitCommon
112
113#endif // CDOWNLOADFILE_H
Download the same file from multiple URLs.
Definition Download.h:48
void sigFinished(const QString szFile)