Make all columns and headers use the same text alignment in the transferlist.

This commit is contained in:
sledgehammer999 2013-11-09 19:39:13 +02:00
parent 850018c86b
commit b6af8f190c
2 changed files with 0 additions and 28 deletions

View file

@ -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();

View file

@ -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;