From da11488ba17f94b230f1084b8a6fcf196c50f3e6 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 23 Jan 2009 19:26:22 +0000 Subject: [PATCH] - Fixes for share ratio calculation --- Changelog | 1 + src/DLListDelegate.h | 5 ++++- src/FinishedListDelegate.h | 5 ++++- src/bittorrent.cpp | 8 +++----- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index 45f7f9315..f4bdfc895 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ - BUGFIX: Torrents paused due to an I/O error were displayed as queued - BUGFIX: qBittorrent now prints backtrace in terminal when segfaulting - BUGFIX: Fixed files progress display in torrent properties + - BUGFIX: Improved torrent ratio calculation - I18N: Updated Bulgarian and Greek translations * Fri Jan 9 2009 - Christophe Dumez - v1.3.0 diff --git a/src/DLListDelegate.h b/src/DLListDelegate.h index 5d070e299..ef394fe98 100644 --- a/src/DLListDelegate.h +++ b/src/DLListDelegate.h @@ -72,7 +72,10 @@ class DLListDelegate: public QItemDelegate { case RATIO:{ QItemDelegate::drawBackground(painter, opt, index); double ratio = index.data().toDouble(); - QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(ratio, 'f', 1))); + if(ratio > 100.) + QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("∞")); + else + QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(ratio, 'f', 1))); break; } case PROGRESS:{ diff --git a/src/FinishedListDelegate.h b/src/FinishedListDelegate.h index cdd9bc748..cb083ba28 100644 --- a/src/FinishedListDelegate.h +++ b/src/FinishedListDelegate.h @@ -63,7 +63,10 @@ class FinishedListDelegate: public QItemDelegate { case F_RATIO:{ QItemDelegate::drawBackground(painter, opt, index); double ratio = index.data().toDouble(); - QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(ratio, 'f', 1))); + if(ratio > 100.) + QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("∞")); + else + QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(ratio, 'f', 1))); break; } default: diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 2e4e7a11c..2598a423b 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -763,14 +763,12 @@ float bittorrent::getRealRatio(QString hash) const{ Q_ASSERT(h.all_time_download() >= 0); Q_ASSERT(h.all_time_upload() >= 0); if(h.all_time_download() == 0) { - if(h.all_time_upload() == 0) - return 1.; - return 10.; + return 101; } float ratio = (float)h.all_time_upload()/(float)h.all_time_download(); Q_ASSERT(ratio >= 0.); - if(ratio > 10.) - ratio = 10.; + if(ratio > 100.) + ratio = 100.; return ratio; }