Commit 97fe8120 authored by Hans Petter Bieker's avatar Hans Petter Bieker
Browse files

* QString::sprintf -> QString::arg

* removed some .data()s.
* removed some warnings.

I hope I didn't break anything..

svn path=/trunk/kdeutils/ktop/; revision=20953
parent e3ae92e9
......@@ -48,14 +48,14 @@ MainMenu::MainMenu(QWidget* parent, const char* name) :
// 'Help' submenu
QString about;
about.sprintf(i18n("KDE Task Manager (KTop) Version %s\n\n"
about = i18n("KDE Task Manager (KTop) Version %1\n\n"
"Copyright:\n"
"1996 : A. Sanda <alex@darkstar.ping.at>\n"
"1997 : Ralf Mueller <ralf@bj-ig.de>\n"
"1997-98 : Bernd Johannes Wuebben <wuebben@kde.org>\n"
"1998 : Nicolas Leclercq <nicknet@planete.net>\n"
"1999 : Chris Schlaeger <cs@kde.org>\n"),
KTOP_VERSION);
"1999 : Chris Schlaeger <cs@kde.org>\n")
.arg(KTOP_VERSION);
help = Kapp->getHelpMenu(true, about);
// 'Refresh Rate' submenu
......
......@@ -107,7 +107,7 @@ OSProcess::OSProcess(int pid_)
error = false;
QString pidStr;
pidStr.sprintf("%d", pid_);
pidStr.setNum(pid_);
if (!read((const void *)pidStr))
return;
......@@ -121,7 +121,7 @@ OSProcess::read(const void* info)
FILE* fd;
QString buf;
buf.sprintf("/proc/%s/status", (const char*) info);
buf = QString("/proc/%1/status").arg(info);
if((fd = fopen(buf, "r")) == 0)
{
error = true;
......@@ -131,9 +131,9 @@ OSProcess::read(const void* info)
* the process probably has died during the calling of this function.
*/
if (kill(pid, 0) == 0)
errMessage.sprintf(i18n("Cannot open %s!\n"), buf.data());
errMessage = i18n("Cannot open %1!\n").arg(buf);
else
errMessage.sprintf(i18n("The Process has been terminated!\n"));
errMessage = i18n("The Process has been terminated!\n");
return (false);
}
......@@ -161,11 +161,11 @@ OSProcess::read(const void* info)
fclose(fd);
buf.sprintf("/proc/%s/stat", (const char *)info);
buf = QString("/proc/%1/stat").arg(info);
if ((fd = fopen(buf, "r")) == 0)
{
error = true;
errMessage.sprintf(i18n("Cannot open %s!\n"), buf.data());
errMessage = i18n("Cannot open %1!\n").arg(buf);
return (false);
}
......@@ -178,11 +178,11 @@ OSProcess::read(const void* info)
fclose(fd);
buf.sprintf("/proc/%s/cmdline", (const char *)info);
buf = QString("/proc/%1/cmdline").arg(info);
if ((fd = fopen(buf, "r")) == 0)
{
error = true;
errMessage.sprintf(i18n("Cannot open %s!\n"), buf.data());
errMessage = i18n("Cannot open %1!\n").arg(buf);
return (false);
}
cbuf[0] = '\0';
......@@ -372,8 +372,8 @@ OSProcess::setNiceLevel(int newNiceLevel)
if (setpriority(PRIO_PROCESS, pid, newNiceLevel) == -1)
{
error = true;
errMessage.sprintf(i18n("Could not set new nice level for process %d"),
pid);
errMessage = i18n("Could not set new nice level for process %1")
.arg(pid);
return (false);
}
......@@ -386,8 +386,8 @@ OSProcess::sendSignal(int sig)
if (kill(pid, sig))
{
error = true;
errMessage.sprintf(i18n("Cound not send signal %d to process %d"),
sig, pid);
errMessage = i18n("Cound not send signal %1 to process %2")
.arg(sig).arg(pid);
return (false);
}
......
......@@ -232,7 +232,7 @@ OSStatus::getCpuCount(void)
QString cpuName;
for (cpuCount = 1; ; cpuCount++)
{
cpuName.sprintf("cpu%d", cpuCount);
cpuName = QString("cpu%1").arg(cpuCount);
if (!readCpuInfo(cpuName, &dum, &dum, &dum, &dum))
{
/*
......@@ -267,7 +267,7 @@ OSStatus::getCpuXLoad(int cpu, int& user, int& sys, int& nice, int& idle)
int currUserTicks, currSysTicks, currNiceTicks, currIdleTicks;
QString cpuName;
cpuName.sprintf("cpu%d", cpu);
cpuName = QString("cpu%1").arg(cpu);
if (!readCpuInfo(cpuName, &currUserTicks, &currSysTicks,
&currNiceTicks, &currIdleTicks))
......@@ -373,11 +373,11 @@ OSStatus::readCpuInfo(const char* cpu, int* u, int* s, int* n, int* i)
if (fscanf(stat, "%32s %d %d %d %d", tag, u, n, s, i) != 5)
{
error = true;
errMessage.sprintf(i18n("Cannot read info for %s from file "
errMessage = i18n("Cannot read info for %1 from file "
"\'/proc/stat\'!\n"
"The kernel needs to be compiled with "
"support\n"
"for /proc filesystem enabled!"), cpu);
"for /proc filesystem enabled!").arg(cpu);
return (false);
}
} while (strcmp(tag, cpu));
......
......@@ -105,9 +105,9 @@ PerfMonPage::PerfMonPage(QWidget* parent = 0, const char* name = 0)
for (int c = 0; c < noCpus; c++)
{
QString name;
name.sprintf("cpu%d_meter", c);
name = QString("cpu%1_meter").arg(c);
QString label;
label.sprintf(i18n("CPU%d Load History"), c);
label = i18n("CPU%1 Load History").arg(c);
FancyPlotter* p = new FancyPlotter(this, name, label, 0, 100);
p->setLowPass(TRUE);
......
......@@ -603,13 +603,13 @@ ProcessList::addProcess(OSProcess* p, ProcessLVI* pli)
QString s;
// pid
pli->setText(col++, s.setNum(p->getPid()).data());
pli->setText(col++, s.setNum(p->getPid()));
TABCOLUMN* tc = &TabCol[2];
// user name
if (tc->visible && tc->supported)
pli->setText(col++, p->getUserName().data());
pli->setText(col++, p->getUserName());
tc++;
// CPU load
......
......@@ -83,7 +83,7 @@ ProcessMenu::killProcess(int pid, int sig)
if (!ps.ok())
{
QString msg;
msg.sprintf(i18n("The process %d is no longer persistent."), pid);
msg = i18n("The process %1 is no longer persistent.").arg(pid);
QMessageBox::warning(this, i18n("Task Manager"), msg, i18n("OK"),
QString::null);
return;
......@@ -121,9 +121,12 @@ ProcessMenu::killProcess(int pid, int sig)
// Make sure user really want to send the signal to that process.
QString msg;
msg.sprintf(i18n("Send signal %s to process %d?\n"
"(Process name: %s Owner: %s)\n"), sigName.data(),
ps.getPid(), ps.getName(), ps.getUserName().data());
msg = i18n("Send signal %1 to process %2?\n"
"(Process name: %3 Owner: %4)\n")
.arg(sigName)
.arg(ps.getPid())
.arg(ps.getName())
.arg(ps.getUserName());
switch(QMessageBox::warning(this, "Task Manager", msg,
i18n("Continue"), i18n("Abort"),\
QString::null, 1))
......@@ -149,7 +152,7 @@ ProcessMenu::reniceProcess(int pid)
if (!ps.ok())
{
QString msg;
msg.sprintf(i18n("The process %d is no longer persistent."), pid);
msg = i18n("The process %1 is no longer persistent.").arg(pid);
QMessageBox::warning(this, i18n("Task Manager"), msg, i18n("OK"),
QString::null);
return;
......
......@@ -7,9 +7,6 @@ If you want to join this development please contact me first. Please
do *NOT* check in unsolicited code as I might am rearranging the code
and merging becomes a real headache so your code will be lost.
DO NOT DO ANY QT2.0 PORTING OF THE CODE!!! This will start after 1.1.1
is out!
This does not mean that I don't appreciate your help. Especially
porting to other platforms is difficult for me. I have introduced a
nice interface so porting is fairly easy. See OSStatus.cpp if you are
......
......@@ -37,11 +37,11 @@ ReniceDlg::ReniceDlg(QWidget* parent, const char* name, int currentPPrio,
vLay = new QVBoxLayout(this, 20, -1, "ReniceLayout");
QString msg;
msg.sprintf(i18n("You are about the change the scheduling priority of\n"
"process %d. Be aware that only the Superuser (root)\n"
msg = i18n("You are about the change the scheduling priority of\n"
"process %1. Be aware that only the Superuser (root)\n"
"can decrease the nice level of a process. The smaller\n"
"the number is the higher is the priority.\n\n"
"Please enter the desired nice level:"), pid);
"Please enter the desired nice level:").arg(pid);
message = new QLabel(msg, this);
message->setMinimumSize(message->sizeHint());
vLay->addWidget(message);
......
......@@ -132,17 +132,17 @@ TopLevel::timerEvent(QTimerEvent*)
{
QString s;
s.sprintf(i18n("%d Processes"), osStatus.getNoProcesses());
s = i18n("%1 Processes").arg(osStatus.getNoProcesses());
statusbar->changeItem(s, 0);
int dum, mUsed, mFree;
osStatus.getMemoryInfo(dum, mFree, mUsed, dum, dum);
s.sprintf(i18n("Memory: %d kB used, %d kB free"), mUsed, mFree);
s = i18n("Memory: %1 kB used, %2 kB free").arg(mUsed).arg(mFree);
statusbar->changeItem(s, 1);
int sTotal, sFree;
osStatus.getSwapInfo(sTotal, sFree);
s.sprintf(i18n("Swap: %d kB used, %d kB free"), sTotal - sFree, sFree);
s = i18n("Swap: %1 kB used, %2 kB free").arg(sTotal - sFree).arg(sFree);
statusbar->changeItem(s, 2);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment