Skip to content

Commit d0452c5

Browse files
committed
fixed units, and enable/disable selectors when switch to/from cumulated
1 parent 0aa834f commit d0452c5

2 files changed

Lines changed: 26 additions & 29 deletions

File tree

retroshare-gui/src/gui/statistics/BWGraph.cpp

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void BWGraphSource::update()
121121
if(!mTrafficHistory.empty())
122122
{
123123
add_missing_elements(thc.out_rstcl,mTrafficHistory.back().out_rstcl);
124-
// add_missing_elements(thc.in_rstcl ,mTrafficHistory.back().in_rstcl);
124+
add_missing_elements(thc.in_rstcl ,mTrafficHistory.back().in_rstcl);
125125
}
126126

127127
std::cerr << "Traffic detail:" << std::endl;
@@ -510,39 +510,27 @@ void BWGraphSource::getValues(std::map<std::string,float>& values) const
510510
_total_recv += 1024 * totalRates.mRateIn * _update_period_msecs/1000.0f ;
511511
}
512512

513-
QString BWGraphSource::unitName() const { return (_current_unit == UNIT_KILOBYTES)?tr("KB/s"):QString(); }
514-
515-
//QString BWGraphSource::displayName(int i) const
516-
//{
517-
// int n=0;
518-
// for(std::map<std::string,std::list<std::pair<qint64,float> > >::const_iterator it = _points.begin();it!=_points.end() ;++it)
519-
// if(n++ == i)
520-
// {
521-
// // find out what is displayed
522-
//
523-
// if(_service_graph_type == GRAPH_TYPE_SINGLE )
524-
// if(_friend_graph_type != GRAPH_TYPE_ALL)
525-
// return QString::fromStdString(it->first) ;// sub item
526-
// else
527-
// return QString::fromStdString(mVisibleFriends[RsPeerId(it->first)]) ;// peer id item
528-
// else
529-
//
530-
//
531-
// }
532-
//
533-
// return QString("[error]");
534-
//}
513+
QString BWGraphSource::unitName() const
514+
{
515+
if(_current_timing == TIMING_CUMULATED)
516+
return tr("KB");
517+
518+
if(_current_unit == UNIT_KILOBYTES)
519+
return tr("KB/s");
520+
521+
return QString();
522+
}
535523

536524
QString BWGraphSource::displayValue(float v) const
537525
{
538526
if(_current_unit == UNIT_KILOBYTES)
539527
{
540-
if(v < 1000)
541-
return QString::number(v,'f',2) + " B/s" ;
542-
else if(v < 1000*1024)
543-
return QString::number(v/1024.0,'f',2) + " KB/s" ;
544-
else
545-
return QString::number(v/(1024.0*1024),'f',2) + " MB/s" ;
528+
QString s = niceNumber(v);
529+
530+
if(_current_timing == TIMING_INSTANT)
531+
return s + "/s";
532+
else
533+
return s ;
546534
}
547535
else if(_current_unit == UNIT_COUNT)
548536
{

retroshare-gui/src/gui/statistics/BandwidthStatsWidget.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,18 @@ void BandwidthStatsWidget::updateTimingSelection(int n)
265265
{
266266
std::cerr << "updating timing to " << n << " !" << std::endl;
267267
if(n==0)
268+
{
268269
ui.bwgraph_BW->setTiming(BWGraphSource::TIMING_INSTANT) ;
270+
ui.unit_CB->setItemText(0,"KB/s");
271+
ui.legend_CB->setEnabled(true);
272+
}
269273
else
274+
{
270275
ui.bwgraph_BW->setTiming(BWGraphSource::TIMING_CUMULATED) ;
276+
ui.unit_CB->setItemText(0,"KB");
277+
ui.legend_CB->setCurrentIndex(0);
278+
ui.legend_CB->setEnabled(false);
279+
}
271280
}
272281

273282
void BandwidthStatsWidget::updateUpDownSelection(int n)

0 commit comments

Comments
 (0)