Browse Source

- Play with Transfer list columns alignment

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
04a3fcb0ed
  1. 9
      src/TransferListDelegate.h
  2. 8
      src/TransferListWidget.cpp

9
src/TransferListDelegate.h

@ -58,7 +58,7 @@ public:
switch(index.column()){ switch(index.column()){
case SIZE:{ case SIZE:{
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignHCenter; 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;
} }
@ -76,6 +76,7 @@ public:
display += " ("+QString::number((qulonglong)(tot_val%100000)/10)+")"; display += " ("+QString::number((qulonglong)(tot_val%100000)/10)+")";
} }
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;
} }
@ -109,11 +110,13 @@ public:
case DLSPEED:{ case DLSPEED:{
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
double speed = index.data().toDouble(); double speed = index.data().toDouble();
opt.displayAlignment = Qt::AlignRight;
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(speed/1024., 'f', 1)+" "+tr("KiB/s")); QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(speed/1024., 'f', 1)+" "+tr("KiB/s"));
break; break;
} }
case RATIO:{ case RATIO:{
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignRight;
double ratio = index.data().toDouble(); double ratio = index.data().toDouble();
if(ratio > 100.) if(ratio > 100.)
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("")); QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8(""));
@ -124,9 +127,11 @@ public:
case PRIORITY: { case PRIORITY: {
int priority = index.data().toInt(); int priority = index.data().toInt();
if(priority >= 0) { if(priority >= 0) {
QItemDelegate::paint(painter, option, index); opt.displayAlignment = Qt::AlignRight;
QItemDelegate::paint(painter, opt, index);
} else { } else {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignRight;
QItemDelegate::drawDisplay(painter, opt, opt.rect, "*"); QItemDelegate::drawDisplay(painter, opt, opt.rect, "*");
} }
break; break;

8
src/TransferListWidget.cpp

@ -59,15 +59,23 @@ TransferListWidget::TransferListWidget(QWidget *parent, bittorrent *_BTSession):
listModel = new QStandardItemModel(0,12); listModel = new QStandardItemModel(0,12);
listModel->setHeaderData(NAME, Qt::Horizontal, tr("Name", "i.e: torrent name")); listModel->setHeaderData(NAME, Qt::Horizontal, tr("Name", "i.e: torrent name"));
listModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: torrent size")); 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->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(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->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->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->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->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->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(ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left"));
listModel->setHeaderData(PRIORITY, Qt::Horizontal, "#"); listModel->setHeaderData(PRIORITY, Qt::Horizontal, "#");
listModel->horizontalHeaderItem(PRIORITY)->setTextAlignment(Qt::AlignRight);
// Set Sort/Filter proxy // Set Sort/Filter proxy
proxyModel = new QSortFilterProxyModel(); proxyModel = new QSortFilterProxyModel();

Loading…
Cancel
Save