diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index ed43ad3a0..4e5f6fa63 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -52,7 +52,7 @@ #include "ChatLobbyWidget.h" #include "HelpDialog.h" #include "AboutDialog.h" -#include "bwgraph/BandwidthGraphWindow.h" +#include "gui/statistics/BandwidthGraphWindow.h" #include "help/browser/helpbrowser.h" #include "chat/ChatDialog.h" #include "RetroShareLink.h" diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.cpp b/retroshare-gui/src/gui/common/RSGraphWidget.cpp index 3bef7f3b9..e60ef9dc8 100644 --- a/retroshare-gui/src/gui/common/RSGraphWidget.cpp +++ b/retroshare-gui/src/gui/common/RSGraphWidget.cpp @@ -142,7 +142,7 @@ void RSGraphWidget::setShowEntry(uint32_t entry,bool b) _masked_entries.insert(_source->displayName(entry).toStdString()) ; } -void RSGraphWidget::addSource(RSGraphSource *gs) +void RSGraphWidget::setSource(RSGraphSource *gs) { if(_source != NULL) delete _source ; diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.h b/retroshare-gui/src/gui/common/RSGraphWidget.h index fb05da67d..c495247e5 100644 --- a/retroshare-gui/src/gui/common/RSGraphWidget.h +++ b/retroshare-gui/src/gui/common/RSGraphWidget.h @@ -134,7 +134,7 @@ class RSGraphWidget: public QFrame // sets the update interval period. // void setTimerPeriod(int miliseconds) ; - void addSource(RSGraphSource *gs) ; + void setSource(RSGraphSource *gs) ; void setTimeScale(float pixels_per_second) ; /** Add data points. */ diff --git a/retroshare-gui/src/gui/statistics/BWGraph.h b/retroshare-gui/src/gui/statistics/BWGraph.h new file mode 100644 index 000000000..a1fb0e76e --- /dev/null +++ b/retroshare-gui/src/gui/statistics/BWGraph.h @@ -0,0 +1,39 @@ +#pragma once + +#include "retroshare/rsconfig.h" +#include + +class BWGraphSource: public RSGraphSource +{ +public: + enum { SELECTOR_TYPE_FRIEND=0x00, SELECTOR_TYPE_SERVICE=0x01 }; + enum { GRAPH_TYPE_SINGLE=0x00, GRAPH_TYPE_ALL=0x01, GRAPH_TYPE_SUM }; + + // re-derived from RSGraphSource + + virtual void getValues(std::map& values) const; + virtual QString displayValue(float v) const; + virtual QString legend(int i,float v) const; + QString unitName() const ; + + // own methdods to control what's used to create displayed info + + void setSelector(int selector_class,int selector_type,const std::string& selector_client_string = std::string()) ; + + private: + QString niceNumber(float v) const; + + mutable float _total_sent ; + mutable float _total_recv ; +}; + +class BWGraph: public RSGraphWidget +{ + public: + BWGraph(QWidget *parent); + + BWGraphSource *source() ; + +protected: + BWGraphSource *_local_source ; +}; diff --git a/retroshare-gui/src/gui/bwgraph/BandwidthGraphWindow.cpp b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp similarity index 99% rename from retroshare-gui/src/gui/bwgraph/BandwidthGraphWindow.cpp rename to retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp index 118e6c713..bc8c0c1bd 100644 --- a/retroshare-gui/src/gui/bwgraph/BandwidthGraphWindow.cpp +++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include diff --git a/retroshare-gui/src/gui/bwgraph/BandwidthGraphWindow.h b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h similarity index 98% rename from retroshare-gui/src/gui/bwgraph/BandwidthGraphWindow.h rename to retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h index 1b3612701..b85ab009f 100644 --- a/retroshare-gui/src/gui/bwgraph/BandwidthGraphWindow.h +++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include "ui_BandwidthGraphWindow.h" diff --git a/retroshare-gui/src/gui/bwgraph/BandwidthGraphWindow.ui b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui similarity index 100% rename from retroshare-gui/src/gui/bwgraph/BandwidthGraphWindow.ui rename to retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp b/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp index c222a884f..1a0a4d1cf 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp @@ -224,7 +224,7 @@ void BwCtrlWindow::updateDisplay() OutQueueStatistics stats ; rsConfig->getOutQueueStatistics(stats) ; - _outqueue_stats_W->updateStatistics(stats) ; + //_outqueue_stats_W->updateStatistics(stats) ; } void BwCtrlWindow::updateBandwidth() diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui b/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui index 55fb7a04b..dc20f8015 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui @@ -6,8 +6,8 @@ 0 0 - 597 - 469 + 1447 + 911 @@ -88,28 +88,17 @@ Qt::Vertical - - - - Qt::NoContextMenu - - + - BWGraph + BandwidthStatsWidget QWidget -
gui/statistics/bwgraph.h
- 1 -
- - OutQueueStatisticsWidget - QWidget -
gui/statistics/OutQueueStatistics.h
+
gui/statistics/BandwidthStatsWidget.h
1
diff --git a/retroshare-gui/src/gui/statistics/RttStatistics.cpp b/retroshare-gui/src/gui/statistics/RttStatistics.cpp index 2e05285ba..45ab5bdcc 100644 --- a/retroshare-gui/src/gui/statistics/RttStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/RttStatistics.cpp @@ -125,7 +125,7 @@ RttStatisticsGraph::RttStatisticsGraph(QWidget *parent) src->setDigits(1) ; src->start() ; - addSource(src) ; + setSource(src) ; setTimeScale(2.0f) ; // 1 pixels per second of time. diff --git a/retroshare-gui/src/gui/statistics/bwgraph.h b/retroshare-gui/src/gui/statistics/bwgraph.h deleted file mode 100644 index 5ef4026a4..000000000 --- a/retroshare-gui/src/gui/statistics/bwgraph.h +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include "retroshare/rsconfig.h" -#include - -class BWGraphSource: public RSGraphSource -{ -public: - virtual void getValues(std::map& values) const - { - RsConfigDataRates totalRates; - rsConfig->getTotalBandwidthRates(totalRates); - - values.insert(std::make_pair(std::string("Bytes in"),1024 * (float)totalRates.mRateIn)) ; - values.insert(std::make_pair(std::string("Bytes out"),1024 * (float)totalRates.mRateOut)) ; - - _total_sent += 1024 * totalRates.mRateOut * _update_period_msecs/1000.0f ; - _total_recv += 1024 * totalRates.mRateIn * _update_period_msecs/1000.0f ; - } - - virtual QString unitName() const { return tr("KB/s"); } - - virtual QString displayValue(float v) const - { - if(v < 1000) - return QString::number(v,'f',2) + " B/s" ; - else if(v < 1000*1024) - return QString::number(v/1024.0,'f',2) + " KB/s" ; - else - return QString::number(v/(1024.0*1024),'f',2) + " MB/s" ; - } - - virtual QString legend(int i,float v) const - { - if(i==0) - return RSGraphSource::legend(i,v) + " Total: " + niceNumber(_total_recv) ; - else - return RSGraphSource::legend(i,v) + " Total: " + niceNumber(_total_sent) ; - } - private: - QString niceNumber(float v) const - { - if(v < 1000) - return QString::number(v,'f',2) + " B" ; - else if(v < 1000*1024) - return QString::number(v/1024.0,'f',2) + " KB" ; - else if(v < 1000*1024*1024) - return QString::number(v/(1024*1024.0),'f',2) + " MB" ; - else - return QString::number(v/(1024*1024.0*1024),'f',2) + " GB"; - } - - mutable float _total_sent ; - mutable float _total_recv ; -}; - -class BWGraph: public RSGraphWidget -{ - public: - BWGraph(QWidget *parent) - : RSGraphWidget(parent) - { - BWGraphSource *src = new BWGraphSource() ; - - src->setCollectionTimeLimit(30*60*1000) ; // 30 mins - src->setCollectionTimePeriod(1000) ; // collect every second - src->setDigits(2) ; - src->start() ; - - addSource(src) ; - - setTimeScale(1.0f) ; // 1 pixels per second of time. - - resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ; - resetFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ; - - setFlags(RSGRAPH_FLAGS_SHOW_LEGEND) ; - } -}; - - diff --git a/retroshare-gui/src/gui/statistics/dhtgraph.h b/retroshare-gui/src/gui/statistics/dhtgraph.h index 2f9e0be34..2ebc2e2ec 100644 --- a/retroshare-gui/src/gui/statistics/dhtgraph.h +++ b/retroshare-gui/src/gui/statistics/dhtgraph.h @@ -67,7 +67,7 @@ class DhtGraph : public RSGraphWidget src->setDigits(0) ; src->start() ; - addSource(src) ; + setSource(src) ; setTimeScale(1.0f) ; // 1 pixels per second of time. diff --git a/retroshare-gui/src/gui/statistics/turtlegraph.h b/retroshare-gui/src/gui/statistics/turtlegraph.h index f9271ee9d..86a74fcb0 100644 --- a/retroshare-gui/src/gui/statistics/turtlegraph.h +++ b/retroshare-gui/src/gui/statistics/turtlegraph.h @@ -42,7 +42,7 @@ class TurtleGraph: public RSGraphWidget src->setDigits(2) ; src->start() ; - addSource(src) ; + setSource(src) ; setTimeScale(1.0f) ; // 1 pixels per second of time. diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index d7c056eb0..8492d8ab6 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -355,8 +355,15 @@ HEADERS += rshare.h \ gui/statistics/TurtleRouterDialog.h \ gui/statistics/TurtleRouterStatistics.h \ gui/statistics/dhtgraph.h \ - gui/statistics/bwgraph.h \ + gui/statistics/BandwidthGraphWindow.h \ gui/statistics/turtlegraph.h \ + gui/statistics/BandwidthStatsWidget.h \ + gui/statistics/DhtWindow.h \ + gui/statistics/GlobalRouterStatistics.h \ + gui/statistics/StatisticsWindow.h \ + gui/statistics/BwCtrlWindow.h \ + gui/statistics/RttStatistics.h \ + gui/statistics/OutQueueStatistics.h \ gui/FileTransfer/TransferUserNotify.h \ gui/plugins/PluginInterface.h \ gui/im_history/ImHistoryBrowser.h \ @@ -390,7 +397,6 @@ HEADERS += rshare.h \ util/ObjectPainter.h \ util/QtVersion.h \ util/RsFile.h \ - gui/bwgraph/BandwidthGraphWindow.h \ gui/profile/ProfileWidget.h \ gui/profile/ProfileManager.h \ gui/profile/StatusMessage.h \ @@ -540,13 +546,8 @@ HEADERS += rshare.h \ gui/connect/ConnectProgressDialog.h \ gui/groups/CreateGroup.h \ gui/GetStartedDialog.h \ - gui/statistics/DhtWindow.h \ - gui/statistics/GlobalRouterStatistics.h \ - gui/statistics/StatisticsWindow.h \ - gui/statistics/BwCtrlWindow.h \ - gui/statistics/RttStatistics.h \ - gui/statistics/OutQueueStatistics.h \ - gui/settings/WebuiPage.h + gui/settings/WebuiPage.h \ + gui/statistics/BWGraph.h # gui/ForumsDialog.h \ # gui/forums/ForumDetails.h \ @@ -585,7 +586,6 @@ FORMS += gui/StartDialog.ui \ gui/help/browser/helpbrowser.ui \ gui/HelpDialog.ui \ gui/ServicePermissionDialog.ui \ - gui/bwgraph/BandwidthGraphWindow.ui \ gui/profile/ProfileWidget.ui \ gui/profile/StatusMessage.ui \ gui/profile/ProfileManager.ui \ @@ -653,6 +653,8 @@ FORMS += gui/StartDialog.ui \ gui/common/HeaderFrame.ui \ gui/common/RSFeedWidget.ui \ gui/style/StyleDialog.ui \ + gui/statistics/BandwidthGraphWindow.ui \ + gui/statistics/BandwidthStatsWidget.ui \ gui/statistics/DhtWindow.ui \ gui/statistics/TurtleRouterDialog.ui \ gui/statistics/TurtleRouterStatistics.ui \ @@ -739,7 +741,6 @@ SOURCES += main.cpp \ util/HandleRichText.cpp \ util/ObjectPainter.cpp \ util/RsFile.cpp \ - gui/bwgraph/BandwidthGraphWindow.cpp \ gui/profile/ProfileWidget.cpp \ gui/profile/StatusMessage.cpp \ gui/profile/ProfileManager.cpp \ @@ -844,6 +845,7 @@ SOURCES += main.cpp \ gui/settings/ServicePermissionsPage.cpp \ gui/settings/AddFileAssociationDialog.cpp \ gui/settings/GroupFrameSettingsWidget.cpp \ + gui/settings/WebuiPage.cpp \ gui/statusbar/peerstatus.cpp \ gui/statusbar/natstatus.cpp \ gui/statusbar/dhtstatus.cpp \ @@ -884,6 +886,8 @@ SOURCES += main.cpp \ gui/connect/ConnectProgressDialog.cpp \ gui/groups/CreateGroup.cpp \ gui/GetStartedDialog.cpp \ + gui/statistics/BandwidthGraphWindow.cpp \ + gui/statistics/BandwidthStatsWidget.cpp \ gui/statistics/DhtWindow.cpp \ gui/statistics/TurtleRouterDialog.cpp \ gui/statistics/TurtleRouterStatistics.cpp \ @@ -892,7 +896,7 @@ SOURCES += main.cpp \ gui/statistics/StatisticsWindow.cpp \ gui/statistics/BwCtrlWindow.cpp \ gui/statistics/RttStatistics.cpp \ - gui/settings/WebuiPage.cpp + gui/statistics/BWGraph.cpp # gui/ForumsDialog.cpp \ # gui/forums/ForumDetails.cpp \