From 395b7d082eec9672dd69ea716eb3efc4a0de8535 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 12 Oct 2008 09:32:13 +0000 Subject: more iograph fixes git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2707 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/iograph/libkviiograph.cpp | 70 ++++++++++++++++++----------------- src/modules/iograph/libkviiograph.h | 5 +-- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/modules/iograph/libkviiograph.cpp b/src/modules/iograph/libkviiograph.cpp index c31d71161..37582c4ed 100644 --- a/src/modules/iograph/libkviiograph.cpp +++ b/src/modules/iograph/libkviiograph.cpp @@ -87,13 +87,13 @@ void KviIOGraphWindow::die() KviIOGraphWidget::KviIOGraphWidget(QWidget * par) : QWidget(par) { - m_maxSendRate = m_uLastSentBytes = g_uOutgoingTraffic; - m_maxRecvRate = m_uLastRecvBytes = g_uIncomingTraffic; + m_uLastSentBytes = g_uOutgoingTraffic; + m_uLastRecvBytes = g_uIncomingTraffic; - if(m_maxSendRate < 1) - m_maxSendRate = 1; - if(m_maxRecvRate < 1) - m_maxRecvRate = 1; + m_maxRate = qMax(m_uLastSentBytes, m_uLastRecvBytes); + + if(m_maxRate < 1) + m_maxRate = 1; m_sendRates.prepend(0); m_recvRates.prepend(0); @@ -117,21 +117,21 @@ void KviIOGraphWidget::timerEvent(QTimerEvent *e) unsigned int sDiff = (sB - m_uLastSentBytes) / KVI_IOGRAPH_HORIZ_SEGMENTS; unsigned int rDiff = (rB - m_uLastRecvBytes) / KVI_IOGRAPH_HORIZ_SEGMENTS; - if(sDiff > m_maxSendRate) - m_maxSendRate = sDiff; - if(rDiff > m_maxRecvRate) - m_maxRecvRate = rDiff; + if(sDiff > m_maxRate) + m_maxRate = sDiff; + if(rDiff > m_maxRate) + m_maxRate = rDiff; m_uLastSentBytes = sB; m_uLastRecvBytes = rB; m_sendRates.prepend(sDiff); -// if(m_sendRates.count()>KVI_IOGRAPH_NUMBER_POINTS) -// m_sendRates.removeLast(); + if(m_sendRates.count()>(KVI_IOGRAPH_NUMBER_POINTS+1)) + m_sendRates.removeLast(); m_recvRates.prepend(rDiff); -// if(m_recvRates.count()>KVI_IOGRAPH_NUMBER_POINTS) -// m_recvRates.removeLast(); + if(m_recvRates.count()>(KVI_IOGRAPH_NUMBER_POINTS+1)) + m_recvRates.removeLast(); update(); } @@ -145,59 +145,61 @@ void KviIOGraphWidget::paintEvent(QPaintEvent * e) p.setRenderHint(QPainter::Antialiasing); p.setPen(QColor("#c0c0c0")); - int c=0; - int sw = width() / KVI_IOGRAPH_HORIZ_SEGMENTS; - int sh = height() / KVI_IOGRAPH_VERT_SEGMENTS; + float c = 1.0; + float sw = (width() - 2.0) / KVI_IOGRAPH_VERT_SEGMENTS; + float sh = (height() - 2.0) / KVI_IOGRAPH_HORIZ_SEGMENTS; - for(int i=0;i0 and i < KVI_IOGRAPH_HORIZ_SEGMENTS) + p.drawText(2,c,KviQString::makeSizeReadable(m_maxRate / i)); c+=sh; } - c=0; - for(int i=0;i m_sendRates; QQueue m_recvRates; - unsigned int m_maxSendRate; - unsigned int m_maxRecvRate; + unsigned int m_maxRate; kvi_u64_t m_uLastSentBytes; kvi_u64_t m_uLastRecvBytes; protected: -- cgit v1.3.1-10-gc9f91