mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
Improve torrent event handling in TrackerFiltersList
This commit is contained in:
parent
2c8447853b
commit
cd9ed1706d
@ -217,6 +217,7 @@ namespace BitTorrent
|
|||||||
virtual bool hasMissingFiles() const = 0;
|
virtual bool hasMissingFiles() const = 0;
|
||||||
virtual bool hasError() const = 0;
|
virtual bool hasError() const = 0;
|
||||||
virtual int queuePosition() const = 0;
|
virtual int queuePosition() const = 0;
|
||||||
|
virtual QVector<QString> trackerURLs() const = 0;
|
||||||
virtual QVector<TrackerEntry> trackers() const = 0;
|
virtual QVector<TrackerEntry> trackers() const = 0;
|
||||||
virtual QVector<QUrl> urlSeeds() const = 0;
|
virtual QVector<QUrl> urlSeeds() const = 0;
|
||||||
virtual QString error() const = 0;
|
virtual QString error() const = 0;
|
||||||
|
@ -517,6 +517,22 @@ void TorrentImpl::setAutoManaged(const bool enable)
|
|||||||
m_nativeHandle.unset_flags(lt::torrent_flags::auto_managed);
|
m_nativeHandle.unset_flags(lt::torrent_flags::auto_managed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QString> TorrentImpl::trackerURLs() const
|
||||||
|
{
|
||||||
|
const std::vector<lt::announce_entry> nativeTrackers = m_nativeHandle.trackers();
|
||||||
|
|
||||||
|
QVector<QString> urls;
|
||||||
|
urls.reserve(static_cast<decltype(urls)::size_type>(nativeTrackers.size()));
|
||||||
|
|
||||||
|
for (const lt::announce_entry &tracker : nativeTrackers)
|
||||||
|
{
|
||||||
|
const QString trackerURL = QString::fromStdString(tracker.url);
|
||||||
|
urls.push_back(trackerURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return urls;
|
||||||
|
}
|
||||||
|
|
||||||
QVector<TrackerEntry> TorrentImpl::trackers() const
|
QVector<TrackerEntry> TorrentImpl::trackers() const
|
||||||
{
|
{
|
||||||
const std::vector<lt::announce_entry> nativeTrackers = m_nativeHandle.trackers();
|
const std::vector<lt::announce_entry> nativeTrackers = m_nativeHandle.trackers();
|
||||||
|
@ -153,6 +153,7 @@ namespace BitTorrent
|
|||||||
bool hasMissingFiles() const override;
|
bool hasMissingFiles() const override;
|
||||||
bool hasError() const override;
|
bool hasError() const override;
|
||||||
int queuePosition() const override;
|
int queuePosition() const override;
|
||||||
|
QVector<QString> trackerURLs() const override;
|
||||||
QVector<TrackerEntry> trackers() const override;
|
QVector<TrackerEntry> trackers() const override;
|
||||||
QVector<QUrl> urlSeeds() const override;
|
QVector<QUrl> urlSeeds() const override;
|
||||||
QString error() const override;
|
QString error() const override;
|
||||||
|
@ -630,12 +630,12 @@ void TrackerFiltersList::applyFilter(const int row)
|
|||||||
void TrackerFiltersList::handleNewTorrent(BitTorrent::Torrent *const torrent)
|
void TrackerFiltersList::handleNewTorrent(BitTorrent::Torrent *const torrent)
|
||||||
{
|
{
|
||||||
const BitTorrent::TorrentID torrentID {torrent->id()};
|
const BitTorrent::TorrentID torrentID {torrent->id()};
|
||||||
const QVector<BitTorrent::TrackerEntry> trackers {torrent->trackers()};
|
const QVector<QString> trackerURLs {torrent->trackerURLs()};
|
||||||
for (const BitTorrent::TrackerEntry &tracker : trackers)
|
for (const QString &trackerURL : trackerURLs)
|
||||||
addItem(tracker.url, torrentID);
|
addItem(trackerURL, torrentID);
|
||||||
|
|
||||||
// Check for trackerless torrent
|
// Check for trackerless torrent
|
||||||
if (trackers.isEmpty())
|
if (trackerURLs.isEmpty())
|
||||||
addItem(NULL_HOST, torrentID);
|
addItem(NULL_HOST, torrentID);
|
||||||
|
|
||||||
item(ALL_ROW)->setText(tr("All (%1)", "this is for the tracker filter").arg(++m_totalTorrents));
|
item(ALL_ROW)->setText(tr("All (%1)", "this is for the tracker filter").arg(++m_totalTorrents));
|
||||||
@ -644,12 +644,12 @@ void TrackerFiltersList::handleNewTorrent(BitTorrent::Torrent *const torrent)
|
|||||||
void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent)
|
void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent)
|
||||||
{
|
{
|
||||||
const BitTorrent::TorrentID torrentID {torrent->id()};
|
const BitTorrent::TorrentID torrentID {torrent->id()};
|
||||||
const QVector<BitTorrent::TrackerEntry> trackers {torrent->trackers()};
|
const QVector<QString> trackerURLs {torrent->trackerURLs()};
|
||||||
for (const BitTorrent::TrackerEntry &tracker : trackers)
|
for (const QString &trackerURL : trackerURLs)
|
||||||
removeItem(tracker.url, torrentID);
|
removeItem(trackerURL, torrentID);
|
||||||
|
|
||||||
// Check for trackerless torrent
|
// Check for trackerless torrent
|
||||||
if (trackers.isEmpty())
|
if (trackerURLs.isEmpty())
|
||||||
removeItem(NULL_HOST, torrentID);
|
removeItem(NULL_HOST, torrentID);
|
||||||
|
|
||||||
item(ALL_ROW)->setText(tr("All (%1)", "this is for the tracker filter").arg(--m_totalTorrents));
|
item(ALL_ROW)->setText(tr("All (%1)", "this is for the tracker filter").arg(--m_totalTorrents));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user