|
|
@ -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,23 +304,32 @@ int TransferListWidget::updateTorrent(int row) { |
|
|
|
return s; |
|
|
|
return s; |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
// Connected_seeds*100000+total_seeds*10 (if total_seeds is available)
|
|
|
|
if(!isColumnHidden(TR_SEEDS)) { |
|
|
|
// Connected_seeds*100000+1 (if total_seeds is unavailable)
|
|
|
|
// Connected_seeds*100000+total_seeds*10 (if total_seeds is available)
|
|
|
|
qulonglong seeds = h.num_seeds()*1000000; |
|
|
|
// Connected_seeds*100000+1 (if total_seeds is unavailable)
|
|
|
|
if(h.num_complete() >= h.num_seeds()) |
|
|
|
qulonglong seeds = h.num_seeds()*1000000; |
|
|
|
seeds += h.num_complete()*10; |
|
|
|
if(h.num_complete() >= h.num_seeds()) |
|
|
|
else |
|
|
|
seeds += h.num_complete()*10; |
|
|
|
seeds += 1; |
|
|
|
else |
|
|
|
listModel->setData(listModel->index(row, TR_SEEDS), QVariant(seeds)); |
|
|
|
seeds += 1; |
|
|
|
qulonglong peers = (h.num_peers()-h.num_seeds())*1000000; |
|
|
|
listModel->setData(listModel->index(row, TR_SEEDS), QVariant(seeds)); |
|
|
|
if(h.num_incomplete() >= (h.num_peers()-h.num_seeds())) |
|
|
|
} |
|
|
|
peers += h.num_incomplete()*10; |
|
|
|
if(!isColumnHidden(TR_PEERS)) { |
|
|
|
else |
|
|
|
qulonglong peers = (h.num_peers()-h.num_seeds())*1000000; |
|
|
|
peers += 1; |
|
|
|
if(h.num_incomplete() >= (h.num_peers()-h.num_seeds())) |
|
|
|
listModel->setData(listModel->index(row, TR_PEERS), QVariant(peers)); |
|
|
|
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
|
|
|
|
// 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,8 +358,10 @@ 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.)); |
|
|
|
listModel->setData(listModel->index(row, TR_SEEDS), QVariant(0.0)); |
|
|
|
if(!isColumnHidden(TR_SEEDS)) |
|
|
|
listModel->setData(listModel->index(row, TR_PEERS), 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)); |
|
|
|
setRowColor(row, QString::fromUtf8("grey")); |
|
|
|
setRowColor(row, QString::fromUtf8("grey")); |
|
|
|
return s; |
|
|
|
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_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())); |
|
|
|
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")); |
|
|
|
setRowColor(row, QString::fromUtf8("grey")); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case torrent_status::downloading: |
|
|
|
case torrent_status::downloading: |
|
|
|
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); |
|
|
|
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; |
|
|
|
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); |
|
|
|
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; |
|
|
|
s = STATE_STALLED_DL; |
|
|
|
setRowColor(row, QApplication::palette().color(QPalette::WindowText)); |
|
|
|
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_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
|
|
|
|
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) { |
|
|
|
}catch(invalid_handle e) { |
|
|
|
deleteTorrent(row, false); |
|
|
|
deleteTorrent(row, false); |
|
|
|
s = STATE_INVALID; |
|
|
|
s = STATE_INVALID; |
|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
@ -922,21 +945,21 @@ void TransferListWidget::askNewLabelForSelection() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::renameSelectedTorrent() { |
|
|
|
void TransferListWidget::renameSelectedTorrent() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
if(selectedIndexes.size() != 1) return; |
|
|
|
if(selectedIndexes.size() != 1) return; |
|
|
|
if(!selectedIndexes.first().isValid()) return; |
|
|
|
if(!selectedIndexes.first().isValid()) return; |
|
|
|
QString hash = getHashFromRow(mapToSource(selectedIndexes.first()).row()); |
|
|
|
QString hash = getHashFromRow(mapToSource(selectedIndexes.first()).row()); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(!h.is_valid()) return; |
|
|
|
if(!h.is_valid()) return; |
|
|
|
// Ask for a new Name
|
|
|
|
// Ask for a new Name
|
|
|
|
bool ok; |
|
|
|
bool ok; |
|
|
|
QString name = QInputDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok); |
|
|
|
QString name = QInputDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok); |
|
|
|
if (ok && !name.isEmpty()) { |
|
|
|
if (ok && !name.isEmpty()) { |
|
|
|
// Remember the name
|
|
|
|
// Remember the name
|
|
|
|
TorrentPersistentData::saveName(hash, name); |
|
|
|
TorrentPersistentData::saveName(hash, name); |
|
|
|
// Visually change the name
|
|
|
|
// Visually change the name
|
|
|
|
proxyModel->setData(selectedIndexes.first(), name); |
|
|
|
proxyModel->setData(selectedIndexes.first(), name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::setSelectionLabel(QString label) { |
|
|
|
void TransferListWidget::setSelectionLabel(QString label) { |
|
|
|