|
|
@ -231,42 +231,36 @@ void StatusFilterWidget::populate() |
|
|
|
|
|
|
|
|
|
|
|
const QVector<BitTorrent::Torrent *> torrents = BitTorrent::Session::instance()->torrents(); |
|
|
|
const QVector<BitTorrent::Torrent *> torrents = BitTorrent::Session::instance()->torrents(); |
|
|
|
for (const BitTorrent::Torrent *torrent : torrents) |
|
|
|
for (const BitTorrent::Torrent *torrent : torrents) |
|
|
|
{ |
|
|
|
|
|
|
|
updateTorrentStatus(torrent); |
|
|
|
updateTorrentStatus(torrent); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateTexts(); |
|
|
|
updateTexts(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void StatusFilterWidget::updateTorrentStatus(const BitTorrent::Torrent *torrent) |
|
|
|
void StatusFilterWidget::updateTorrentStatus(const BitTorrent::Torrent *torrent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const auto update = [this, torrent](const TorrentFilter::Type status, const bool insert, int &count) |
|
|
|
TorrentFilterBitset &torrentStatus = m_torrentsStatus[torrent]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const auto update = [this, &torrentStatus](const TorrentFilter::Type status, const bool needStatus, int &counter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const bool contains = m_torrentsStatus.contains(torrent, status); |
|
|
|
const bool hasStatus = torrentStatus[status]; |
|
|
|
if (insert && !contains) |
|
|
|
if (needStatus && !hasStatus) |
|
|
|
{ |
|
|
|
{ |
|
|
|
++count; |
|
|
|
++counter; |
|
|
|
m_torrentsStatus.insert(torrent, status); |
|
|
|
torrentStatus.set(status); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!insert && contains) |
|
|
|
else if (!needStatus && hasStatus) |
|
|
|
{ |
|
|
|
{ |
|
|
|
--count; |
|
|
|
--counter; |
|
|
|
m_torrentsStatus.remove(torrent, status); |
|
|
|
torrentStatus.reset(status); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
update(TorrentFilter::Downloading, torrent->isDownloading(), m_nbDownloading); |
|
|
|
update(TorrentFilter::Downloading, torrent->isDownloading(), m_nbDownloading); |
|
|
|
|
|
|
|
|
|
|
|
update(TorrentFilter::Seeding, torrent->isUploading(), m_nbSeeding); |
|
|
|
update(TorrentFilter::Seeding, torrent->isUploading(), m_nbSeeding); |
|
|
|
|
|
|
|
|
|
|
|
update(TorrentFilter::Completed, torrent->isCompleted(), m_nbCompleted); |
|
|
|
update(TorrentFilter::Completed, torrent->isCompleted(), m_nbCompleted); |
|
|
|
|
|
|
|
|
|
|
|
update(TorrentFilter::Resumed, torrent->isResumed(), m_nbResumed); |
|
|
|
update(TorrentFilter::Resumed, torrent->isResumed(), m_nbResumed); |
|
|
|
|
|
|
|
|
|
|
|
update(TorrentFilter::Paused, torrent->isPaused(), m_nbPaused); |
|
|
|
update(TorrentFilter::Paused, torrent->isPaused(), m_nbPaused); |
|
|
|
|
|
|
|
|
|
|
|
update(TorrentFilter::Active, torrent->isActive(), m_nbActive); |
|
|
|
update(TorrentFilter::Active, torrent->isActive(), m_nbActive); |
|
|
|
|
|
|
|
|
|
|
|
update(TorrentFilter::Inactive, torrent->isInactive(), m_nbInactive); |
|
|
|
update(TorrentFilter::Inactive, torrent->isInactive(), m_nbInactive); |
|
|
|
|
|
|
|
|
|
|
|
const bool isStalledUploading = (torrent->state() == BitTorrent::TorrentState::StalledUploading); |
|
|
|
const bool isStalledUploading = (torrent->state() == BitTorrent::TorrentState::StalledUploading); |
|
|
@ -276,7 +270,6 @@ void StatusFilterWidget::updateTorrentStatus(const BitTorrent::Torrent *torrent) |
|
|
|
update(TorrentFilter::StalledDownloading, isStalledDownloading, m_nbStalledDownloading); |
|
|
|
update(TorrentFilter::StalledDownloading, isStalledDownloading, m_nbStalledDownloading); |
|
|
|
|
|
|
|
|
|
|
|
update(TorrentFilter::Checking, torrent->isChecking(), m_nbChecking); |
|
|
|
update(TorrentFilter::Checking, torrent->isChecking(), m_nbChecking); |
|
|
|
|
|
|
|
|
|
|
|
update(TorrentFilter::Errored, torrent->isErrored(), m_nbErrored); |
|
|
|
update(TorrentFilter::Errored, torrent->isErrored(), m_nbErrored); |
|
|
|
|
|
|
|
|
|
|
|
m_nbStalled = m_nbStalledUploading + m_nbStalledDownloading; |
|
|
|
m_nbStalled = m_nbStalledUploading + m_nbStalledDownloading; |
|
|
@ -336,54 +329,33 @@ void StatusFilterWidget::handleNewTorrent(BitTorrent::Torrent *const torrent) |
|
|
|
|
|
|
|
|
|
|
|
void StatusFilterWidget::torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent) |
|
|
|
void StatusFilterWidget::torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (const TorrentFilter::Type status : m_torrentsStatus.values(torrent)) |
|
|
|
const TorrentFilterBitset status = m_torrentsStatus.take(torrent); |
|
|
|
{ |
|
|
|
|
|
|
|
switch (status) |
|
|
|
if (status[TorrentFilter::Downloading]) |
|
|
|
{ |
|
|
|
|
|
|
|
case TorrentFilter::Downloading: |
|
|
|
|
|
|
|
--m_nbDownloading; |
|
|
|
--m_nbDownloading; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::Seeding]) |
|
|
|
case TorrentFilter::Seeding: |
|
|
|
|
|
|
|
--m_nbSeeding; |
|
|
|
--m_nbSeeding; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::Completed]) |
|
|
|
case TorrentFilter::Completed: |
|
|
|
|
|
|
|
--m_nbCompleted; |
|
|
|
--m_nbCompleted; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::Resumed]) |
|
|
|
case TorrentFilter::Resumed: |
|
|
|
|
|
|
|
--m_nbResumed; |
|
|
|
--m_nbResumed; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::Paused]) |
|
|
|
case TorrentFilter::Paused: |
|
|
|
|
|
|
|
--m_nbPaused; |
|
|
|
--m_nbPaused; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::Active]) |
|
|
|
case TorrentFilter::Active: |
|
|
|
|
|
|
|
--m_nbActive; |
|
|
|
--m_nbActive; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::Inactive]) |
|
|
|
case TorrentFilter::Inactive: |
|
|
|
|
|
|
|
--m_nbInactive; |
|
|
|
--m_nbInactive; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::StalledUploading]) |
|
|
|
case TorrentFilter::StalledUploading: |
|
|
|
|
|
|
|
--m_nbStalledUploading; |
|
|
|
--m_nbStalledUploading; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::StalledDownloading]) |
|
|
|
case TorrentFilter::StalledDownloading: |
|
|
|
|
|
|
|
--m_nbStalledDownloading; |
|
|
|
--m_nbStalledDownloading; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::Checking]) |
|
|
|
case TorrentFilter::Checking: |
|
|
|
|
|
|
|
--m_nbChecking; |
|
|
|
--m_nbChecking; |
|
|
|
break; |
|
|
|
if (status[TorrentFilter::Errored]) |
|
|
|
case TorrentFilter::Errored: |
|
|
|
|
|
|
|
--m_nbErrored; |
|
|
|
--m_nbErrored; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
Q_ASSERT(false); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_nbStalled = m_nbStalledUploading + m_nbStalledDownloading; |
|
|
|
m_nbStalled = m_nbStalledUploading + m_nbStalledDownloading; |
|
|
|
|
|
|
|
|
|
|
|
m_torrentsStatus.remove(torrent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateTexts(); |
|
|
|
updateTexts(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|