TQt4 port knetload

This enables compilation under both Qt3 and Qt4


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knetload@1238870 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent be4569a48c
commit e72017be3c

@ -15,11 +15,11 @@
#include <kcombobox.h>
#include <klocale.h>
#include <qlabel.h>
#include <qhbox.h>
#include <tqlabel.h>
#include <tqhbox.h>
#ifdef Q_OS_LINUX
#include <qdir.h>
#include <tqdir.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
@ -27,13 +27,13 @@
#define MAX_NET_DEV_LINE 512
DeviceDialog::DeviceDialog(const QString& defaultDevice, QWidget* parent) :
KDialogBase(parent, "device dialog", true,
DeviceDialog::DeviceDialog(const TQString& defaultDevice, TQWidget* tqparent) :
KDialogBase(tqparent, "device dialog", true,
i18n("Select Network Device"), Ok|Cancel, Ok),
device(defaultDevice) {
QHBox* page = makeHBoxMainWidget();
TQHBox* page = makeHBoxMainWidget();
new QLabel(i18n("Network device to monitor:"), page);
new TQLabel(i18n("Network device to monitor:"), page);
// Items in the combo box are not wrapped with i18n() since they're
// literal interface names.
@ -45,11 +45,11 @@ DeviceDialog::DeviceDialog(const QString& defaultDevice, QWidget* parent) :
deviceBox->insertItem("ippp0");
deviceBox->insertItem("ppp0");
#else
if ( QDir::root().exists("/sys/class/net") )
if ( TQDir::root().exists("/sys/class/net") )
{ // Exists /sys, 2.6 series kernel
QDir sys("/sys/class/net");
QStringList l = sys.entryList();
for(QStringList::iterator it = l.begin(); it != l.end(); it++)
TQDir sys("/sys/class/net");
TQStringList l = sys.entryList();
for(TQStringList::iterator it = l.begin(); it != l.end(); it++)
{
if ( (*it)[0] == '.' )
continue;
@ -91,15 +91,15 @@ DeviceDialog::DeviceDialog(const QString& defaultDevice, QWidget* parent) :
#endif
deviceBox->setCurrentText(defaultDevice);
connect(deviceBox, SIGNAL(textChanged(const QString&)),
this, SLOT(updateDevice(const QString&)));
connect(deviceBox, TQT_SIGNAL(textChanged(const TQString&)),
this, TQT_SLOT(updateDevice(const TQString&)));
}
const QString& DeviceDialog::getDevice() const {
const TQString& DeviceDialog::getDevice() const {
return device;
}
void DeviceDialog::updateDevice(const QString& text) {
void DeviceDialog::updateDevice(const TQString& text) {
device = text;
}

@ -22,29 +22,30 @@
*/
class DeviceDialog : public KDialogBase {
Q_OBJECT
TQ_OBJECT
public:
/**
* Constructor.
*/
DeviceDialog(const QString& defaultDevice, QWidget* parent);
DeviceDialog(const TQString& defaultDevice, TQWidget* tqparent);
/**
* Returns the device currently selected in the dialog.
* This is valid after the dialog has closed, though the string
* itself will be destroyed when this object is deleted.
*/
const QString& getDevice() const;
const TQString& getDevice() const;
private slots:
/**
* Updates the device variable to reflect the latest changes in
* the device combo box.
*/
virtual void updateDevice(const QString&);
virtual void updateDevice(const TQString&);
private:
QString device;
TQString device;
/**< The device currently selected in the device combo box. */
};

@ -14,39 +14,39 @@
#include "icontoggleaction.h"
IconToggleAction::IconToggleAction(
const QString& useTextUnchecked, const QString& useIconUnchecked,
const QString& useTextChecked, const QString& useIconChecked,
const KShortcut& cut, const QObject* receiver, const char* slot,
QObject* parent, const char* name) :
const TQString& useTextUnchecked, const TQString& useIconUnchecked,
const TQString& useTextChecked, const TQString& useIconChecked,
const KShortcut& cut, const TQObject* receiver, const char* slot,
TQObject* tqparent, const char* name) :
KToggleAction(useTextUnchecked, useIconUnchecked, cut, receiver,
slot, parent, name),
slot, tqparent, name),
textChecked(useTextChecked), textUnchecked(useTextUnchecked),
iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) {
}
IconToggleAction::IconToggleAction(const QString& useText,
const QString& useIconUnchecked, const QString& useIconChecked,
const KShortcut& cut, const QObject* receiver, const char* slot,
QObject* parent, const char* name) :
IconToggleAction::IconToggleAction(const TQString& useText,
const TQString& useIconUnchecked, const TQString& useIconChecked,
const KShortcut& cut, const TQObject* receiver, const char* slot,
TQObject* tqparent, const char* name) :
KToggleAction(useText, useIconUnchecked, cut, receiver,
slot, parent, name),
slot, tqparent, name),
textChecked(useText), textUnchecked(useText),
iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) {
}
IconToggleAction::IconToggleAction(
const QString& useTextUnchecked, const QString& useIconUnchecked,
const QString& useTextChecked, const QString& useIconChecked,
const KShortcut& cut, QObject* parent, const char* name) :
KToggleAction(useTextUnchecked, useIconUnchecked, cut, parent, name),
const TQString& useTextUnchecked, const TQString& useIconUnchecked,
const TQString& useTextChecked, const TQString& useIconChecked,
const KShortcut& cut, TQObject* tqparent, const char* name) :
KToggleAction(useTextUnchecked, useIconUnchecked, cut, tqparent, name),
textChecked(useTextChecked), textUnchecked(useTextUnchecked),
iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) {
}
IconToggleAction::IconToggleAction(const QString& useText,
const QString& useIconUnchecked, const QString& useIconChecked,
const KShortcut& cut, QObject* parent, const char* name) :
KToggleAction(useText, useIconUnchecked, cut, parent, name),
IconToggleAction::IconToggleAction(const TQString& useText,
const TQString& useIconUnchecked, const TQString& useIconChecked,
const KShortcut& cut, TQObject* tqparent, const char* name) :
KToggleAction(useText, useIconUnchecked, cut, tqparent, name),
textChecked(useText), textUnchecked(useText),
iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) {
}

