Clean up code

This commit is contained in:
Chocobo1
2018-11-19 12:00:50 +08:00
committed by sledgehammer999
parent fd50d6e9af
commit 1e9151364a
3 changed files with 20 additions and 19 deletions

View File

@@ -142,13 +142,14 @@ void TorrentContentModelFolder::recalculateProgress()
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 (child->priority() == prio::IGNORED)
continue;
if (child->itemType() == FolderType)
static_cast<TorrentContentModelFolder *>(child)->recalculateProgress();
tProgress += child->progress() * child->size();
tSize += child->size();
tRemaining += child->remaining();
}
if (!isRootItem() && (tSize > 0)) {

View File

@@ -74,9 +74,7 @@ qreal TorrentContentModelItem::progress() const
{
Q_ASSERT(!isRootItem());
if (m_size > 0) return m_progress;
return 1;
return (m_size > 0) ? m_progress : 1;
}
qulonglong TorrentContentModelItem::remaining() const
@@ -89,7 +87,7 @@ qreal TorrentContentModelItem::availability() const
{
Q_ASSERT(!isRootItem());
return m_size > 0 ? m_availability : 0.;
return (m_size > 0) ? m_availability : 0;
}
int TorrentContentModelItem::priority() const