mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 01:33:07 -07:00
Remove confusing helpers from Session interface
Such helpers do not make practical sense, since they can be trivially implemented on top of the base interface, but at the same time they can lead to undesirable consequences when some calling code requires slightly different behavior than another. PR #18367. Fixes #18338.
This commit is contained in:
parent
9cdf660ddb
commit
719e4afd8c
4 changed files with 22 additions and 34 deletions
|
@ -2228,30 +2228,6 @@ Torrent *SessionImpl::findTorrent(const InfoHash &infoHash) const
|
|||
return m_torrents.value(altID);
|
||||
}
|
||||
|
||||
bool SessionImpl::hasActiveTorrents() const
|
||||
{
|
||||
return std::any_of(m_torrents.begin(), m_torrents.end(), [](TorrentImpl *torrent)
|
||||
{
|
||||
return TorrentFilter::ActiveTorrent.match(torrent);
|
||||
});
|
||||
}
|
||||
|
||||
bool SessionImpl::hasUnfinishedTorrents() const
|
||||
{
|
||||
return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentImpl *torrent)
|
||||
{
|
||||
return (!torrent->isSeed() && !torrent->isPaused() && !torrent->isErrored() && torrent->hasMetadata());
|
||||
});
|
||||
}
|
||||
|
||||
bool SessionImpl::hasRunningSeed() const
|
||||
{
|
||||
return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentImpl *torrent)
|
||||
{
|
||||
return (torrent->isSeed() && !torrent->isPaused());
|
||||
});
|
||||
}
|
||||
|
||||
void SessionImpl::banIP(const QString &ip)
|
||||
{
|
||||
if (m_bannedIPs.get().contains(ip))
|
||||
|
@ -4771,7 +4747,11 @@ void SessionImpl::handleTorrentFinished(TorrentImpl *const torrent)
|
|||
}
|
||||
}
|
||||
|
||||
if (!hasUnfinishedTorrents())
|
||||
const bool hasUnfinishedTorrents = std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentImpl *torrent)
|
||||
{
|
||||
return !(torrent->isSeed() || torrent->isPaused() || torrent->isErrored());
|
||||
});
|
||||
if (!hasUnfinishedTorrents)
|
||||
emit allTorrentsFinished();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue