Merge pull request #9244 from Couchy/inhibit_sleep_options

Inhibit sleep for running downloads or uploads regardless of network activity
This commit is contained in:
sledgehammer999 2018-08-12 16:31:01 +03:00 committed by GitHub
commit 366239ca7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 72 additions and 36 deletions

View file

@ -1863,20 +1863,26 @@ TorrentHandle *Session::findTorrent(const InfoHash &hash) const
bool Session::hasActiveTorrents() const
{
foreach (TorrentHandle *const torrent, m_torrents)
if (TorrentFilter::ActiveTorrent.match(torrent))
return true;
return false;
return std::any_of(m_torrents.begin(), m_torrents.end(), [](TorrentHandle *torrent)
{
return TorrentFilter::ActiveTorrent.match(torrent);
});
}
bool Session::hasUnfinishedTorrents() const
{
foreach (TorrentHandle *const torrent, m_torrents)
if (!torrent->isSeed() && !torrent->isPaused())
return true;
return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentHandle *torrent)
{
return (!torrent->isSeed() && !torrent->isPaused());
});
}
return false;
bool Session::hasRunningSeed() const
{
return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentHandle *torrent)
{
return (torrent->isSeed() && !torrent->isPaused());
});
}
void Session::banIP(const QString &ip)