From d8c40084a77e6ba2214955030a38162c1cd6782a Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Wed, 4 Jun 2014 00:35:23 +0300 Subject: [PATCH] Rework the GUI code for private torrents. Conflicts: src/qtlibtorrent/qtorrenthandle.cpp --- src/properties/trackerlist.cpp | 30 +++++++++++++++++------------ src/qtlibtorrent/qtorrenthandle.cpp | 2 ++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/properties/trackerlist.cpp b/src/properties/trackerlist.cpp index ed5f16e38..c36dc12c2 100644 --- a/src/properties/trackerlist.cpp +++ b/src/properties/trackerlist.cpp @@ -198,27 +198,33 @@ void TrackerList::clear() { } void TrackerList::loadStickyItems(const QTorrentHandle &h) { + QString working = tr("Working"); + QString disabled = tr("Disabled"); + // load DHT information - if (QBtSession::instance()->isDHTEnabled() && (!h.has_metadata() || !h.priv())) { - dht_item->setText(COL_STATUS, tr("Working")); - } else { - dht_item->setText(COL_STATUS, tr("Disabled")); - } - if (h.has_metadata() && h.priv()) { - dht_item->setText(COL_MSG, tr("This torrent is private")); - } + if (QBtSession::instance()->isDHTEnabled() && !h.priv()) + dht_item->setText(COL_STATUS, working); + else + dht_item->setText(COL_STATUS, disabled); // Load PeX Information if (QBtSession::instance()->isPexEnabled() && !h.priv()) - pex_item->setText(COL_STATUS, tr("Working")); + pex_item->setText(COL_STATUS, working); else - pex_item->setText(COL_STATUS, tr("Disabled")); + pex_item->setText(COL_STATUS, disabled); // Load LSD Information if (QBtSession::instance()->isLSDEnabled() && !h.priv()) - lsd_item->setText(COL_STATUS, tr("Working")); + lsd_item->setText(COL_STATUS, working); else - lsd_item->setText(COL_STATUS, tr("Disabled")); + lsd_item->setText(COL_STATUS, disabled); + + if (h.priv()) { + QString privateMsg = tr("This torrent is private"); + dht_item->setText(COL_MSG, privateMsg); + pex_item->setText(COL_MSG, privateMsg); + lsd_item->setText(COL_MSG, privateMsg); + } // XXX: libtorrent should provide this info... // Count peers from DHT, LSD, PeX diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index b608caeac..3cde87596 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -550,6 +550,8 @@ int QTorrentHandle::connections_limit() const { } bool QTorrentHandle::priv() const { + if (!has_metadata()) + return false; return torrent_handle::get_torrent_info().priv(); }