@ -22,28 +22,29 @@
*/
class IconToggleAction : public KToggleAction {
Q_OBJECT
TQ_OBJECT
public:
/**
* Constructors.
*/
IconToggleAction(
const QString& useTextUnchecked, const QString& useIconUnchecked,
const QString& useTextChecked, const QString& useIconChecked,
const KShortcut& cut, const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0);
IconToggleAction(const QString& useText,
const QString& useIconUnchecked, const QString& useIconChecked,
const KShortcut& cut, const QObject* receiver, const char* slot,
QObject* parent, const char* name = 0);
const TQString& useTextUnchecked, const TQString& useIconUnchecked,
const TQString& useTextChecked, const TQString& useIconChecked,
const KShortcut& cut, const TQObject* receiver, const char* slot,
TQObject* tqparent, const char* name = 0);
IconToggleAction(const TQString& useText,
const TQString& useIconUnchecked, const TQString& useIconChecked,
const KShortcut& cut, const TQObject* receiver, const char* slot,
TQObject* tqparent, const char* name = 0);
IconToggleAction(
const QString& useTextUnchecked, const QString& useIconUnchecked,
const QString& useTextChecked, const QString& useIconChecked,
const KShortcut& cut = KShortcut(), QObject* parent = 0,
const TQString& useTextUnchecked, const TQString& useIconUnchecked,
const TQString& useTextChecked, const TQString& useIconChecked,
const KShortcut& cut = KShortcut(), TQObject* tqparent = 0,
const char* name = 0);
IconToggleAction(const QString& useText,
const QString& useIconUnchecked, const QString& useIconChecked,
const KShortcut& cut = KShortcut(), QObject* parent = 0,
IconToggleAction(const TQString& useText,
const TQString& useIconUnchecked, const TQString& useIconChecked,
const KShortcut& cut = KShortcut(), TQObject* tqparent = 0,
const char* name = 0);
/**
@ -52,9 +53,9 @@ class IconToggleAction : public KToggleAction {
virtual void setChecked(bool);
private:
QString textChecked, textUnchecked;
TQString textChecked, textUnchecked;
/**< The labels to use in the checked and unchecked states. */
QString iconChecked, iconUnchecked;
TQString iconChecked, iconUnchecked;
/**< The icons to use in the checked and unchecked states. */
};

