From 04a3fcb0edc1e3bd5e77165d4b7ef44d4bb18208 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 17 Nov 2009 09:04:16 +0000 Subject: [PATCH] - Play with Transfer list columns alignment --- src/TransferListDelegate.h | 9 +++++++-- src/TransferListWidget.cpp | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/TransferListDelegate.h b/src/TransferListDelegate.h index 20660c724..b6636bb3a 100644 --- a/src/TransferListDelegate.h +++ b/src/TransferListDelegate.h @@ -58,7 +58,7 @@ public: switch(index.column()){ case SIZE:{ QItemDelegate::drawBackground(painter, opt, index); - opt.displayAlignment = Qt::AlignHCenter; + opt.displayAlignment = Qt::AlignRight; QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong())); break; } @@ -76,6 +76,7 @@ public: display += " ("+QString::number((qulonglong)(tot_val%100000)/10)+")"; } QItemDelegate::drawBackground(painter, opt, index); + opt.displayAlignment = Qt::AlignRight; QItemDelegate::drawDisplay(painter, opt, opt.rect, display); break; } @@ -109,11 +110,13 @@ public: case DLSPEED:{ QItemDelegate::drawBackground(painter, opt, index); double speed = index.data().toDouble(); + opt.displayAlignment = Qt::AlignRight; QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(speed/1024., 'f', 1)+" "+tr("KiB/s")); break; } case RATIO:{ QItemDelegate::drawBackground(painter, opt, index); + opt.displayAlignment = Qt::AlignRight; double ratio = index.data().toDouble(); if(ratio > 100.) QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("∞")); @@ -124,9 +127,11 @@ public: case PRIORITY: { int priority = index.data().toInt(); if(priority >= 0) { - QItemDelegate::paint(painter, option, index); + 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; diff --git a/src/TransferListWidget.cpp b/src/TransferListWidget.cpp index d54517992..61f42ac34 100644 --- a/src/TransferListWidget.cpp +++ b/src/TransferListWidget.cpp @@ -59,15 +59,23 @@ TransferListWidget::TransferListWidget(QWidget *parent, bittorrent *_BTSession): listModel = new QStandardItemModel(0,12); listModel->setHeaderData(NAME, Qt::Horizontal, tr("Name", "i.e: torrent name")); listModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: torrent size")); + listModel->horizontalHeaderItem(SIZE)->setTextAlignment(Qt::AlignRight); listModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Done", "% Done")); + listModel->horizontalHeaderItem(PROGRESS)->setTextAlignment(Qt::AlignHCenter); listModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status", "Torrent status (e.g. downloading, seeding, paused)")); listModel->setHeaderData(SEEDS, Qt::Horizontal, tr("Seeds", "i.e. full sources (often untranslated)")); + listModel->horizontalHeaderItem(SEEDS)->setTextAlignment(Qt::AlignRight); listModel->setHeaderData(PEERS, Qt::Horizontal, tr("Peers", "i.e. partial sources (often untranslated)")); + listModel->horizontalHeaderItem(PEERS)->setTextAlignment(Qt::AlignRight); listModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("Down Speed", "i.e: Download speed")); + listModel->horizontalHeaderItem(DLSPEED)->setTextAlignment(Qt::AlignRight); listModel->setHeaderData(UPSPEED, Qt::Horizontal, tr("Up Speed", "i.e: Upload speed"));; + listModel->horizontalHeaderItem(UPSPEED)->setTextAlignment(Qt::AlignRight); listModel->setHeaderData(RATIO, Qt::Horizontal, tr("Ratio", "Share ratio")); + listModel->horizontalHeaderItem(RATIO)->setTextAlignment(Qt::AlignRight); listModel->setHeaderData(ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left")); listModel->setHeaderData(PRIORITY, Qt::Horizontal, "#"); + listModel->horizontalHeaderItem(PRIORITY)->setTextAlignment(Qt::AlignRight); // Set Sort/Filter proxy proxyModel = new QSortFilterProxyModel();