Right align numerical values in the transfer list. Partially revert 51a9a9aab. Closes #1903.

This commit is contained in:
sledgehammer999 2014-08-30 18:36:20 +03:00
commit 0c3d5f0430

View file

@ -64,11 +64,13 @@ public:
case TorrentModelItem::TR_COMPLETED: case TorrentModelItem::TR_COMPLETED:
case TorrentModelItem::TR_SIZE: { case TorrentModelItem::TR_SIZE: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignRight;
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong())); QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
break; break;
} }
case TorrentModelItem::TR_ETA: { case TorrentModelItem::TR_ETA: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignRight;
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::userFriendlyDuration(index.data().toLongLong())); QItemDelegate::drawDisplay(painter, opt, option.rect, misc::userFriendlyDuration(index.data().toLongLong()));
break; break;
} }
@ -80,6 +82,7 @@ public:
display += " ("+QString::number(index.data(Qt::UserRole).toLongLong())+")"; display += " ("+QString::number(index.data(Qt::UserRole).toLongLong())+")";
} }
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignRight;
QItemDelegate::drawDisplay(painter, opt, opt.rect, display); QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
break; break;
} }
@ -132,6 +135,7 @@ public:
case TorrentModelItem::TR_DLSPEED: { case TorrentModelItem::TR_DLSPEED: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
const qulonglong speed = index.data().toULongLong(); 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)")); QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)"));
break; break;
} }
@ -139,6 +143,7 @@ public:
case TorrentModelItem::TR_DLLIMIT: { case TorrentModelItem::TR_DLLIMIT: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
const qlonglong limit = index.data().toLongLong(); const qlonglong limit = index.data().toLongLong();
opt.displayAlignment = Qt::AlignRight;
QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? misc::accurateDoubleToString(limit/1024., 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)") : QString::fromUtf8("")); QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? misc::accurateDoubleToString(limit/1024., 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)") : QString::fromUtf8(""));
break; break;
} }
@ -159,6 +164,7 @@ public:
case TorrentModelItem::TR_RATIO_LIMIT: case TorrentModelItem::TR_RATIO_LIMIT:
case TorrentModelItem::TR_RATIO: { case TorrentModelItem::TR_RATIO: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignRight;
const qreal ratio = index.data().toDouble(); const qreal ratio = index.data().toDouble();
QItemDelegate::drawDisplay(painter, opt, opt.rect, QItemDelegate::drawDisplay(painter, opt, opt.rect,
(ratio == -1 || ratio > QBtSession::MAX_RATIO) ? QString::fromUtf8("") : misc::accurateDoubleToString(ratio, 2)); (ratio == -1 || ratio > QBtSession::MAX_RATIO) ? QString::fromUtf8("") : misc::accurateDoubleToString(ratio, 2));
@ -166,9 +172,10 @@ public:
} }
case TorrentModelItem::TR_PRIORITY: { case TorrentModelItem::TR_PRIORITY: {
const int priority = index.data().toInt(); const int priority = index.data().toInt();
if (priority >= 0) { opt.displayAlignment = Qt::AlignRight;
if (priority >= 0)
QItemDelegate::paint(painter, opt, index); QItemDelegate::paint(painter, opt, index);
} else { else {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, opt.rect, "*"); QItemDelegate::drawDisplay(painter, opt, opt.rect, "*");
} }