diff options
Diffstat (limited to 'api/logic/net/NetAction.h')
-rw-r--r-- | api/logic/net/NetAction.h | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/api/logic/net/NetAction.h b/api/logic/net/NetAction.h index a533c317..f164dda3 100644 --- a/api/logic/net/NetAction.h +++ b/api/logic/net/NetAction.h @@ -43,18 +43,26 @@ protected: public: virtual ~NetAction() {}; -public: - virtual qint64 totalProgress() const + bool isRunning() const { - return m_total_progress; + return m_status == Job_InProgress; } - virtual qint64 currentProgress() const + bool isFinished() const { - return m_progress; + return m_status >= Job_Finished; } - virtual qint64 numberOfFailures() const + bool wasSuccessful() const { - return m_failures; + return m_status == Job_Finished || m_status == Job_Failed_Proceed; + } + + qint64 totalProgress() const + { + return m_total_progress; + } + qint64 currentProgress() const + { + return m_progress; } virtual bool abort() { @@ -64,25 +72,10 @@ public: { return false; } - -public: - /// the network reply - unique_qobject_ptr<QNetworkReply> m_reply; - - /// source URL - QUrl m_url; - - /// The file's status - JobStatus m_status = Job_NotStarted; - - /// index within the parent job - int m_index_within_job = 0; - - qint64 m_progress = 0; - qint64 m_total_progress = 1; - - /// number of failures up to this point - int m_failures = 0; + QUrl url() + { + return m_url; + } signals: void started(int index); @@ -91,14 +84,28 @@ signals: void failed(int index); void aborted(int index); -protected -slots: +protected slots: virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) = 0; virtual void downloadError(QNetworkReply::NetworkError error) = 0; virtual void downloadFinished() = 0; virtual void downloadReadyRead() = 0; -public -slots: +public slots: virtual void start() = 0; + +public: + /// index within the parent job, FIXME: nuke + int m_index_within_job = 0; + + /// the network reply + unique_qobject_ptr<QNetworkReply> m_reply; + + /// source URL + QUrl m_url; + + qint64 m_progress = 0; + qint64 m_total_progress = 1; + +protected: + JobStatus m_status = Job_NotStarted; }; |