From 51a9a9aabb2be8a2a34e5e8324fc3d70e332b3b9 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sat, 9 Nov 2013 19:39:13 +0200 Subject: [PATCH] Make all columns and headers use the same text alignment in the transferlist. --- src/qtlibtorrent/torrentmodel.cpp | 21 --------------------- src/transferlistdelegate.h | 7 ------- 2 files changed, 28 deletions(-) diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index 05a521d97..d51b2665e 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -290,27 +290,6 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, return QVariant(); } } - if (role == Qt::TextAlignmentRole) { - switch(section) { - case TorrentModelItem::TR_PRIORITY: - case TorrentModelItem::TR_SIZE: - case TorrentModelItem::TR_SEEDS: - case TorrentModelItem::TR_PEERS: - case TorrentModelItem::TR_DLSPEED: - case TorrentModelItem::TR_UPSPEED: - case TorrentModelItem::TR_RATIO: - case TorrentModelItem::TR_DLLIMIT: - case TorrentModelItem::TR_UPLIMIT: - case TorrentModelItem::TR_AMOUNT_DOWNLOADED: - case TorrentModelItem::TR_AMOUNT_UPLOADED: - case TorrentModelItem::TR_AMOUNT_LEFT: - return Qt::AlignRight; - case TorrentModelItem::TR_PROGRESS: - return Qt::AlignHCenter; - default: - return Qt::AlignLeft; - } - } } return QVariant(); diff --git a/src/transferlistdelegate.h b/src/transferlistdelegate.h index f908ad296..96b892d3b 100644 --- a/src/transferlistdelegate.h +++ b/src/transferlistdelegate.h @@ -63,7 +63,6 @@ public: case TorrentModelItem::TR_AMOUNT_LEFT: case TorrentModelItem::TR_SIZE:{ QItemDelegate::drawBackground(painter, opt, index); - opt.displayAlignment = Qt::AlignRight; QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong())); break; } @@ -80,7 +79,6 @@ public: display += " ("+QString::number(index.data(Qt::UserRole).toLongLong())+")"; } QItemDelegate::drawBackground(painter, opt, index); - opt.displayAlignment = Qt::AlignRight; QItemDelegate::drawDisplay(painter, opt, opt.rect, display); break; } @@ -133,7 +131,6 @@ public: case TorrentModelItem::TR_DLSPEED:{ QItemDelegate::drawBackground(painter, opt, index); const qulonglong speed = index.data().toULongLong(); - opt.displayAlignment = Qt::AlignRight; QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)")); break; } @@ -141,7 +138,6 @@ public: case TorrentModelItem::TR_DLLIMIT:{ QItemDelegate::drawBackground(painter, opt, index); const qlonglong limit = index.data().toLongLong(); - opt.displayAlignment = Qt::AlignRight; /* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9 ** but QString::number(0.9999*100.0, 'f' ,1) == 100.0 */ QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? QString::number((int)((limit/1024.)*10)/10.0, 'f', 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)") : QString::fromUtf8("∞")); @@ -163,7 +159,6 @@ public: break; case TorrentModelItem::TR_RATIO:{ QItemDelegate::drawBackground(painter, opt, index); - opt.displayAlignment = Qt::AlignRight; const qreal ratio = index.data().toDouble(); /* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9 ** but QString::number(0.9999*100.0, 'f' ,1) == 100.0 */ @@ -173,11 +168,9 @@ public: case TorrentModelItem::TR_PRIORITY: { const int priority = index.data().toInt(); if (priority >= 0) { - opt.displayAlignment = Qt::AlignRight; QItemDelegate::paint(painter, opt, index); } else { QItemDelegate::drawBackground(painter, opt, index); - opt.displayAlignment = Qt::AlignRight; QItemDelegate::drawDisplay(painter, opt, opt.rect, "*"); } break;