Browse Source

- Fixed share ratio display in properties widget and in Web UI

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
4908458729
  1. 6
      src/eventmanager.cpp
  2. 14
      src/propertieswidget.cpp
  3. 10
      src/webui/scripts/dynamicTable.js

6
src/eventmanager.cpp

@ -258,7 +258,11 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
leechs += " ("+QString::number(h.num_incomplete())+")"; leechs += " ("+QString::number(h.num_incomplete())+")";
event["num_leechs"] = QVariant(leechs); event["num_leechs"] = QVariant(leechs);
event["seed"] = QVariant(h.is_seed()); event["seed"] = QVariant(h.is_seed());
event["ratio"] = QVariant(QString::number(BTSession->getRealRatio(hash), 'f', 1)); double ratio = BTSession->getRealRatio(hash);
if(ratio > 100.)
QString::fromUtf8("");
else
event["ratio"] = QVariant(QString::number(ratio, 'f', 1));
event["hash"] = QVariant(hash); event["hash"] = QVariant(hash);
event_list[hash] = event; event_list[hash] = event;
} }

14
src/propertieswidget.cpp

@ -320,18 +320,10 @@ void PropertiesWidget::loadDynamicData() {
else else
lbl_connections->setText(QString::number(h.num_connections())); lbl_connections->setText(QString::number(h.num_connections()));
// Update ratio info // Update ratio info
float ratio; double ratio = BTSession->getRealRatio(h.hash());
if(h.total_payload_download() == 0){ if(ratio > 100.)
if(h.total_payload_upload() == 0) shareRatio->setText(QString::fromUtf8(""));
ratio = 1.;
else else
ratio = 10.; // Max ratio
}else{
ratio = (double)h.total_payload_upload()/(double)h.total_payload_download();
if(ratio > 10.){
ratio = 10.;
}
}
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1))); shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1)));
if(!h.is_seed()) { if(!h.is_seed()) {
// Downloaded pieces // Downloaded pieces

10
src/webui/scripts/dynamicTable.js

@ -101,10 +101,16 @@ var dynamicTable = new Class ({
else else
return (tr2.getElements('td')[i].get('html').split(' ')[0].toInt() - tr1.getElements('td')[i].get('html').split(' ')[0].toInt()); return (tr2.getElements('td')[i].get('html').split(' ')[0].toInt() - tr1.getElements('td')[i].get('html').split(' ')[0].toInt());
default: // Ratio default: // Ratio
var ratio1 = tr1.getElements('td')[i].get('html');
if(ratio1 == '∞')
ratio1 = '101.0';
var ratio2 = tr2.getElements('td')[i].get('html');
if(ratio2 == '∞')
ratio2 = '101.0';
if(order == "ASC") if(order == "ASC")
return (tr1.getElements('td')[i].get('html').toFloat() - tr2.getElements('td')[i].get('html')).toFloat(); return (ratio1.toFloat() - ratio2.toFloat());
else else
return (tr2.getElements('td')[i].get('html').toFloat() - tr1.getElements('td')[i].get('html')).toFloat(); return (ratio2.toFloat() - ratio1.toFloat());
} }
}, },

Loading…
Cancel
Save