mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-31 08:54:26 +00:00
FEATURE: Added "Upload/Download limit" columns to transfer list
This commit is contained in:
parent
fb79146ae6
commit
5656fe9a9b
@ -2,6 +2,7 @@
|
||||
- FEATURE: User can set alternative speed limits for fast toggling
|
||||
- FEATURE: Bandwidth scheduler (automatically use alternative speed limits for a given period)
|
||||
- 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
|
||||
- FEATURE: Graphical User Interface can be disabled at compilation time (headless running)
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
// 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 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 {
|
||||
Q_OBJECT
|
||||
@ -117,6 +117,17 @@ public:
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)"));
|
||||
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_SEED_DATE:
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
|
@ -59,7 +59,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, Bittor
|
||||
setItemDelegate(listDelegate);
|
||||
|
||||
// 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_PRIORITY, Qt::Horizontal, "#");
|
||||
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->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_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_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_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
|
||||
@ -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_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_UPLIMIT), QVariant(h.upload_limit()));
|
||||
listModel->setData(listModel->index(row, TR_DLLIMIT), QVariant(h.download_limit()));
|
||||
QString label = TorrentPersistentData::getLabel(h.hash());
|
||||
listModel->setData(listModel->index(row, TR_LABEL), QVariant(label));
|
||||
if(BTSession->isQueueingEnabled())
|
||||
@ -298,23 +304,32 @@ int TransferListWidget::updateTorrent(int row) {
|
||||
return s;
|
||||
}
|
||||
try {
|
||||
// Connected_seeds*100000+total_seeds*10 (if total_seeds is available)
|
||||
// Connected_seeds*100000+1 (if total_seeds is unavailable)
|
||||
qulonglong seeds = h.num_seeds()*1000000;
|
||||
if(h.num_complete() >= h.num_seeds())
|
||||
seeds += h.num_complete()*10;
|
||||
else
|
||||
seeds += 1;
|
||||
listModel->setData(listModel->index(row, TR_SEEDS), QVariant(seeds));
|
||||
qulonglong peers = (h.num_peers()-h.num_seeds())*1000000;
|
||||
if(h.num_incomplete() >= (h.num_peers()-h.num_seeds()))
|
||||
peers += h.num_incomplete()*10;
|
||||
else
|
||||
peers += 1;
|
||||
listModel->setData(listModel->index(row, TR_PEERS), QVariant(peers));
|
||||
if(!isColumnHidden(TR_SEEDS)) {
|
||||
// Connected_seeds*100000+total_seeds*10 (if total_seeds is available)
|
||||
// Connected_seeds*100000+1 (if total_seeds is unavailable)
|
||||
qulonglong seeds = h.num_seeds()*1000000;
|
||||
if(h.num_complete() >= h.num_seeds())
|
||||
seeds += h.num_complete()*10;
|
||||
else
|
||||
seeds += 1;
|
||||
listModel->setData(listModel->index(row, TR_SEEDS), QVariant(seeds));
|
||||
}
|
||||
if(!isColumnHidden(TR_PEERS)) {
|
||||
qulonglong peers = (h.num_peers()-h.num_seeds())*1000000;
|
||||
if(h.num_incomplete() >= (h.num_peers()-h.num_seeds()))
|
||||
peers += h.num_incomplete()*10;
|
||||
else
|
||||
peers += 1;
|
||||
listModel->setData(listModel->index(row, TR_PEERS), QVariant(peers));
|
||||
}
|
||||
// Update torrent size. It changes when files are filtered from torrent properties
|
||||
// or Web UI
|
||||
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
|
||||
if(!h.is_seed() && BTSession->isQueueingEnabled()) {
|
||||
listModel->setData(listModel->index(row, TR_PRIORITY), QVariant((int)h.queue_position()));
|
||||
@ -343,8 +358,10 @@ int TransferListWidget::updateTorrent(int row) {
|
||||
// Reset speeds and seeds/leech
|
||||
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_SEEDS), QVariant(0.0));
|
||||
listModel->setData(listModel->index(row, TR_PEERS), QVariant(0.0));
|
||||
if(!isColumnHidden(TR_SEEDS))
|
||||
listModel->setData(listModel->index(row, TR_SEEDS), QVariant(0.0));
|
||||
if(!isColumnHidden(TR_PEERS))
|
||||
listModel->setData(listModel->index(row, TR_PEERS), QVariant(0.0));
|
||||
setRowColor(row, QString::fromUtf8("grey"));
|
||||
return s;
|
||||
}
|
||||
@ -372,19 +389,22 @@ 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_PROGRESS), QVariant((double)h.progress()));
|
||||
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1));
|
||||
if(!isColumnHidden(TR_ETA))
|
||||
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1));
|
||||
setRowColor(row, QString::fromUtf8("grey"));
|
||||
break;
|
||||
case torrent_status::downloading:
|
||||
case torrent_status::downloading_metadata:
|
||||
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_ETA), QVariant((qlonglong)BTSession->getETA(hash)));
|
||||
if(!isColumnHidden(TR_ETA))
|
||||
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)BTSession->getETA(hash)));
|
||||
s = STATE_DOWNLOADING;
|
||||
setRowColor(row, QString::fromUtf8("green"));
|
||||
}else{
|
||||
listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalledDL.png"))), Qt::DecorationRole);
|
||||
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1));
|
||||
if(!isColumnHidden(TR_ETA))
|
||||
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1));
|
||||
s = STATE_STALLED_DL;
|
||||
setRowColor(row, QApplication::palette().color(QPalette::WindowText));
|
||||
}
|
||||
@ -407,7 +427,8 @@ int TransferListWidget::updateTorrent(int row) {
|
||||
listModel->setData(listModel->index(row, TR_STATUS), s);
|
||||
listModel->setData(listModel->index(row, TR_UPSPEED), QVariant((double)h.upload_payload_rate()));
|
||||
// Share ratio
|
||||
listModel->setData(listModel->index(row, TR_RATIO), QVariant(BTSession->getRealRatio(hash)));
|
||||
if(!isColumnHidden(TR_RATIO))
|
||||
listModel->setData(listModel->index(row, TR_RATIO), QVariant(BTSession->getRealRatio(hash)));
|
||||
}catch(invalid_handle e) {
|
||||
deleteTorrent(row, false);
|
||||
s = STATE_INVALID;
|
||||
@ -830,10 +851,12 @@ bool TransferListWidget::loadHiddenColumns() {
|
||||
}
|
||||
loaded = true;
|
||||
}
|
||||
// As a default, hide date columns
|
||||
// As a default, hide less useful columns
|
||||
if(!loaded) {
|
||||
setColumnHidden(TR_ADD_DATE, true);
|
||||
setColumnHidden(TR_SEED_DATE, true);
|
||||
setColumnHidden(TR_UPLIMIT, true);
|
||||
setColumnHidden(TR_DLLIMIT, true);
|
||||
}
|
||||
return loaded;
|
||||
}
|
||||
@ -922,21 +945,21 @@ void TransferListWidget::askNewLabelForSelection() {
|
||||
}
|
||||
|
||||
void TransferListWidget::renameSelectedTorrent() {
|
||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||
if(selectedIndexes.size() != 1) return;
|
||||
if(!selectedIndexes.first().isValid()) return;
|
||||
QString hash = getHashFromRow(mapToSource(selectedIndexes.first()).row());
|
||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||
if(!h.is_valid()) return;
|
||||
// Ask for a new Name
|
||||
bool ok;
|
||||
QString name = QInputDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok);
|
||||
if (ok && !name.isEmpty()) {
|
||||
// Remember the name
|
||||
TorrentPersistentData::saveName(hash, name);
|
||||
// Visually change the name
|
||||
proxyModel->setData(selectedIndexes.first(), name);
|
||||
}
|
||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||
if(selectedIndexes.size() != 1) return;
|
||||
if(!selectedIndexes.first().isValid()) return;
|
||||
QString hash = getHashFromRow(mapToSource(selectedIndexes.first()).row());
|
||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||
if(!h.is_valid()) return;
|
||||
// Ask for a new Name
|
||||
bool ok;
|
||||
QString name = QInputDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok);
|
||||
if (ok && !name.isEmpty()) {
|
||||
// Remember the name
|
||||
TorrentPersistentData::saveName(hash, name);
|
||||
// Visually change the name
|
||||
proxyModel->setData(selectedIndexes.first(), name);
|
||||
}
|
||||
}
|
||||
|
||||
void TransferListWidget::setSelectionLabel(QString label) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user