improved tunnel statistics gui

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4224 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-05-28 22:25:42 +00:00
parent 7edcf59116
commit 429d6f2dc3
4 changed files with 63 additions and 63 deletions

View File

@ -262,14 +262,16 @@ TransfersDialog::TransfersDialog(QWidget *parent)
QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ; QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ;
TurtleRouterDialog *trdl = new TurtleRouterDialog(); ui.tabWidget->addTab( new TurtleRouterDialog(), tr("Tunneling")) ;
ui.tunnelInfoWidget->setWidget(trdl);
ui.tunnelInfoWidget->setWidgetResizable(true); // TurtleRouterDialog *trdl = new TurtleRouterDialog();
ui.tunnelInfoWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // ui.tunnelInfoWidget->setWidget(trdl);
ui.tunnelInfoWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); // ui.tunnelInfoWidget->setWidgetResizable(true);
ui.tunnelInfoWidget->viewport()->setBackgroundRole(QPalette::NoRole); // ui.tunnelInfoWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui.tunnelInfoWidget->setFrameStyle(QFrame::NoFrame); // ui.tunnelInfoWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
ui.tunnelInfoWidget->setFocusPolicy(Qt::NoFocus); // ui.tunnelInfoWidget->viewport()->setBackgroundRole(QPalette::NoRole);
// ui.tunnelInfoWidget->setFrameStyle(QFrame::NoFrame);
// ui.tunnelInfoWidget->setFocusPolicy(Qt::NoFocus);
/* Hide platform specific features */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN

View File

@ -656,9 +656,6 @@ p, li { white-space: pre-wrap; }
<attribute name="headerStretchLastSection"> <attribute name="headerStretchLastSection">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -671,7 +668,7 @@ p, li { white-space: pre-wrap; }
</font> </font>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="icon"> <attribute name="icon">
@ -826,30 +823,6 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Tunneling</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QScrollArea" name="tunnelInfoWidget">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>

View File

