mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 14:57:52 +00:00
TorrentContentModel code clean up
This commit is contained in:
parent
268dad58f6
commit
c43c362903
@ -113,7 +113,7 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu
|
|||||||
qDebug("setData(%s, %d", qPrintable(item->name()), value.toInt());
|
qDebug("setData(%s, %d", qPrintable(item->name()), value.toInt());
|
||||||
if (item->priority() != value.toInt()) {
|
if (item->priority() != value.toInt()) {
|
||||||
if (value.toInt() == Qt::PartiallyChecked)
|
if (value.toInt() == Qt::PartiallyChecked)
|
||||||
item->setPriority(prio::PARTIAL);
|
item->setPriority(prio::MIXED);
|
||||||
else if (value.toInt() == Qt::Unchecked)
|
else if (value.toInt() == Qt::Unchecked)
|
||||||
item->setPriority(prio::IGNORED);
|
item->setPriority(prio::IGNORED);
|
||||||
else
|
else
|
||||||
@ -171,7 +171,7 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
|
|||||||
if (index.column() == 0 && role == Qt::CheckStateRole) {
|
if (index.column() == 0 && role == Qt::CheckStateRole) {
|
||||||
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::IGNORED)
|
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::IGNORED)
|
||||||
return Qt::Unchecked;
|
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::PartiallyChecked;
|
||||||
return Qt::Checked;
|
return Qt::Checked;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ int TorrentContentModelFile::fileIndex() const
|
|||||||
|
|
||||||
void TorrentContentModelFile::setPriority(int new_prio, bool update_parent)
|
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)
|
if (m_priority == new_prio)
|
||||||
return;
|
return;
|
||||||
|
@ -106,14 +106,13 @@ void TorrentContentModelFolder::updatePriority()
|
|||||||
const int prio = m_childItems.first()->priority();
|
const int prio = m_childItems.first()->priority();
|
||||||
for (int i=1; i<m_childItems.size(); ++i) {
|
for (int i=1; i<m_childItems.size(); ++i) {
|
||||||
if (m_childItems.at(i)->priority() != prio) {
|
if (m_childItems.at(i)->priority() != prio) {
|
||||||
setPriority(prio::PARTIAL);
|
setPriority(prio::MIXED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// All child items have the same priority
|
// All child items have the same priority
|
||||||
// Update own if necessary
|
// Update own if necessary
|
||||||
if (prio != m_priority)
|
setPriority(prio);
|
||||||
setPriority(prio);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentContentModelFolder::setPriority(int new_prio, bool update_parent)
|
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();
|
m_parentItem->updatePriority();
|
||||||
|
|
||||||
// Update children
|
// Update children
|
||||||
if (m_priority != prio::PARTIAL) {
|
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);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <libtorrent/torrent_info.hpp>
|
#include <libtorrent/torrent_info.hpp>
|
||||||
|
|
||||||
namespace prio {
|
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;
|
class TorrentContentModelFolder;
|
||||||
|
Loading…
Reference in New Issue
Block a user