mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-12 02:55:18 -04:00
Added a new Statistics Window
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7501 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
29a11b021e
commit
05be764186
16 changed files with 1175 additions and 940 deletions
198
retroshare-gui/src/gui/statistics/StatisticsWindow.cpp
Normal file
198
retroshare-gui/src/gui/statistics/StatisticsWindow.cpp
Normal file
|
@ -0,0 +1,198 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2011 Robert Fernie
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "StatisticsWindow.h"
|
||||
#include "ui_StatisticsWindow.h"
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <time.h>
|
||||
|
||||
#include "retroshare-gui/RsAutoUpdatePage.h"
|
||||
#include "retroshare/rsconfig.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include <retroshare/rsplugin.h>
|
||||
|
||||
#include <gui/FileTransfer/TurtleRouterStatistics.h>
|
||||
#include <gui/settings/GlobalRouterStatistics.h>
|
||||
#include <gui/bwctrl/BwCtrlWindow.h>
|
||||
#include <gui/dht/DhtWindow.h>
|
||||
|
||||
/****
|
||||
* #define SHOW_RTT_STATISTICS 1
|
||||
****/
|
||||
#define SHOW_RTT_STATISTICS 1
|
||||
|
||||
#ifdef SHOW_RTT_STATISTICS
|
||||
#include "gui/RttStatistics.h"
|
||||
#endif
|
||||
|
||||
#define IMAGE_DHT ":/images/dht32.png"
|
||||
#define IMAGE_TURTLE ":images/turtle.png"
|
||||
#define IMAGE_BWGRAPH ":/images/ksysguard.png"
|
||||
#define IMAGE_GLOBALROUTER ":/images/network32.png"
|
||||
#define IMAGE_BANDWIDTH ":images/office-chart-area-stacked.png"
|
||||
#define IMAGE_RTT ":images/office-chart-line.png"
|
||||
|
||||
/********************************************** STATIC WINDOW *************************************/
|
||||
StatisticsWindow * StatisticsWindow::mInstance = NULL;
|
||||
|
||||
void StatisticsWindow::showYourself()
|
||||
{
|
||||
if (mInstance == NULL) {
|
||||
mInstance = new StatisticsWindow();
|
||||
}
|
||||
|
||||
mInstance->show();
|
||||
mInstance->activateWindow();
|
||||
}
|
||||
|
||||
StatisticsWindow* StatisticsWindow::getInstance()
|
||||
{
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
void StatisticsWindow::releaseInstance()
|
||||
{
|
||||
if (mInstance) {
|
||||
delete mInstance;
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************** STATIC WINDOW *************************************/
|
||||
|
||||
|
||||
|
||||
StatisticsWindow::StatisticsWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::StatisticsWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
initStackedPage();
|
||||
connect(ui->stackPages, SIGNAL(currentChanged(int)), this, SLOT(setNewPage(int)));
|
||||
ui->stackPages->setCurrentIndex(0);
|
||||
|
||||
}
|
||||
|
||||
StatisticsWindow::~StatisticsWindow()
|
||||
{
|
||||
delete ui;
|
||||
mInstance = NULL;
|
||||
}
|
||||
|
||||
void StatisticsWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
QMainWindow::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Initialyse Stacked Page*/
|
||||
void StatisticsWindow::initStackedPage()
|
||||
{
|
||||
|
||||
QList<QPair<MainPage*, QAction*> > notify;
|
||||
|
||||
/* Create the Main pages and actions */
|
||||
QActionGroup *grp = new QActionGroup(this);
|
||||
QAction *action;
|
||||
|
||||
ui->stackPages->add(dhtw = new DhtWindow(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_DHT), tr("DHT"), grp));
|
||||
|
||||
ui->stackPages->add(bwdlg = new BwCtrlWindow(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_BANDWIDTH), tr("Bandwidth"), grp));
|
||||
|
||||
ui->stackPages->add(trsdlg = new TurtleRouterStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle Router"), grp));
|
||||
|
||||
ui->stackPages->add(grsdlg = new GlobalRouterStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_GLOBALROUTER), tr("Global Router"), grp));
|
||||
|
||||
#ifdef SHOW_RTT_STATISTICS
|
||||
|
||||
ui->stackPages->add(rttdlg = new RttStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_RTT), tr("RTT Statistics"), grp));
|
||||
#endif
|
||||
|
||||
std::cerr << "Looking for interfaces in existing plugins:" << std::endl;
|
||||
for(int i = 0;i<rsPlugins->nbPlugins();++i)
|
||||
{
|
||||
QIcon icon ;
|
||||
|
||||
if(rsPlugins->plugin(i) != NULL && rsPlugins->plugin(i)->qt_page() != NULL)
|
||||
{
|
||||
if(rsPlugins->plugin(i)->qt_icon() != NULL)
|
||||
icon = *rsPlugins->plugin(i)->qt_icon() ;
|
||||
else
|
||||
icon = QIcon(":images/extension_48.png") ;
|
||||
|
||||
std::cerr << " Addign widget page for plugin " << rsPlugins->plugin(i)->getPluginName() << std::endl;
|
||||
MainPage *pluginPage = rsPlugins->plugin(i)->qt_page();
|
||||
QAction *pluginAction = createPageAction(icon, QString::fromUtf8(rsPlugins->plugin(i)->getPluginName().c_str()), grp);
|
||||
ui->stackPages->add(pluginPage, pluginAction);
|
||||
//notify.push_back(QPair<MainPage*, QAction*>(pluginPage, pluginAction));
|
||||
}
|
||||
else if(rsPlugins->plugin(i) == NULL)
|
||||
std::cerr << " No plugin object !" << std::endl;
|
||||
else
|
||||
std::cerr << " No plugin page !" << std::endl;
|
||||
|
||||
}
|
||||
|
||||
/* Create the toolbar */
|
||||
ui->toolBar->addActions(grp->actions());
|
||||
|
||||
connect(grp, SIGNAL(triggered(QAction *)), ui->stackPages, SLOT(showPage(QAction *)));
|
||||
|
||||
}
|
||||
|
||||
/** Creates a new action associated with a main page. */
|
||||
QAction *StatisticsWindow::createPageAction(const QIcon &icon, const QString &text, QActionGroup *group)
|
||||
{
|
||||
QFont font;
|
||||
QAction *action = new QAction(icon, text, group);
|
||||
font = action->font();
|
||||
font.setPointSize(9);
|
||||
action->setCheckable(true);
|
||||
action->setFont(font);
|
||||
return action;
|
||||
}
|
||||
|
||||
/** Selection page. */
|
||||
void StatisticsWindow::setNewPage(int page)
|
||||
{
|
||||
MainPage *pagew = dynamic_cast<MainPage*>(ui->stackPages->widget(page)) ;
|
||||
|
||||
if(pagew)
|
||||
{
|
||||
ui->stackPages->setCurrentIndex(page);
|
||||
}
|
||||
}
|
78
retroshare-gui/src/gui/statistics/StatisticsWindow.h
Normal file
78
retroshare-gui/src/gui/statistics/StatisticsWindow.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
#ifndef RSSTATS_WINDOW_H
|
||||
#define RSSTATS_WINDOW_H
|
||||
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2011 Robert Fernie
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class StatisticsWindow;
|
||||
}
|
||||
|
||||
class MainPage;
|
||||
class QActionGroup;
|
||||
|
||||
class DhtWindow;
|
||||
class BwCtrlWindow;
|
||||
class TurtleRouterStatistics;
|
||||
class GlobalRouterStatistics;
|
||||
class RttStatistics;
|
||||
|
||||
class StatisticsWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
static void showYourself ();
|
||||
static StatisticsWindow* getInstance();
|
||||
static void releaseInstance();
|
||||
|
||||
|
||||
StatisticsWindow(QWidget *parent = 0);
|
||||
~StatisticsWindow();
|
||||
|
||||
DhtWindow *dhtw;
|
||||
GlobalRouterStatistics *grsdlg;
|
||||
BwCtrlWindow *bwdlg;
|
||||
TurtleRouterStatistics *trsdlg;
|
||||
RttStatistics *rttdlg;
|
||||
|
||||
|
||||
public slots:
|
||||
void setNewPage(int page);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
void initStackedPage();
|
||||
|
||||
Ui::StatisticsWindow *ui;
|
||||
|
||||
static StatisticsWindow *mInstance;
|
||||
|
||||
/** Creates a new action for a Main page. */
|
||||
QAction* createPageAction(const QIcon &icon, const QString &text, QActionGroup *group);
|
||||
|
||||
};
|
||||
|
||||
#endif // RSDHT_WINDOW_H
|
||||
|
151
retroshare-gui/src/gui/statistics/StatisticsWindow.ui
Normal file
151
retroshare-gui/src/gui/statistics/StatisticsWindow.ui
Normal file
|
@ -0,0 +1,151 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>StatisticsWindow</class>
|
||||
<widget class="QMainWindow" name="StatisticsWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>571</width>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">RetroShare Statistics</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="handleWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="MainPageStack" name="stackPages" native="true"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<action name="actionAdd_Friend">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/user/add_user24.png</normaloff>:/images/user/add_user24.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Friend</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add a Friend Wizard</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAdd_Share">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Share</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOptions">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/kcmsystem24.png</normaloff>:/images/kcmsystem24.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMessenger">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/messenger.png</normaloff>:/images/messenger.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Messenger</string>
|
||||
</property>
|
||||
<property name="visible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/informations_24x24.png</normaloff>:/images/informations_24x24.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSMPlayer">
|
||||
<property name="text">
|
||||
<string>SMPlayer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/exit_24x24.png</normaloff>:/images/exit_24x24.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuick_Start_Wizard">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/tools_wizard.png</normaloff>:/images/tools_wizard.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quick Start Wizard</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Quick Start Wizard</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionServicePermissions">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/admin-24.png</normaloff>:/images/admin-24.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ServicePermissions</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Service permissions matrix</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>MainPageStack</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">gui/mainpagestack.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Add table
Add a link
Reference in a new issue