mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-16 05:01:37 +03:00
PeerList: align text to the right in columns that handle numbers
This commit is contained in:
parent
ba1e5b8d58
commit
daf33ef8aa
2 changed files with 16 additions and 0 deletions
|
@ -52,15 +52,22 @@ public:
|
||||||
painter->save();
|
painter->save();
|
||||||
QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option);
|
QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option);
|
||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
|
case PORT:
|
||||||
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
|
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||||
|
QItemDelegate::drawDisplay(painter, opt, option.rect, index.data().toString());
|
||||||
|
break;
|
||||||
case TOT_DOWN:
|
case TOT_DOWN:
|
||||||
case TOT_UP:
|
case TOT_UP:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
|
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
||||||
break;
|
break;
|
||||||
case DOWN_SPEED:
|
case DOWN_SPEED:
|
||||||
case UP_SPEED:{
|
case UP_SPEED:{
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
qreal speed = index.data().toDouble();
|
qreal speed = index.data().toDouble();
|
||||||
|
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||||
if (speed > 0.0)
|
if (speed > 0.0)
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true));
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true));
|
||||||
break;
|
break;
|
||||||
|
@ -69,6 +76,7 @@ public:
|
||||||
case RELEVANCE:{
|
case RELEVANCE:{
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
qreal progress = index.data().toDouble();
|
qreal progress = index.data().toDouble();
|
||||||
|
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress*100.0, 1)+"%");
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress*100.0, 1)+"%");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,14 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
||||||
m_listModel->setHeaderData(PeerListDelegate::TOT_UP, Qt::Horizontal, tr("Uploaded", "i.e: total data uploaded"));
|
m_listModel->setHeaderData(PeerListDelegate::TOT_UP, Qt::Horizontal, tr("Uploaded", "i.e: total data uploaded"));
|
||||||
m_listModel->setHeaderData(PeerListDelegate::RELEVANCE, Qt::Horizontal, tr("Relevance", "i.e: How relevant this peer is to us. How many pieces it has that we don't."));
|
m_listModel->setHeaderData(PeerListDelegate::RELEVANCE, Qt::Horizontal, tr("Relevance", "i.e: How relevant this peer is to us. How many pieces it has that we don't."));
|
||||||
m_listModel->setHeaderData(PeerListDelegate::DOWNLOADING_PIECE, Qt::Horizontal, tr("Files", "i.e. files that are being downloaded right now"));
|
m_listModel->setHeaderData(PeerListDelegate::DOWNLOADING_PIECE, Qt::Horizontal, tr("Files", "i.e. files that are being downloaded right now"));
|
||||||
|
// Set header text alignment
|
||||||
|
m_listModel->setHeaderData(PeerListDelegate::PORT, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
|
||||||
|
m_listModel->setHeaderData(PeerListDelegate::PROGRESS, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
|
||||||
|
m_listModel->setHeaderData(PeerListDelegate::DOWN_SPEED, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
|
||||||
|
m_listModel->setHeaderData(PeerListDelegate::UP_SPEED, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
|
||||||
|
m_listModel->setHeaderData(PeerListDelegate::TOT_DOWN, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
|
||||||
|
m_listModel->setHeaderData(PeerListDelegate::TOT_UP, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
|
||||||
|
m_listModel->setHeaderData(PeerListDelegate::RELEVANCE, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
|
||||||
// Proxy model to support sorting without actually altering the underlying model
|
// Proxy model to support sorting without actually altering the underlying model
|
||||||
m_proxyModel = new PeerListSortModel();
|
m_proxyModel = new PeerListSortModel();
|
||||||
m_proxyModel->setDynamicSortFilter(true);
|
m_proxyModel->setDynamicSortFilter(true);
|
||||||
|
|
Loading…
Reference in a new issue