From 88b2b2600793c9d1489c3833855e5ab8ab1c90ff Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sun, 25 Dec 2016 01:44:49 +0200 Subject: [PATCH] Don't use hardcoded numbers to refer to columns. --- src/gui/torrentcontentfiltermodel.cpp | 2 +- src/gui/torrentcontentmodel.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/torrentcontentfiltermodel.cpp b/src/gui/torrentcontentfiltermodel.cpp index bb957c92d..a11e9b951 100644 --- a/src/gui/torrentcontentfiltermodel.cpp +++ b/src/gui/torrentcontentfiltermodel.cpp @@ -83,7 +83,7 @@ bool TorrentContentFilterModel::filterAcceptsRow(int source_row, const QModelInd bool TorrentContentFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { switch (sortColumn()) { - case NAME: { // PropColumn::NAME + case TorrentContentModelItem::COL_NAME: { QString vL = left.data().toString(); QString vR = right.data().toString(); TorrentContentModelItem::ItemType leftType = m_model->itemType(m_model->index(left.row(), 0, left.parent())); diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index 830e32751..1336bb17e 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -122,7 +122,7 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu if (!index.isValid()) return false; - if ((index.column() == 0) && (role == Qt::CheckStateRole)) { + if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::CheckStateRole)) { TorrentContentModelItem *item = static_cast(index.internalPointer()); qDebug("setData(%s, %d", qPrintable(item->name()), value.toInt()); if (item->priority() != value.toInt()) { @@ -182,14 +182,14 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const TorrentContentModelItem* item = static_cast(index.internalPointer()); - if ((index.column() == 0) && (role == Qt::DecorationRole)) { + if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::DecorationRole)) { if (item->itemType() == TorrentContentModelItem::FolderType) return getDirectoryIcon(); else return getFileIcon(); } - if ((index.column() == 0) && (role == Qt::CheckStateRole)) { + if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::CheckStateRole)) { if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::IGNORED) return Qt::Unchecked; if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::MIXED)