Commit 15b5ecd1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove 'remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY'

parent a36cfa17
cmake_minimum_required(VERSION 3.0)
project(libksysguard)
set(PROJECT_VERSION "5.12.80")
set(PROJECT_VERSION_MAJOR 5)
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
include(FeatureSummary)
include(WriteBasicConfigVersionFile)
find_package(ECM 1.2.0 REQUIRED NO_MODULE)
find_package(ECM 5.30 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
find_package(Qt5 REQUIRED CONFIG COMPONENTS DBus Network Widgets)
......@@ -90,7 +91,7 @@ endif()
add_subdirectory( ksgrd )
if(BUILD_TESTING)
add_subdirectory( tests )
add_subdirectory( tests )
endif()
install(DIRECTORY scripts/ DESTINATION ${DATA_INSTALL_DIR}/ksysguard/scripts)
......
remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY)
add_definitions(-DTRANSLATION_DOMAIN=\"processcore\")
########### next target ###############
......
......@@ -31,7 +31,7 @@ KSysGuardProcessListHelper::KSysGuardProcessListHelper()
}
/* The functions here run as ROOT. So be careful. DO NOT TRUST THE INPUTS TO BE SANE. */
#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toULongLong(); if(pid < 0) return ActionReply(ActionReply::HelperErrorType);
#define GET_PID(i) parameters.value(QStringLiteral("pid%1").arg(i), -1).toULongLong(); if(pid < 0) return ActionReply(ActionReply::HelperErrorType);
ActionReply KSysGuardProcessListHelper::sendsignal(const QVariantMap &parameters) {
ActionReply reply(ActionReply::HelperErrorType);
if(!parameters.contains(QStringLiteral("signal"))) {
......
......@@ -130,7 +130,7 @@ ProcessesLocal::ProcessesLocal() : d(new Private())
}
bool ProcessesLocal::Private::readProcStatus(const QString &dir, Process *process)
{
mFile.setFileName(dir + "status");
mFile.setFileName(dir + QStringLiteral("status"));
if(!mFile.open(QIODevice::ReadOnly))
return false; /* process has terminated in the meantime */
......@@ -199,7 +199,7 @@ bool ProcessesLocal::Private::readProcStatus(const QString &dir, Process *proces
long ProcessesLocal::getParentPid(long pid) {
if (pid <= 0)
return -1;
d->mFile.setFileName("/proc/" + QString::number(pid) + "/stat");
d->mFile.setFileName(QStringLiteral("/proc/") + QString::number(pid) + QStringLiteral("/stat"));
if(!d->mFile.open(QIODevice::ReadOnly))
return -1; /* process has terminated in the meantime */
......@@ -236,7 +236,7 @@ long ProcessesLocal::getParentPid(long pid) {
bool ProcessesLocal::Private::readProcStat(const QString &dir, Process *ps)
{
QString filename = dir + "stat";
QString filename = dir + QStringLiteral("stat");
// As an optimization, if the last file read in was stat, then we already have this info in memory
if(mFile.fileName() != filename) {
mFile.setFileName(filename);
......@@ -356,7 +356,7 @@ bool ProcessesLocal::Private::readProcStat(const QString &dir, Process *ps)
bool ProcessesLocal::Private::readProcStatm(const QString &dir, Process *process)
{
#ifdef _SC_PAGESIZE
mFile.setFileName(dir + "statm");
mFile.setFileName(dir + QStringLiteral("statm"));
if(!mFile.open(QIODevice::ReadOnly))
return false; /* process has terminated in the meantime */
......@@ -392,7 +392,7 @@ bool ProcessesLocal::Private::readProcStatm(const QString &dir, Process *process
bool ProcessesLocal::Private::readProcCmdline(const QString &dir, Process *process)
{
if(!process->command().isNull()) return true; //only parse the cmdline once. This function takes up 25% of the CPU time :-/
mFile.setFileName(dir + "cmdline");
mFile.setFileName(dir + QStringLiteral("cmdline"));
if(!mFile.open(QIODevice::ReadOnly))
return false; /* process has terminated in the meantime */
......@@ -402,8 +402,8 @@ bool ProcessesLocal::Private::readProcCmdline(const QString &dir, Process *proce
//cmdline separates parameters with the NULL character
if(!process->command().isEmpty()) {
//extract non-truncated name from cmdline
int zeroIndex = process->command().indexOf(QChar('\0'));
int processNameStart = process->command().lastIndexOf(QChar('/'), zeroIndex);
int zeroIndex = process->command().indexOf(QLatin1Char('\0'));
int processNameStart = process->command().lastIndexOf(QLatin1Char('/'), zeroIndex);
if(processNameStart == -1)
processNameStart = 0;
else
......@@ -412,7 +412,7 @@ bool ProcessesLocal::Private::readProcCmdline(const QString &dir, Process *proce
if(nameFromCmdLine.startsWith(process->name()))
process->setName(nameFromCmdLine);
process->command().replace('\0', ' ');
process->command().replace(QLatin1Char('\0'), QLatin1Char(' '));
}
mFile.close();
......@@ -468,7 +468,7 @@ bool ProcessesLocal::Private::getNiceness(long pid, Process *process) {
bool ProcessesLocal::Private::getIOStatistics(const QString &dir, Process *process)
{
QString filename = dir + "io";
QString filename = dir + QStringLiteral("io");
// As an optimization, if the last file read in was io, then we already have this info in memory
mFile.setFileName(filename);
if(!mFile.open(QIODevice::ReadOnly))
......@@ -513,7 +513,7 @@ bool ProcessesLocal::Private::getIOStatistics(const QString &dir, Process *proce
bool ProcessesLocal::updateProcessInfo( long pid, Process *process)
{
bool success = true;
QString dir = "/proc/" + QString::number(pid) + '/';
QString dir = QStringLiteral("/proc/") + QString::number(pid) + QLatin1Char('/');
if(!d->readProcStat(dir, process)) success = false;
if(!d->readProcStatus(dir, process)) success = false;
if(!d->readProcStatm(dir, process)) success = false;
......
......@@ -111,7 +111,7 @@ bool ProcessesRemote::updateProcessInfo( long pid, Process *process)
}
QList<QByteArray> p = d->processByPid[pid];
if(d->nameColumn!= -1) process->setName(p.at(d->nameColumn));
if(d->nameColumn!= -1) process->setName(QString::fromUtf8(p.at(d->nameColumn)));
if(d->uidColumn!= -1) process->setUid(p.at(d->uidColumn).toLong());
if(d->gidColumn!= -1) process->setGid(p.at(d->gidColumn).toLong());
if(d->statusColumn!= -1) {
......@@ -166,16 +166,16 @@ QSet<long> ProcessesRemote::getAllPids( )
bool ProcessesRemote::sendSignal(long pid, int sig) {
//TODO run the proper command for all these functions below
emit runCommand("kill " + QString::number(pid) + " " + QString::number(sig), (int)Kill);
emit runCommand(QStringLiteral("kill ") + QString::number(pid) + QStringLiteral(" ") + QString::number(sig), (int)Kill);
return true;
}
bool ProcessesRemote::setNiceness(long pid, int priority) {
emit runCommand("setpriority " + QString::number(pid) + " " + QString::number(priority), (int)Renice);
emit runCommand(QStringLiteral("setpriority ") + QString::number(pid) + QStringLiteral(" ") + QString::number(priority), (int)Renice);
return true;
}
bool ProcessesRemote::setIoNiceness(long pid, int priorityClass, int priority) {
emit runCommand("ionice " + QString::number(pid) + " " + QString::number(priorityClass) + " " + QString::number(priority), (int)Ionice);
emit runCommand(QStringLiteral("ionice ") + QString::number(pid) + QStringLiteral(" ") + QString::number(priorityClass) + QStringLiteral(" ") + QString::number(priority), (int)Ionice);
return true;
}
......
Supports Markdown
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