Browse Source

Share ratio can now go over 100

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
2da5e03741
  1. 2
      src/properties/propertieswidget.cpp
  2. 7
      src/qtlibtorrent/qbtsession.cpp
  3. 3
      src/qtlibtorrent/qbtsession.h
  4. 3
      src/transferlistdelegate.h

2
src/properties/propertieswidget.cpp

@ -349,7 +349,7 @@ void PropertiesWidget::loadDynamicData() { @@ -349,7 +349,7 @@ void PropertiesWidget::loadDynamicData() {
reannounce_lbl->setText(h.next_announce());
// Update ratio info
const qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
if(ratio > 100.)
if(ratio > QBtSession::MAX_RATIO)
shareRatio->setText(QString::fromUtf8(""));
else
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 2)));

7
src/qtlibtorrent/qbtsession.cpp

@ -82,7 +82,6 @@ using namespace libtorrent; @@ -82,7 +82,6 @@ using namespace libtorrent;
QBtSession* QBtSession::m_instance = 0;
const int MAX_TRACKER_ERRORS = 2;
const qreal MAX_RATIO = 100.;
enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL };
// Main constructor
@ -1442,12 +1441,12 @@ qreal QBtSession::getRealRatio(QString hash) const{ @@ -1442,12 +1441,12 @@ qreal QBtSession::getRealRatio(QString hash) const{
if(h.total_done() == 0) {
if(h.all_time_upload() == 0)
return 0;
return 101;
return MAX_RATIO+1;
}
qreal ratio = (float)h.all_time_upload()/(float)h.total_done();
Q_ASSERT(ratio >= 0.);
if(ratio > 100.)
ratio = 100.;
if(ratio > MAX_RATIO)
ratio = MAX_RATIO;
return ratio;
}

3
src/qtlibtorrent/qbtsession.h

@ -65,6 +65,9 @@ class QBtSession : public QObject { @@ -65,6 +65,9 @@ class QBtSession : public QObject {
Q_OBJECT
Q_DISABLE_COPY(QBtSession)
public:
static const qreal MAX_RATIO = 9999.;
private:
explicit QBtSession();
static QBtSession* m_instance;

3
src/transferlistdelegate.h

@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
#include <QDateTime>
#include "misc.h"
#include "torrentmodel.h"
#include "qbtsession.h"
#ifdef Q_WS_WIN
#include <QPlastiqueStyle>
@ -155,7 +156,7 @@ public: @@ -155,7 +156,7 @@ public:
QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignRight;
const qreal ratio = index.data().toDouble();
if(ratio > 100.)
if(ratio > QBtSession::MAX_RATIO)
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8(""));
else
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(ratio, 'f', 2));

Loading…
Cancel
Save