From d3f0f9dde38b5c39cfc09c3ad6fb67ca72e6fca3 Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Tue, 7 Mar 2017 17:50:13 +0300 Subject: [PATCH] router stats - mark active tunnels bold --- libretroshare/src/turtle/p3turtle.cc | 2 +- .../src/gui/statistics/TurtleRouterDialog.cpp | 29 +++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index bb4684f01..997fe0e7e 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -2047,7 +2047,7 @@ void p3turtle::getInfo( std::vector >& hashes_info, tunnel.push_back(it->second.hash.toStdString()) ; tunnel.push_back(printNumber(now-it->second.time_stamp) + " secs ago") ; - tunnel.push_back(printFloatNumber(it->second.speed_Bps,true)) ; + tunnel.push_back(printFloatNumber(it->second.speed_Bps,false)) ; // } search_reqs_info.clear(); diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp index d3de0e9e1..6d8a46e32 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp +++ b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp @@ -133,12 +133,31 @@ void TurtleRouterDialog::updateTunnelRequests( const std::vectortext(0).left(14) == tr("Unknown hashes")) unknown_hash_found = true ; + + float num = strtof(tunnels_info[i][5].c_str(), NULL); // printFloatNumber + char tmp[100] ; + std::string units[4] = { "B/s","KB/s","MB/s","GB/s" } ; + int k=0 ; + while(num >= 800.0f && k<4) + num /= 1024.0f,++k; + sprintf(tmp,"%3.2f %s",num,units[k].c_str()) ; - QString str = tr("Tunnel id") + ": " + QString::fromUtf8(tunnels_info[i][0].c_str()) + "\t [" + QString::fromUtf8(tunnels_info[i][2].c_str()) + "] --> [" + QString::fromUtf8(tunnels_info[i][1].c_str()) + "]\t\t " + tr("last transfer") + ": " + QString::fromStdString(tunnels_info[i][4]) + "\t " + tr("Speed") + ": " + QString::fromStdString(tunnels_info[i][5]) ; + QString str = tr("Tunnel id") + ": " + QString::fromUtf8(tunnels_info[i][0].c_str()) + "\t [" + QString::fromUtf8(tunnels_info[i][2].c_str()) + "] --> [" + QString::fromUtf8(tunnels_info[i][1].c_str()) + "]\t\t " + tr("last transfer") + ": " + QString::fromStdString(tunnels_info[i][4]) + " " + "\t " + tr("Speed") + ": " + QString::fromStdString(tmp) ; stl.clear() ; stl.push_back(str) ; - - parent->addChild(new QTreeWidgetItem(stl)) ; + QTreeWidgetItem *item = new QTreeWidgetItem(stl); + parent->addChild(item); + QFont font = item->font(0); + if(strtol(tunnels_info[i][4].c_str(), NULL, 0)>10) // stuck + { + font.setItalic(true); + item->setFont(0,font); + } + if(strtol(tunnels_info[i][5].c_str(), NULL, 0)>1000) // fast + { + font.setBold(true); + item->setFont(0,font); + } } for(uint i=0;iaddChild(new QTreeWidgetItem(stl)) ; } - top_level_s_requests->setText(0, tr("Search requests") + "(" + QString::number(search_reqs_info.size()) + ")" ) ; + top_level_s_requests->setText(0, tr("Search requests") + " (" + QString::number(search_reqs_info.size()) + ")" ) ; for(uint i=0;i= tunnel_reqs_info.size() || i < MAX_TUNNEL_REQUESTS_DISPLAY) @@ -170,7 +189,7 @@ void TurtleRouterDialog::updateTunnelRequests( const std::vectorsetText(0, tr("Tunnel requests") + "("+QString::number(tunnel_reqs_info.size()) + ")") ; + top_level_t_requests->setText(0, tr("Tunnel requests") + " ("+QString::number(tunnel_reqs_info.size()) + ")") ; QTreeWidgetItem *unknown_hashs_item = findParentHashItem(RsFileHash().toStdString()) ; unknown_hashs_item->setText(0,tr("Unknown hashes") + " (" + QString::number(unknown_hashs_item->childCount())+QString(")")) ;