mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 06:57:24 -06:00
Revise 'Add trackers' dialog
* Now it allow user to add tracker to different tier. * The downloaded trackers are now displayed as is (without modifying). * Now the dialog remember dialog size and last used URL. Closes #17692.
This commit is contained in:
@@ -28,6 +28,34 @@
|
||||
|
||||
#include "trackerentry.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
|
||||
QVector<BitTorrent::TrackerEntry> BitTorrent::parseTrackerEntries(const QStringView str)
|
||||
{
|
||||
const QList<QStringView> trackers = str.split(u'\n'); // keep the empty parts to track tracker tier
|
||||
|
||||
QVector<BitTorrent::TrackerEntry> entries;
|
||||
entries.reserve(trackers.size());
|
||||
|
||||
int trackerTier = 0;
|
||||
for (QStringView tracker : trackers)
|
||||
{
|
||||
tracker = tracker.trimmed();
|
||||
|
||||
if (tracker.isEmpty())
|
||||
{
|
||||
if (trackerTier < std::numeric_limits<decltype(trackerTier)>::max()) // prevent overflow
|
||||
++trackerTier;
|
||||
continue;
|
||||
}
|
||||
|
||||
entries.append({tracker.toString(), trackerTier});
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
bool BitTorrent::operator==(const TrackerEntry &left, const TrackerEntry &right)
|
||||
{
|
||||
return (left.url == right.url);
|
||||
|
||||
Reference in New Issue
Block a user