Commit a36cfa17 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Const'ref

parent b7afabca
......@@ -32,7 +32,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);
ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters) {
ActionReply KSysGuardProcessListHelper::sendsignal(const QVariantMap &parameters) {
ActionReply reply(ActionReply::HelperErrorType);
if(!parameters.contains(QStringLiteral("signal"))) {
reply.setErrorDescription(QStringLiteral("Internal error - no signal parameter was passed to the helper"));
......@@ -66,7 +66,7 @@ ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters) {
}
}
ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
ActionReply KSysGuardProcessListHelper::renice(const QVariantMap &parameters) {
if(!parameters.contains(QStringLiteral("nicevalue")) || !parameters.contains(QStringLiteral("pidcount")))
return ActionReply(ActionReply::HelperErrorType);
......@@ -84,7 +84,7 @@ ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
return ActionReply(ActionReply::HelperErrorType);
}
ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap parameters) {
ActionReply KSysGuardProcessListHelper::changeioscheduler(const QVariantMap &parameters) {
if(!parameters.contains(QStringLiteral("ioScheduler")) || !parameters.contains(QStringLiteral("ioSchedulerPriority")) || !parameters.contains(QStringLiteral("pidcount")))
return ActionReply(ActionReply::HelperErrorType);
......@@ -103,7 +103,7 @@ ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap parameters
return ActionReply(ActionReply::HelperErrorType);
}
ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters) {
ActionReply KSysGuardProcessListHelper::changecpuscheduler(const QVariantMap &parameters) {
if(!parameters.contains(QStringLiteral("cpuScheduler")) || !parameters.contains(QStringLiteral("cpuSchedulerPriority")) || !parameters.contains(QStringLiteral("pidcount")))
return ActionReply(ActionReply::HelperErrorType);
......
......@@ -33,10 +33,10 @@ class KSysGuardProcessListHelper : public QObject {
KSysGuardProcessListHelper();
public Q_SLOTS:
ActionReply sendsignal(QVariantMap parameters);
ActionReply renice(QVariantMap parameters);
ActionReply changeioscheduler(QVariantMap parameters);
ActionReply changecpuscheduler(QVariantMap parameters);
ActionReply sendsignal(const QVariantMap &parameters);
ActionReply renice(const QVariantMap &parameters);
ActionReply changeioscheduler(const QVariantMap &parameters);
ActionReply changecpuscheduler(const QVariantMap &parameters);
};
Q_DECLARE_METATYPE( QList<long long> )
......@@ -86,22 +86,22 @@ bool ProcessesATop::Private::loadHistoryFile(const QString &filename) {
ready = false;
currentlySelectedIndex = -1;
if(!atopLog.exists()) {
lastError = "File " + filename + " does not exist";
lastError = QStringLiteral("File ") + filename + QStringLiteral(" does not exist");
return false;
}
if(!atopLog.open(QIODevice::ReadOnly)) {
lastError = "Could not open file" + filename;
lastError = QStringLiteral("Could not open file ") + filename;
return false;
}
int sizeRead = atopLog.read((char*)(&rh), sizeof(RawHeader));
if(sizeRead != sizeof(RawHeader)) {
lastError = "Could not read header from file" + filename;
lastError = QStringLiteral("Could not read header from file ") + filename;
return false;
}
if(rh.magic != ATOPLOGMAGIC) {
lastError = "File " + filename + " does not contain raw atop/atopsar output (wrong magic number)";
lastError = QStringLiteral("File ") + filename + QStringLiteral(" does not contain raw atop/atopsar output (wrong magic number)");
return false;
}
if (/*rh.sstatlen != sizeof(SStat) ||*/
......@@ -109,7 +109,7 @@ bool ProcessesATop::Private::loadHistoryFile(const QString &filename) {
rh.rawheadlen != sizeof(RawHeader) ||
rh.rawreclen != sizeof(RawRecord) )
{
lastError = "File " + filename + " has incompatible format";
lastError = QStringLiteral("File ") + filename + QStringLiteral(" has incompatible format");
if (rh.aversion & 0x8000) {
lastError = QStringLiteral("(created by version %1.%2. This program understands the format written by version 1.23")
.arg((rh.aversion >> 8) & 0x7f).arg(rh.aversion & 0xff);
......@@ -184,7 +184,7 @@ bool ProcessesATop::Private::loadDataForHistory(int index)
lastError = QStringLiteral("Could not uncompress record data due to corrupted data");
break;
default:
lastError = "Could not uncompress record data due to unexpected error: " + QString::number(ret);
lastError = QStringLiteral("Could not uncompress record data due to unexpected error: ") + QString::number(ret);
break;
}
delete [] pstats;
......@@ -254,10 +254,10 @@ bool ProcessesATop::updateProcessInfo( long pid, Process *process)
//cmdline separates parameters with the NULL character
if(!command.isEmpty()) {
if(command.startsWith(name)) {
int index = command.indexOf(QChar('\0'));
int index = command.indexOf(QLatin1Char('\0'));
name = command.left(index);
}
command.replace('\0', ' ');
command.replace(QLatin1Char('\0'), QLatin1Char(' '));
}
process->setName(name);
process->setCommand(command);
......@@ -351,7 +351,8 @@ bool ProcessesATop::setScheduler(long pid, int priorityClass, int priority) {
}
bool ProcessesATop::setIoNiceness(long pid, int priorityClass, int priority) {
bool ProcessesATop::setIoNiceness(long pid, int priorityClass, int priority)
{
Q_UNUSED(pid);
Q_UNUSED(priorityClass);
Q_UNUSED(priority);
......@@ -360,13 +361,16 @@ bool ProcessesATop::setIoNiceness(long pid, int priorityClass, int priority) {
return false;
}
bool ProcessesATop::supportsIoNiceness() {
bool ProcessesATop::supportsIoNiceness()
{
return false;
}
long long ProcessesATop::totalPhysicalMemory() {
long long ProcessesATop::totalPhysicalMemory()
{
return 0;
}
ProcessesATop::~ProcessesATop()
{
delete d;
......
......@@ -144,14 +144,14 @@ void KTextEditVT::insertVTChar(const QChar & c) {
}
}
void KTextEditVT::insertVTText(const QByteArray & string)
void KTextEditVT::insertVTText(const QByteArray &string)
{
int size= string.size();
const int size= string.size();
for(int i =0; i < size; i++)
insertVTChar(QLatin1Char(string.at(i)));
}
void KTextEditVT::insertVTText(const QString & string)
void KTextEditVT::insertVTText(const QString &string)
{
int size= string.size();
for(int i =0; i < size; i++)
......
......@@ -41,7 +41,7 @@ ReniceDlg::ReniceDlg(QWidget* parent, const QStringList& processes, int currentC
setObjectName( QStringLiteral("Renice Dialog") );
setModal( true );
setWindowTitle( i18n("Set Priority") );
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
previous_cpuscheduler = 0;
if(currentIoSched == KSysGuard::Process::None) {
......@@ -56,8 +56,7 @@ ReniceDlg::ReniceDlg(QWidget* parent, const QStringList& processes, int currentC
ioniceSupported = (currentIoPrio != -2);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
......
......@@ -441,7 +441,7 @@ void KSysGuardProcessListPrivate::setupKAuthAction(KAuth::Action &action, const
{
action.setHelperId(QStringLiteral("org.kde.ksysguard.processlisthelper"));
int processCount = pids.count();
const int processCount = pids.count();
for(int i = 0; i < processCount; i++) {
action.addArgument(QStringLiteral("pid%1").arg(i), pids[i]);
}
......@@ -468,8 +468,8 @@ void KSysGuardProcessList::showProcessContextMenu(const QModelIndex &index) {
void KSysGuardProcessList::showProcessContextMenu(const QPoint &point) {
d->mProcessContextMenu->clear();
QModelIndexList selectedIndexes = d->mUi->treeView->selectionModel()->selectedRows();
int numProcesses = selectedIndexes.size();
const QModelIndexList selectedIndexes = d->mUi->treeView->selectionModel()->selectedRows();
const int numProcesses = selectedIndexes.size();
if(numProcesses == 0) {
//No processes selected, so no process context menu
......
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