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. 18
      src/propertieswidget.cpp
  3. 10
      src/webui/scripts/dynamicTable.js

6
src/eventmanager.cpp

@ -258,7 +258,11 @@ void EventManager::modifiedTorrent(QTorrentHandle h) @@ -258,7 +258,11 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
leechs += " ("+QString::number(h.num_incomplete())+")";
event["num_leechs"] = QVariant(leechs);
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_list[hash] = event;
}

18
src/propertieswidget.cpp

@ -320,19 +320,11 @@ void PropertiesWidget::loadDynamicData() { @@ -320,19 +320,11 @@ void PropertiesWidget::loadDynamicData() {
else
lbl_connections->setText(QString::number(h.num_connections()));
// Update ratio info
float ratio;
if(h.total_payload_download() == 0){
if(h.total_payload_upload() == 0)
ratio = 1.;
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)));
double ratio = BTSession->getRealRatio(h.hash());
if(ratio > 100.)
shareRatio->setText(QString::fromUtf8(""));
else
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1)));
if(!h.is_seed()) {
// Downloaded pieces
downloaded_pieces->setProgress(h.pieces());

10
src/webui/scripts/dynamicTable.js

@ -101,10 +101,16 @@ var dynamicTable = new Class ({ @@ -101,10 +101,16 @@ var dynamicTable = new Class ({
else
return (tr2.getElements('td')[i].get('html').split(' ')[0].toInt() - tr1.getElements('td')[i].get('html').split(' ')[0].toInt());
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")
return (tr1.getElements('td')[i].get('html').toFloat() - tr2.getElements('td')[i].get('html')).toFloat();
return (ratio1.toFloat() - ratio2.toFloat());
else
return (tr2.getElements('td')[i].get('html').toFloat() - tr1.getElements('td')[i].get('html')).toFloat();
return (ratio2.toFloat() - ratio1.toFloat());
}
},

Loading…
Cancel
Save