mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-04 12:49:28 -04:00
* 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:
parent
168c854738
commit
82bffd9e09
3 changed files with 69 additions and 42 deletions
|
@ -19,12 +19,21 @@
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "rshare.h"
|
#include "rshare.h"
|
||||||
#include "StatisticDialog.h"
|
#include "StatisticDialog.h"
|
||||||
//#include <control/bandwidthevent.h>
|
#include <control/bandwidthevent.h>
|
||||||
#include "rsiface/rsiface.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 */
|
/** Constructor */
|
||||||
StatisticDialog::StatisticDialog(QWidget *parent)
|
StatisticDialog::StatisticDialog(QWidget *parent)
|
||||||
|
@ -39,12 +48,27 @@ StatisticDialog::StatisticDialog(QWidget *parent)
|
||||||
/* Bind events to actions */
|
/* Bind events to actions */
|
||||||
createActions();
|
createActions();
|
||||||
|
|
||||||
|
UpDays=0;
|
||||||
|
dayChange=false;
|
||||||
|
UpTime.start();
|
||||||
|
|
||||||
/* Initialize Sent/Receive data counters */
|
/* Initialize Sent/Receive data counters */
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
/* Hide Bandwidth Graph Settings frame */
|
/* Hide Bandwidth Graph Settings frame */
|
||||||
showSettingsFrame(false);
|
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 */
|
/* Turn off opacity group on unsupported platforms */
|
||||||
#if defined(Q_WS_WIN)
|
#if defined(Q_WS_WIN)
|
||||||
if(!(QSysInfo::WV_2000 <= QSysInfo::WindowsVersion <= QSysInfo::WV_2003)) {
|
if(!(QSysInfo::WV_2000 <= QSysInfo::WindowsVersion <= QSysInfo::WV_2003)) {
|
||||||
|
@ -56,9 +80,8 @@ StatisticDialog::StatisticDialog(QWidget *parent)
|
||||||
ui.frmOpacity->setVisible(false);
|
ui.frmOpacity->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QTimer *timer = new QTimer(this);
|
Timer=startTimer(REFRESH_RATE);
|
||||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updategraph2status()));
|
|
||||||
timer->start(5113);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
|
@ -69,7 +92,7 @@ StatisticDialog::~StatisticDialog()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Custom event handler. Checks if the event is a bandwidth update event. If it
|
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
|
void
|
||||||
StatisticDialog::customEvent(QEvent *event)
|
StatisticDialog::customEvent(QEvent *event)
|
||||||
|
@ -78,7 +101,40 @@ StatisticDialog::customEvent(QEvent *event)
|
||||||
BandwidthEvent *bw = (BandwidthEvent *)event;
|
BandwidthEvent *bw = (BandwidthEvent *)event;
|
||||||
updateGraph(bw->bytesRead(), bw->bytesWritten());
|
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
|
Binds events to actions
|
||||||
|
@ -112,17 +168,6 @@ StatisticDialog::updateGraph(quint64 bytesRead, quint64 bytesWritten)
|
||||||
ui.frmGraph->addPoints(bytesRead, 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
|
Loads the saved Bandwidth Graph settings
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
//#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,8 +47,10 @@ public:
|
||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
~StatisticDialog();
|
~StatisticDialog();
|
||||||
protected:
|
protected:
|
||||||
/** Called to deliver a bandwidth update event from Tor. */
|
/** Called to deliver a bandwidth update event from RetroShare. */
|
||||||
// void customEvent(QEvent *event);
|
void customEvent(QEvent *event);
|
||||||
|
void timerEvent(QTimerEvent*);
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/** Adds new data to the graph */
|
/** Adds new data to the graph */
|
||||||
|
@ -64,8 +66,6 @@ private slots:
|
||||||
/** Called when the reset button is pressed */
|
/** Called when the reset button is pressed */
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void updategraph2status();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Create and bind actions to events **/
|
/** Create and bind actions to events **/
|
||||||
|
@ -73,9 +73,7 @@ private:
|
||||||
/** Loads the saved Bandwidth Graph settings */
|
/** Loads the saved Bandwidth Graph settings */
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
/** A TorControl object used to talk to Tor. */
|
/** A RetroShareSettings object that handles getting/saving settings */
|
||||||
// TorControl* _torControl;
|
|
||||||
/** A VidaliaSettings object that handles getting/saving settings */
|
|
||||||
RshareSettings* _settings;
|
RshareSettings* _settings;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
|
|
|
@ -585,14 +585,6 @@
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Average Downloadspeed:</string>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Count of Downloads:</string>
|
<string>Count of Downloads:</string>
|
||||||
|
@ -661,14 +653,6 @@
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Average Uploadspeed:</string>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Count of Uploads:</string>
|
<string>Count of Uploads:</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue