Browse Source

Cosmetic fix for eta sorting in torrent list: 'infinity' must always come last

adaptive-webui-19844
Nick Tiskov 12 years ago
parent
commit
0c0c7459f1
  1. 8
      src/qtlibtorrent/torrentspeedmonitor.cpp

8
src/qtlibtorrent/torrentspeedmonitor.cpp

@ -124,18 +124,18 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const @@ -124,18 +124,18 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
QMutexLocker locker(&m_mutex);
QTorrentHandle h = m_session->getTorrentHandle(hash);
if (h.is_paused() || !m_samples.contains(hash))
return -1;
return MAX_ETA;
const QPair<qreal, qreal> speed_average = m_samples.value(hash).average();
if(h.is_seed()) {
if (speed_average.second == 0)
return -1;
return MAX_ETA;
bool _unused;
qreal max_ratio = m_session->getMaxRatioPerTorrent(hash, &_unused);
if (max_ratio < 0)
return -1;
return MAX_ETA;
libtorrent::size_type realDL = h.all_time_download();
if (realDL <= 0)
@ -144,7 +144,7 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const @@ -144,7 +144,7 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
return (realDL * max_ratio - h.all_time_upload()) / speed_average.second;
} else {
if (speed_average.first == 0)
return -1;
return MAX_ETA;
return (h.total_wanted() - h.total_done()) / speed_average.first;
}

Loading…
Cancel
Save