4Q_DECLARE_METATYPE(CSecurityLevel::Levels)
9 , m_lastTime(QDateTime::currentDateTime())
16QString CStats::Convertbytes(quint64 bytes)
19 if((1 << 10) >= bytes)
20 szBytes = QString::number(bytes) +
" " + tr(
"B");
21 else if((1 << 20) >= bytes)
22 szBytes = QString::number((qreal)bytes / (1 << 10),
'f', 2) +
" " + tr(
"KB");
23 else if((1 << 30) >= bytes)
24 szBytes = QString::number((qreal)bytes / (1 << 20),
'f', 2) +
" " + tr(
"MB");
26 szBytes = QString::number((qreal)bytes / (1 << 30),
'f', 2) +
" " + tr(
"GB");
30QString CStats::TotalSends()
32 return Convertbytes(GetTotalSends());
35QString CStats::TotalReceives()
37 return Convertbytes(GetTotalReceives());
40quint64 CStats::GetTotalSends()
45quint64 CStats::GetTotalReceives()
47 return m_TotalReceives;
50void CStats::AddSends(quint64 size)
57void CStats::AddReceives(quint64 size)
59 m_TotalReceives += size;
60 if(GetReceiveRate() <= 0)
64QString CStats::SendRate()
69QString CStats::ReceiveRate()
71 return Convertbytes(GetReceiveRate()) +
"/" + tr(
"S");
79double CStats::GetReceiveRate()
81 return m_dbReceiveRate;
91 if(m_tmInterval == interval)
94 m_tmInterval = interval;
101 qint64 interval = m_lastTime.msecsTo(QDateTime::currentDateTime());
104 m_dbSendRate = (double)(m_TotalSends - m_lastSends) * 1000 / interval;
105 m_dbReceiveRate = (double)(m_TotalReceives - m_lastReceives) * 1000 / interval;
109 m_lastSends = m_TotalSends;
110 m_lastReceives = m_TotalReceives;
111 m_lastTime = QDateTime::currentDateTime();
115int CStats::OnLoad(QSettings &set)
120int CStats::OnSave(QSettings &set)
126 :
CStats(parent, szPrefix)
130QString CStatsSever::ToString()
const
132 return tr(
"Connect count: Current: %1; Disconnect: %2; Total: %3")
133 .arg(GetTotalConnects() - GetDisconnects())
134 .arg(GetDisconnects()).arg(GetTotalConnects());
137quint64 CStatsSever::GetTotalConnects()
const
139 return m_TotalConnects;
142quint64 CStatsSever::GetConnects()
const
144 return m_TotalConnects - m_Disconnects;
147quint64 CStatsSever::GetDisconnects()
const
149 return m_Disconnects;
152void CStatsSever::AddConnects(quint64 c)
154 m_TotalConnects += c;
157void CStatsSever::Disconnects(quint64 c)
162CSecurityLevel::CSecurityLevel(Levels level, QObject* parent)
168CSecurityLevel::~CSecurityLevel()
171CSecurityLevel::Levels CSecurityLevel::GetLevel()
const
176QString CSecurityLevel::GetString()
const
178 return GetString(GetLevel());
181QColor CSecurityLevel::GetColor()
const
183 return GetColor(GetLevel());
186QString CSecurityLevel::GetUnicodeIcon()
const
188 return GetUnicodeIcon(GetLevel());
191QIcon CSecurityLevel::GetIcon()
const
193 return GetIcon(GetLevel());
196QString CSecurityLevel::GetString(
const Levels &level)
199 if(Level::SecureChannel & level) {
200 if(!szSecurity.isEmpty())
202 szSecurity += tr(
"Secure channel");
204 if(Level::Authentication & level) {
205 if(!szSecurity.isEmpty())
207 szSecurity += tr(
"Authentication");
210 if(Level::Proxy & level) {
211 if(!szNormal.isEmpty())
213 szNormal += tr(
"Proxy");
215 if(Level::Gateway & level) {
216 if(!szNormal.isEmpty())
218 szNormal += tr(
"Gateway");
220 if(Level::Redirect & level) {
221 if(!szNormal.isEmpty())
223 szNormal += tr(
"Redirect");
226 if(level & Level::No)
229 if(level == Level::SecureMask)
230 return tr(
"Secure") +
": " + szSecurity;
231 if(Level::SecureMask & level) {
232 QString szMsg = tr(
"Normal") +
": " + szSecurity;
233 if(!szNormal.isEmpty()) {
234 if(!szSecurity.isEmpty())
260QString CSecurityLevel::GetUnicodeIcon(
const Levels &level)
262 if(Level::No & level)
264 if(level == Level::SecureMask)
266 if(Level::SecureMask & level) {
268 if(Level::SecureChannel & level)
270 else if(Level::Authentication & level)
277QColor CSecurityLevel::GetColor(
const Levels &level)
279 if(Level::No & level)
281 if(level == Level::SecureMask)
282 return Qt::GlobalColor::green;
283 if(Level::SecureMask & level)
284 return Qt::GlobalColor::yellow;
285 return Qt::GlobalColor::red;
288QIcon CSecurityLevel::GetIcon(
const Levels &level)
290 if(Level::No & level)
292 if(level == Level::SecureMask)
293 return QIcon::fromTheme(
"lock");
294 if(Level::SecureMask & level)
295 return QIcon::fromTheme(
"dialog-warning");
296 return QIcon::fromTheme(
"unlock");
Operational parameter interface.
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.
virtual void slotCalculating()
Calculating.
int SetInterval(int interval=1)
Set interval.
void sigDataChanged()
Triggered when data changes, used to notify users to call slotCalculating(true) in real time for calc...
virtual double GetSendRate()
Send rate.
int GetInterval()
Get interval.