mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 08:27:24 -06:00
Redesign main core classes.
This commit is contained in:
@@ -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.);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user