diff options
author | Slávek Banko <[email protected]> | 2018-10-26 04:07:01 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2018-10-27 13:36:02 +0200 |
commit | 42673b0179d00e2b5a05fb48438577b923f00b8b (patch) | |
tree | c42ef21f0799c5e73ae1ccb6ed439d690ec9e59c /src/statistics.cpp | |
parent | 0e396d6b00651d811959f8d4c7ccad9ff868a1a1 (diff) | |
download | knetstats-42673b0179d00e2b5a05fb48438577b923f00b8b.tar.gz knetstats-42673b0179d00e2b5a05fb48438577b923f00b8b.zip |
Fix structure of directories
Signed-off-by: Slávek Banko <[email protected]>
(cherry picked from commit 06772a369f2beef80bb291ded30cbe125a24af56)
Diffstat (limited to 'src/statistics.cpp')
-rw-r--r-- | src/statistics.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/statistics.cpp b/src/statistics.cpp new file mode 100644 index 0000000..6097be1 --- /dev/null +++ b/src/statistics.cpp @@ -0,0 +1,79 @@ +/*************************************************************************** +* Copyright (C) 2004 by Hugo Parente Lima * +* [email protected] * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +***************************************************************************/ +#include "statistics.h" +#include "chart.h" +#include "knetstatsview.h" + +#include <tdelocale.h> +#include <tdeapplication.h> +#include <kactivelabel.h> +#include <tqtimer.h> +#include <tqlayout.h> + + + +Statistics::Statistics( KNetStatsView* parent, const char *name ) +: StatisticsBase( parent, name ), mInterface(parent->interface()), mParent(parent) { + setCaption( i18n( "Details of %1" ).arg( mInterface ) ); + + TQBoxLayout* l = new TQHBoxLayout( mChart ); + l->setAutoAdd( true ); + Chart* chart = new Chart(mChart, parent->speedHistoryTx(), parent->speedHistoryRx(), parent->historyBufferSize(), parent->historyPointer(), parent->maxSpeed()); + mMAC->setText(mParent->readInterfaceStringValue("address", 18)); + mIP->setAlignment(TQt::AlignRight); + mMAC->setAlignment(TQt::AlignRight); + mNetmask->setAlignment(TQt::AlignRight); + update(); + + mTimer = new TQTimer( this ); + connect( mTimer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( update() ) ); + connect( mTimer, TQT_SIGNAL( timeout() ), chart, TQT_SLOT( update() ) ); +} + +void Statistics::update() { + mMaxSpeed->setText(byteFormat( *mParent->maxSpeed() )+"/s"); + mBRx->setText( byteFormat( mParent->totalBytesRx() ) ); + mBTx->setText( byteFormat( mParent->totalBytesTx() ) ); + mByteSpeedRx->setText( byteFormat( mParent->byteSpeedRx() )+"/s" ); + mByteSpeedTx->setText( byteFormat( mParent->byteSpeedTx() )+"/s" ); + + mPRx->setText( TQString::number( mParent->totalPktRx() ) ); + mPTx->setText( TQString::number( mParent->totalPktTx() ) ); + mPktSpeedRx->setText( TQString::number( mParent->pktSpeedRx(), 'f', 1 )+"pkts/s" ); + mPktSpeedTx->setText( TQString::number( mParent->pktSpeedTx(), 'f', 1 )+"pkts/s" ); +} + +void Statistics::show() { + // Update details... + mMTU->setText(mParent->readInterfaceStringValue("mtu", 6)); + mIP->setText( mParent->getIp() ); + mNetmask->setText( mParent->getNetmask() ); + + mTimer->start( mParent->updateInterval() ); + StatisticsBase::show(); +} + +void Statistics::accept() { + mTimer->stop(); + StatisticsBase::accept(); +} + + +#include "statistics.moc" |