MCPcopy Create free account
hub / github.com/amule-project/amule / GetString

Method GetString

src/StatTree.cpp:539–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537/* CStatTreeItemRatio */
538
539wxString 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
574wxString CStatTreeItemRatio::GetDisplayString() const

Callers 1

GetDisplayStringMethod · 0.45

Calls 2

CFormatClass · 0.85
GetValueMethod · 0.45

Tested by

no test coverage detected