玉兔远程控制 0.1.0-bate8
载入中...
搜索中...
未找到
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
10class PLUGIN_EXPORT CStats : public CParameterOperate
11{
12 Q_OBJECT
13
14public:
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
43Q_SIGNALS:
50
51public Q_SLOTS:
55 virtual void slotCalculating();
56 virtual void AddSends(quint64 size);
57 virtual void AddReceives(quint64 size);
58
59private:
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
70protected:
71 virtual int OnLoad(QSettings &set) override;
72 virtual int OnSave(QSettings &set) override;
73};
74
79class PLUGIN_EXPORT CSecurityLevel : QObject {
80 Q_OBJECT
81
82public:
83 enum Level {
84 No = 0x8000, // No the function
85 Risk = 0x00,
86 Authentication = 0x01,
87 SecureChannel = 0x02,
88 Proxy = 0x04,
89 Gateway = 0x08,
90 Redirect = 0x010,
91
92 SecureMask = Authentication | SecureChannel, // Green
93 NormalMask = Proxy | Gateway | Redirect, // Yellow
94 RiskyMask = ~SecureMask // Red
95 };
96 Q_ENUM(Level)
97 Q_DECLARE_FLAGS(Levels, Level)
98 Q_FLAG(Levels)
99
100 CSecurityLevel(Levels level = Level::No, QObject* parent = nullptr);
102
103 [[nodiscard]] virtual Levels GetLevel() const;
104 [[nodiscard]] virtual QString GetString() const;
105 [[nodiscard]] virtual QColor GetColor() const;
106 [[nodiscard]] virtual QString GetUnicodeIcon() const;
107 [[nodiscard]] virtual QIcon GetIcon() const;
108 [[nodiscard]] static QString GetString(const Levels &level);
109 [[nodiscard]] static QString GetUnicodeIcon(const Levels &level);
110 [[nodiscard]] static QIcon GetIcon(const Levels &level);
111 [[nodiscard]] static QColor GetColor(const Levels &level);
112
113Q_SIGNALS:
118 void sigSecurityLevel(Levels level);
119
120private:
121 Levels m_Level;
122};
123
124// 在类外部声明操作符(通常放在头文件末尾)
125Q_DECLARE_OPERATORS_FOR_FLAGS(CSecurityLevel::Levels)
操作参数接口。仅在插件内有效。
安全级别
Definition Stats.h:79
void sigSecurityLevel(Levels level)
当安全级别改变时触发
Definition Stats.h:11
void sigDataChanged()
当数据发生变化时触发,用于通知用户实时调用 slotCalculating 进行计算。