|
|
@ -53,6 +53,11 @@ TorrentContentModelFolder::~TorrentContentModelFolder() |
|
|
|
qDeleteAll(m_childItems); |
|
|
|
qDeleteAll(m_childItems); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TorrentContentModelItem::ItemType TorrentContentModelFolder::itemType() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return FolderType; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentContentModelFolder::deleteAllChildren() |
|
|
|
void TorrentContentModelFolder::deleteAllChildren() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_ASSERT(isRootItem()); |
|
|
|
Q_ASSERT(isRootItem()); |
|
|
@ -81,10 +86,9 @@ TorrentContentModelItem* TorrentContentModelFolder::child(int row) const |
|
|
|
|
|
|
|
|
|
|
|
TorrentContentModelFolder *TorrentContentModelFolder::childFolderWithName(const QString &name) const |
|
|
|
TorrentContentModelFolder *TorrentContentModelFolder::childFolderWithName(const QString &name) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (TorrentContentModelItem* child, m_childItems) { |
|
|
|
foreach (TorrentContentModelItem *child, m_childItems) |
|
|
|
if (child->itemType() == FolderType && child->name() == name) |
|
|
|
if ((child->itemType() == FolderType) && (child->name() == name)) |
|
|
|
return static_cast<TorrentContentModelFolder *>(child); |
|
|
|
return static_cast<TorrentContentModelFolder *>(child); |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -116,23 +120,22 @@ void TorrentContentModelFolder::updatePriority() |
|
|
|
setPriority(prio); |
|
|
|
setPriority(prio); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentContentModelFolder::setPriority(int new_prio, bool update_parent) |
|
|
|
void TorrentContentModelFolder::setPriority(int newPriority, bool updateParent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_priority == new_prio) |
|
|
|
if (m_priority == newPriority) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
m_priority = new_prio; |
|
|
|
m_priority = newPriority; |
|
|
|
|
|
|
|
|
|
|
|
// Update parent priority
|
|
|
|
// Update parent priority
|
|
|
|
if (update_parent) |
|
|
|
if (updateParent) |
|
|
|
m_parentItem->updatePriority(); |
|
|
|
m_parentItem->updatePriority(); |
|
|
|
|
|
|
|
|
|
|
|
// Update children
|
|
|
|
// Update children
|
|
|
|
if (m_priority != prio::MIXED) { |
|
|
|
if (m_priority != prio::MIXED) |
|
|
|
foreach (TorrentContentModelItem *child, m_childItems) |
|
|
|
foreach (TorrentContentModelItem *child, m_childItems) |
|
|
|
child->setPriority(m_priority, false); |
|
|
|
child->setPriority(m_priority, false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TorrentContentModelFolder::recalculateProgress() |
|
|
|
void TorrentContentModelFolder::recalculateProgress() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -149,7 +152,7 @@ void TorrentContentModelFolder::recalculateProgress() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!isRootItem() && tSize > 0) { |
|
|
|
if (!isRootItem() && (tSize > 0)) { |
|
|
|
m_progress = tProgress / tSize; |
|
|
|
m_progress = tProgress / tSize; |
|
|
|
m_remaining = tRemaining; |
|
|
|
m_remaining = tRemaining; |
|
|
|
Q_ASSERT(m_progress <= 1.); |
|
|
|
Q_ASSERT(m_progress <= 1.); |
|
|
|