From 6cb837e0ef048bb22ee13fd110d15a57d55359c4 Mon Sep 17 00:00:00 2001 From: AdKiller Date: Tue, 27 May 2025 12:38:12 +0200 Subject: [PATCH 1/3] Update trackersfilterwidget.h This pull request adds a new special sidebar filter to the transfer list: Only HTTP. The filter displays torrents that have only HTTP tracker addresses (no HTTPS trackers present). Implementation follows project coding guidelines for naming, formatting, and Qt usage. UI and logic are consistent with other special tracker filters in the sidebar. All user-visible strings are wrapped in tr() for translation and localization. Use case: This feature is useful for users who want to quickly locate torrents that do not use secure (HTTPS) trackers, which may be relevant for diagnosing tracker issues or for privacy/security considerations. --- src/gui/transferlistfilters/trackersfilterwidget.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/transferlistfilters/trackersfilterwidget.h b/src/gui/transferlistfilters/trackersfilterwidget.h index 0b7e82731..cf4cc1821 100644 --- a/src/gui/transferlistfilters/trackersfilterwidget.h +++ b/src/gui/transferlistfilters/trackersfilterwidget.h @@ -85,6 +85,9 @@ private: void downloadFavicon(const QString &trackerHost, const QString &faviconURL); void removeTracker(const QString &tracker); +static bool isOnlyHttpTrackers(const QList &trackers); + QSet m_onlyHttpTorrents; + struct TrackerData { QSet torrents; From dcde896d1d25aae91e8c219e5c7d5e46a666e431 Mon Sep 17 00:00:00 2001 From: AdKiller Date: Tue, 27 May 2025 13:12:33 +0200 Subject: [PATCH 2/3] Update trackersfilterwidget.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces an "Only HTTP" special filter row in the Trackers sidebar of the Transfer List. The following changes were made: Added ONLY_HTTP_ROW to the TRACKER_FILTER_ROW enum This new row allows filtering torrents that use only HTTP (not HTTPS or other protocols) trackers. Displayed a dedicated sidebar entry labeled "Only HTTP" The sidebar now includes a "Only HTTP" row, grouped with the other special rows such as "All", "Trackerless", "Tracker error", "Other error", and "Warning". Provided a translation string for the new row Added an entry in getFormatStringForRow() to display the count of matching torrents in the "Only HTTP" row. Stubbed out the filtering logic in getTorrentIDs() Added a placeholder for returning the set of torrents that should appear in the "Only HTTP" row. Actual filtering logic to select torrents with only HTTP trackers will be implemented in a subsequent commit. Added a helper function (isOnlyHttpTrackers) Introduced a static method to determine if a given torrent’s tracker list consists solely of HTTP trackers, to be used by the filtering implementation. These changes lay the groundwork for supporting HTTP-only tracker filtering in the UI, with the actual selection logic to be completed in a follow-up commit. The code follows qBittorrent’s coding style and ensures clarity and future extensibility. --- .../trackersfilterwidget.cpp | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/gui/transferlistfilters/trackersfilterwidget.cpp b/src/gui/transferlistfilters/trackersfilterwidget.cpp index 60f8a08b8..835f8957a 100644 --- a/src/gui/transferlistfilters/trackersfilterwidget.cpp +++ b/src/gui/transferlistfilters/trackersfilterwidget.cpp @@ -57,7 +57,7 @@ namespace TRACKERERROR_ROW, OTHERERROR_ROW, WARNING_ROW, - + ONLY_HTTP_ROW, // Only HTTP special row NUM_SPECIAL_ROWS }; @@ -97,12 +97,15 @@ namespace return TrackersFilterWidget::tr("All (%1)", "this is for the tracker filter"); case TRACKERLESS_ROW: return TrackersFilterWidget::tr("Trackerless (%1)"); + case ONLY_HTTP_ROW: + return TrackersFilterWidget::tr("Only HTTP (%1)"); case TRACKERERROR_ROW: return TrackersFilterWidget::tr("Tracker error (%1)"); case OTHERERROR_ROW: return TrackersFilterWidget::tr("Other error (%1)"); case WARNING_ROW: return TrackersFilterWidget::tr("Warning (%1)"); + default: return {}; } @@ -141,6 +144,10 @@ TrackersFilterWidget::TrackersFilterWidget(QWidget *parent, TransferListWidget * warningItem->setData(Qt::DisplayRole, formatItemText(WARNING_ROW, 0)); warningItem->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"tracker-warning"_s, u"dialog-warning"_s)); + auto *onlyHttpItem = new QListWidgetItem(this); + onlyHttpItem->setData(Qt::DisplayRole, formatItemText(ONLY_HTTP_ROW, 0)); + onlyHttpItem->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"trackers"_s, u"network-server"_s)); + m_trackers[NULL_HOST] = {{}, trackerlessItem}; handleTorrentsLoaded(BitTorrent::Session::instance()->torrents()); @@ -717,7 +724,27 @@ QSet TrackersFilterWidget::getTorrentIDs(const int row) c return {m_trackerErrors.keyBegin(), m_trackerErrors.keyEnd()}; case WARNING_ROW: return {m_warnings.keyBegin(), m_warnings.keyEnd()}; + case ONLY_HTTP_ROW: + // Placeholder: implement the "only HTTP" logic later + return {}; // TODO: Populate with IDs of torrents having only HTTP trackers default: return m_trackers.value(trackerFromRow(row)).torrents; } + + bool TrackersFilterWidget::isOnlyHttpTrackers(const QList &trackers) +{ + if (trackers.isEmpty()) + return false; + + bool anyHttps = false; + for (const auto &tracker : trackers) { + const QString scheme = QUrl(tracker.url).scheme(); + if (scheme.compare(u"https", Qt::CaseInsensitive) == 0) + anyHttps = true; + else if (!scheme.isEmpty() && scheme.compare(u"http", Qt::CaseInsensitive) != 0) + return false; + } + return !anyHttps; +} + } From 8089b5903b2bb34403cc48eaf738b6e78f84b9fc Mon Sep 17 00:00:00 2001 From: AdKiller Date: Tue, 27 May 2025 13:43:17 +0200 Subject: [PATCH 3/3] Update trackersfilterwidget.h This commit updates the TrackersFilterWidget header to support the new "Only HTTP" filter functionality: Adds a static helper function declaration Declares the static method static bool isOnlyHttpTrackers(const QList &trackers); in the private section of the class. This method is used to determine whether a torrent's trackers are exclusively HTTP (and not HTTPS, UDP, or other schemes). This declaration allows the implementation in the corresponding .cpp file to be accessible for filtering logic, specifically enabling the new "Only HTTP" sidebar row to function correctly. The addition follows the existing coding style and encapsulates the helper within the class as a private static utility. --- src/gui/transferlistfilters/trackersfilterwidget.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/transferlistfilters/trackersfilterwidget.h b/src/gui/transferlistfilters/trackersfilterwidget.h index cf4cc1821..39456f664 100644 --- a/src/gui/transferlistfilters/trackersfilterwidget.h +++ b/src/gui/transferlistfilters/trackersfilterwidget.h @@ -102,4 +102,6 @@ static bool isOnlyHttpTrackers(const QList &trac int m_totalTorrents = 0; bool m_downloadTrackerFavicon = false; QHash> m_downloadingFavicons; // + + static bool isOnlyHttpTrackers(const QList &trackers); };