1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-25 14:04:23 +00:00

Fix progress calculation in Content tab. Closes #2639 Closes #2752

This commit is contained in:
ngosang 2015-07-11 13:41:37 +02:00
parent 647140c7c7
commit e20a24ab2e

View File

@ -136,19 +136,19 @@ void TorrentContentModelFolder::setPriority(int new_prio, bool update_parent)
void TorrentContentModelFolder::recalculateProgress() void TorrentContentModelFolder::recalculateProgress()
{ {
qreal progress = 0; qreal tProgress = 0;
int count = 0; qulonglong tSize = 0;
foreach (TorrentContentModelItem* child, m_childItems) { foreach (TorrentContentModelItem* child, m_childItems) {
if (child->priority() != prio::IGNORED) { if (child->priority() != prio::IGNORED) {
if (child->itemType() == FolderType) if (child->itemType() == FolderType)
static_cast<TorrentContentModelFolder*>(child)->recalculateProgress(); static_cast<TorrentContentModelFolder*>(child)->recalculateProgress();
progress += child->progress(); tProgress += child->progress() * child->size();
++count; tSize += child->size();
} }
} }
if (!isRootItem() && (count > 0)) { if (!isRootItem() && tSize > 0) {
m_progress = progress / count; m_progress = tProgress / tSize;
Q_ASSERT(m_progress <= 1.); Q_ASSERT(m_progress <= 1.);
} }
} }