Commit 53b808d7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some foreach

parent 7b792569
......@@ -26,8 +26,8 @@
#include "logging.h"
CrontabPrinter::CrontabPrinter(CrontabWidget *crontabWidget)
: mCrontabWidget(crontabWidget)
{
mCrontabWidget = crontabWidget;
}
CrontabPrinter::~CrontabPrinter()
......
......@@ -88,7 +88,7 @@ private:
/**
* Pointer to parent widget
*/
CrontabWidget *mCrontabWidget = nullptr;
CrontabWidget *const mCrontabWidget;
QPainter *mPainter = nullptr;
......
......@@ -234,7 +234,7 @@ void CrontabWidget::copy()
logDebug() << "Variables copying";
const QList<VariableWidget *> variablesWidget = mVariablesWidget->selectedVariablesWidget();
foreach (VariableWidget *variableWidget, variablesWidget) {
for (VariableWidget *variableWidget : variablesWidget) {
CTVariable *variable = new CTVariable(*(variableWidget->getCTVariable()));
mClipboardVariables.append(variable);
......
......@@ -142,13 +142,15 @@ CTCron &CTCron::operator =(const CTCron &source)
}
d->variable.clear();
foreach (CTVariable *ctVariable, source.variables()) {
const auto variables = source.variables();
for (CTVariable *ctVariable : variables) {
CTVariable *tmp = new CTVariable(*ctVariable);
d->variable.append(tmp);
}
d->task.clear();
foreach (CTTask *ctTask, source.tasks()) {
const auto tasks = source.tasks();
for (CTTask *ctTask : tasks) {
CTTask *tmp = new CTTask(*ctTask);
d->task.append(tmp);
}
......@@ -223,12 +225,12 @@ QString CTCron::exportCron() const
{
QString exportCron;
foreach (CTVariable *ctVariable, d->variable) {
for (CTVariable *ctVariable : qAsConst(d->variable)) {
exportCron += ctVariable->exportVariable();
exportCron += QLatin1String("\n");
}
foreach (CTTask *ctTask, d->task) {
for (CTTask *ctTask : qAsConst(d->task)) {
exportCron += ctTask->exportTask();
exportCron += QLatin1String("\n");
}
......@@ -316,7 +318,7 @@ CTSaveStatus CTCron::save()
}
//Mark as applied
foreach (CTTask *ctTask, d->task) {
for (CTTask *ctTask : qAsConst(d->task)) {
ctTask->apply();
}
......@@ -353,7 +355,7 @@ bool CTCron::isDirty() const
return true;
}
foreach (CTTask *ctTask, d->task) {
for (CTTask *ctTask : qAsConst(d->task)) {
if (ctTask->dirty()) {
return true;
}
......
......@@ -403,10 +403,9 @@ QPair<QString, bool> CTTask::unQuoteCommand() const
QString fullCommand = command;
fullCommand = fullCommand.trimmed();
QStringList quotes;
quotes << QStringLiteral("\"") << QStringLiteral("'");
const QStringList quotes{QStringLiteral("\""), QStringLiteral("'")};
foreach (const QString &quote, quotes) {
for (const QString &quote : quotes) {
if (fullCommand.indexOf(quote) == 0) {
int nextQuote = fullCommand.indexOf(quote, 1);
if (nextQuote == -1) {
......
......@@ -285,7 +285,7 @@ int CTUnit::fieldToValue(const QString &entry) const
*/
int CTUnit::findPeriod(const QList<int> &periods) const
{
foreach (int period, periods) {
for (int period : periods) {
bool validPeriod = true;
for (int i = minimum(); i <= maximum(); i++) {
......
......@@ -105,7 +105,7 @@ bool KCMCron::init()
// if there currently are no scheduled tasks...
if (!mCtHost->isRootUser()) {
int taskCount = 0;
foreach (CTCron *ctCron, mCtHost->mCrons) {
for (CTCron *ctCron : qAsConst(mCtHost->mCrons)) {
taskCount += ctCron->tasks().count();
}
......
......@@ -167,7 +167,8 @@ void VariablesWidget::refreshVariables(CTCron *cron)
refreshHeaders();
foreach (CTVariable *ctVariable, cron->variables()) {
const auto variables = cron->variables();
for (CTVariable *ctVariable : variables) {
new VariableWidget(this, ctVariable);
}
......@@ -230,7 +231,8 @@ void VariablesWidget::prepareContextualMenu()
treeWidget()->addAction(createSeparator());
foreach (QAction *action, crontabWidget()->cutCopyPasteActions()) {
const auto cutCopyPasteActions = crontabWidget()->cutCopyPasteActions();
for (QAction *action : cutCopyPasteActions) {
treeWidget()->addAction(action);
}
}
......
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