From 1a1db877bfde76469a70214975cb866783167623 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Fri, 21 Nov 2014 17:13:39 +0300 Subject: [PATCH] Use QTorrentHandle::torrentState() in btjson. --- src/webui/btjson.cpp | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index 1452ef67b..ac713ce84 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -154,42 +154,8 @@ static QVariantMap toMap(const QTorrentHandle& h) ret[KEY_TORRENT_NUM_INCOMPLETE] = status.num_incomplete; const qreal ratio = QBtSession::instance()->getRealRatio(status); ret[KEY_TORRENT_RATIO] = (ratio > 100.) ? -1 : ratio; - qulonglong eta = 0; - QString state; - if (h.is_paused(status)) { - if (h.has_error(status)) - state = "error"; - else - state = h.is_seed(status) ? "pausedUP" : "pausedDL"; - } - else { - if (QBtSession::instance()->isQueueingEnabled() && h.is_queued(status)) { - state = h.is_seed(status) ? "queuedUP" : "queuedDL"; - } - else { - switch (status.state) { - case torrent_status::finished: - case torrent_status::seeding: - state = status.upload_payload_rate > 0 ? "uploading" : "stalledUP"; - break; - case torrent_status::allocating: - case torrent_status::checking_files: - case torrent_status::queued_for_checking: - case torrent_status::checking_resume_data: - state = h.is_seed(status) ? "checkingUP" : "checkingDL"; - break; - case torrent_status::downloading: - case torrent_status::downloading_metadata: - state = status.download_payload_rate > 0 ? "downloading" : "stalledDL"; - eta = QBtSession::instance()->getETA(h.hash(), status); - break; - default: - qWarning("Unrecognized torrent status, should not happen!!! status was %d", h.state()); - } - } - } - ret[KEY_TORRENT_ETA] = eta ? eta : MAX_ETA; - ret[KEY_TORRENT_STATE] = state; + ret[KEY_TORRENT_STATE] = h.torrentState().toString(); + ret[KEY_TORRENT_ETA] = h.eta(); return ret; }