Browse Source

Fix sorting of ETA column when having infinite values (closes #583347)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
29e79dc54d
  1. 2
      src/misc.cpp
  2. 2
      src/misc.h
  3. 10
      src/transferlistwidget.cpp

2
src/misc.cpp

@ -519,7 +519,7 @@ QString misc::expandPath(QString path) { @@ -519,7 +519,7 @@ QString misc::expandPath(QString path) {
// Take a number of seconds and return an user-friendly
// time duration like "1d 2h 10m".
QString misc::userFriendlyDuration(qlonglong seconds) {
if(seconds < 0) {
if(seconds < 0 || seconds >= MAX_ETA) {
return QString::fromUtf8("");
}
if(seconds == 0) {

2
src/misc.h

@ -42,6 +42,8 @@ @@ -42,6 +42,8 @@
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/torrent_handle.hpp>
const qlonglong MAX_ETA = 8640000;
using namespace libtorrent;
/* Miscellaneaous functions that can be useful */

10
src/transferlistwidget.cpp

@ -167,7 +167,7 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) { @@ -167,7 +167,7 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) {
listModel->insertRow(row);
listModel->setData(listModel->index(row, TR_NAME), QVariant(h.name()));
listModel->setData(listModel->index(row, TR_SIZE), QVariant((qlonglong)h.actual_size()));
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1));
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)MAX_ETA));
listModel->setData(listModel->index(row, TR_SEEDS), 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())));
@ -252,7 +252,7 @@ void TransferListWidget::pauseTorrent(int row, bool refresh_list) { @@ -252,7 +252,7 @@ void TransferListWidget::pauseTorrent(int row, bool refresh_list) {
} else {
listModel->setData(listModel->index(row, TR_STATUS), STATE_PAUSED_DL);
listModel->setData(listModel->index(row, TR_NAME), QIcon(QString::fromUtf8(":/Icons/skin/pausedDL.png")), Qt::DecorationRole);
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1));
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)MAX_ETA));
}
listModel->setData(listModel->index(row, TR_SEEDS), QVariant(0.0));
listModel->setData(listModel->index(row, TR_PEERS), QVariant(0.0));
@ -351,7 +351,7 @@ int TransferListWidget::updateTorrent(int row) { @@ -351,7 +351,7 @@ int TransferListWidget::updateTorrent(int row) {
}
listModel->setData(listModel->index(row, TR_STATUS), s);
}else {
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1));
listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)MAX_ETA));
if(h.is_seed()) {
s = STATE_QUEUED_UP;
listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/queuedUP.png"))), Qt::DecorationRole);
@ -396,7 +396,7 @@ int TransferListWidget::updateTorrent(int row) { @@ -396,7 +396,7 @@ int TransferListWidget::updateTorrent(int row) {
}
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)MAX_ETA));
setRowColor(row, QString::fromUtf8("grey"));
break;
case torrent_status::downloading:
@ -410,7 +410,7 @@ int TransferListWidget::updateTorrent(int row) { @@ -410,7 +410,7 @@ int TransferListWidget::updateTorrent(int row) {
}else{
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)MAX_ETA));
s = STATE_STALLED_DL;
setRowColor(row, QApplication::palette().color(QPalette::WindowText));
}

Loading…
Cancel
Save