Browse Source

Correctly populate trackers filter list

PR #16814.
adaptive-webui-19844
Vladimir Golovnev 3 years ago committed by GitHub
parent
commit
33ffe95294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      src/gui/transferlistfilterswidget.cpp

22
src/gui/transferlistfilterswidget.cpp

@ -390,31 +390,35 @@ TrackerFiltersList::~TrackerFiltersList()
void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::TorrentID &id) void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::TorrentID &id)
{ {
const QString host {getHost(tracker)}; const QString host = getHost(tracker);
const auto existingDataItr = m_trackers.find(host); auto trackersIt = m_trackers.find(host);
const bool exists {existingDataItr != m_trackers.end()}; const bool exists = (trackersIt != m_trackers.end());
QListWidgetItem *trackerItem {nullptr}; QListWidgetItem *trackerItem = nullptr;
if (exists) if (exists)
{ {
if (existingDataItr->torrents.contains(id)) if (trackersIt->torrents.contains(id))
return; return;
trackerItem = (host == NULL_HOST) trackerItem = (host == NULL_HOST)
? item(TRACKERLESS_ROW) ? item(TRACKERLESS_ROW)
: existingDataItr->item; : trackersIt->item;
} }
else else
{ {
trackerItem = new QListWidgetItem(); trackerItem = new QListWidgetItem();
trackerItem->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"network-server"_qs)); trackerItem->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"network-server"_qs));
TrackerData trackerData {{}, trackerItem};
trackersIt = m_trackers.insert(host, trackerData);
const QString scheme = getScheme(tracker); const QString scheme = getScheme(tracker);
downloadFavicon(u"%1://%2/favicon.ico"_qs.arg((scheme.startsWith(u"http") ? scheme : u"http"_qs), host)); downloadFavicon(u"%1://%2/favicon.ico"_qs.arg((scheme.startsWith(u"http") ? scheme : u"http"_qs), host));
} }
if (!trackerItem) return;
QSet<BitTorrent::TorrentID> &torrentIDs {m_trackers[host].torrents}; Q_ASSERT(trackerItem);
QSet<BitTorrent::TorrentID> &torrentIDs = trackersIt->torrents;
torrentIDs.insert(id); torrentIDs.insert(id);
if (host == NULL_HOST) if (host == NULL_HOST)
@ -428,7 +432,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::Torre
trackerItem->setText(u"%1 (%2)"_qs.arg(host, QString::number(torrentIDs.size()))); trackerItem->setText(u"%1 (%2)"_qs.arg(host, QString::number(torrentIDs.size())));
if (exists) if (exists)
{ {
if (trackerFromRow(currentRow()) == host) if (item(currentRow()) == trackerItem)
applyFilter(currentRow()); applyFilter(currentRow());
return; return;
} }

Loading…
Cancel
Save