Browse Source

TorrentContentModel code clean up

adaptive-webui-19844
Christophe Dumez 12 years ago
parent
commit
c43c362903
  1. 4
      src/torrentcontentmodel.cpp
  2. 2
      src/torrentcontentmodelfile.cpp
  3. 5
      src/torrentcontentmodelfolder.cpp
  4. 2
      src/torrentcontentmodelitem.h

4
src/torrentcontentmodel.cpp

@ -113,7 +113,7 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu @@ -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 @@ -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;
}

2
src/torrentcontentmodelfile.cpp

@ -66,7 +66,7 @@ int TorrentContentModelFile::fileIndex() const @@ -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;

5
src/torrentcontentmodelfolder.cpp

@ -106,13 +106,12 @@ void TorrentContentModelFolder::updatePriority() @@ -106,13 +106,12 @@ 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);
}
@ -128,7 +127,7 @@ 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);
}

2
src/torrentcontentmodelitem.h

@ -36,7 +36,7 @@ @@ -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…
Cancel
Save