From 82bffd9e097158f56f995651ff81682fceb8dc98 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 12 Feb 2009 23:24:27 +0000 Subject: [PATCH] * Added Uptime and Since to Statistics git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1044 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/StatisticDialog.cpp | 81 +++++++++++++++++----- retroshare-gui/src/gui/StatisticDialog.h | 14 ++-- retroshare-gui/src/gui/StatisticDialog.ui | 16 ----- 3 files changed, 69 insertions(+), 42 deletions(-) diff --git a/retroshare-gui/src/gui/StatisticDialog.cpp b/retroshare-gui/src/gui/StatisticDialog.cpp index 3087a41dd..e796aec7f 100644 --- a/retroshare-gui/src/gui/StatisticDialog.cpp +++ b/retroshare-gui/src/gui/StatisticDialog.cpp @@ -19,12 +19,21 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ - #include "rshare.h" #include "StatisticDialog.h" -//#include +#include #include "rsiface/rsiface.h" +#include +#include + +/* Define the format used for displaying the date and time */ +#define DATETIME_FMT "yyyy MM dd hh:mm:ss" + +QTime UpTime; +int UpDays; +bool dayChange; +static int Timer=0; /** Constructor */ StatisticDialog::StatisticDialog(QWidget *parent) @@ -39,12 +48,27 @@ StatisticDialog::StatisticDialog(QWidget *parent) /* Bind events to actions */ createActions(); + UpDays=0; + dayChange=false; + UpTime.start(); + /* Initialize Sent/Receive data counters */ reset(); /* Hide Bandwidth Graph Settings frame */ showSettingsFrame(false); + /* Set header resize modes and initial section sizes */ + QHeaderView * _stheader = ui.treeWidget-> header(); + _stheader->resizeSection ( 0, 210 ); + + QAbstractItemModel * model =ui.treeWidget->model(); + QModelIndex ind2; + // set Times --> Session --> Since + ind2=model->index(4,0).child(0,0).child(1,1); + model->setData(ind2,QDateTime::currentDateTime() + .toString(DATETIME_FMT)); + /* Turn off opacity group on unsupported platforms */ #if defined(Q_WS_WIN) if(!(QSysInfo::WV_2000 <= QSysInfo::WindowsVersion <= QSysInfo::WV_2003)) { @@ -56,9 +80,8 @@ StatisticDialog::StatisticDialog(QWidget *parent) ui.frmOpacity->setVisible(false); #endif - QTimer *timer = new QTimer(this); - timer->connect(timer, SIGNAL(timeout()), this, SLOT(updategraph2status())); - timer->start(5113); + Timer=startTimer(REFRESH_RATE); + } /** Default destructor */ @@ -69,7 +92,7 @@ StatisticDialog::~StatisticDialog() /** Custom event handler. Checks if the event is a bandwidth update event. If it - is, it will add the data point to the history and updates the graph. + is, it will add the data point to the history and updates the graph.*/ void StatisticDialog::customEvent(QEvent *event) @@ -78,7 +101,40 @@ StatisticDialog::customEvent(QEvent *event) BandwidthEvent *bw = (BandwidthEvent *)event; updateGraph(bw->bytesRead(), bw->bytesWritten()); } -}*/ +} + +void StatisticDialog::timerEvent( QTimerEvent * ) +{ + QAbstractItemModel * model =ui.treeWidget->model(); + QModelIndex ind1; + // set download --> session bytes + //ind1=model->index(1,0).child(0,0).child(0,1); + //model->setData(ind1,totalToString(TotBytesDownloaded/1024.0)); + // set upload --> session bytes + //ind1=model->index(2,0).child(0,0).child(0,1); + //model->setData(ind1,totalToString(TotBytesUploaded/1024.0)); + + // set Times --> Session --> Uptime + ind1=model->index(4,0).child(0,0).child(0,1); + if(! dayChange && (UpTime.elapsed()/1000 > 60*60*23)) dayChange=true; + if( dayChange && (UpTime.elapsed() <10000)) {dayChange=false;UpDays++;} + + QTime elapsed; + elapsed= QTime(0,0,0).addMSecs(UpTime.elapsed()); + if( UpDays>0) + model->setData(ind1,QString(tr("%1 days ")).arg(UpDays)+elapsed.toString("hh:mm:ss")); + else + model->setData(ind1,elapsed.toString("hh:mm:ss")); + + /* set users/friends/network */ + float downKb = 0; + float upKb = 0; + rsicontrol -> ConfigGetDataRates(downKb, upKb); + + updateGraph(downKb,upKb); + // + +} /** Binds events to actions @@ -112,17 +168,6 @@ StatisticDialog::updateGraph(quint64 bytesRead, quint64 bytesWritten) ui.frmGraph->addPoints(bytesRead, bytesWritten); } -void -StatisticDialog::updategraph2status( ) -{ - /* set users/friends/network */ - float downKb = 0; - float upKb = 0; - rsicontrol -> ConfigGetDataRates(downKb, upKb); - - updateGraph(downKb,upKb); - -} /** Loads the saved Bandwidth Graph settings diff --git a/retroshare-gui/src/gui/StatisticDialog.h b/retroshare-gui/src/gui/StatisticDialog.h index d61450d99..5219eb535 100644 --- a/retroshare-gui/src/gui/StatisticDialog.h +++ b/retroshare-gui/src/gui/StatisticDialog.h @@ -24,7 +24,7 @@ #include #include -//#include +#include #include @@ -47,8 +47,10 @@ public: /** Default Destructor */ ~StatisticDialog(); protected: - /** Called to deliver a bandwidth update event from Tor. */ -// void customEvent(QEvent *event); + /** Called to deliver a bandwidth update event from RetroShare. */ + void customEvent(QEvent *event); + void timerEvent(QTimerEvent*); + private slots: /** Adds new data to the graph */ @@ -64,8 +66,6 @@ private slots: /** Called when the reset button is pressed */ void reset(); - void updategraph2status(); - private: /** Create and bind actions to events **/ @@ -73,9 +73,7 @@ private: /** Loads the saved Bandwidth Graph settings */ void loadSettings(); - /** A TorControl object used to talk to Tor. */ - // TorControl* _torControl; - /** A VidaliaSettings object that handles getting/saving settings */ + /** A RetroShareSettings object that handles getting/saving settings */ RshareSettings* _settings; /** Qt Designer generated object */ diff --git a/retroshare-gui/src/gui/StatisticDialog.ui b/retroshare-gui/src/gui/StatisticDialog.ui index 7cb3cb2a1..26f11ca42 100644 --- a/retroshare-gui/src/gui/StatisticDialog.ui +++ b/retroshare-gui/src/gui/StatisticDialog.ui @@ -585,14 +585,6 @@ - - - Average Downloadspeed: - - - - - Count of Downloads: @@ -661,14 +653,6 @@ - - - Average Uploadspeed: - - - - - Count of Uploads: