* Added Uptime and Since to Statistics

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1044 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-02-12 23:24:27 +00:00
parent 168c854738
commit 82bffd9e09
3 changed files with 69 additions and 42 deletions

View File

@ -19,12 +19,21 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "rshare.h"
#include "StatisticDialog.h"
//#include <control/bandwidthevent.h>
#include <control/bandwidthevent.h>
#include "rsiface/rsiface.h"
#include <QTime>
#include <QHeaderView>
/* 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

View File

@ -24,7 +24,7 @@
#include <QFileDialog>
#include <QDateTime>
//#include <QEvent>
#include <QEvent>
#include <QTimer>
@ -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 */

View File

@ -585,14 +585,6 @@
<string/>
</property>
</item>
<item>
<property name="text" >
<string>Average Downloadspeed:</string>
</property>
<property name="text" >
<string/>
</property>
</item>
<item>
<property name="text" >
<string>Count of Downloads:</string>
@ -661,14 +653,6 @@
<string/>
</property>
</item>
<item>
<property name="text" >
<string>Average Uploadspeed:</string>
</property>
<property name="text" >
<string/>
</property>
</item>
<item>
<property name="text" >
<string>Count of Uploads:</string>