You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
3.4 KiB
80 lines
3.4 KiB
15 years ago
|
/***************************************************************************
|
||
|
* Copyright (C) 2004 by Hugo Parente Lima *
|
||
|
* hugo_pl@users.sourceforge.net *
|
||
|
* *
|
||
|
* 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., *
|
||
10 years ago
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||
15 years ago
|
***************************************************************************/
|
||
|
#include "statistics.h"
|
||
|
#include "chart.h"
|
||
|
#include "knetstatsview.h"
|
||
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
15 years ago
|
#include <kactivelabel.h>
|
||
13 years ago
|
#include <tqtimer.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
|
||
|
|
||
|
|
||
13 years ago
|
Statistics::Statistics( KNetStatsView* parent, const char *name )
|
||
|
: StatisticsBase( parent, name ), mInterface(parent->interface()), mParent(parent) {
|
||
13 years ago
|
setCaption( i18n( "Details of %1" ).arg( mInterface ) );
|
||
15 years ago
|
|
||
13 years ago
|
TQBoxLayout* l = new TQHBoxLayout( mChart );
|
||
15 years ago
|
l->setAutoAdd( true );
|
||
13 years ago
|
Chart* chart = new Chart(mChart, parent->speedHistoryTx(), parent->speedHistoryRx(), parent->historyBufferSize(), parent->historyPointer(), parent->maxSpeed());
|
||
15 years ago
|
mMAC->setText(mParent->readInterfaceStringValue("address", 18));
|
||
13 years ago
|
mIP->setAlignment(TQt::AlignRight);
|
||
|
mMAC->setAlignment(TQt::AlignRight);
|
||
|
mNetmask->setAlignment(TQt::AlignRight);
|
||
15 years ago
|
update();
|
||
|
|
||
13 years ago
|
mTimer = new TQTimer( this );
|
||
|
connect( mTimer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( update() ) );
|
||
|
connect( mTimer, TQT_SIGNAL( timeout() ), chart, TQT_SLOT( update() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
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" );
|
||
|
|
||
13 years ago
|
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" );
|
||
15 years ago
|
}
|
||
|
|
||
|
void Statistics::show() {
|
||
|
// Update details...
|
||
|
mMTU->setText(mParent->readInterfaceStringValue("mtu", 6));
|
||
|
mIP->setText( mParent->getIp() );
|
||
13 years ago
|
mNetmask->setText( mParent->getNetmask() );
|
||
15 years ago
|
|
||
|
mTimer->start( mParent->updateInterval() );
|
||
|
StatisticsBase::show();
|
||
|
}
|
||
|
|
||
|
void Statistics::accept() {
|
||
|
mTimer->stop();
|
||
|
StatisticsBase::accept();
|
||
|
}
|
||
|
|
||
|
|
||
|
#include "statistics.moc"
|