Browse Source

- Fixes for share ratio calculation

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
da11488ba1
  1. 1
      Changelog
  2. 3
      src/DLListDelegate.h
  3. 3
      src/FinishedListDelegate.h
  4. 8
      src/bittorrent.cpp

1
Changelog

@ -2,6 +2,7 @@ @@ -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 <chris@qbittorrent.org> - v1.3.0

3
src/DLListDelegate.h

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

3
src/FinishedListDelegate.h

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

8
src/bittorrent.cpp

@ -763,14 +763,12 @@ float bittorrent::getRealRatio(QString hash) const{ @@ -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;
}

Loading…
Cancel
Save