| 537 | /* CStatTreeItemRatio */ |
| 538 | |
| 539 | wxString CStatTreeItemRatio::GetString() const |
| 540 | { |
| 541 | wxString ret; |
| 542 | double v1 = m_counter1->GetValue(); |
| 543 | double v2 = m_counter2->GetValue(); |
| 544 | if (v1 > 0 && v2 > 0) { |
| 545 | if (v2 < v1) { |
| 546 | ret = CFormat("%.2f : 1") % (v1 / v2); |
| 547 | } else { |
| 548 | ret = CFormat("1 : %.2f") % (v2 / v1); |
| 549 | } |
| 550 | } else { |
| 551 | ret = _("Not available"); |
| 552 | } |
| 553 | |
| 554 | // show the total ratio |
| 555 | if (m_totalfunc1 && m_totalfunc2) { |
| 556 | double t1 = m_totalfunc1() + v1; |
| 557 | double t2 = m_totalfunc2() + v2; |
| 558 | // Guard against fresh-install / zero-history cases. Without |
| 559 | // this, t1/t2 or t2/t1 divides by zero and the UI surfaces |
| 560 | // "(1 : nan)" or "(1 : inf)". |
| 561 | if (t1 > 0 && t2 > 0) { |
| 562 | if (t2 < t1) { |
| 563 | ret += CFormat(" (%.2f : 1)") % (t1 / t2); |
| 564 | } else { |
| 565 | ret += CFormat(" (1 : %.2f)") % (t2 / t1); |
| 566 | } |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | return ret; |
| 571 | } |
| 572 | |
| 573 | #ifndef AMULE_DAEMON |
| 574 | wxString CStatTreeItemRatio::GetDisplayString() const |
no test coverage detected