mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 05:27:15 +03:00
Allow to cancel download request
This commit is contained in:
parent
b144d3b797
commit
73ef69526d
2 changed files with 17 additions and 1 deletions
|
@ -121,6 +121,8 @@ namespace
|
||||||
explicit DownloadHandlerImpl(const Net::DownloadRequest &downloadRequest, QObject *parent);
|
explicit DownloadHandlerImpl(const Net::DownloadRequest &downloadRequest, QObject *parent);
|
||||||
~DownloadHandlerImpl() override;
|
~DownloadHandlerImpl() override;
|
||||||
|
|
||||||
|
void cancel() override;
|
||||||
|
|
||||||
QString url() const;
|
QString url() const;
|
||||||
const Net::DownloadRequest downloadRequest() const;
|
const Net::DownloadRequest downloadRequest() const;
|
||||||
|
|
||||||
|
@ -416,6 +418,17 @@ namespace
|
||||||
delete m_reply;
|
delete m_reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownloadHandlerImpl::cancel()
|
||||||
|
{
|
||||||
|
if (m_reply) {
|
||||||
|
m_reply->abort();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setError(errorCodeToString(QNetworkReply::OperationCanceledError));
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadHandlerImpl::assignNetworkReply(QNetworkReply *reply)
|
void DownloadHandlerImpl::assignNetworkReply(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
Q_ASSERT(reply);
|
Q_ASSERT(reply);
|
||||||
|
|
|
@ -104,6 +104,8 @@ namespace Net
|
||||||
public:
|
public:
|
||||||
using QObject::QObject;
|
using QObject::QObject;
|
||||||
|
|
||||||
|
virtual void cancel() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished(const DownloadResult &result);
|
void finished(const DownloadResult &result);
|
||||||
};
|
};
|
||||||
|
@ -118,6 +120,8 @@ namespace Net
|
||||||
static void freeInstance();
|
static void freeInstance();
|
||||||
static DownloadManager *instance();
|
static DownloadManager *instance();
|
||||||
|
|
||||||
|
DownloadHandler *download(const DownloadRequest &downloadRequest);
|
||||||
|
|
||||||
template <typename Context, typename Func>
|
template <typename Context, typename Func>
|
||||||
void download(const DownloadRequest &downloadRequest, Context context, Func &&slot);
|
void download(const DownloadRequest &downloadRequest, Context context, Func &&slot);
|
||||||
|
|
||||||
|
@ -137,7 +141,6 @@ namespace Net
|
||||||
private:
|
private:
|
||||||
explicit DownloadManager(QObject *parent = nullptr);
|
explicit DownloadManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
DownloadHandler *download(const DownloadRequest &downloadRequest);
|
|
||||||
void applyProxySettings();
|
void applyProxySettings();
|
||||||
void handleReplyFinished(const QNetworkReply *reply);
|
void handleReplyFinished(const QNetworkReply *reply);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue