玉兔远程控制
0.1.0-bate11
Toggle main menu visibility
载入中...
搜索中...
未找到
Src
ParameterCompone
Stats.h
1
// Author: Kang Lin <kl222@126.com>
2
3
#pragma once
4
5
#include <QAtomicInteger>
6
#include <QAtomicInt>
7
#include <QDateTime>
8
#include "ParameterOperate.h"
9
10
class
PLUGIN_EXPORT CStats :
public
CParameterOperate
11
{
12
Q_OBJECT
13
14
public
:
15
explicit
CStats(
CParameterOperate
* parent =
nullptr
,
16
const
QString& szPrefix = QString());
17
18
[[nodiscard]]
static
QString Convertbytes(quint64 bytes);
19
20
QString TotalSends();
21
QString TotalReceives();
22
quint64 GetTotalSends();
23
quint64 GetTotalReceives();
24
25
QString SendRate();
26
QString ReceiveRate();
31
[[nodiscard]]
virtual
double
GetSendRate
();
32
[[nodiscard]]
virtual
double
GetReceiveRate();
33
37
[[nodiscard]]
int
GetInterval
();
41
int
SetInterval
(
int
interval = 1);
42
43
Q_SIGNALS:
49
void
sigDataChanged
();
50
51
public
Q_SLOTS:
55
virtual
void
slotCalculating
();
56
virtual
void
AddSends(quint64 size);
57
virtual
void
AddReceives(quint64 size);
58
59
private
:
60
QAtomicInteger<quint64> m_TotalSends;
61
QAtomicInteger<quint64> m_TotalReceives;
62
int
m_tmInterval;
63
QDateTime m_lastTime;
64
QAtomicInteger<quint64> m_lastSends;
65
QAtomicInteger<quint64> m_lastReceives;
66
double
m_dbSendRate;
67
double
m_dbReceiveRate;
68
69
// CParameter interface
70
protected
:
71
virtual
int
OnLoad(QSettings &set)
override
;
72
virtual
int
OnSave(QSettings &set)
override
;
73
};
74
75
class
PLUGIN_EXPORT CStatsSever :
public
CStats {
76
Q_OBJECT
77
78
public
:
79
explicit
CStatsSever(
CParameterOperate
* parent =
nullptr
,
80
const
QString& szPrefix = QString());
81
QString ToString()
const
;
82
quint64 GetTotalConnects()
const
;
83
quint64 GetConnects()
const
;
84
quint64 GetDisconnects()
const
;
85
void
AddConnects(quint64 c = 1);
86
void
Disconnects(quint64 c = 1);
87
88
private
:
89
QAtomicInteger<quint64> m_TotalConnects;
90
QAtomicInteger<quint64> m_Disconnects;
91
};
92
97
class
PLUGIN_EXPORT CSecurityLevel :
public
QObject {
98
Q_OBJECT
99
100
public
:
101
enum
Level {
102
No = 0x8000,
// No the function
103
Risk = 0x00,
104
Authentication = 0x01,
105
SecureChannel = 0x02,
106
Proxy = 0x04,
107
Gateway = 0x08,
108
Redirect = 0x010,
109
110
SecureMask = Authentication | SecureChannel,
// Green
111
NormalMask = Proxy | Gateway | Redirect,
// Yellow
112
RiskyMask = ~SecureMask
// Red
113
};
114
Q_ENUM(Level)
115
Q_DECLARE_FLAGS(Levels, Level)
116
Q_FLAG(Levels)
117
118
CSecurityLevel(Levels level = Level::No, QObject* parent =
nullptr
);
119
~CSecurityLevel();
120
121
[[nodiscard]]
virtual
Levels GetLevel()
const
;
122
[[nodiscard]]
virtual
QString GetString()
const
;
123
[[nodiscard]]
virtual
QColor GetColor()
const
;
124
[[nodiscard]]
virtual
QString GetUnicodeIcon()
const
;
125
[[nodiscard]]
virtual
QIcon GetIcon()
const
;
126
[[nodiscard]]
static
QString GetString(
const
Levels &level);
127
[[nodiscard]]
static
QString GetUnicodeIcon(
const
Levels &level);
128
[[nodiscard]]
static
QIcon GetIcon(
const
Levels &level);
129
[[nodiscard]]
static
QColor GetColor(
const
Levels &level);
130
131
Q_SIGNALS:
136
void
sigSecurityLevel
(Levels level);
137
138
private
:
139
Levels m_Level;
140
};
141
142
// 在类外部声明操作符(通常放在头文件末尾)
143
Q_DECLARE_OPERATORS_FOR_FLAGS(CSecurityLevel::Levels)
CParameterOperate::CParameterOperate
CParameterOperate(QObject *parent, const QString &szPrefix=QString())
CSecurityLevel::sigSecurityLevel
void sigSecurityLevel(Levels level)
当安全级别改变时触发
CStats::slotCalculating
virtual void slotCalculating()
Calculating
定义
Stats.cpp:99
CStats::SetInterval
int SetInterval(int interval=1)
Set interval.
定义
Stats.cpp:89
CStats::sigDataChanged
void sigDataChanged()
当数据发生变化时触发,用于通知用户实时调用 slotCalculating 进行计算。
CStats::GetSendRate
virtual double GetSendRate()
Send rate.
定义
Stats.cpp:74
CStats::GetInterval
int GetInterval()
Get interval.
定义
Stats.cpp:84
作者:康林 (kl222@126.com)
版权所有(c) 康林工作室 保留所有权力