Redesign main core classes.

This commit is contained in:
Vladimir Golovnev (Glassez)
2015-04-19 18:17:47 +03:00
parent 60c0939e05
commit d16d1fdb3a
152 changed files with 11366 additions and 8967 deletions

View File

@@ -28,6 +28,7 @@
* Contact : chris@qbittorrent.org
*/
#include <QDebug>
#include "torrentcontentmodelfolder.h"
TorrentContentModelFolder::TorrentContentModelFolder(const QString& name, TorrentContentModelFolder* parent)
@@ -135,18 +136,20 @@ void TorrentContentModelFolder::setPriority(int new_prio, bool update_parent)
void TorrentContentModelFolder::recalculateProgress()
{
qulonglong totalDone = 0;
qreal progress = 0;
int count = 0;
foreach (TorrentContentModelItem* child, m_childItems) {
if (child->priority() != prio::IGNORED) {
if (child->itemType() == FolderType)
static_cast<TorrentContentModelFolder*>(child)->recalculateProgress();
totalDone += child->totalDone();
progress += child->progress();
++count;
}
}
if (!isRootItem()) {
m_totalDone = totalDone;
Q_ASSERT(m_totalDone <= m_size);
if (!isRootItem() && (count > 0)) {
m_progress = progress / count;
Q_ASSERT(m_progress <= 1.);
}
}