Commit 7b792569 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some foreach

parent 4d6c48ca
...@@ -15,7 +15,7 @@ QString CTInitializationError::errorMessage() const ...@@ -15,7 +15,7 @@ QString CTInitializationError::errorMessage() const
void CTInitializationError::setErrorMessage(const QString &errorMessage) void CTInitializationError::setErrorMessage(const QString &errorMessage)
{ {
this->mError = errorMessage; mError = errorMessage;
} }
bool CTInitializationError::hasErrorMessage() const bool CTInitializationError::hasErrorMessage() const
......
...@@ -320,7 +320,7 @@ CTSaveStatus CTCron::save() ...@@ -320,7 +320,7 @@ CTSaveStatus CTCron::save()
ctTask->apply(); ctTask->apply();
} }
foreach (CTVariable *ctVariable, d->variable) { for (CTVariable *ctVariable : qAsConst(d->variable)) {
ctVariable->apply(); ctVariable->apply();
} }
...@@ -359,7 +359,7 @@ bool CTCron::isDirty() const ...@@ -359,7 +359,7 @@ bool CTCron::isDirty() const
} }
} }
foreach (CTVariable *ctVariable, d->variable) { for (CTVariable *ctVariable : qAsConst(d->variable)) {
if (ctVariable->dirty()) { if (ctVariable->dirty()) {
return true; return true;
} }
...@@ -372,7 +372,7 @@ QString CTCron::path() const ...@@ -372,7 +372,7 @@ QString CTCron::path() const
{ {
QString path; QString path;
foreach (CTVariable *ctVariable, d->variable) { for (CTVariable *ctVariable : qAsConst(d->variable)) {
if (ctVariable->variable == QLatin1String("PATH")) { if (ctVariable->variable == QLatin1String("PATH")) {
path = ctVariable->value; path = ctVariable->value;
} }
......
...@@ -18,8 +18,7 @@ CTHour::CTHour(const QString &tokStr) ...@@ -18,8 +18,7 @@ CTHour::CTHour(const QString &tokStr)
int CTHour::findPeriod() const int CTHour::findPeriod() const
{ {
QList<int> periods; const QList<int> periods{2, 3, 4, 6, 8};
periods << 2 << 3 << 4 << 6 << 8;
return CTUnit::findPeriod(periods); return CTUnit::findPeriod(periods);
} }
......
...@@ -224,12 +224,10 @@ QString CTTask::schedulingCronFormat() const ...@@ -224,12 +224,10 @@ QString CTTask::schedulingCronFormat() const
return QStringLiteral("@reboot"); return QStringLiteral("@reboot");
} }
QString scheduling; QString scheduling = minute.exportUnit() + QLatin1Char(' ');
scheduling += hour.exportUnit() + QLatin1Char(' ');
scheduling += minute.exportUnit() + QLatin1String(" "); scheduling += dayOfMonth.exportUnit() + QLatin1Char(' ');
scheduling += hour.exportUnit() + QLatin1String(" "); scheduling += month.exportUnit() + QLatin1Char(' ');
scheduling += dayOfMonth.exportUnit() + QLatin1String(" ");
scheduling += month.exportUnit() + QLatin1String(" ");
scheduling += dayOfWeek.exportUnit(); scheduling += dayOfWeek.exportUnit();
return scheduling; return scheduling;
......
...@@ -25,9 +25,7 @@ CTVariable::CTVariable(const QString &tokenString, const QString &_comment, cons ...@@ -25,9 +25,7 @@ CTVariable::CTVariable(const QString &tokenString, const QString &_comment, cons
enabled = true; enabled = true;
} }
int spacepos(0); const int spacepos = tokStr.indexOf(QRegExp(QLatin1String("[ =]")));
spacepos = tokStr.indexOf(QRegExp(QLatin1String("[ =]")));
variable = tokStr.mid(0, spacepos); variable = tokStr.mid(0, spacepos);
value = tokStr.mid(spacepos+1, tokStr.length()-spacepos-1); value = tokStr.mid(spacepos+1, tokStr.length()-spacepos-1);
......
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