@ -16,7 +16,10 @@ class TRHistogram
QColor colorScale(float f) QColor colorScale(float f)
{ {
return QColor::fromHsv((int)((1.0-f)*280),200,255) ; if(f == 0)
return QColor::fromHsv(0,0,128) ;
else
return QColor::fromHsv((int)((1.0-f)*280),200,255) ;
} }
virtual void draw(QPainter *painter,int& ox,int& oy,const QString& title) virtual void draw(QPainter *painter,int& ox,int& oy,const QString& title)
@ -93,7 +96,7 @@ class TRHistogram
painter->setPen(QColor::fromRgb(0,0,0)) ; painter->setPen(QColor::fromRgb(0,0,0)) ;
painter->drawText(ox+MaxDepth*cellx+30+(MaxTime+1)*cellx,oy+(p+1)*celly,TurtleRouterDialog::getPeerName(it->first)) ; painter->drawText(ox+MaxDepth*cellx+30+(MaxTime+1)*cellx,oy+(p+1)*celly,TurtleRouterDialog::getPeerName(it->first)) ;
painter->drawText(ox+MaxDepth*cellx+30+(MaxTime+1)*cellx+80,oy+(p+1)*celly,"("+QString::number(total)+")") ; painter->drawText(ox+MaxDepth*cellx+30+(MaxTime+1)*cellx+120,oy+(p+1)*celly,"("+QString::number(total)+")") ;
} }
painter->drawRect(ox,oy,MaxTime*cellx,p*celly) ; painter->drawRect(ox,oy,MaxTime*cellx,p*celly) ;
@ -150,8 +153,13 @@ TurtleRouterDialog::TurtleRouterDialog(QWidget *parent)
top_level_hashes.clear() ; top_level_hashes.clear() ;
QVBoxLayout v(_tunnel_statistics_F) ; _tunnel_statistics_F->setWidget( _tst_CW = new TurtleRouterStatisticsWidget() ) ;
v.addWidget( _tst_CW = new TurtleRouterStatisticsWidget() ) ; _tunnel_statistics_F->setWidgetResizable(true);
_tunnel_statistics_F->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
_tunnel_statistics_F->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
_tunnel_statistics_F->viewport()->setBackgroundRole(QPalette::NoRole);
_tunnel_statistics_F->setFrameStyle(QFrame::NoFrame);
_tunnel_statistics_F->setFocusPolicy(Qt::NoFocus);
} }
void TurtleRouterDialog::updateDisplay() void TurtleRouterDialog::updateDisplay()
@ -165,6 +173,7 @@ void TurtleRouterDialog::updateDisplay()
updateTunnelRequests(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ; updateTunnelRequests(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;
_tst_CW->updateTunnelStatistics(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ; _tst_CW->updateTunnelStatistics(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;
_tst_CW->update();
} }
QString TurtleRouterDialog::getPeerName(const std::string& peer_id) QString TurtleRouterDialog::getPeerName(const std::string& peer_id)
@ -303,7 +312,7 @@ TurtleRouterStatisticsWidget::TurtleRouterStatisticsWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
maxWidth = 200 ; maxWidth = 200 ;
maxHeight = 100 ; maxHeight = 0 ;
} }
void TurtleRouterStatisticsWidget::updateTunnelStatistics(const std::vector<std::vector<std::string> >& hashes_info, void TurtleRouterStatisticsWidget::updateTunnelStatistics(const std::vector<std::vector<std::string> >& hashes_info,
@ -312,25 +321,38 @@ void TurtleRouterStatisticsWidget::updateTunnelStatistics(const std::vector<std:
const std::vector<TurtleRequestDisplayInfo >& tunnel_reqs_info) const std::vector<TurtleRequestDisplayInfo >& tunnel_reqs_info)
{ {
static const int cellx = 6 ;
static const int celly = 10+4 ;
QPixmap tmppixmap(maxWidth, maxHeight); QPixmap tmppixmap(maxWidth, maxHeight);
tmppixmap.fill(this, 0, 0); tmppixmap.fill(this, 0, 0);
setFixedHeight(maxHeight);
QPainter painter(&tmppixmap); QPainter painter(&tmppixmap);
painter.initFrom(this); painter.initFrom(this);
maxHeight = 500 ;
// std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl;
// draw... // draw...
int ox=5,oy=5 ; int ox=5,oy=5 ;
TRHistogram(search_reqs_info).draw(&painter,ox,oy,QObject::tr("Evolution of search requests:")) ;
TRHistogram(tunnel_reqs_info).draw(&painter,ox,oy,QObject::tr("Evolution of tunnel requests:")) ; TRHistogram(search_reqs_info).draw(&painter,ox,oy,QObject::tr("Search requests repartition:")) ;
painter.setPen(QColor::fromRgb(70,70,70)) ;
painter.drawLine(0,oy,maxWidth,oy) ;
oy += celly ;
TRHistogram(tunnel_reqs_info).draw(&painter,ox,oy,QObject::tr("Tunnel requests repartition:")) ;
// now give information about turtle traffic. // now give information about turtle traffic.
// //
TurtleTrafficStatisticsInfo info ; TurtleTrafficStatisticsInfo info ;
rsTurtle->getTrafficStatistics(info) ; rsTurtle->getTrafficStatistics(info) ;
static const int cellx = 6 ; painter.setPen(QColor::fromRgb(70,70,70)) ;
static const int celly = 10+4 ; painter.drawLine(0,oy,maxWidth,oy) ;
oy += celly ;
painter.drawText(ox,oy+celly,tr("Turtle router traffic:")) ; oy += celly*2 ; painter.drawText(ox,oy+celly,tr("Turtle router traffic:")) ; oy += celly*2 ;
painter.drawText(ox+2*cellx,oy+celly,tr("Tunnel requests Up")+"\t: " + speedString(info.tr_up_Bps) ) ; oy += celly ; painter.drawText(ox+2*cellx,oy+celly,tr("Tunnel requests Up")+"\t: " + speedString(info.tr_up_Bps) ) ; oy += celly ;
@ -342,6 +364,7 @@ void TurtleRouterStatisticsWidget::updateTunnelStatistics(const std::vector<std:
// update the pixmap // update the pixmap
// //
pixmap = tmppixmap; pixmap = tmppixmap;
maxHeight = oy ;
} }
QString TurtleRouterStatisticsWidget::speedString(float f) QString TurtleRouterStatisticsWidget::speedString(float f)
@ -362,10 +385,11 @@ void TurtleRouterStatisticsWidget::paintEvent(QPaintEvent *event)
void TurtleRouterStatisticsWidget::resizeEvent(QResizeEvent *event) void TurtleRouterStatisticsWidget::resizeEvent(QResizeEvent *event)
{ {
QRect TaskGraphRect = geometry(); QRect TaskGraphRect = geometry();
maxWidth = 900;//TaskGraphRect.width(); maxWidth = TaskGraphRect.width();
maxHeight = TaskGraphRect.height(); maxHeight = TaskGraphRect.height() ;
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
update();
} }

View File

@ -33,25 +33,26 @@
</property> </property>
</column> </column>
</widget> </widget>
<widget class="QFrame" name="_tunnel_statistics_F"> <widget class="QScrollArea" name="_tunnel_statistics_F">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>800</width>
<height>0</height>
</size>
</property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow"> <property name="horizontalScrollBarPolicy">
<enum>QFrame::Raised</enum> <enum>Qt::ScrollBarAlwaysOff</enum>
</property> </property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>847</width>
<height>283</height>
</rect>
</property>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>