mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
Made progress calculation more efficient in torrent content model
Stop to address issue #24.
This commit is contained in:
parent
f73f267997
commit
ca2a659970
4 changed files with 16 additions and 18 deletions
|
@ -131,25 +131,22 @@ void TorrentContentModelFolder::setPriority(int new_prio, bool update_parent)
|
|||
foreach (TorrentContentModelItem* child, m_childItems)
|
||||
child->setPriority(m_priority, false);
|
||||
}
|
||||
|
||||
updateProgress();
|
||||
}
|
||||
|
||||
void TorrentContentModelFolder::updateProgress()
|
||||
void TorrentContentModelFolder::recalculateProgress()
|
||||
{
|
||||
if (isRootItem())
|
||||
return;
|
||||
|
||||
qulonglong total_done = 0;
|
||||
qulonglong totalDone = 0;
|
||||
foreach (TorrentContentModelItem* child, m_childItems) {
|
||||
if (child->priority() > 0)
|
||||
total_done += child->totalDone();
|
||||
if (child->priority() != prio::IGNORED) {
|
||||
if (child->itemType() == FolderType)
|
||||
static_cast<TorrentContentModelFolder*>(child)->recalculateProgress();
|
||||
totalDone += child->totalDone();
|
||||
}
|
||||
}
|
||||
|
||||
Q_ASSERT(total_done <= m_size);
|
||||
if (total_done != m_totalDone) {
|
||||
m_totalDone = total_done;
|
||||
m_parentItem->updateProgress();
|
||||
if (!isRootItem()) {
|
||||
m_totalDone = totalDone;
|
||||
Q_ASSERT(m_totalDone <= m_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue