From 375b15727d8b572b7a4c749a4ab9d1a0415740c0 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Mon, 9 Apr 2018 16:52:37 +0300 Subject: [PATCH] Show rechecking progress When having big torrents, the rechecking might take a while to complete. Users need some sort of feedback that progress is being made. Also, I changed the float to qreal since that's the return type. --- src/base/bittorrent/torrenthandle.cpp | 18 +++++++++++------- src/webui/api/synccontroller.cpp | 2 +- src/webui/api/torrentscontroller.cpp | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index bc75f0e9c..cbe77267a 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -519,15 +519,19 @@ int TorrentHandle::piecesHave() const qreal TorrentHandle::progress() const { - if (!m_nativeStatus.total_wanted) - return 0.; + if (!isChecking()) { + if (!m_nativeStatus.total_wanted) + return 0.; - if (m_nativeStatus.total_wanted_done == m_nativeStatus.total_wanted) - return 1.; + if (m_nativeStatus.total_wanted_done == m_nativeStatus.total_wanted) + return 1.; - float progress = static_cast(m_nativeStatus.total_wanted_done) / m_nativeStatus.total_wanted; - Q_ASSERT((progress >= 0.f) && (progress <= 1.f)); - return progress; + qreal progress = static_cast(m_nativeStatus.total_wanted_done) / m_nativeStatus.total_wanted; + Q_ASSERT((progress >= 0.f) && (progress <= 1.f)); + return progress; + } + + return m_nativeStatus.progress; } QString TorrentHandle::category() const diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp index 1c2126fd2..a90e69a93 100644 --- a/src/webui/api/synccontroller.cpp +++ b/src/webui/api/synccontroller.cpp @@ -327,7 +327,7 @@ namespace // Each value of the 'torrents' dictionary contains map. The map can contain following keys: // - "name": Torrent name // - "size": Torrent size -// - "progress: Torrent progress +// - "progress": Torrent progress // - "dlspeed": Torrent download speed // - "upspeed": Torrent upload speed // - "priority": Torrent priority (-1 if queuing is disabled) diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index c8afa9252..8b6b46c4f 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -132,7 +132,7 @@ namespace // - "hash": Torrent hash // - "name": Torrent name // - "size": Torrent size -// - "progress: Torrent progress +// - "progress": Torrent progress // - "dlspeed": Torrent download speed // - "upspeed": Torrent upload speed // - "priority": Torrent priority (-1 if queuing is disabled)