add a remaining column to the torrent content model

This commit is contained in:
Ben Lau
2016-01-09 10:10:57 -08:00
parent 6054e05e70
commit cd9cae4121
7 changed files with 30 additions and 3 deletions

View File

@@ -138,17 +138,20 @@ void TorrentContentModelFolder::recalculateProgress()
{
qreal tProgress = 0;
qulonglong tSize = 0;
qulonglong tRemaining = 0;
foreach (TorrentContentModelItem* child, m_childItems) {
if (child->priority() != prio::IGNORED) {
if (child->itemType() == FolderType)
static_cast<TorrentContentModelFolder*>(child)->recalculateProgress();
tProgress += child->progress() * child->size();
tSize += child->size();
tRemaining += child->remaining();
}
}
if (!isRootItem() && tSize > 0) {
m_progress = tProgress / tSize;
m_remaining = tRemaining;
Q_ASSERT(m_progress <= 1.);
}
}