@ -15,8 +15,8 @@
#include <klocale.h>
KNetDock::KNetDock(int whichDock, bool dirIn, StatPopup* parent,
KNetDock::KNetDock(int whichDock, bool dirIn, StatPopup* tqparent,
const char* name) :
StatDock(whichDock, dirIn ? i18n("IN").utf8() : i18n("OUT").utf8(), parent, name) {
StatDock(whichDock, dirIn ? i18n("IN").utf8() : i18n("OUT").utf8(), tqparent, name) {
}

@ -29,7 +29,7 @@ public:
* incoming traffic and \c false if this diagram represents outgoing
* traffic.
*/
KNetDock(int whichDock, bool dirIn, StatPopup *parent = 0,
KNetDock(int whichDock, bool dirIn, StatPopup *tqparent = 0,
const char* name = 0);
};

@ -23,13 +23,13 @@
#include <klocale.h>
#include <kmessagebox.h>
#include <kpopupmenu.h>
#include <qdir.h>
#include <tqdir.h>
#define DEFAULT_SCALE 128000
#define MAX_NET_DEV_LINE 512
KNetLoad::KNetLoad(QWidget *parent, const char *name) :
StatPopup(false, parent, name) {
KNetLoad::KNetLoad(TQWidget *tqparent, const char *name) :
StatPopup(false, tqparent, name) {
// Create the raw network data reader.
proc = new KNetProc();
@ -41,11 +41,11 @@ KNetLoad::KNetLoad(QWidget *parent, const char *name) :
stockDevice.push_back("ppp0"); stockDeviceIconOff.push_back("devppp0"); stockDeviceIconOn.push_back("devppp0on");
stockDevice.push_back("ippp0"); stockDeviceIconOff.push_back("devippp0"); stockDeviceIconOn.push_back("devippp0on");
#else
if ( QDir::root().exists("/sys/class/net") )
if ( TQDir::root().exists("/sys/class/net") )
{ // Exists /sys, 2.6 series kernel
QDir sys("/sys/class/net");
QStringList l = sys.entryList();
for(QStringList::iterator it = l.begin(); it != l.end(); it++)
TQDir sys("/sys/class/net");
TQStringList l = sys.entryList();
for(TQStringList::iterator it = l.begin(); it != l.end(); it++)
{
if ( (*it)[0] == '.' )
continue;
@ -54,13 +54,13 @@ KNetLoad::KNetLoad(QWidget *parent, const char *name) :
if ( *it == "lo" ) {
stockDeviceIconOn.push_back("devloon");
stockDeviceIconOff.push_back("devlo");
} else if ( (*it).find("eth") == 0 ) {
} else if ( (*it).tqfind("eth") == 0 ) {
stockDeviceIconOn.push_back("deveth0on");
stockDeviceIconOff.push_back("deveth0");
} else if ( (*it).find("ppp") == 0 ) {
} else if ( (*it).tqfind("ppp") == 0 ) {
stockDeviceIconOn.push_back("devppp0on");
stockDeviceIconOff.push_back("devppp0");
} else if ( (*it).find("ippp") == 0 ) {
} else if ( (*it).tqfind("ippp") == 0 ) {
stockDeviceIconOn.push_back("devippp0on");
stockDeviceIconOff.push_back("devippp0");
} else {
@ -139,7 +139,7 @@ KNetLoad::~KNetLoad() {
delete proc;
}
void KNetLoad::setDevice(const QString& newDevice) {
void KNetLoad::setDevice(const TQString& newDevice) {
proc->setDevice(newDevice);
clearHistory();
updateDeviceMenus();
@ -161,7 +161,7 @@ void KNetLoad::setDevice(int deviceIndex) {
// It's a custom device. Open a dialog.
DeviceDialog dlg(proc->getDevice(), firstDock());
if (dlg.exec()) {
QString newDevice = dlg.getDevice().stripWhiteSpace();
TQString newDevice = dlg.getDevice().stripWhiteSpace();
if (newDevice.isEmpty())
KMessageBox::error(firstDock(),
i18n("The device name cannot be empty."));
@ -224,12 +224,12 @@ void KNetLoad::setScaleOut(int scale) {
config->sync();
}
QString KNetLoad::dockName(int which) const {
TQString KNetLoad::dockName(int which) const {
return (which == 0 ? i18n("In") : i18n("Out"));
}
QColor KNetLoad::defaultDockColor(int which) const {
return (which == 0 ? QColor(0, 0, 255) : QColor(255, 0, 255));
TQColor KNetLoad::defaultDockColor(int which) const {
return (which == 0 ? TQColor(0, 0, 255) : TQColor(255, 0, 255));
}
void KNetLoad::setupCustomActions() {
@ -254,7 +254,7 @@ void KNetLoad::insertCustomItems(KPopupMenu* menu) {
stockDevice[i], i);
deviceMenu->insertItem(SmallIcon("devother"), i18n("Other..."));
updateDeviceMenu(deviceMenu);
connect(deviceMenu, SIGNAL(activated(int)), this, SLOT(setDevice(int)));
connect(deviceMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(setDevice(int)));
menu->insertItem(SmallIcon("devselect"), i18n("&Device"), deviceMenu);
// Scale menus. The menu item IDs are the scales themselves (in bits
@ -274,7 +274,7 @@ void KNetLoad::insertCustomItems(KPopupMenu* menu) {
scaleInMenu->insertItem(i18n("10MBit/s"), 10000000);
scaleInMenu->insertItem(i18n("Other..."));
updateScaleInMenu(scaleInMenu);
connect(scaleInMenu, SIGNAL(activated(int)), this, SLOT(setScaleIn(int)));
connect(scaleInMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(setScaleIn(int)));
menu->insertItem(SmallIcon("scalein"), i18n("&Scale (In)"), scaleInMenu);
KPopupMenu* scaleOutMenu = new KPopupMenu(menu);
@ -294,7 +294,7 @@ void KNetLoad::insertCustomItems(KPopupMenu* menu) {
scaleOutMenu->insertSeparator();
scaleOutMenu->insertItem(i18n("Same as for in"), 0);
updateScaleOutMenu(scaleOutMenu);
connect(scaleOutMenu, SIGNAL(activated(int)), this, SLOT(setScaleOut(int)));
connect(scaleOutMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(setScaleOut(int)));
menu->insertItem(SmallIcon("scaleout"), i18n("&Scale (Out)"), scaleOutMenu);
// The final separator.
@ -328,12 +328,12 @@ void KNetLoad::takeReadingInternal() {
fullReading = i18n(
"Current In: %1 KBit/s, Total In: %2 MB.\n"
"Current Out: %3 KBit/s, Total Out: %4 MB.")
.arg(KGlobal::locale()->formatNumber((int)((bitRateIn + 50) / 100) / 10.0)).arg(KGlobal::locale()->formatNumber(proc->totalMbIn()))
.arg(KGlobal::locale()->formatNumber((int)((bitRateOut + 50) / 100) / 10.0)).arg(KGlobal::locale()->formatNumber(proc->totalMbOut()));
.tqarg(KGlobal::locale()->formatNumber((int)((bitRateIn + 50) / 100) / 10.0)).tqarg(KGlobal::locale()->formatNumber(proc->totalMbIn()))
.tqarg(KGlobal::locale()->formatNumber((int)((bitRateOut + 50) / 100) / 10.0)).tqarg(KGlobal::locale()->formatNumber(proc->totalMbOut()));
}
void KNetLoad::updateDeviceMenu(KPopupMenu* menu) {
const QString& dev = proc->getDevice();
const TQString& dev = proc->getDevice();
// Update the checked/unchecked states of menu items.
bool found = false;
@ -369,7 +369,7 @@ void KNetLoad::updateDeviceMenu(KPopupMenu* menu) {
menu->setItemChecked(otherId, false);
} else {
menu->changeItem(otherId, SmallIcon("devotheron"),
QString(i18n("Other (%1)...")).arg(dev));
TQString(i18n("Other (%1)...")).tqarg(dev));
menu->setItemChecked(otherId, true);
}
}
@ -403,7 +403,7 @@ void KNetLoad::updateScaleInMenu(KPopupMenu* menu) {
if (found)
menu->changeItem(otherId, i18n("Other..."));
else {
QString text = i18n("Other (%1KBit/s)...").arg(int(((float) scaleIn) / 1000));
TQString text = i18n("Other (%1KBit/s)...").tqarg(int(((float) scaleIn) / 1000));
menu->changeItem(otherId, text);
}
@ -441,7 +441,7 @@ void KNetLoad::updateScaleOutMenu(KPopupMenu* menu) {
if (found)
menu->changeItem(otherId, i18n("Other..."));
else {
QString text = i18n("Other (%1KBit/s)...").arg(int(((float) scaleOut) / 1000));
TQString text = i18n("Other (%1KBit/s)...").tqarg(int(((float) scaleOut) / 1000));
menu->changeItem(otherId, text);
}

@ -16,7 +16,7 @@
#include "statpopup.h"
#include <qptrlist.h>
#include <tqptrlist.h>
class KAction;
class KNetProc;
@ -27,19 +27,20 @@ class KPopupMenu;
*/
class KNetLoad : public StatPopup {
Q_OBJECT
TQ_OBJECT
public:
/**
* Constructor and destructor.
*/
KNetLoad(QWidget *parent = 0, const char *name = 0);
KNetLoad(TQWidget *tqparent = 0, const char *name = 0);
~KNetLoad();
public slots:
/**
* Slots for menu items.
*/
void setDevice(const QString& newDevice);
void setDevice(const TQString& newDevice);
void setDevice(int deviceIndex);
void setScaleIn(int scale);
void setScaleOut(int scale);
@ -48,8 +49,8 @@ protected:
/**
* Overrides from StatPopup.
*/
virtual QString dockName(int which) const;
virtual QColor defaultDockColor(int which) const;
virtual TQString dockName(int which) const;
virtual TQColor defaultDockColor(int which) const;
virtual void setupCustomActions();
virtual void insertCustomItems(KPopupMenu* menu);
virtual void takeReadingInternal();
@ -84,13 +85,13 @@ private:
/**
* Lists of menus that must be kept up-to-date.
*/
QPtrList<KPopupMenu> deviceMenus;
QPtrList<KPopupMenu> scaleInMenus;
QPtrList<KPopupMenu> scaleOutMenus;
TQPtrList<KPopupMenu> deviceMenus;
TQPtrList<KPopupMenu> scaleInMenus;
TQPtrList<KPopupMenu> scaleOutMenus;
QStringList stockDevice;
QStringList stockDeviceIconOn;
QStringList stockDeviceIconOff;
TQStringList stockDevice;
TQStringList stockDeviceIconOn;
TQStringList stockDeviceIconOff;
};
#endif

@ -33,7 +33,7 @@
// Linux-specific includes.
#ifdef Q_OS_LINUX
#include <qdir.h>
#include <tqdir.h>
#endif
/**
@ -90,7 +90,7 @@ KNetProc::KNetProc() {
// ========== Linux-specific (begin) ==========
#ifdef Q_OS_LINUX
useSys = QDir::home().exists("/sys/class/net");
useSys = TQDir::home().exists("/sys/class/net");
#endif
// ========== Linux-specific (end) ==========
}
@ -106,7 +106,7 @@ KNetProc::~KNetProc() {
// ========== BSD-specific (end) ==========
}
void KNetProc::setDevice(const QString &interface) {
void KNetProc::setDevice(const TQString &interface) {
// Actually set the device.
device = interface;

@ -14,8 +14,8 @@
#ifndef __KNETPROC_H
#define __KNETPROC_H
#include <qglobal.h>
#include <qstring.h>
#include <tqglobal.h>
#include <tqstring.h>
/**
* A class used to read raw network throughput details from the system.
@ -46,12 +46,12 @@ public:
*
* An initial set of total traffic readings will be taken.
*/
void setDevice(const QString &interface);
void setDevice(const TQString &interface);
/**
* Returns the network device currently being monitored.
*/
QString getDevice() const;
TQString getDevice() const;
/**
* Takes a fresh set of throughput readings. The values returned by
@ -86,7 +86,7 @@ private:
/**
* Device and results of readings.
*/
QString device;
TQString device;
/**< The interface name of the device to monitor. */
float currIn, currOut;
/**< Total traffic in bytes from the last reading. */
@ -122,7 +122,7 @@ private:
// ========== Linux specific (end) ==========
};
inline QString KNetProc::getDevice() const {
inline TQString KNetProc::getDevice() const {
return device;
}

@ -16,35 +16,35 @@
#include <cstdlib>
#include <klineedit.h>
#include <klocale.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qvalidator.h>
#include <tqlabel.h>
#include <tqhbox.h>
#include <tqvalidator.h>
ScaleDialog::ScaleDialog(int defaultScale, const QString &title,
QWidget* parent) :
KDialogBase(parent, "scale dialog", true, title, Ok|Cancel, Ok),
ScaleDialog::ScaleDialog(int defaultScale, const TQString &title,
TQWidget* tqparent) :
KDialogBase(tqparent, "scale dialog", true, title, Ok|Cancel, Ok),
scale(defaultScale) {
QHBox* page = makeHBoxMainWidget();
TQHBox* page = makeHBoxMainWidget();
new QLabel(i18n("Scale in KBit/s:"), page);
new TQLabel(i18n("Scale in KBit/s:"), page);
QString scaleStr;
TQString scaleStr;
scaleStr.setNum(defaultScale);
KLineEdit* scaleBox = new KLineEdit(scaleStr, page);
QIntValidator* val = new QIntValidator(this);
TQIntValidator* val = new TQIntValidator(TQT_TQOBJECT(this));
val->setBottom(1);
scaleBox->setValidator(val);
connect(scaleBox, SIGNAL(textChanged(const QString&)),
this, SLOT(updateScale(const QString&)));
connect(scaleBox, TQT_SIGNAL(textChanged(const TQString&)),
this, TQT_SLOT(updateScale(const TQString&)));
}
int ScaleDialog::getScale() const {
return scale;
}
void ScaleDialog::updateScale(const QString& text) {
void ScaleDialog::updateScale(const TQString& text) {
scale = text.toInt();
}

@ -21,12 +21,13 @@
*/
class ScaleDialog : public KDialogBase {
Q_OBJECT
TQ_OBJECT
public:
/**
* Constructor.
*/
ScaleDialog(int defaultScale, const QString & title, QWidget* parent);
ScaleDialog(int defaultScale, const TQString & title, TQWidget* tqparent);
/**
* Returns the scale currently selected in the dialog.
@ -39,7 +40,7 @@ class ScaleDialog : public KDialogBase {
* Updates the scale variable to reflect the latest changes in
* the scale entry box.
*/
virtual void updateScale(const QString&);
virtual void updateScale(const TQString&);
private:
int scale;

@ -16,30 +16,30 @@
#include <cstdlib>
#include <kcombobox.h>
#include <klocale.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qvalidator.h>
#include <tqlabel.h>
#include <tqhbox.h>
#include <tqvalidator.h>
static int stockSpeed[] = {
100, 150, 200, 250, 300, 400, 600, 800, 1000, 1200, 1500, 2000, 2500,
3000, 4000, 5000, 0
};
SpeedDialog::SpeedDialog(int defaultSpeed, QWidget* parent) :
KDialogBase(parent, "speed dialog", true,
SpeedDialog::SpeedDialog(int defaultSpeed, TQWidget* tqparent) :
KDialogBase(tqparent, "speed dialog", true,
i18n("Select Speed"), Ok|Cancel, Ok),
speed(defaultSpeed) {
QHBox* page = makeHBoxMainWidget();
TQHBox* page = makeHBoxMainWidget();
new QLabel(i18n("Update interval in milliseconds:"), page);
new TQLabel(i18n("Update interval in milliseconds:"), page);
KComboBox* speedBox = new KComboBox(true, page);
QIntValidator* val = new QIntValidator(this);
TQIntValidator* val = new TQIntValidator(TQT_TQOBJECT(this));
val->setBottom(1);
speedBox->setValidator(val);
QString speedStr;
TQString speedStr;
for (int i = 0; stockSpeed[i]; i++) {
speedStr.setNum(stockSpeed[i]);
speedBox->insertItem(speedStr);
@ -48,15 +48,15 @@ SpeedDialog::SpeedDialog(int defaultSpeed, QWidget* parent) :
speedStr.setNum(defaultSpeed);
speedBox->setCurrentText(speedStr);
connect(speedBox, SIGNAL(textChanged(const QString&)),
this, SLOT(updateSpeed(const QString&)));
connect(speedBox, TQT_SIGNAL(textChanged(const TQString&)),
this, TQT_SLOT(updateSpeed(const TQString&)));
}
int SpeedDialog::getSpeed() const {
return speed;
}
void SpeedDialog::updateSpeed(const QString& text) {
void SpeedDialog::updateSpeed(const TQString& text) {
speed = text.toInt();
}

@ -21,12 +21,13 @@
*/
class SpeedDialog : public KDialogBase {
Q_OBJECT
TQ_OBJECT
public:
/**
* Constructor.
*/
SpeedDialog(int defaultSpeed, QWidget* parent);
SpeedDialog(int defaultSpeed, TQWidget* tqparent);
/**
* Returns the speed currently selected in the dialog.
@ -39,7 +40,7 @@ class SpeedDialog : public KDialogBase {
* Updates the speed variable to reflect the latest changes in
* the speed combo box.
*/
virtual void updateSpeed(const QString&);
virtual void updateSpeed(const TQString&);
private:
int speed;

@ -13,19 +13,19 @@
#include "statdock.h"
#include "statpopup.h"
#include <qpainter.h>
#include <tqpainter.h>
const int StatDock::fillLines = 0;
const int StatDock::fillBars = 1;
const int StatDock::fillShaded = 2;
const QColor StatDock::colorGrid(120, 120, 120);
const QColor StatDock::colorGridInactive(60, 60, 60);
const QColor StatDock::colorLabel(255, 255, 255);
const QColor StatDock::colorLabelInactive(125, 125, 125);
const QColor StatDock::colorLower(255, 255, 255);
const QColor StatDock::colorLowerInactive(125, 125, 125);
const QColor StatDock::colorBlack(0, 0, 0);
const TQColor StatDock::colorGrid(120, 120, 120);
const TQColor StatDock::colorGridInactive(60, 60, 60);
const TQColor StatDock::colorLabel(255, 255, 255);
const TQColor StatDock::colorLabelInactive(125, 125, 125);
const TQColor StatDock::colorLower(255, 255, 255);
const TQColor StatDock::colorLowerInactive(125, 125, 125);
const TQColor StatDock::colorBlack(0, 0, 0);
//#define DOCK_SIZE 24
#define DOCK_SIZE width()
@ -33,9 +33,9 @@ const QColor StatDock::colorBlack(0, 0, 0);
#define SOFT_STEP 3
StatDock::StatDock(int whichDock, const char* useLabel,
StatPopup *parent, const char *name) :
KSystemTray(parent,name),
label(QString::fromUtf8(useLabel)),
StatPopup *tqparent, const char *name) :
KSystemTray(tqparent,name),
label(TQString::fromUtf8(useLabel)),
bufUpper(0),
bufLower(0),
pos(0) {
@ -48,7 +48,7 @@ StatDock::StatDock(int whichDock, const char* useLabel,
bufUpper[i] = bufLower[i] = 0;
// Initialise the display.
parent->initDock(this, contextMenu(), whichDock);
tqparent->initDock(this, contextMenu(), whichDock);
setBackgroundColor(colorBlack);
resize(DOCK_SIZE, DOCK_SIZE);
show();
@ -59,7 +59,7 @@ StatDock::~StatDock() {
delete[] bufLower;
}
void StatDock::resizeEvent ( QResizeEvent * )
void StatDock::resizeEvent ( TQResizeEvent * )
{
// Honor Free Desktop specifications that allow for arbitrary system tray icon sizes
int* bufUpperOld;
@ -78,54 +78,54 @@ void StatDock::resizeEvent ( QResizeEvent * )
delete[] bufUpperOld;
delete[] bufLowerOld;
repaint();
tqrepaint();
}
void StatDock::setGrid(bool set) {
grid = set;
repaint();
tqrepaint();
}
void StatDock::setActive(bool set) {
active = set;
repaint();
tqrepaint();
}
void StatDock::setSoft(bool set) {
soft = set;
repaint();
tqrepaint();
}
void StatDock::setSplit(bool set) {
split = set;
repaint();
tqrepaint();
}
void StatDock::setLabelled(bool set) {
labelled = set;
repaint();
tqrepaint();
}
void StatDock::setLabel(const char* set) {
label = set;
repaint();
tqrepaint();
}
void StatDock::setFill(int set) {
fill = set;
repaint();
tqrepaint();
}
void StatDock::setColor(const QColor& set) {
void StatDock::setColor(const TQColor& set) {
colorUpper = set;
colorUpperInactive = colorUpper.dark();
repaint();
tqrepaint();
}
void StatDock::clearHistory(void) {
for (i = 0; i < DOCK_SIZE; i++)
bufUpper[i] = bufLower[i] = 0;
repaint();
tqrepaint();
}
void StatDock::addPercentReading(int upper, int lower) {
@ -164,11 +164,11 @@ void StatDock::addPercentReading(int upper, int lower) {
}
// Refresh the diagram.
repaint();
tqrepaint();
}
void StatDock::paintEvent(QPaintEvent*) {
QPainter p(this);
void StatDock::paintEvent(TQPaintEvent*) {
TQPainter p(this);
// Start by drawing the grid.
if(grid) {
@ -261,7 +261,7 @@ void StatDock::paintEvent(QPaintEvent*) {
// Finally label the diagrams.
if(labelled) {
p.setFont(QFont( "Helvetica", ((8*DOCK_SIZE)/24) ));
p.setFont(TQFont( "Helvetica", ((8*DOCK_SIZE)/24) ));
p.setPen((active) ? colorLabel : colorLabelInactive);
p.drawText(rect(), AlignLeft | AlignTop, label);
}

@ -14,7 +14,7 @@
#ifndef __STATDOCK_H
#define __STATDOCK_H
#include <qcolor.h>
#include <tqcolor.h>
#include <ksystemtray.h>
class StatPopup;
@ -29,11 +29,12 @@ class StatPopup;
* with the upper readings shown above the lower readings. When diagram
* splitting is switched off, only the upper readings will be displayed.
*
* The parent window of a StatDock must be a StatPopup, which provides
* The tqparent window of a StatDock must be a StatPopup, which provides
* all of the actions in this window's context menu.
*/
class StatDock : public KSystemTray {
Q_OBJECT
TQ_OBJECT
public:
/**
@ -46,26 +47,26 @@ public:
/**
* Colour constants.
*/
static const QColor colorGrid;
static const QColor colorGridInactive;
static const QColor colorLabel;
static const QColor colorLabelInactive;
static const QColor colorLower;
static const QColor colorLowerInactive;
static const QColor colorBlack;
static const TQColor colorGrid;
static const TQColor colorGridInactive;
static const TQColor colorLabel;
static const TQColor colorLabelInactive;
static const TQColor colorLower;
static const TQColor colorLowerInactive;
static const TQColor colorBlack;
public:
/**
* Constructor and destructor.
*
* Note that the constructor will call parent->initDock().
* Note that the constructor will call tqparent->initDock().
*
* Parameter whichDock must be 0 or 1 to specify whether this dock
* will become dock[0] or dock[1] in the given StatPopup parent.
* will become dock[0] or dock[1] in the given StatPopup tqparent.
* Parameter useLabel should contain the label that will be drawn on
* the diagram if labelling is enabled.
*/
StatDock(int whichDock, const char* useLabel, StatPopup *parent,
StatDock(int whichDock, const char* useLabel, StatPopup *tqparent,
const char *name = 0);
~StatDock();
@ -79,7 +80,7 @@ public:
void setLabelled(bool);
void setLabel(const char*);
void setFill(int);
void setColor(const QColor&);
void setColor(const TQColor&);
public slots:
/**
@ -108,7 +109,7 @@ private:
/**
* Repaint this system tray window with a fresh diagram.
*/
void paintEvent(QPaintEvent*);
void paintEvent(TQPaintEvent*);
private:
/**
@ -125,13 +126,13 @@ private:
/**< Are we displaying both upper and lower readings? */
bool labelled;
/**< Should this diagram be labelled? */
QString label;
TQString label;
/**< The specific label to draw on this diagram. */
int fill;
/**< Specifies which of the predefined fill styles to use. */
QColor colorUpper;
TQColor colorUpper;
/**< Colour for displaying the upper readings. */
QColor colorUpperInactive;
TQColor colorUpperInactive;
/**< Colour for displaying the upper readings whilst the diagram
is inactive. */
@ -157,7 +158,7 @@ private:
/**< Temporary variables used during computations. */
protected:
void resizeEvent ( QResizeEvent * );
void resizeEvent ( TQResizeEvent * );
};
#endif

@ -16,8 +16,8 @@
#include "statdock.h"
#include "statpopup.h"
#include <qpainter.h>
#include <qtimer.h>
#include <tqpainter.h>
#include <tqtimer.h>
#include <kaction.h>
#include <kcolordialog.h>
#include <kconfig.h>
@ -33,11 +33,11 @@
#define TEXT_EXPANSION_HORIZONTAL 10
#define TEXT_EXPANSION_VERTICAL 3
const QColor StatPopup::colorBorder(0, 0, 0);
const TQColor StatPopup::colorBorder(0, 0, 0);
StatPopup::StatPopup(bool useSupportSplit, QWidget *parent, const char *name) :
QWidget(parent, name, Qt::WStyle_Customize | Qt::WStyle_NoBorder |
Qt::WStyle_StaysOnTop | Qt::WDestructiveClose | Qt::WType_TopLevel),
StatPopup::StatPopup(bool useSupportSplit, TQWidget *tqparent, const char *name) :
TQWidget(tqparent, name, TQt::WStyle_Customize | TQt::WStyle_NoBorder |
TQt::WStyle_StaysOnTop | TQt::WDestructiveClose | TQt::WType_TopLevel),
supportSplit(useSupportSplit) {
// Window management.
KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
@ -60,8 +60,8 @@ StatPopup::StatPopup(bool useSupportSplit, QWidget *parent, const char *name) :
coll = new KActionCollection(this);
// Set up a timer for our periodic updates.
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(takeReading()));
timer = new TQTimer(this);
connect(timer, TQT_SIGNAL(timeout()), TQT_TQOBJECT(this), TQT_SLOT(takeReading()));
}
StatPopup::~StatPopup() {
@ -291,9 +291,9 @@ void StatPopup::setGrid(bool set) {
void StatPopup::selectColor0() {
if (dock[0]) {
QColor ans;
TQColor ans;
if (KColorDialog::getColor(ans, color[0], firstDock()) ==
QDialog::Accepted) {
TQDialog::Accepted) {
color[0] = ans;
dock[0]->setColor(ans);
@ -306,9 +306,9 @@ void StatPopup::selectColor0() {
void StatPopup::selectColor1() {
if (dock[1]) {
QColor ans;
TQColor ans;
if (KColorDialog::getColor(ans, color[1], firstDock()) ==
QDialog::Accepted) {
TQDialog::Accepted) {
color[1] = ans;
dock[1]->setColor(ans);
@ -344,30 +344,30 @@ void StatPopup::setupActions() {
bVal = config->readBoolEntry("Active", true);
actActive = new KToggleAction(i18n("&Active"), 0, coll, "active");
actActive->setChecked(bVal);
connect(actActive, SIGNAL(toggled(bool)), this, SLOT(setActive(bool)));
connect(actActive, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setActive(bool)));
actClearHistory = new KAction(i18n("&Clear"), "editdelete", 0,
this, SLOT(clearHistory()), coll, "clear");
TQT_TQOBJECT(this), TQT_SLOT(clearHistory()), coll, "clear");
speed = config->readNumEntry("Speed", DEFAULT_SPEED);
actSpeed = new KAction(i18n("&Speed..."), "speedarrow", 0,
this, SLOT(selectSpeed()), coll, "speed");
TQT_TQOBJECT(this), TQT_SLOT(selectSpeed()), coll, "speed");
if (supportSplit) {
bVal = config->readBoolEntry("Split", true);
actSplit = new IconToggleAction(i18n("Sp&lit Graph"), "split",
i18n("Graph Sp&litting Enabled"), "spliton", 0, coll, "split");
actSplit->setChecked(bVal);
connect(actSplit, SIGNAL(toggled(bool)), this, SLOT(setSplit(bool)));
connect(actSplit, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setSplit(bool)));
}
iVal = config->readNumEntry("StyleID", StatDock::fillShaded);
actFillLines = new IconToggleAction(i18n("&Lines"), "lines", "lineson", 0,
this, SLOT(setFillLines()), coll, "filllines");
TQT_TQOBJECT(this), TQT_SLOT(setFillLines()), coll, "filllines");
actFillBars = new IconToggleAction(i18n("&Bars"), "bars", "barson", 0,
this, SLOT(setFillBars()), coll, "fillbars");
TQT_TQOBJECT(this), TQT_SLOT(setFillBars()), coll, "fillbars");
actFillShaded = new IconToggleAction(i18n("&Shaded"), "shaded", "shadedon",
0, this, SLOT(setFillShaded()), coll, "fillshaded");
0, TQT_TQOBJECT(this), TQT_SLOT(setFillShaded()), coll, "fillshaded");
if (iVal == StatDock::fillLines)
setFillLines();
else if (iVal == StatDock::fillBars)
@ -379,37 +379,37 @@ void StatPopup::setupActions() {
actSoft = new IconToggleAction(i18n("So&ft Curves"), "soft",
i18n("So&ft Curves Enabled"), "softon", 0, coll, "soft");
actSoft->setChecked(bVal);
connect(actSoft, SIGNAL(toggled(bool)), this, SLOT(setSoft(bool)));
connect(actSoft, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setSoft(bool)));
bVal = config->readBoolEntry("Labelled", true);
actLabelled= new IconToggleAction(i18n("Show &Labels"), "labels",
i18n("&Labels Enabled"), "labelson", 0, coll, "labelled");
actLabelled->setChecked(bVal);
connect(actLabelled, SIGNAL(toggled(bool)), this, SLOT(setLabelled(bool)));
connect(actLabelled, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setLabelled(bool)));
bVal = config->readBoolEntry("Grid", true);
actGrid = new IconToggleAction(i18n("Show &Grid"), "grid",
i18n("&Grid Enabled"), "gridon", 0, coll, "grid");
actGrid->setChecked(bVal);
connect(actGrid, SIGNAL(toggled(bool)), this, SLOT(setGrid(bool)));
connect(actGrid, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setGrid(bool)));
color[0] = defaultDockColor(0);
color[0] = config->readColorEntry("Color0", color);
actColor0 = new KAction(QString(i18n("Color (%1)...")).arg(dockName(0)),
"color0", 0, this, SLOT(selectColor0()), coll, "color0");
actColor0 = new KAction(TQString(i18n("Color (%1)...")).tqarg(dockName(0)),
"color0", 0, TQT_TQOBJECT(this), TQT_SLOT(selectColor0()), coll, "color0");
actColor0->setEnabled(false);
color[1] = defaultDockColor(1);
color[1] = config->readColorEntry("Color1", color + 1);
actColor1 = new KAction(QString(i18n("Color (%1)...")).arg(dockName(1)),
"color1", 0, this, SLOT(selectColor1()), coll, "color1");
actColor1 = new KAction(TQString(i18n("Color (%1)...")).tqarg(dockName(1)),
"color1", 0, TQT_TQOBJECT(this), TQT_SLOT(selectColor1()), coll, "color1");
actColor1->setEnabled(false);
setupCustomActions();
}
void StatPopup::paintEvent(QPaintEvent*) {
QPainter p(this);
void StatPopup::paintEvent(TQPaintEvent*) {
TQPainter p(this);
// Draw the border.
p.setPen(colorBorder);
@ -424,12 +424,12 @@ void StatPopup::paintEvent(QPaintEvent*) {
// Draw the text.
p.setFont(font());
p.setPen(colorGroup().foreground());
p.setPen(tqcolorGroup().foreground());
p.drawText(rect(), AlignHCenter | AlignVCenter, fullReading);
}
void StatPopup::mousePressEvent(QMouseEvent* e) {
if(e->button() == RightButton) {
void StatPopup::mousePressEvent(TQMouseEvent* e) {
if(e->button() == Qt::RightButton) {
// Hide the pop-up.
hide();
} else {
@ -437,45 +437,45 @@ void StatPopup::mousePressEvent(QMouseEvent* e) {
isDragged = true;
relX = e->x();
relY = e->y();
repaint();
tqrepaint();
}
}
void StatPopup::mouseMoveEvent(QMouseEvent* e) {
void StatPopup::mouseMoveEvent(TQMouseEvent* e) {
// In the middle of a drag operation.
move(e->globalX() - relX, e->globalY() - relY);
}
void StatPopup::mouseReleaseEvent(QMouseEvent* e) {
void StatPopup::mouseReleaseEvent(TQMouseEvent* e) {
// The end of a drag operation.
move(e->globalX() - relX, e->globalY() - relY);
isDragged = false;
repaint();
tqrepaint();
}
void StatPopup::closeEvent(QCloseEvent* e) {
void StatPopup::closeEvent(TQCloseEvent* e) {
// We're about to close. Save the current state for the last time.
savePopupState();
closing = true;
QWidget::closeEvent(e);
TQWidget::closeEvent(e);
}
void StatPopup::hideEvent(QHideEvent* e) {
void StatPopup::hideEvent(TQHideEvent* e) {
// We're about to hide. Save the current state if we're not
// closing altogether.
if (! closing)
savePopupState();
QWidget::hideEvent(e);
TQWidget::hideEvent(e);
}
void StatPopup::showEvent(QShowEvent* e) {
void StatPopup::showEvent(TQShowEvent* e) {
// Make sure we're up-to-date and properly resized.
if (isActive())
takeReading();
else
resizeToText();
QWidget::showEvent(e);
TQWidget::showEvent(e);
}
void StatPopup::takeReading() {
@ -492,17 +492,17 @@ void StatPopup::takeReading() {
if (resizeRequested)
resizeToText();
repaint();
tqrepaint();
}
}
void StatPopup::resizeToText() {
resizeRequested = false;
QSize size = fontMetrics().size(0, fullReading);
TQSize size = fontMetrics().size(0, fullReading);
resize(size.width() + 2 * TEXT_EXPANSION_HORIZONTAL,
size.height() + 2 * TEXT_EXPANSION_VERTICAL);
repaint();
tqrepaint();
}

@ -14,7 +14,7 @@
#ifndef __STATPOPUP_H
#define __STATPOPUP_H
#include <qwidget.h>
#include <tqwidget.h>
class KAction;
class KActionCollection;
@ -23,7 +23,7 @@ class KPopupMenu;
class KRadioAction;
class KSelectAction;
class KToggleAction;
class QTimer;
class TQTimer;
class StatDock;
/**
@ -47,14 +47,15 @@ class StatDock;
* require either subclass initialisation or an existing system tray
* window.
*/
class StatPopup : public QWidget {
class StatPopup : public TQWidget {
Q_OBJECT
TQ_OBJECT
public:
/**
* Colour constants.
*/
static const QColor colorBorder;
static const TQColor colorBorder;
public:
/**
@ -64,7 +65,7 @@ public:
* any configuration information. See the general class notes also
* for a list of other routines this constructor will not call.
*/
StatPopup(bool useSupportSplit, QWidget *parent = 0, const char *name = 0);
StatPopup(bool useSupportSplit, TQWidget *tqparent = 0, const char *name = 0);
~StatPopup();
/**
@ -141,8 +142,8 @@ protected:
* The argument given will be either 0 or 1, referring to window
* dock[0] or dock[1] respectively.
*/
virtual QString dockName(int which) const = 0;
virtual QColor defaultDockColor(int which) const = 0;
virtual TQString dockName(int which) const = 0;
virtual TQColor defaultDockColor(int which) const = 0;
/**
* Take a fresh reading. Subclasses must override this routine.
@ -208,21 +209,21 @@ protected:
/**
* Custom painting routine.
*/
void paintEvent(QPaintEvent *);
void paintEvent(TQPaintEvent *);
/**
* Overrides for dragging support.
*/
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void mousePressEvent(TQMouseEvent *);
void mouseReleaseEvent(TQMouseEvent *);
void mouseMoveEvent(TQMouseEvent *);
/**
* Overrides for saving the popup state.
*/
void closeEvent(QCloseEvent *);
void hideEvent(QHideEvent *);
void showEvent(QShowEvent *);
void closeEvent(TQCloseEvent *);
void hideEvent(TQHideEvent *);
void showEvent(TQShowEvent *);
protected slots:
/**
@ -251,7 +252,7 @@ protected:
int lower[2];
/**< The lower readings taken during the last reading,
one for each system tray window. */
QString fullReading;
TQString fullReading;
/**< A full string describing the last reading taken,
to be displayed in this pop-up. */
@ -267,7 +268,7 @@ private:
/**
* Update support.
*/
QTimer* timer;
TQTimer* timer;
/**< The timer handling periodic updates. */
int speed;
/**< The frequency of updates in milliseconds. */
@ -275,7 +276,7 @@ private:
/**
* Diagram support.
*/
QColor color[2];
TQColor color[2];
/**< The colours used in the two system tray diagrams. */
int fillStyle;
/**< The fill style used in the system tray diagrams. */

Loading…
Cancel
Save