From c43c36290391582ae1f63666d380c7a28ea7ad67 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 26 Aug 2012 20:52:53 +0300 Subject: [PATCH] TorrentContentModel code clean up --- src/torrentcontentmodel.cpp | 4 ++-- src/torrentcontentmodelfile.cpp | 2 +- src/torrentcontentmodelfolder.cpp | 7 +++---- src/torrentcontentmodelitem.h | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/torrentcontentmodel.cpp b/src/torrentcontentmodel.cpp index 820dcd3f0..a5992d77b 100644 --- a/src/torrentcontentmodel.cpp +++ b/src/torrentcontentmodel.cpp @@ -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; } diff --git a/src/torrentcontentmodelfile.cpp b/src/torrentcontentmodelfile.cpp index 23216f4bb..a55a7be53 100644 --- a/src/torrentcontentmodelfile.cpp +++ b/src/torrentcontentmodelfile.cpp @@ -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; diff --git a/src/torrentcontentmodelfolder.cpp b/src/torrentcontentmodelfolder.cpp index 6162da668..91f50e817 100644 --- a/src/torrentcontentmodelfolder.cpp +++ b/src/torrentcontentmodelfolder.cpp @@ -106,14 +106,13 @@ void TorrentContentModelFolder::updatePriority() const int prio = m_childItems.first()->priority(); for (int i=1; ipriority() != 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); } diff --git a/src/torrentcontentmodelitem.h b/src/torrentcontentmodelitem.h index 2e74c0670..8145430ac 100644 --- a/src/torrentcontentmodelitem.h +++ b/src/torrentcontentmodelitem.h @@ -36,7 +36,7 @@ #include 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;