|
|
@ -385,13 +385,13 @@ void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::Torre |
|
|
|
updateGeometry(); |
|
|
|
updateGeometry(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TrackerFiltersList::removeItem(const QString &tracker, const BitTorrent::TorrentID &id) |
|
|
|
void TrackerFiltersList::removeItem(const QString &trackerURL, const BitTorrent::TorrentID &id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QString host = getHost(tracker); |
|
|
|
const QString host = getHost(trackerURL); |
|
|
|
QSet<BitTorrent::TorrentID> torrentIDs = m_trackers.value(host); |
|
|
|
QSet<BitTorrent::TorrentID> torrentIDs = m_trackers.value(host); |
|
|
|
|
|
|
|
|
|
|
|
if (torrentIDs.empty()) |
|
|
|
if (torrentIDs.empty()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
torrentIDs.remove(id); |
|
|
|
torrentIDs.remove(id); |
|
|
|
|
|
|
|
|
|
|
|
int row = 0; |
|
|
|
int row = 0; |
|
|
@ -400,7 +400,34 @@ void TrackerFiltersList::removeItem(const QString &tracker, const BitTorrent::To |
|
|
|
if (!host.isEmpty()) |
|
|
|
if (!host.isEmpty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Remove from 'Error' and 'Warning' view
|
|
|
|
// Remove from 'Error' and 'Warning' view
|
|
|
|
trackerSuccess(id, tracker); |
|
|
|
const auto errorHashesIt = m_errors.find(id); |
|
|
|
|
|
|
|
if (errorHashesIt != m_errors.end()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QSet<QString> &errored = errorHashesIt.value(); |
|
|
|
|
|
|
|
errored.remove(trackerURL); |
|
|
|
|
|
|
|
if (errored.isEmpty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_errors.erase(errorHashesIt); |
|
|
|
|
|
|
|
item(ERROR_ROW)->setText(tr("Error (%1)").arg(m_errors.size())); |
|
|
|
|
|
|
|
if (currentRow() == ERROR_ROW) |
|
|
|
|
|
|
|
applyFilter(ERROR_ROW); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const auto warningHashesIt = m_warnings.find(id); |
|
|
|
|
|
|
|
if (warningHashesIt != m_warnings.end()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QSet<QString> &warned = *warningHashesIt; |
|
|
|
|
|
|
|
warned.remove(trackerURL); |
|
|
|
|
|
|
|
if (warned.isEmpty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_warnings.erase(warningHashesIt); |
|
|
|
|
|
|
|
item(WARNING_ROW)->setText(tr("Warning (%1)").arg(m_warnings.size())); |
|
|
|
|
|
|
|
if (currentRow() == WARNING_ROW) |
|
|
|
|
|
|
|
applyFilter(WARNING_ROW); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
row = rowFromTracker(host); |
|
|
|
row = rowFromTracker(host); |
|
|
|
trackerItem = item(row); |
|
|
|
trackerItem = item(row); |
|
|
|
|
|
|
|
|
|
|
@ -458,58 +485,64 @@ void TrackerFiltersList::setDownloadTrackerFavicon(bool value) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TrackerFiltersList::trackerSuccess(const BitTorrent::TorrentID &id, const QString &tracker) |
|
|
|
void TrackerFiltersList::handleTrackerEntriesUpdated(const QHash<BitTorrent::Torrent *, QHash<QString, BitTorrent::TrackerEntryUpdateInfo>> &updateInfos) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const auto errorHashesIter = m_errors.find(id); |
|
|
|
for (auto torrentsIt = updateInfos.cbegin(); torrentsIt != updateInfos.cend(); ++torrentsIt) |
|
|
|
if (errorHashesIter != m_errors.end()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
QSet<QString> &errored = *errorHashesIter; |
|
|
|
const BitTorrent::TorrentID id = torrentsIt.key()->id(); |
|
|
|
errored.remove(tracker); |
|
|
|
const QHash<QString, BitTorrent::TrackerEntryUpdateInfo> &infos = torrentsIt.value(); |
|
|
|
if (errored.empty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_errors.erase(errorHashesIter); |
|
|
|
|
|
|
|
item(ERROR_ROW)->setText(tr("Error (%1)").arg(m_errors.size())); |
|
|
|
|
|
|
|
if (currentRow() == ERROR_ROW) |
|
|
|
|
|
|
|
applyFilter(ERROR_ROW); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const auto warningHashesIter = m_warnings.find(id); |
|
|
|
auto errorHashesIt = m_errors.find(id); |
|
|
|
if (warningHashesIter != m_warnings.end()) |
|
|
|
auto warningHashesIt = m_warnings.find(id); |
|
|
|
{ |
|
|
|
|
|
|
|
QSet<QString> &warned = *warningHashesIter; |
|
|
|
for (auto trackerIt = infos.cbegin(); trackerIt != infos.cend(); ++trackerIt) |
|
|
|
warned.remove(tracker); |
|
|
|
|
|
|
|
if (warned.empty()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
m_warnings.erase(warningHashesIter); |
|
|
|
const QString &trackerURL = trackerIt.key(); |
|
|
|
item(WARNING_ROW)->setText(tr("Warning (%1)").arg(m_warnings.size())); |
|
|
|
const BitTorrent::TrackerEntryUpdateInfo &updateInfo = trackerIt.value(); |
|
|
|
if (currentRow() == WARNING_ROW) |
|
|
|
|
|
|
|
applyFilter(WARNING_ROW); |
|
|
|
if (updateInfo.status == BitTorrent::TrackerEntry::Working) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (errorHashesIt != m_errors.end()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QSet<QString> &errored = errorHashesIt.value(); |
|
|
|
|
|
|
|
errored.remove(trackerURL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!updateInfo.hasMessages) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (warningHashesIt != m_warnings.end()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QSet<QString> &warned = *warningHashesIt; |
|
|
|
|
|
|
|
warned.remove(trackerURL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (warningHashesIt == m_warnings.end()) |
|
|
|
|
|
|
|
warningHashesIt = m_warnings.insert(id, {}); |
|
|
|
|
|
|
|
warningHashesIt.value().insert(trackerURL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (updateInfo.status == BitTorrent::TrackerEntry::NotWorking) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (errorHashesIt == m_errors.end()) |
|
|
|
|
|
|
|
errorHashesIt = m_errors.insert(id, {}); |
|
|
|
|
|
|
|
errorHashesIt.value().insert(trackerURL); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TrackerFiltersList::trackerError(const BitTorrent::TorrentID &id, const QString &tracker) |
|
|
|
if ((errorHashesIt != m_errors.end()) && errorHashesIt.value().isEmpty()) |
|
|
|
{ |
|
|
|
m_errors.erase(errorHashesIt); |
|
|
|
QSet<QString> &trackers {m_errors[id]}; |
|
|
|
if ((warningHashesIt != m_warnings.end()) && warningHashesIt.value().isEmpty()) |
|
|
|
if (trackers.contains(tracker)) |
|
|
|
m_warnings.erase(warningHashesIt); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
trackers.insert(tracker); |
|
|
|
|
|
|
|
item(ERROR_ROW)->setText(tr("Error (%1)").arg(m_errors.size())); |
|
|
|
item(ERROR_ROW)->setText(tr("Error (%1)").arg(m_errors.size())); |
|
|
|
|
|
|
|
item(WARNING_ROW)->setText(tr("Warning (%1)").arg(m_warnings.size())); |
|
|
|
|
|
|
|
|
|
|
|
if (currentRow() == ERROR_ROW) |
|
|
|
if (currentRow() == ERROR_ROW) |
|
|
|
applyFilter(ERROR_ROW); |
|
|
|
applyFilter(ERROR_ROW); |
|
|
|
} |
|
|
|
else if (currentRow() == WARNING_ROW) |
|
|
|
|
|
|
|
|
|
|
|
void TrackerFiltersList::trackerWarning(const BitTorrent::TorrentID &id, const QString &tracker) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QSet<QString> &trackers {m_warnings[id]}; |
|
|
|
|
|
|
|
if (trackers.contains(tracker)) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trackers.insert(tracker); |
|
|
|
|
|
|
|
item(WARNING_ROW)->setText(tr("Warning (%1)").arg(m_warnings.size())); |
|
|
|
|
|
|
|
if (currentRow() == WARNING_ROW) |
|
|
|
|
|
|
|
applyFilter(WARNING_ROW); |
|
|
|
applyFilter(WARNING_ROW); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -732,13 +765,6 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi |
|
|
|
connect(statusLabel, &QCheckBox::toggled, pref, &Preferences::setStatusFilterState); |
|
|
|
connect(statusLabel, &QCheckBox::toggled, pref, &Preferences::setStatusFilterState); |
|
|
|
connect(trackerLabel, &QCheckBox::toggled, m_trackerFilters, &TrackerFiltersList::toggleFilter); |
|
|
|
connect(trackerLabel, &QCheckBox::toggled, m_trackerFilters, &TrackerFiltersList::toggleFilter); |
|
|
|
connect(trackerLabel, &QCheckBox::toggled, pref, &Preferences::setTrackerFilterState); |
|
|
|
connect(trackerLabel, &QCheckBox::toggled, pref, &Preferences::setTrackerFilterState); |
|
|
|
|
|
|
|
|
|
|
|
connect(this, qOverload<const BitTorrent::TorrentID &, const QString &>(&TransferListFiltersWidget::trackerSuccess) |
|
|
|
|
|
|
|
, m_trackerFilters, &TrackerFiltersList::trackerSuccess); |
|
|
|
|
|
|
|
connect(this, qOverload<const BitTorrent::TorrentID &, const QString &>(&TransferListFiltersWidget::trackerError) |
|
|
|
|
|
|
|
, m_trackerFilters, &TrackerFiltersList::trackerError); |
|
|
|
|
|
|
|
connect(this, qOverload<const BitTorrent::TorrentID &, const QString &>(&TransferListFiltersWidget::trackerWarning) |
|
|
|
|
|
|
|
, m_trackerFilters, &TrackerFiltersList::trackerWarning); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListFiltersWidget::setDownloadTrackerFavicon(bool value) |
|
|
|
void TransferListFiltersWidget::setDownloadTrackerFavicon(bool value) |
|
|
@ -763,19 +789,9 @@ void TransferListFiltersWidget::changeTrackerless(const BitTorrent::Torrent *tor |
|
|
|
m_trackerFilters->changeTrackerless(trackerless, torrent->id()); |
|
|
|
m_trackerFilters->changeTrackerless(trackerless, torrent->id()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListFiltersWidget::trackerSuccess(const BitTorrent::Torrent *torrent, const QString &tracker) |
|
|
|
void TransferListFiltersWidget::trackerEntriesUpdated(const QHash<BitTorrent::Torrent *, QHash<QString, BitTorrent::TrackerEntryUpdateInfo>> &updateInfos) |
|
|
|
{ |
|
|
|
|
|
|
|
emit trackerSuccess(torrent->id(), tracker); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TransferListFiltersWidget::trackerWarning(const BitTorrent::Torrent *torrent, const QString &tracker) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
emit trackerWarning(torrent->id(), tracker); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TransferListFiltersWidget::trackerError(const BitTorrent::Torrent *torrent, const QString &tracker) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
emit trackerError(torrent->id(), tracker); |
|
|
|
m_trackerFilters->handleTrackerEntriesUpdated(updateInfos); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListFiltersWidget::onCategoryFilterStateChanged(bool enabled) |
|
|
|
void TransferListFiltersWidget::onCategoryFilterStateChanged(bool enabled) |
|
|
|