mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-10 13:54:23 +00:00
Update torrent status filter counters consistently
PR #17097. Closes #15981. Closes #16490.
This commit is contained in:
parent
2c9e1d942b
commit
4f62900cd3
@ -157,6 +157,7 @@ bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const
|
|||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case All:
|
case All:
|
||||||
|
default:
|
||||||
return true;
|
return true;
|
||||||
case Downloading:
|
case Downloading:
|
||||||
return torrent->isDownloading();
|
return torrent->isDownloading();
|
||||||
@ -185,8 +186,6 @@ bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const
|
|||||||
|| (torrent->state() == BitTorrent::TorrentState::CheckingResumeData);
|
|| (torrent->state() == BitTorrent::TorrentState::CheckingResumeData);
|
||||||
case Errored:
|
case Errored:
|
||||||
return torrent->isErrored();
|
return torrent->isErrored();
|
||||||
default: // All
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,9 +241,10 @@ void StatusFilterWidget::updateTorrentStatus(const BitTorrent::Torrent *torrent)
|
|||||||
{
|
{
|
||||||
TorrentFilterBitset &torrentStatus = m_torrentsStatus[torrent];
|
TorrentFilterBitset &torrentStatus = m_torrentsStatus[torrent];
|
||||||
|
|
||||||
const auto update = [&torrentStatus](const TorrentFilter::Type status, const bool needStatus, int &counter)
|
const auto update = [torrent, &torrentStatus](const TorrentFilter::Type status, int &counter)
|
||||||
{
|
{
|
||||||
const bool hasStatus = torrentStatus[status];
|
const bool hasStatus = torrentStatus[status];
|
||||||
|
const bool needStatus = TorrentFilter(status).match(torrent);
|
||||||
if (needStatus && !hasStatus)
|
if (needStatus && !hasStatus)
|
||||||
{
|
{
|
||||||
++counter;
|
++counter;
|
||||||
@ -256,22 +257,17 @@ void StatusFilterWidget::updateTorrentStatus(const BitTorrent::Torrent *torrent)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
update(TorrentFilter::Downloading, torrent->isDownloading(), m_nbDownloading);
|
update(TorrentFilter::Downloading, m_nbDownloading);
|
||||||
update(TorrentFilter::Seeding, torrent->isUploading(), m_nbSeeding);
|
update(TorrentFilter::Seeding, m_nbSeeding);
|
||||||
update(TorrentFilter::Completed, torrent->isCompleted(), m_nbCompleted);
|
update(TorrentFilter::Completed, m_nbCompleted);
|
||||||
update(TorrentFilter::Resumed, torrent->isResumed(), m_nbResumed);
|
update(TorrentFilter::Resumed, m_nbResumed);
|
||||||
update(TorrentFilter::Paused, torrent->isPaused(), m_nbPaused);
|
update(TorrentFilter::Paused, m_nbPaused);
|
||||||
update(TorrentFilter::Active, torrent->isActive(), m_nbActive);
|
update(TorrentFilter::Active, m_nbActive);
|
||||||
update(TorrentFilter::Inactive, torrent->isInactive(), m_nbInactive);
|
update(TorrentFilter::Inactive, m_nbInactive);
|
||||||
|
update(TorrentFilter::StalledUploading, m_nbStalledUploading);
|
||||||
const bool isStalledUploading = (torrent->state() == BitTorrent::TorrentState::StalledUploading);
|
update(TorrentFilter::StalledDownloading, m_nbStalledDownloading);
|
||||||
update(TorrentFilter::StalledUploading, isStalledUploading, m_nbStalledUploading);
|
update(TorrentFilter::Checking, m_nbChecking);
|
||||||
|
update(TorrentFilter::Errored, m_nbErrored);
|
||||||
const bool isStalledDownloading = (torrent->state() == BitTorrent::TorrentState::StalledDownloading);
|
|
||||||
update(TorrentFilter::StalledDownloading, isStalledDownloading, m_nbStalledDownloading);
|
|
||||||
|
|
||||||
update(TorrentFilter::Checking, torrent->isChecking(), m_nbChecking);
|
|
||||||
update(TorrentFilter::Errored, torrent->isErrored(), m_nbErrored);
|
|
||||||
|
|
||||||
m_nbStalled = m_nbStalledUploading + m_nbStalledDownloading;
|
m_nbStalled = m_nbStalledUploading + m_nbStalledDownloading;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user