Browse Source

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

adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
51a9a9aabb
  1. 21
      src/qtlibtorrent/torrentmodel.cpp
  2. 7
      src/transferlistdelegate.h

21
src/qtlibtorrent/torrentmodel.cpp

@ -290,27 +290,6 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, @@ -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();

7
src/transferlistdelegate.h

@ -63,7 +63,6 @@ public: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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;

Loading…
Cancel
Save