mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 05:13:30 -07:00
TorrentContentModel code clean up
This commit is contained in:
parent
268dad58f6
commit
c43c362903
4 changed files with 7 additions and 8 deletions
|
@ -113,7 +113,7 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu
|
|||
qDebug("setData(%s, %d", qPrintable(item->name()), value.toInt());
|
||||
if (item->priority() != value.toInt()) {
|
||||
if (value.toInt() == Qt::PartiallyChecked)
|
||||
item->setPriority(prio::PARTIAL);
|
||||
item->setPriority(prio::MIXED);
|
||||
else if (value.toInt() == Qt::Unchecked)
|
||||
item->setPriority(prio::IGNORED);
|
||||
else
|
||||
|
@ -171,7 +171,7 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
|
|||
if (index.column() == 0 && role == Qt::CheckStateRole) {
|
||||
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::IGNORED)
|
||||
return Qt::Unchecked;
|
||||
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::PARTIAL)
|
||||
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::MIXED)
|
||||
return Qt::PartiallyChecked;
|
||||
return Qt::Checked;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ int TorrentContentModelFile::fileIndex() const
|
|||
|
||||
void TorrentContentModelFile::setPriority(int new_prio, bool update_parent)
|
||||
{
|
||||
Q_ASSERT(new_prio != prio::PARTIAL);
|
||||
Q_ASSERT(new_prio != prio::MIXED);
|
||||
|
||||
if (m_priority == new_prio)
|
||||
return;
|
||||
|
|
|
@ -106,14 +106,13 @@ void TorrentContentModelFolder::updatePriority()
|
|||
const int prio = m_childItems.first()->priority();
|
||||
for (int i=1; i<m_childItems.size(); ++i) {
|
||||
if (m_childItems.at(i)->priority() != prio) {
|
||||
setPriority(prio::PARTIAL);
|
||||
setPriority(prio::MIXED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// All child items have the same priority
|
||||
// Update own if necessary
|
||||
if (prio != m_priority)
|
||||
setPriority(prio);
|
||||
setPriority(prio);
|
||||
}
|
||||
|
||||
void TorrentContentModelFolder::setPriority(int new_prio, bool update_parent)
|
||||
|
@ -128,7 +127,7 @@ void TorrentContentModelFolder::setPriority(int new_prio, bool update_parent)
|
|||
m_parentItem->updatePriority();
|
||||
|
||||
// Update children
|
||||
if (m_priority != prio::PARTIAL) {
|
||||
if (m_priority != prio::MIXED) {
|
||||
foreach (TorrentContentModelItem* child, m_childItems)
|
||||
child->setPriority(m_priority, false);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <libtorrent/torrent_info.hpp>
|
||||
|
||||
namespace prio {
|
||||
enum FilePriority {IGNORED=0, NORMAL=1, HIGH=2, MAXIMUM=7, PARTIAL=-1};
|
||||
enum FilePriority {IGNORED=0, NORMAL=1, HIGH=2, MAXIMUM=7, MIXED=-1};
|
||||
}
|
||||
|
||||
class TorrentContentModelFolder;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue