Browse Source

FEATURE: Added "Upload/Download limit" columns to transfer list

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
5656fe9a9b
  1. 1
      Changelog
  2. 13
      src/transferlistdelegate.h
  3. 31
      src/transferlistwidget.cpp

1
Changelog

@ -2,6 +2,7 @@
- FEATURE: User can set alternative speed limits for fast toggling - FEATURE: User can set alternative speed limits for fast toggling
- FEATURE: Bandwidth scheduler (automatically use alternative speed limits for a given period) - FEATURE: Bandwidth scheduler (automatically use alternative speed limits for a given period)
- FEATURE: Added "Added/Completed On" columns to transfer list - FEATURE: Added "Added/Completed On" columns to transfer list
- FEATURE: Added "Upload/Download limit" columns to transfer list
* Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0 * Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0
- FEATURE: Graphical User Interface can be disabled at compilation time (headless running) - FEATURE: Graphical User Interface can be disabled at compilation time (headless running)

13
src/transferlistdelegate.h

@ -42,7 +42,7 @@
// Defines for download list list columns // Defines for download list list columns
enum TorrentState {STATE_DOWNLOADING, STATE_STALLED_DL, STATE_STALLED_UP, STATE_SEEDING, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_INVALID}; enum TorrentState {STATE_DOWNLOADING, STATE_STALLED_DL, STATE_STALLED_UP, STATE_SEEDING, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_INVALID};
enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_HASH}; enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_DLLIMIT, TR_UPLIMIT, TR_HASH};
class TransferListDelegate: public QItemDelegate { class TransferListDelegate: public QItemDelegate {
Q_OBJECT Q_OBJECT
@ -117,6 +117,17 @@ public:
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;
} }
case TR_UPLIMIT:
case TR_DLLIMIT:{
QItemDelegate::drawBackground(painter, opt, index);
qlonglong limit = index.data().toLongLong();
opt.displayAlignment = Qt::AlignRight;
if(limit > 0)
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(limit/1024., 'f', 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)"));
else
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8(""));
break;
}
case TR_ADD_DATE: case TR_ADD_DATE:
case TR_SEED_DATE: case TR_SEED_DATE:
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);

31
src/transferlistwidget.cpp

@ -59,7 +59,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, Bittor
setItemDelegate(listDelegate); setItemDelegate(listDelegate);
// Create transfer list model // Create transfer list model
listModel = new QStandardItemModel(0,15); listModel = new QStandardItemModel(0,17);
listModel->setHeaderData(TR_NAME, Qt::Horizontal, tr("Name", "i.e: torrent name")); listModel->setHeaderData(TR_NAME, Qt::Horizontal, tr("Name", "i.e: torrent name"));
listModel->setHeaderData(TR_PRIORITY, Qt::Horizontal, "#"); listModel->setHeaderData(TR_PRIORITY, Qt::Horizontal, "#");
listModel->horizontalHeaderItem(TR_PRIORITY)->setTextAlignment(Qt::AlignRight); listModel->horizontalHeaderItem(TR_PRIORITY)->setTextAlignment(Qt::AlignRight);
@ -80,8 +80,12 @@ TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, Bittor
listModel->horizontalHeaderItem(TR_RATIO)->setTextAlignment(Qt::AlignRight); listModel->horizontalHeaderItem(TR_RATIO)->setTextAlignment(Qt::AlignRight);
listModel->setHeaderData(TR_ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left")); listModel->setHeaderData(TR_ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left"));
listModel->setHeaderData(TR_LABEL, Qt::Horizontal, tr("Label")); listModel->setHeaderData(TR_LABEL, Qt::Horizontal, tr("Label"));
listModel->setHeaderData(TR_ADD_DATE, Qt::Horizontal, tr("Added on", "Torrent was added to transfer list on 01/01/2010 08:00")); listModel->setHeaderData(TR_ADD_DATE, Qt::Horizontal, tr("Added On", "Torrent was added to transfer list on 01/01/2010 08:00"));
listModel->setHeaderData(TR_SEED_DATE, Qt::Horizontal, tr("Completed on", "Torrent was completed on 01/01/2010 08:00")); listModel->setHeaderData(TR_SEED_DATE, Qt::Horizontal, tr("Completed On", "Torrent was completed on 01/01/2010 08:00"));
listModel->setHeaderData(TR_DLLIMIT, Qt::Horizontal, tr("Down Limit", "i.e: Download limit"));
listModel->horizontalHeaderItem(TR_DLLIMIT)->setTextAlignment(Qt::AlignRight);
listModel->setHeaderData(TR_UPLIMIT, Qt::Horizontal, tr("Up Limit", "i.e: Upload limit"));;
listModel->horizontalHeaderItem(TR_UPLIMIT)->setTextAlignment(Qt::AlignRight);
// Set Sort/Filter proxy // Set Sort/Filter proxy
@ -168,6 +172,8 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) {
listModel->setData(listModel->index(row, TR_PEERS), QVariant((double)0.0)); listModel->setData(listModel->index(row, TR_PEERS), QVariant((double)0.0));
listModel->setData(listModel->index(row, TR_ADD_DATE), QVariant(TorrentPersistentData::getAddedDate(h.hash()))); listModel->setData(listModel->index(row, TR_ADD_DATE), QVariant(TorrentPersistentData::getAddedDate(h.hash())));
listModel->setData(listModel->index(row, TR_SEED_DATE), QVariant(TorrentPersistentData::getSeedDate(h.hash()))); listModel->setData(listModel->index(row, TR_SEED_DATE), QVariant(TorrentPersistentData::getSeedDate(h.hash())));
listModel->setData(listModel->index(row, TR_UPLIMIT), QVariant(h.upload_limit()));
listModel->setData(listModel->index(row, TR_DLLIMIT), QVariant(h.download_limit()));
QString label = TorrentPersistentData::getLabel(h.hash()); QString label = TorrentPersistentData::getLabel(h.hash());
listModel->setData(listModel->index(row, TR_LABEL), QVariant(label)); listModel->setData(listModel->index(row, TR_LABEL), QVariant(label));
if(BTSession->isQueueingEnabled()) if(BTSession->isQueueingEnabled())
@ -298,6 +304,7 @@ int TransferListWidget::updateTorrent(int row) {
return s; return s;
} }
try { try {
if(!isColumnHidden(TR_SEEDS)) {
// Connected_seeds*100000+total_seeds*10 (if total_seeds is available) // Connected_seeds*100000+total_seeds*10 (if total_seeds is available)
// Connected_seeds*100000+1 (if total_seeds is unavailable) // Connected_seeds*100000+1 (if total_seeds is unavailable)
qulonglong seeds = h.num_seeds()*1000000; qulonglong seeds = h.num_seeds()*1000000;
@ -306,15 +313,23 @@ int TransferListWidget::updateTorrent(int row) {
else else
seeds += 1; seeds += 1;
listModel->setData(listModel->index(row, TR_SEEDS), QVariant(seeds)); listModel->setData(listModel->index(row, TR_SEEDS), QVariant(seeds));
}
if(!isColumnHidden(TR_PEERS)) {
qulonglong peers = (h.num_peers()-h.num_seeds())*1000000; qulonglong peers = (h.num_peers()-h.num_seeds())*1000000;
if(h.num_incomplete() >= (h.num_peers()-h.num_seeds())) if(h.num_incomplete() >= (h.num_peers()-h.num_seeds()))
peers += h.num_incomplete()*10; peers += h.num_incomplete()*10;
else else
peers += 1; peers += 1;
listModel->setData(listModel->index(row, TR_PEERS), QVariant(peers)); listModel->setData(listModel->index(row, TR_PEERS), QVariant(peers));
}
// Update torrent size. It changes when files are filtered from torrent properties // Update torrent size. It changes when files are filtered from torrent properties
// or Web UI // or Web UI
listModel->setData(listModel->index(row, TR_SIZE), QVariant((qlonglong)h.actual_size())); listModel->setData(listModel->index(row, TR_SIZE), QVariant((qlonglong)h.actual_size()));
// Update Up/Dl limits
if(!isColumnHidden(TR_UPLIMIT))
listModel->setData(listModel->index(row, TR_UPLIMIT), QVariant((qlonglong)h.upload_limit()));
if(!isColumnHidden(TR_DLLIMIT))
listModel->setData(listModel->index(row, TR_DLLIMIT), QVariant((qlonglong)h.download_limit()));
// Queueing code // Queueing code
if(!h.is_seed() && BTSession->isQueueingEnabled()) { if(!h.is_seed() && BTSession->isQueueingEnabled()) {
listModel->setData(listModel->index(row, TR_PRIORITY), QVariant((int)h.queue_position())); listModel->setData(listModel->index(row, TR_PRIORITY), QVariant((int)h.queue_position()));
@ -343,7 +358,9 @@ int TransferListWidget::updateTorrent(int row) {
// Reset speeds and seeds/leech // Reset speeds and seeds/leech
listModel->setData(listModel->index(row, TR_DLSPEED), QVariant((double)0.)); listModel->setData(listModel->index(row, TR_DLSPEED), QVariant((double)0.));
listModel->setData(listModel->index(row, TR_UPSPEED), QVariant((double)0.)); listModel->setData(listModel->index(row, TR_UPSPEED), QVariant((double)0.));
if(!isColumnHidden(TR_SEEDS))
listModel->setData(listModel->index(row, TR_SEEDS), QVariant(0.0)); listModel->setData(listModel->index(row, TR_SEEDS), QVariant(0.0));
if(!isColumnHidden(TR_PEERS))
listModel->setData(listModel->index(row, TR_PEERS), QVariant(0.0)); listModel->setData(listModel->index(row, TR_PEERS), QVariant(0.0));
setRowColor(row, QString::fromUtf8("grey")); setRowColor(row, QString::fromUtf8("grey"));
return s; return s;
@ -372,6 +389,7 @@ int TransferListWidget::updateTorrent(int row) {
listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/checkingDL.png"))), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/checkingDL.png"))), Qt::DecorationRole);
} }
listModel->setData(listModel->index(row, TR_PROGRESS), QVariant((double)h.progress())); listModel->setData(listModel->index(row, TR_PROGRESS), QVariant((double)h.progress()));
if(!isColumnHidden(TR_ETA))
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1)); listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1));
setRowColor(row, QString::fromUtf8("grey")); setRowColor(row, QString::fromUtf8("grey"));
break; break;
@ -379,11 +397,13 @@ int TransferListWidget::updateTorrent(int row) {
case torrent_status::downloading_metadata: case torrent_status::downloading_metadata:
if(h.download_payload_rate() > 0) { if(h.download_payload_rate() > 0) {
listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))), Qt::DecorationRole);
if(!isColumnHidden(TR_ETA))
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)BTSession->getETA(hash))); listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)BTSession->getETA(hash)));
s = STATE_DOWNLOADING; s = STATE_DOWNLOADING;
setRowColor(row, QString::fromUtf8("green")); setRowColor(row, QString::fromUtf8("green"));
}else{ }else{
listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalledDL.png"))), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalledDL.png"))), Qt::DecorationRole);
if(!isColumnHidden(TR_ETA))
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1)); listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1));
s = STATE_STALLED_DL; s = STATE_STALLED_DL;
setRowColor(row, QApplication::palette().color(QPalette::WindowText)); setRowColor(row, QApplication::palette().color(QPalette::WindowText));
@ -407,6 +427,7 @@ int TransferListWidget::updateTorrent(int row) {
listModel->setData(listModel->index(row, TR_STATUS), s); listModel->setData(listModel->index(row, TR_STATUS), s);
listModel->setData(listModel->index(row, TR_UPSPEED), QVariant((double)h.upload_payload_rate())); listModel->setData(listModel->index(row, TR_UPSPEED), QVariant((double)h.upload_payload_rate()));
// Share ratio // Share ratio
if(!isColumnHidden(TR_RATIO))
listModel->setData(listModel->index(row, TR_RATIO), QVariant(BTSession->getRealRatio(hash))); listModel->setData(listModel->index(row, TR_RATIO), QVariant(BTSession->getRealRatio(hash)));
}catch(invalid_handle e) { }catch(invalid_handle e) {
deleteTorrent(row, false); deleteTorrent(row, false);
@ -830,10 +851,12 @@ bool TransferListWidget::loadHiddenColumns() {
} }
loaded = true; loaded = true;
} }
// As a default, hide date columns // As a default, hide less useful columns
if(!loaded) { if(!loaded) {
setColumnHidden(TR_ADD_DATE, true); setColumnHidden(TR_ADD_DATE, true);
setColumnHidden(TR_SEED_DATE, true); setColumnHidden(TR_SEED_DATE, true);
setColumnHidden(TR_UPLIMIT, true);
setColumnHidden(TR_DLLIMIT, true);
} }
return loaded; return loaded;
} }

Loading…
Cancel
Save