mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 03:39:39 +03:00
Don't use hardcoded numbers to refer to columns.
This commit is contained in:
parent
2d37a39e43
commit
88b2b26007
2 changed files with 4 additions and 4 deletions
|
@ -83,7 +83,7 @@ bool TorrentContentFilterModel::filterAcceptsRow(int source_row, const QModelInd
|
||||||
|
|
||||||
bool TorrentContentFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
bool TorrentContentFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
||||||
switch (sortColumn()) {
|
switch (sortColumn()) {
|
||||||
case NAME: { // PropColumn::NAME
|
case TorrentContentModelItem::COL_NAME: {
|
||||||
QString vL = left.data().toString();
|
QString vL = left.data().toString();
|
||||||
QString vR = right.data().toString();
|
QString vR = right.data().toString();
|
||||||
TorrentContentModelItem::ItemType leftType = m_model->itemType(m_model->index(left.row(), 0, left.parent()));
|
TorrentContentModelItem::ItemType leftType = m_model->itemType(m_model->index(left.row(), 0, left.parent()));
|
||||||
|
|
|
@ -122,7 +122,7 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((index.column() == 0) && (role == Qt::CheckStateRole)) {
|
if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::CheckStateRole)) {
|
||||||
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
|
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
|
||||||
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()) {
|
||||||
|
@ -182,14 +182,14 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
|
||||||
|
|
||||||
TorrentContentModelItem* item = static_cast<TorrentContentModelItem*>(index.internalPointer());
|
TorrentContentModelItem* item = static_cast<TorrentContentModelItem*>(index.internalPointer());
|
||||||
|
|
||||||
if ((index.column() == 0) && (role == Qt::DecorationRole)) {
|
if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::DecorationRole)) {
|
||||||
if (item->itemType() == TorrentContentModelItem::FolderType)
|
if (item->itemType() == TorrentContentModelItem::FolderType)
|
||||||
return getDirectoryIcon();
|
return getDirectoryIcon();
|
||||||
else
|
else
|
||||||
return getFileIcon();
|
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)
|
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::IGNORED)
|
||||||
return Qt::Unchecked;
|
return Qt::Unchecked;
|
||||||
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::MIXED)
|
if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::MIXED)
|
||||||
|
|
Loading…
Reference in a new issue