2015-07-10 03:24:39 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "retroshare/rsconfig.h"
|
|
|
|
#include <gui/common/RSGraphWidget.h>
|
|
|
|
|
|
|
|
class BWGraphSource: public RSGraphSource
|
|
|
|
{
|
|
|
|
public:
|
2015-07-12 04:04:18 +00:00
|
|
|
struct TrafficHistoryChunk
|
|
|
|
{
|
|
|
|
time_t time_stamp;
|
|
|
|
std::list<RSTrafficClue> out_rstcl ;
|
|
|
|
std::list<RSTrafficClue> in_rstcl ;
|
|
|
|
};
|
|
|
|
|
2015-07-15 19:29:41 +00:00
|
|
|
BWGraphSource() ;
|
|
|
|
|
2015-07-10 03:24:39 +00:00
|
|
|
enum { SELECTOR_TYPE_FRIEND=0x00, SELECTOR_TYPE_SERVICE=0x01 };
|
2015-07-12 04:04:18 +00:00
|
|
|
enum { GRAPH_TYPE_SINGLE=0x00, GRAPH_TYPE_ALL=0x01, GRAPH_TYPE_SUM=0x02 };
|
|
|
|
enum { UNIT_KILOBYTES=0x00, UNIT_COUNT=0x01 };
|
2015-07-13 03:04:36 +00:00
|
|
|
enum { DIRECTION_UP=0x00, DIRECTION_DOWN=0x01 };
|
2015-07-10 03:24:39 +00:00
|
|
|
|
|
|
|
// re-derived from RSGraphSource
|
|
|
|
|
|
|
|
virtual void getValues(std::map<std::string,float>& values) const;
|
|
|
|
virtual QString displayValue(float v) const;
|
|
|
|
virtual QString legend(int i,float v) const;
|
2015-07-12 04:04:18 +00:00
|
|
|
virtual void update();
|
2015-07-10 03:24:39 +00:00
|
|
|
QString unitName() const ;
|
|
|
|
|
|
|
|
// own methdods to control what's used to create displayed info
|
|
|
|
|
2015-07-13 03:04:36 +00:00
|
|
|
void setSelector(int selector_type, int graph_type, const std::string& selector_client_string = std::string()) ;
|
|
|
|
void setDirection(int dir) ;
|
|
|
|
void setUnit(int unit) ;
|
|
|
|
|
|
|
|
int direction() const { return _current_direction ;}
|
|
|
|
int unit() const { return _current_unit ;}
|
|
|
|
int friendGraphType() const { return _friend_graph_type ;}
|
|
|
|
int serviceGraphType() const { return _service_graph_type ;}
|
|
|
|
|
|
|
|
const std::set<RsPeerId>& visibleFriends() const { return mVisibleFriends; }
|
|
|
|
const std::set<uint16_t>& visibleServices() const { return mVisibleServices; }
|
2015-07-10 03:24:39 +00:00
|
|
|
|
2015-07-12 04:04:18 +00:00
|
|
|
protected:
|
|
|
|
void convertTrafficClueToValues(const std::list<RSTrafficClue> &lst, std::map<std::string, float> &vals) const;
|
2015-07-13 03:04:36 +00:00
|
|
|
void recomputeCurrentCurves() ;
|
2015-07-12 04:04:18 +00:00
|
|
|
|
|
|
|
private:
|
2015-07-10 03:24:39 +00:00
|
|
|
QString niceNumber(float v) const;
|
|
|
|
|
|
|
|
mutable float _total_sent ;
|
|
|
|
mutable float _total_recv ;
|
2015-07-12 04:04:18 +00:00
|
|
|
|
|
|
|
int _friend_graph_type ;
|
|
|
|
int _service_graph_type ;
|
|
|
|
|
2015-07-13 03:04:36 +00:00
|
|
|
RsPeerId _current_selected_friend ;
|
2015-07-12 04:04:18 +00:00
|
|
|
std::string _current_selected_friend_name ;
|
2015-07-13 03:04:36 +00:00
|
|
|
uint16_t _current_selected_service ;
|
|
|
|
int _current_unit ;
|
|
|
|
int _current_direction ;
|
2015-07-12 04:04:18 +00:00
|
|
|
|
|
|
|
std::list<TrafficHistoryChunk> mTrafficHistory ;
|
2015-07-13 03:04:36 +00:00
|
|
|
|
|
|
|
std::set<RsPeerId> mVisibleFriends ;
|
|
|
|
std::set<uint16_t> mVisibleServices ;
|
2015-07-10 03:24:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BWGraph: public RSGraphWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BWGraph(QWidget *parent);
|
|
|
|
|
|
|
|
BWGraphSource *source() ;
|
|
|
|
|
2015-07-13 03:04:36 +00:00
|
|
|
const std::set<RsPeerId>& visibleFriends() const { return _local_source->visibleFriends(); }
|
|
|
|
const std::set<uint16_t>& visibleServices() const { return _local_source->visibleServices(); }
|
2015-07-10 03:24:39 +00:00
|
|
|
protected:
|
|
|
|
BWGraphSource *_local_source ;
|
|
|
|
};
|