- Fixes for share ratio calculation

This commit is contained in:
Christophe Dumez 2009-01-23 19:26:22 +00:00
parent 968c3e1c3e
commit da11488ba1
4 changed files with 12 additions and 7 deletions

View file

@ -2,6 +2,7 @@
- BUGFIX: Torrents paused due to an I/O error were displayed as queued - BUGFIX: Torrents paused due to an I/O error were displayed as queued
- BUGFIX: qBittorrent now prints backtrace in terminal when segfaulting - BUGFIX: qBittorrent now prints backtrace in terminal when segfaulting
- BUGFIX: Fixed files progress display in torrent properties - BUGFIX: Fixed files progress display in torrent properties
- BUGFIX: Improved torrent ratio calculation
- I18N: Updated Bulgarian and Greek translations - I18N: Updated Bulgarian and Greek translations
* Fri Jan 9 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.3.0 * Fri Jan 9 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.3.0

View file

@ -72,7 +72,10 @@ class DLListDelegate: public QItemDelegate {
case RATIO:{ case RATIO:{
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
double ratio = index.data().toDouble(); 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; break;
} }
case PROGRESS:{ case PROGRESS:{

View file

@ -63,7 +63,10 @@ class FinishedListDelegate: public QItemDelegate {
case F_RATIO:{ case F_RATIO:{
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
double ratio = index.data().toDouble(); 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; break;
} }
default: default:

View file

@ -763,14 +763,12 @@ float bittorrent::getRealRatio(QString hash) const{
Q_ASSERT(h.all_time_download() >= 0); Q_ASSERT(h.all_time_download() >= 0);
Q_ASSERT(h.all_time_upload() >= 0); Q_ASSERT(h.all_time_upload() >= 0);
if(h.all_time_download() == 0) { if(h.all_time_download() == 0) {
if(h.all_time_upload() == 0) return 101;
return 1.;
return 10.;
} }
float ratio = (float)h.all_time_upload()/(float)h.all_time_download(); float ratio = (float)h.all_time_upload()/(float)h.all_time_download();
Q_ASSERT(ratio >= 0.); Q_ASSERT(ratio >= 0.);
if(ratio > 10.) if(ratio > 100.)
ratio = 10.; ratio = 100.;
return ratio; return ratio;
} }