From 068115608dea3467ea28e9b85547657da8d632e7 Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 30 Jun 2011 19:04:06 +0000 Subject: TQt4 convert knetstats This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knetstats@1238873 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/src/chart.cpp | 22 ++++---- src/src/chart.h | 12 ++--- src/src/configure.cpp | 48 +++++++++--------- src/src/configure.h | 25 +++++----- src/src/configurebase.ui | 88 ++++++++++++++++---------------- src/src/interface.cpp | 4 +- src/src/interface.h | 16 +++--- src/src/knetstats.cpp | 46 ++++++++--------- src/src/knetstats.h | 11 ++-- src/src/knetstatsview.cpp | 124 +++++++++++++++++++++++----------------------- src/src/knetstatsview.h | 61 ++++++++++++----------- src/src/statistics.cpp | 36 +++++++------- src/src/statistics.h | 17 ++++--- src/src/statisticsbase.ui | 98 ++++++++++++++++++------------------ 14 files changed, 306 insertions(+), 302 deletions(-) diff --git a/src/src/chart.cpp b/src/src/chart.cpp index 9f48f14..9aad2d0 100644 --- a/src/src/chart.cpp +++ b/src/src/chart.cpp @@ -19,19 +19,19 @@ ***************************************************************************/ #include "chart.h" -#include -#include +#include +#include -Chart::Chart(QWidget* parent, const double* uploadBuffer, const double* downloadBuffer, int bufferSize, const int* ptr, const double* maxspeed) : QWidget(parent), mUplBuffer(uploadBuffer), mDldBuffer(downloadBuffer), mBufferSize(bufferSize), mPtr(ptr), mMaxSpeed(maxspeed) { - setWFlags(Qt::WNoAutoErase); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); +Chart::Chart(TQWidget* tqparent, const double* uploadBuffer, const double* downloadBuffer, int bufferSize, const int* ptr, const double* maxspeed) : TQWidget(tqparent), mUplBuffer(uploadBuffer), mDldBuffer(downloadBuffer), mBufferSize(bufferSize), mPtr(ptr), mMaxSpeed(maxspeed) { + setWFlags(TQt::WNoAutoErase); + tqsetSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding); } -void Chart::paintEvent(QPaintEvent*) { - QPainter paint(this); - paint.setBackgroundColor(Qt::black); +void Chart::paintEvent(TQPaintEvent*) { + TQPainter paint(this); + paint.setBackgroundColor(TQt::black); paint.setBackgroundMode(Qt::OpaqueMode); - QBrush brush(QColor(0x33, 0x33, 0x33), CrossPattern); + TQBrush brush(TQColor(0x33, 0x33, 0x33), CrossPattern); paint.fillRect(0, 0, width(), height(), brush); const double step = width()/double(mBufferSize); @@ -48,9 +48,9 @@ void Chart::paintEvent(QPaintEvent*) { i = mBufferSize-1; int rxY = HEIGHT - int(HEIGHT * (mDldBuffer[i]/(*mMaxSpeed))); int txY = HEIGHT - int(HEIGHT * (mUplBuffer[i]/(*mMaxSpeed))); - paint.setPen(Qt::green); + paint.setPen(TQt::green); paint.drawLine(lastX, lastRxY, x, rxY); - paint.setPen(Qt::red); + paint.setPen(TQt::red); paint.drawLine(lastX, lastTxY, x, txY); //qDebug("%d => %d", i, int(mSpeedHistoryRx[i])); lastX = x; diff --git a/src/src/chart.h b/src/src/chart.h index 2e89540..346eb40 100644 --- a/src/src/chart.h +++ b/src/src/chart.h @@ -21,16 +21,16 @@ #ifndef CHART_H #define CHART_H -#include +#include -class QPaintEvent; +class TQPaintEvent; -class Chart : public QWidget { +class Chart : public TQWidget { public: - Chart(QWidget* parent, const double* uploadBuffer, const double* downloadBuffer, int bufferSize, const int* ptr, const double* maxspeed); - QSize sizeHint() { return QSize(200, 100); } + Chart(TQWidget* tqparent, const double* uploadBuffer, const double* downloadBuffer, int bufferSize, const int* ptr, const double* maxspeed); + TQSize tqsizeHint() { return TQSize(200, 100); } protected: - void paintEvent( QPaintEvent* ev ); + void paintEvent( TQPaintEvent* ev ); private: const double* mUplBuffer; diff --git a/src/src/configure.cpp b/src/src/configure.cpp index 4e10636..93258b1 100644 --- a/src/src/configure.cpp +++ b/src/src/configure.cpp @@ -21,13 +21,13 @@ #include "configure.h" #include "knetstats.h" -// Qt includes -#include -#include -#include -#include -#include -#include +// TQt includes +#include +#include +#include +#include +#include +#include // Kde includes #include #include @@ -41,30 +41,30 @@ #include -Configure::Configure(KNetStats* parent, const InterfaceMap& ifs) : ConfigureBase(parent) { +Configure::Configure(KNetStats* tqparent, const InterfaceMap& ifs) : ConfigureBase(tqparent) { // Load configuration KIconLoader* loader = kapp->iconLoader(); - QPixmap iconPCI = loader->loadIcon("icon_pci.png", KIcon::Small, 16); + TQPixmap iconPCI = loader->loadIcon("icon_pci.png", KIcon::Small, 16); // Clone the configuration. for (InterfaceMap::ConstIterator it = ifs.begin(); it != ifs.end(); ++it) { mInterfaces->insertItem(iconPCI, it.key()); mConfig[it.key()] = it.data()->options(); -// parent->readInterfaceOptions(*it, &mConfig[*it]); +// tqparent->readInterfaceOptions(*it, &mConfig[*it]); } mInterfaces->setCurrentItem(0); changeInterface(mInterfaces->selectedItem()); - connect(mInterfaces, SIGNAL(selectionChanged(QListBoxItem*)), this, SLOT(changeInterface(QListBoxItem*))); - connect(mTheme, SIGNAL(activated(int)), this, SLOT(changeTheme(int))); - //connect(mInterfaces, SIGNAL(contextMenuRequested(QListBoxItem*, const QPoint&)), this, SLOT(showInterfaceContextMenu(QListBoxItem*, const QPoint&))); + connect(mInterfaces, TQT_SIGNAL(selectionChanged(TQListBoxItem*)), this, TQT_SLOT(changeInterface(TQListBoxItem*))); + connect(mTheme, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changeTheme(int))); + //connect(mInterfaces, TQT_SIGNAL(contextMenuRequested(TQListBoxItem*, const TQPoint&)), this, TQT_SLOT(showInterfaceContextMenu(TQListBoxItem*, const TQPoint&))); } -void Configure::changeInterface(QListBoxItem* item) { - QString interface = item->text(); +void Configure::changeInterface(TQListBoxItem* item) { + TQString interface = item->text(); if (!mCurrentItem.isEmpty()) { @@ -132,24 +132,24 @@ bool Configure::canSaveConfig() void Configure::changeTheme(int theme) { KIconLoader* loader = kapp->iconLoader(); - mIconError->setPixmap(loader->loadIcon("theme"+QString::number(theme)+"_error.png", + mIconError->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_error.png", KIcon::Panel, ICONSIZE)); - mIconNone->setPixmap(loader->loadIcon("theme"+QString::number(theme)+"_none.png", + mIconNone->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_none.png", KIcon::Panel, ICONSIZE)); - mIconTx->setPixmap(loader->loadIcon("theme"+QString::number(theme)+"_tx.png", + mIconTx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_tx.png", KIcon::Panel, ICONSIZE)); - mIconRx->setPixmap(loader->loadIcon("theme"+QString::number(theme)+"_rx.png", + mIconRx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_rx.png", KIcon::Panel, ICONSIZE)); - mIconBoth->setPixmap(loader->loadIcon("theme"+QString::number(theme)+"_both.png", + mIconBoth->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_both.png", KIcon::Panel, ICONSIZE)); } /* -void Configure::showInterfaceContextMenu(QListBoxItem* item, const QPoint& point) { +void Configure::showInterfaceContextMenu(TQListBoxItem* item, const TQPoint& point) { if (!item && mConfig.size() == 1) return; - QPixmap icon = kapp->iconLoader()->loadIcon("editdelete", KIcon::Small, 16); - QPopupMenu* menu = new QPopupMenu(this); - menu->insertItem(icon, i18n("Renomve Interface"), this, SLOT(removeInterface())); + TQPixmap icon = kapp->iconLoader()->loadIcon("editdelete", KIcon::Small, 16); + TQPopupMenu* menu = new TQPopupMenu(this); + menu->insertItem(icon, i18n("Renomve Interface"), this, TQT_SLOT(removeInterface())); menu->exec(point); } diff --git a/src/src/configure.h b/src/src/configure.h index a0098f7..e35f100 100644 --- a/src/src/configure.h +++ b/src/src/configure.h @@ -23,20 +23,20 @@ #include "configurebase.h" #include "interface.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include static const int ICONSIZE = 22; class KNetStats; -class QListBoxItem; +class TQListBoxItem; -typedef QMap OptionsMap; +typedef TQMap OptionsMap; /** @@ -45,20 +45,21 @@ typedef QMap OptionsMap; class Configure : public ConfigureBase { Q_OBJECT + TQ_OBJECT public: - Configure(KNetStats* parent, const InterfaceMap& ifs); + Configure(KNetStats* tqparent, const InterfaceMap& ifs); const OptionsMap& currentConfig() const { return mConfig; } bool canSaveConfig(); const OptionsMap& options() const { return mConfig; } private: - QString mCurrentItem; + TQString mCurrentItem; OptionsMap mConfig; protected slots: - void changeInterface(QListBoxItem* item); + void changeInterface(TQListBoxItem* item); void changeTheme(int theme); - //void showInterfaceContextMenu(QListBoxItem* item, const QPoint& point); + //void showInterfaceContextMenu(TQListBoxItem* item, const TQPoint& point); //void removeInterface(); }; diff --git a/src/src/configurebase.ui b/src/src/configurebase.ui index 4444be0..a148132 100644 --- a/src/src/configurebase.ui +++ b/src/src/configurebase.ui @@ -1,6 +1,6 @@ ConfigureBase - + ConfigureBase @@ -30,9 +30,9 @@ Minimum - + - layout7 + tqlayout7 @@ -48,7 +48,7 @@ Expanding - + 120 20 @@ -84,7 +84,7 @@ - + mInterfaces @@ -97,7 +97,7 @@ - + mAppearanceGroup @@ -116,11 +116,11 @@ unnamed - + mWdgStack - + mIconPage @@ -134,15 +134,15 @@ 0 - + - layout5 + tqlayout5 unnamed - + mLabel4 @@ -150,7 +150,7 @@ Theme: - + Classic @@ -190,7 +190,7 @@ Expanding - + 21 20 @@ -199,15 +199,15 @@ - + - layout7_2 + tqlayout7_2 unnamed - + mIconError @@ -219,7 +219,7 @@ 0 - + 22 22 @@ -239,14 +239,14 @@ Expanding - + 20 20 - + mIconNone @@ -258,7 +258,7 @@ 0 - + 22 22 @@ -278,14 +278,14 @@ Expanding - + 20 20 - + mIconTx @@ -297,7 +297,7 @@ 0 - + 22 22 @@ -317,14 +317,14 @@ Expanding - + 20 20 - + mIconRx @@ -336,7 +336,7 @@ 0 - + 22 22 @@ -356,14 +356,14 @@ Expanding - + 20 20 - + mIconBoth @@ -375,7 +375,7 @@ 0 - + 22 22 @@ -397,7 +397,7 @@ Expanding - + 20 20 @@ -406,7 +406,7 @@ - + mTextPage @@ -428,7 +428,7 @@ - + mLabel5 @@ -457,7 +457,7 @@ - + mLabel6 @@ -467,7 +467,7 @@ - + mBarsPage @@ -481,7 +481,7 @@ 0 - + mChartBgLabel @@ -497,7 +497,7 @@ - + mLabel7 @@ -505,7 +505,7 @@ Upload color: - + mLabel8 @@ -529,7 +529,7 @@ - + mChartTransparentBackground @@ -542,7 +542,7 @@ - + mConfigurationGroup @@ -581,7 +581,7 @@ mViewMode - + mLabel3 @@ -589,14 +589,14 @@ View mode: - + mLabel2 Update interval: - + WordBreak|AlignVCenter @@ -617,7 +617,7 @@ ms - + mMonitoring @@ -666,7 +666,7 @@ mChartBgColor mChartTransparentBackground - + kpushbutton.h kpushbutton.h diff --git a/src/src/interface.cpp b/src/src/interface.cpp index 26a02a5..3a8a7bb 100644 --- a/src/src/interface.cpp +++ b/src/src/interface.cpp @@ -14,7 +14,7 @@ #include #include -Interface::Interface(KNetStats* parent, const QString& name) : mName(name), mView(0), mParent(parent) { +Interface::Interface(KNetStats* tqparent, const TQString& name) : mName(name), mView(0), mParent(tqparent) { update(); } @@ -50,7 +50,7 @@ KNetStatsView::Options Interface::options() { } } -void Interface::say(const QString& message) { +void Interface::say(const TQString& message) { if (mView) mView->say(message); } diff --git a/src/src/interface.h b/src/src/interface.h index 71b29f8..4ad1323 100644 --- a/src/src/interface.h +++ b/src/src/interface.h @@ -13,12 +13,12 @@ #ifndef INTERFACE_H #define INTERFACE_H -#include +#include #include "knetstatsview.h" class KNetStats; class Interface { - QString mName; + TQString mName; KNetStatsView* mView; KNetStats* mParent; @@ -26,10 +26,10 @@ class Interface { public: /** * Constructs a new interface. - * \param parent parent of the view of this interface. - * \param name name of this interface (not the QObject name!!) + * \param tqparent tqparent of the view of this interface. + * \param name name of this interface (not the TQObject name!!) */ - Interface(KNetStats* parent, const QString& name); + Interface(KNetStats* tqparent, const TQString& name); /** * Set this interface visible to the user via a KNetStatsView. @@ -39,13 +39,13 @@ public: void update(); - void say(const QString& message); + void say(const TQString& message); KNetStatsView::Options options(); }; -#include -typedef QMap InterfaceMap; +#include +typedef TQMap InterfaceMap; #endif diff --git a/src/src/knetstats.cpp b/src/src/knetstats.cpp index e02e3f6..0dc149c 100644 --- a/src/src/knetstats.cpp +++ b/src/src/knetstats.cpp @@ -23,10 +23,10 @@ #include "configure.h" #include "interface.h" -// Qt includes -#include -#include -#include +// TQt includes +#include +#include +#include // KDE includes #include #include @@ -43,7 +43,7 @@ #include #include -KNetStats::KNetStats() : QWidget(0, "knetstats"), mConfigure(0), mBoot(true) { +KNetStats::KNetStats() : TQWidget(0, "knetstats"), mConfigure(0), mBoot(true) { setupUi(); int count; detectNewInterfaces(&count); @@ -53,8 +53,8 @@ KNetStats::KNetStats() : QWidget(0, "knetstats"), mConfigure(0), mBoot(true) { mBoot = false; - QTimer* timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(detectNewInterfaces())); + TQTimer* timer = new TQTimer(this); + connect(timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(detectNewInterfaces())); timer->start(IF_DETECTION_INTERVAL); } @@ -70,26 +70,26 @@ void KNetStats::setupUi() { mActionCollection = new KActionCollection(this); mContextMenu = new KPopupMenu(this); mContextMenu->insertTitle( kapp->miniIcon(), kapp->caption() ); - KAction* configure = KStdAction::preferences(this, SLOT(configure()), mActionCollection, "configure"); + KAction* configure = KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT(configure()), mActionCollection, "configure"); configure->plug(mContextMenu); mContextMenu->insertSeparator(); - KHelpMenu* helpmenu = new KHelpMenu(this, QString::null, false); + KHelpMenu* helpmenu = new KHelpMenu(this, TQString(), false); mContextMenu->insertItem( i18n("&Help"), helpmenu->menu() ); mContextMenu->insertSeparator(); - KAction* quitAction = KStdAction::quit(kapp, SLOT(quit()), mActionCollection); + KAction* quitAction = KStdAction::quit(TQT_TQOBJECT(kapp), TQT_SLOT(quit()), mActionCollection); quitAction->plug(mContextMenu); - connect(helpmenu, SIGNAL(showAboutApplication()), this, SLOT(about())); + connect(helpmenu, TQT_SIGNAL(showAboutApplication()), this, TQT_SLOT(about())); } -QStringList KNetStats::scanInterfaces() { - QDir dir("/sys/class/net"); +TQStringList KNetStats::scanInterfaces() { + TQDir dir("/sys/class/net"); if (!dir.exists()) { KMessageBox::error(0, i18n("You need kernel 2.6.x with support to the /sys filesystem.")); - return QStringList(); + return TQStringList(); } else { - QStringList list = dir.entryList(QDir::Dirs); + TQStringList list = dir.entryList(TQDir::Dirs); list.pop_front(); // removes "." and ".." entries list.pop_front(); return list; @@ -106,9 +106,9 @@ bool KNetStats::configure() { }*/ mConfigure = new Configure(this, mInterfaces); - connect(mConfigure->mOk, SIGNAL(clicked()), this, SLOT(configOk())); - connect(mConfigure->mApply, SIGNAL(clicked()), this, SLOT(configApply())); - connect(mConfigure->mCancel, SIGNAL(clicked()), this, SLOT(configCancel())); + connect(mConfigure->mOk, TQT_SIGNAL(clicked()), this, TQT_SLOT(configOk())); + connect(mConfigure->mApply, TQT_SIGNAL(clicked()), this, TQT_SLOT(configApply())); + connect(mConfigure->mCancel, TQT_SIGNAL(clicked()), this, TQT_SLOT(configCancel())); mConfigure->show(); } return true; @@ -167,10 +167,10 @@ void KNetStats::about() { void KNetStats::detectNewInterfaces(int* count_ptr) { int count = 0; - const QStringList& interfaces = KNetStats::scanInterfaces(); - QStringList::ConstIterator i = interfaces.begin(); + const TQStringList& interfaces = KNetStats::scanInterfaces(); + TQStringList::ConstIterator i = interfaces.begin(); for(; i != interfaces.end(); ++i) { - InterfaceMap::Iterator elem = mInterfaces.find(*i); + InterfaceMap::Iterator elem = mInterfaces.tqfind(*i); if (elem == mInterfaces.end()) if (createInterface(*i)) count++; @@ -179,12 +179,12 @@ void KNetStats::detectNewInterfaces(int* count_ptr) { *count_ptr = count; } -bool KNetStats::createInterface(const QString& name) { +bool KNetStats::createInterface(const TQString& name) { // Cria a interface e adiciona em mInterfaces. Interface* interface = new Interface(this, name); mInterfaces.insert(name, interface); if (!mBoot) - interface->say(i18n("New interface detected: %1").arg(name)); + interface->say(i18n("New interface detected: %1").tqarg(name)); return interface->isVisible(); } diff --git a/src/src/knetstats.h b/src/src/knetstats.h index 4282890..33ce801 100644 --- a/src/src/knetstats.h +++ b/src/src/knetstats.h @@ -21,9 +21,9 @@ #ifndef KNETSTATS_H #define KNETSTATS_H -#include +#include #include -#include +#include #include "configure.h" class KNetStatsView; @@ -34,9 +34,10 @@ class KActionCollection; class Interface; -class KNetStats : public QWidget +class KNetStats : public TQWidget { Q_OBJECT + TQ_OBJECT enum { IF_DETECTION_INTERVAL = 5000 @@ -52,7 +53,7 @@ public: * \brief Search for network interfaces parsing /proc/net/dev * \return A StringList with the network interface names */ - static QStringList scanInterfaces(); + static TQStringList scanInterfaces(); int numInterfaces() const { return mInterfaces.size(); } @@ -86,7 +87,7 @@ private: void clearOptions(OptionsMap* options); void setupUi(); // Creates a new interface, returns true or false if the new interface is visible or not. - bool createInterface(const QString& interface); + bool createInterface(const TQString& interface); }; diff --git a/src/src/knetstatsview.cpp b/src/src/knetstatsview.cpp index ea480ab..501e092 100644 --- a/src/src/knetstatsview.cpp +++ b/src/src/knetstatsview.cpp @@ -36,15 +36,15 @@ #include #include -// Qt headers -#include -#include -#include -#include -#include -#include -#include -#include +// TQt headers +#include +#include +#include +#include +#include +#include +#include +#include // C headers #include @@ -63,8 +63,8 @@ extern "C" { extern const char* programName; -KNetStatsView::KNetStatsView(KNetStats* parent, const QString& interface) -: KSystemTray(parent, 0), mSysDevPath("/sys/class/net/"+interface+"/"), mInterface(interface) { +KNetStatsView::KNetStatsView(KNetStats* tqparent, const TQString& interface) +: KSystemTray(tqparent, 0), mSysDevPath("/sys/class/net/"+interface+"/"), mInterface(interface) { mFdSock = 0; mFirstUpdate = true; mMaxSpeedAge = 0; @@ -81,15 +81,15 @@ KNetStatsView::KNetStatsView(KNetStats* parent, const QString& interface) memset(&mDevInfo, 0, sizeof(mDevInfo)); strcpy(mDevInfo.ifr_name, mInterface.latin1()); - setTextFormat(Qt::PlainText); - mContextMenu = parent->contextMenu(); + setTextFormat(TQt::PlainText); + mContextMenu = tqparent->contextMenu(); show(); // Timer - mTimer = new QTimer(this, "timer"); - connect(mTimer, SIGNAL(timeout()), this, SLOT(updateStats(void))); + mTimer = new TQTimer(this, "timer"); + connect(mTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(updateStats(void))); - QToolTip::add(this, i18n("Monitoring %1").arg(mInterface)); + TQToolTip::add(this, i18n("Monitoring %1").tqarg(mInterface)); setup(); mStatistics = new Statistics(this); } @@ -106,25 +106,25 @@ void KNetStatsView::setup() { else if (mOptions.mViewMode == Icon) { // Load Icons KIconLoader* loader = kapp->iconLoader(); - mIconError = loader->loadIcon("theme"+QString::number(mOptions.mTheme)+"_error.png", + mIconError = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_error.png", KIcon::Panel, ICONSIZE); - mIconNone = loader->loadIcon("theme"+QString::number(mOptions.mTheme)+"_none.png", + mIconNone = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_none.png", KIcon::Panel, ICONSIZE); - mIconTx = loader->loadIcon("theme"+QString::number(mOptions.mTheme)+"_tx.png", + mIconTx = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_tx.png", KIcon::Panel, ICONSIZE); - mIconRx =loader->loadIcon("theme"+QString::number(mOptions.mTheme)+"_rx.png", + mIconRx =loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_rx.png", KIcon::Panel, ICONSIZE); - mIconBoth = loader->loadIcon("theme"+QString::number(mOptions.mTheme)+"_both.png", + mIconBoth = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_both.png", KIcon::Panel, ICONSIZE); mCurrentIcon = &mIconNone; } mTimer->start(mOptions.mUpdateInterval); updateStats(); - QWidget::update(); + TQWidget::update(); mFirstUpdate = false; } -void KNetStatsView::say(const QString& message) { +void KNetStatsView::say(const TQString& message) { KPassivePopup::message(programName, message, kapp->miniIcon(), this); } @@ -135,24 +135,24 @@ void KNetStatsView::updateViewOptions() { void KNetStatsView::updateStats() { FILE* flags_fp = fopen((mSysDevPath+"flags").latin1(), "r"); - bool currentStatus; + bool currenttqStatus; if (!flags_fp) - currentStatus = false; + currenttqStatus = false; else { int flags; fscanf(flags_fp, "%Xu", &flags); fclose(flags_fp); - currentStatus = IFF_UP & flags; + currenttqStatus = IFF_UP & flags; } - if (!currentStatus && mConnected) { // interface down... + if (!currenttqStatus && mConnected) { // interface down... mConnected = false; resetBuffers(); - QWidget::update(); - say(i18n("%1 is inactive").arg(mInterface)); - } else if (currentStatus && !mConnected) { + TQWidget::update(); + say(i18n("%1 is inactive").tqarg(mInterface)); + } else if (currenttqStatus && !mConnected) { mConnected = true; - say(i18n("%1 is active").arg(mInterface)); + say(i18n("%1 is active").tqarg(mInterface)); } // kernel < 2.6.9 (I think) does not have carrier info, considering carrier ever on. @@ -168,13 +168,13 @@ void KNetStatsView::updateStats() { if (carrierFlag == '0') { // carrier down if (mCarrier) { mCarrier = false; - QWidget::update(); - say(i18n("%1 is disconnected").arg(mInterface)); + TQWidget::update(); + say(i18n("%1 is disconnected").tqarg(mInterface)); } return; } else if (!mCarrier) { // carrier up mCarrier = true; - say(i18n("%1 is connected").arg(mInterface)); + say(i18n("%1 is connected").tqarg(mInterface)); } unsigned int brx = readInterfaceNumValue("rx_bytes"); @@ -213,7 +213,7 @@ void KNetStatsView::updateStats() { } if (mOptions.mViewMode == Icon) { - QPixmap* newIcon; + TQPixmap* newIcon; if (brx == mBRx) { if (btx == mBTx ) newIcon = &mIconNone; @@ -228,10 +228,10 @@ void KNetStatsView::updateStats() { if (newIcon != mCurrentIcon) { mCurrentIcon = newIcon; - QWidget::update(); + TQWidget::update(); } } else if (mOptions.mViewMode == Graphic || (btx != mBTx && brx != mBRx)) - QWidget::update(); + TQWidget::update(); // Update stats mTotalBytesRx += brx - mBRx; @@ -246,7 +246,7 @@ void KNetStatsView::updateStats() { } unsigned long KNetStatsView::readInterfaceNumValue(const char* name) { - // stdio functions appear to be more fast than QFile? + // stdio functions appear to be more fast than TQFile? FILE* fp = fopen((mSysDevPath+"statistics/"+name).latin1(), "r"); long retval; fscanf(fp, "%lu", &retval); @@ -254,10 +254,10 @@ unsigned long KNetStatsView::readInterfaceNumValue(const char* name) { return retval; } -QString KNetStatsView::readInterfaceStringValue(const char* name, int maxlength) { - QFile macFile(mSysDevPath+name); +TQString KNetStatsView::readInterfaceStringValue(const char* name, int maxlength) { + TQFile macFile(mSysDevPath+name); macFile.open(IO_ReadOnly); - QString value; + TQString value; macFile.readLine(value, maxlength); return value; } @@ -271,8 +271,8 @@ void KNetStatsView::resetBuffers() { memset(mSpeedBufferPTx, 0, sizeof(double)*SPEED_BUFFER_SIZE); } -void KNetStatsView::paintEvent( QPaintEvent* ) { - QPainter paint(this); +void KNetStatsView::paintEvent( TQPaintEvent* ) { + TQPainter paint(this); switch(mOptions.mViewMode) { case Icon: if (!mCarrier || !mConnected) @@ -288,25 +288,25 @@ void KNetStatsView::paintEvent( QPaintEvent* ) { } } -void KNetStatsView::drawText(QPainter& paint) { +void KNetStatsView::drawText(TQPainter& paint) { if (!mCarrier || !mConnected) { - paint.drawText(rect(), Qt::AlignCenter, "?"); + paint.drawText(rect(), TQt::AlignCenter, "?"); } else { paint.setFont( mOptions.mTxtFont ); paint.setPen( mOptions.mTxtUplColor ); - paint.drawText( rect(), Qt::AlignTop, Statistics::byteFormat(byteSpeedTx(), "KB", "MB")); + paint.drawText( rect(), TQt::AlignTop, Statistics::byteFormat(byteSpeedTx(), "KB", "MB")); paint.setPen( mOptions.mTxtDldColor ); - paint.drawText( rect(), Qt::AlignBottom, Statistics::byteFormat(byteSpeedRx(), "KB", "MB")); + paint.drawText( rect(), TQt::AlignBottom, Statistics::byteFormat(byteSpeedRx(), "KB", "MB")); } } -void KNetStatsView::drawGraphic(QPainter& paint) { +void KNetStatsView::drawGraphic(TQPainter& paint) { if (!mCarrier || !mConnected) { - paint.drawText(rect(), Qt::AlignCenter, "X"); + paint.drawText(rect(), TQt::AlignCenter, "X"); return; } - QSize size = this->size(); + TQSize size = this->size(); if (!mOptions.mChartTransparentBackground) paint.fillRect(0, 0, size.width(), size.height(), mOptions.mChartBgColor); @@ -339,9 +339,9 @@ void KNetStatsView::drawGraphic(QPainter& paint) { } } -void KNetStatsView::mousePressEvent(QMouseEvent* ev) { +void KNetStatsView::mousePressEvent(TQMouseEvent* ev) { if (ev->button() == Qt::RightButton ) - mContextMenu->exec(QCursor::pos()); + mContextMenu->exec(TQCursor::pos()); else if (ev->button() == Qt::LeftButton) if (mStatistics->isShown()) mStatistics->accept(); @@ -357,7 +357,7 @@ bool KNetStatsView::openFdSocket() { return false; } -QString KNetStatsView::getIp() { +TQString KNetStatsView::getIp() { if (mFdSock == -1 && !openFdSocket()) return ""; @@ -366,15 +366,15 @@ QString KNetStatsView::getIp() { return inet_ntoa(sin.sin_addr); } -QString KNetStatsView::getNetmask() { +TQString KNetStatsView::getNettqmask() { if (mFdSock == -1 && !openFdSocket()) return ""; ioctl(mFdSock, SIOCGIFNETMASK, &mDevInfo); - sockaddr_in mask = ((sockaddr_in&)mDevInfo.ifr_netmask); - return inet_ntoa(mask.sin_addr); + sockaddr_in tqmask = ((sockaddr_in&)mDevInfo.ifr_netmask); + return inet_ntoa(tqmask.sin_addr); } -void KNetStatsView::readOptions( const QString& name, KNetStatsView::Options* opts, bool defaultVisibility ) { +void KNetStatsView::readOptions( const TQString& name, KNetStatsView::Options* opts, bool defaultVisibility ) { KConfig* cfg = kapp->config(); KConfigGroupSaver groupSaver(cfg, name); @@ -384,17 +384,17 @@ void KNetStatsView::readOptions( const QString& name, KNetStatsView::Options* op opts->mMonitoring = cfg->readBoolEntry("Monitoring", defaultVisibility); // txt view opts->mTxtFont = cfg->readFontEntry("TxtFont"); - opts->mTxtUplColor = cfg->readColorEntry("TxtUplColor", &Qt::red); - opts->mTxtDldColor = cfg->readColorEntry("TxtDldColor", &Qt::green); + opts->mTxtUplColor = cfg->readColorEntry("TxtUplColor", &TQt::red); + opts->mTxtDldColor = cfg->readColorEntry("TxtDldColor", &TQt::green); // IconView int defaultTheme = 0; if (name.startsWith("wlan")) defaultTheme = 3; // three... is a magic number... a magic number.... opts->mTheme = cfg->readNumEntry("Theme", defaultTheme); // Graphic - opts->mChartUplColor = cfg->readColorEntry("ChartUplColor", &Qt::red); - opts->mChartDldColor = cfg->readColorEntry("ChartDldColor", &Qt::blue); - opts->mChartBgColor = cfg->readColorEntry("ChartBgColor", &Qt::white); + opts->mChartUplColor = cfg->readColorEntry("ChartUplColor", &TQt::red); + opts->mChartDldColor = cfg->readColorEntry("ChartDldColor", &TQt::blue); + opts->mChartBgColor = cfg->readColorEntry("ChartBgColor", &TQt::white); opts->mChartTransparentBackground = cfg->readBoolEntry("ChartUseTransparentBackground", true); } diff --git a/src/src/knetstatsview.h b/src/src/knetstatsview.h index 4e97392..c7caa2b 100644 --- a/src/src/knetstatsview.h +++ b/src/src/knetstatsview.h @@ -22,17 +22,17 @@ #define KNETSTATSVIEW_H #include -#include -#include -#include +#include +#include +#include #include #include -class QTimer; -class QMouseEvent; -class QPainter; -class QPaintEvent; +class TQTimer; +class TQMouseEvent; +class TQPainter; +class TQPaintEvent; class Statistics; class KNetStats; @@ -42,6 +42,7 @@ class KNetStats; class KNetStatsView : public KSystemTray { Q_OBJECT + TQ_OBJECT enum { HISTORY_SIZE = 50, // Speed history buffer size @@ -65,29 +66,29 @@ public: Mode mViewMode; bool mMonitoring; // txt view - QFont mTxtFont; - QColor mTxtUplColor; - QColor mTxtDldColor; + TQFont mTxtFont; + TQColor mTxtUplColor; + TQColor mTxtDldColor; // icon view int mTheme; // chart view - QColor mChartUplColor; - QColor mChartDldColor; - QColor mChartBgColor; + TQColor mChartUplColor; + TQColor mChartDldColor; + TQColor mChartBgColor; bool mChartTransparentBackground; }; - KNetStatsView(KNetStats* parent, const QString& interface); + KNetStatsView(KNetStats* tqparent, const TQString& interface); ~KNetStatsView(); - void say(const QString& message); + void say(const TQString& message); void updateViewOptions(); // read a value from /sys/class/net/interface/name unsigned long readInterfaceNumValue(const char* name); // read a value from /sys/class/net/interface/name - QString readInterfaceStringValue(const char* name, int maxlength); - QString getIp(); - QString getNetmask(); + TQString readInterfaceStringValue(const char* name, int maxlength); + TQString getIp(); + TQString getNettqmask(); const double* speedHistoryRx() const { return mSpeedHistoryRx; } const double* speedHistoryTx() const { return mSpeedHistoryTx; } @@ -98,10 +99,10 @@ public: /// Return a copy of the current view options. Options options() const { return mOptions; } /// read the interface view options - static void readOptions( const QString& name, Options* opts, bool defaultVisibility = false ); + static void readOptions( const TQString& name, Options* opts, bool defaultVisibility = false ); /// The current monitored network interface - inline const QString& interface() const; + inline const TQString& interface() const; /// The current Update Interval in miliseconds inline int updateInterval() const; /// We are in textmode? @@ -125,8 +126,8 @@ public: inline double pktSpeedTx() const; protected: - void mousePressEvent( QMouseEvent* ev ); - void paintEvent( QPaintEvent* ev ); + void mousePressEvent( TQMouseEvent* ev ); + void paintEvent( TQPaintEvent* ev ); private: @@ -134,19 +135,19 @@ private: struct ifreq mDevInfo; // info struct about our interface - QString mSysDevPath; // Path to the device. + TQString mSysDevPath; // Path to the device. bool mCarrier; // Interface carrier is on? bool mConnected; // Interface exists? KPopupMenu* mContextMenu; // Global ContextMenu Statistics* mStatistics; // Statistics window - QString mInterface; // Current interface + TQString mInterface; // Current interface Options mOptions; // View options // Icons - QPixmap mIconError, mIconNone, mIconTx, mIconRx, mIconBoth; - QPixmap* mCurrentIcon; // Current state - QTimer* mTimer; // Timer + TQPixmap mIconError, mIconNone, mIconTx, mIconRx, mIconBoth; + TQPixmap* mCurrentIcon; // Current state + TQTimer* mTimer; // Timer // Rx e Tx to bytes and packets unsigned long mBRx, mBTx, mPRx, mPTx; @@ -170,8 +171,8 @@ private: // setup the view. void setup(); - void drawText(QPainter& paint); - void drawGraphic(QPainter& paint); + void drawText(TQPainter& paint); + void drawGraphic(TQPainter& paint); // Reset speed and history buffers void resetBuffers(); // calc tha max. speed stored in the history buffer @@ -211,7 +212,7 @@ double KNetStatsView::calcSpeed(const double* buffer) const { return total/SPEED_BUFFER_SIZE; } -const QString& KNetStatsView::interface() const { +const TQString& KNetStatsView::interface() const { return mInterface; } diff --git a/src/src/statistics.cpp b/src/src/statistics.cpp index efa571e..72deabc 100644 --- a/src/src/statistics.cpp +++ b/src/src/statistics.cpp @@ -24,27 +24,27 @@ #include #include #include -#include -#include +#include +#include -Statistics::Statistics( KNetStatsView* parent, const char *name ) -: StatisticsBase( parent, name ), mInterface(parent->interface()), mParent(parent) { - setCaption( i18n( "Details of %1" ).arg( mInterface ) ); +Statistics::Statistics( KNetStatsView* tqparent, const char *name ) +: StatisticsBase( tqparent, name ), mInterface(tqparent->interface()), mParent(tqparent) { + setCaption( i18n( "Details of %1" ).tqarg( mInterface ) ); - QBoxLayout* l = new QHBoxLayout( mChart ); + TQBoxLayout* l = new TQHBoxLayout( mChart ); l->setAutoAdd( true ); - Chart* chart = new Chart(mChart, parent->speedHistoryTx(), parent->speedHistoryRx(), parent->historyBufferSize(), parent->historyPointer(), parent->maxSpeed()); + Chart* chart = new Chart(mChart, tqparent->speedHistoryTx(), tqparent->speedHistoryRx(), tqparent->historyBufferSize(), tqparent->historyPointer(), tqparent->maxSpeed()); mMAC->setText(mParent->readInterfaceStringValue("address", 18)); - mIP->setAlignment(Qt::AlignRight); - mMAC->setAlignment(Qt::AlignRight); - mNetmask->setAlignment(Qt::AlignRight); + mIP->tqsetAlignment(TQt::AlignRight); + mMAC->tqsetAlignment(TQt::AlignRight); + mNettqmask->tqsetAlignment(TQt::AlignRight); update(); - mTimer = new QTimer( this ); - connect( mTimer, SIGNAL( timeout() ), this, SLOT( update() ) ); - connect( mTimer, SIGNAL( timeout() ), chart, SLOT( 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() { @@ -54,17 +54,17 @@ void Statistics::update() { mByteSpeedRx->setText( byteFormat( mParent->byteSpeedRx() )+"/s" ); mByteSpeedTx->setText( byteFormat( mParent->byteSpeedTx() )+"/s" ); - mPRx->setText( QString::number( mParent->totalPktRx() ) ); - mPTx->setText( QString::number( mParent->totalPktTx() ) ); - mPktSpeedRx->setText( QString::number( mParent->pktSpeedRx(), 'f', 1 )+"pkts/s" ); - mPktSpeedTx->setText( QString::number( mParent->pktSpeedTx(), 'f', 1 )+"pkts/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() ); + mNettqmask->setText( mParent->getNettqmask() ); mTimer->start( mParent->updateInterval() ); StatisticsBase::show(); diff --git a/src/src/statistics.h b/src/src/statistics.h index 40ba1a0..359d40e 100644 --- a/src/src/statistics.h +++ b/src/src/statistics.h @@ -21,16 +21,17 @@ #define STATISTICS_H #include "statisticsbase.h" -#include +#include class KNetStatsView; class Statistics : public StatisticsBase { Q_OBJECT + TQ_OBJECT public: - Statistics( KNetStatsView* parent = 0, const char *name = 0 ); + Statistics( KNetStatsView* tqparent = 0, const char *name = 0 ); /** * Formats a numberic byte representation @@ -40,12 +41,12 @@ public: * \param ksufix Sufix for kilobytes * \param msufix Sufix for megabytes */ - static inline QString byteFormat( double num, const char* ksufix = " KB", const char* msufix = " MB"); + static inline TQString byteFormat( double num, const char* ksufix = " KB", const char* msufix = " MB"); void show(); private: - QTimer* mTimer; - const QString& mInterface; + TQTimer* mTimer; + const TQString& mInterface; KNetStatsView* mParent; public slots: void accept(); @@ -54,13 +55,13 @@ private slots: void update(); }; -QString Statistics::byteFormat( double num, const char* ksufix, const char* msufix ) { +TQString Statistics::byteFormat( double num, const char* ksufix, const char* msufix ) { const double ONE_KB = 1024.0; const double ONE_MB = ONE_KB*ONE_KB; if ( num >= ONE_MB ) // MB - return QString::number( num/(ONE_MB), 'f', 1 ) + msufix; + return TQString::number( num/(ONE_MB), 'f', 1 ) + msufix; else // Kb - return QString::number( num/ONE_KB, 'f', 1 ) + ksufix; + return TQString::number( num/ONE_KB, 'f', 1 ) + ksufix; } #endif diff --git a/src/src/statisticsbase.ui b/src/src/statisticsbase.ui index d8f0662..f05db4d 100644 --- a/src/src/statisticsbase.ui +++ b/src/src/statisticsbase.ui @@ -1,6 +1,6 @@ StatisticsBase - + StatisticsBase @@ -30,15 +30,15 @@ Minimum - + - layout3 + tqlayout3 unnamed - + mChart @@ -67,14 +67,14 @@ Expanding - + 20 41 - + mMaxSpeed @@ -86,11 +86,11 @@ ? KB/s - + AlignVCenter|AlignRight - + textLabel2_3 @@ -102,13 +102,13 @@ 0 KB/s - + AlignVCenter|AlignRight - + tabWidget2 @@ -120,7 +120,7 @@ 0 - + tab @@ -131,7 +131,7 @@ unnamed - + mLabel5 @@ -139,7 +139,7 @@ Upload speed: - + mLabel1 @@ -147,7 +147,7 @@ Received: - + mLabel6 @@ -155,7 +155,7 @@ Download speed: - + mLabel2 @@ -173,22 +173,22 @@ Expanding - + 71 20 - + mPktSpeedRx - + AlignVCenter|AlignRight - + textLabel1 @@ -196,63 +196,63 @@ Bytes - + mPRx - + AlignVCenter|AlignRight - + mByteSpeedTx - + AlignVCenter|AlignRight - + mBTx - + AlignVCenter|AlignRight - + mPTx - + AlignVCenter|AlignRight - + mPktSpeedTx - + AlignVCenter|AlignRight - + mBRx - + AlignVCenter|AlignRight - + mByteSpeedRx - + AlignVCenter|AlignRight - + textLabel2 @@ -262,7 +262,7 @@ - + tab @@ -273,7 +273,7 @@ unnamed - + textLabel1_2 @@ -281,15 +281,15 @@ IP: - + textLabel2_2 - Netmask: + Nettqmask: - + textLabel3 @@ -297,7 +297,7 @@ MAC: - + textLabel7 @@ -315,7 +315,7 @@ Expanding - + 200 21 @@ -332,7 +332,7 @@ Expanding - + 51 80 @@ -357,7 +357,7 @@ - mNetmask + mNettqmask @@ -393,7 +393,7 @@ NoWrap - + mMTU @@ -403,16 +403,16 @@ - + AlignVCenter - + - layout2 + tqlayout2 @@ -428,7 +428,7 @@ Expanding - + 91 20 @@ -470,7 +470,7 @@ tabWidget2 mOk - + kactivelabel.h kactivelabel.h -- cgit v1.2.1