Commit 406310ec authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port foreach

parent cab29df9
......@@ -84,7 +84,7 @@ void ConfigurationDialog::setupLogModeConfigurations()
d->logModeConfigurations.append(logMode->logModeConfigurationWidget());
}
foreach (LogModeConfigurationWidget *logModeConfigurationWidget, d->logModeConfigurations) {
for (LogModeConfigurationWidget *logModeConfigurationWidget : qAsConst(d->logModeConfigurations)) {
logDebug() << "Adding " << logModeConfigurationWidget->itemName() << " configuration...";
addPage(logModeConfigurationWidget, logModeConfigurationWidget->itemName(),
......@@ -120,7 +120,7 @@ void ConfigurationDialog::updateSettings()
d->generalConfiguration->saveConfig();
foreach (LogModeConfigurationWidget *logModeConfigurationWidget, d->logModeConfigurations) {
for (LogModeConfigurationWidget *logModeConfigurationWidget : qAsConst(d->logModeConfigurations)) {
logModeConfigurationWidget->saveConfig();
}
......@@ -143,7 +143,7 @@ void ConfigurationDialog::updateConfiguration()
bool valid = d->generalConfiguration->isValid();
if (valid) {
foreach (LogModeConfigurationWidget *logModeConfigurationWidget, d->logModeConfigurations) {
for (LogModeConfigurationWidget *logModeConfigurationWidget : qAsConst(d->logModeConfigurations)) {
if (logModeConfigurationWidget->isValid() == false) {
valid = false;
break;
......@@ -173,7 +173,7 @@ void ConfigurationDialog::updateWidgets()
logDebug() << "Reading configuration...";
d->generalConfiguration->readConfig();
foreach (LogModeConfigurationWidget *logModeConfigurationWidget, d->logModeConfigurations) {
for (LogModeConfigurationWidget *logModeConfigurationWidget : qAsConst(d->logModeConfigurations)) {
logModeConfigurationWidget->readConfig();
}
......@@ -185,7 +185,7 @@ void ConfigurationDialog::updateWidgetsDefault()
logDebug() << "Loading default configuration...";
d->generalConfiguration->defaultConfig();
foreach (LogModeConfigurationWidget *logModeConfigurationWidget, d->logModeConfigurations) {
for (LogModeConfigurationWidget *logModeConfigurationWidget : qAsConst(d->logModeConfigurations)) {
logModeConfigurationWidget->defaultConfig();
}
......
......@@ -93,9 +93,10 @@ GeneralConfigurationWidget::~GeneralConfigurationWidget()
void GeneralConfigurationWidget::addDateFormatExample()
{
foreach (QAbstractButton *button, d->dateFormatGroup->buttons()) {
Globals::DateFormat currentButtonFormat = static_cast<Globals::DateFormat>(d->dateFormatGroup->id(button));
QString formattedDate = Globals::instance().formatDate(currentButtonFormat, QDateTime().currentDateTime());
const auto buttons = d->dateFormatGroup->buttons();
for (QAbstractButton *button : buttons) {
const Globals::DateFormat currentButtonFormat = static_cast<Globals::DateFormat>(d->dateFormatGroup->id(button));
const QString formattedDate = Globals::instance().formatDate(currentButtonFormat, QDateTime().currentDateTime());
button->setText(i18nc("Date format option (date example)", "%1 (%2)", button->text(), formattedDate));
}
}
......
......@@ -271,8 +271,8 @@ void LogViewSearchWidget::setSearchLineNotFound(bool notFound)
void LogViewSearchWidget::unselectAll()
{
QList<QTreeWidgetItem *> selectedItems = d->logViewWidget->selectedItems();
foreach (QTreeWidgetItem *item, selectedItems) {
const QList<QTreeWidgetItem *> selectedItems = d->logViewWidget->selectedItems();
for (QTreeWidgetItem *item : selectedItems) {
item->setSelected(false);
}
}
......
......@@ -56,7 +56,7 @@ bool AuthenticationAnalyzer::hasErrorKeywords(const QString &message)
bool AuthenticationAnalyzer::hasKeywords(const QString &message, const QStringList &keywords)
{
foreach (const QString &keyword, keywords) {
for (const QString &keyword : keywords) {
if (message.contains(keyword, Qt::CaseInsensitive)) {
return true;
}
......
......@@ -144,9 +144,9 @@ void FileList::modifyItem(QListWidgetItem *item)
void FileList::removeSelectedItem()
{
QList<QListWidgetItem *> selectedItems = fileList->selectedItems();
const QList<QListWidgetItem *> selectedItems = fileList->selectedItems();
foreach (QListWidgetItem *item, selectedItems) {
for (QListWidgetItem *item : selectedItems) {
delete fileList->takeItem(fileList->row(item));
}
......
......@@ -178,8 +178,8 @@ void FileListHelper::setEnabledAction(QPushButton *button, bool enabled)
{
button->setEnabled(enabled);
QList<QAction *> actions = button->actions();
foreach (QAction *action, actions) {
const QList<QAction *> actions = button->actions();
for (QAction *action : actions) {
action->setEnabled(enabled);
}
}
......@@ -113,7 +113,7 @@ bool XSessionAnalyzer::hasErrorKeywords(const QString &message)
bool XSessionAnalyzer::hasKeywords(const QString &message, const QStringList &keywords)
{
foreach (const QString &keyword, keywords) {
for (const QString &keyword : keywords) {
if (message.contains(keyword, Qt::CaseInsensitive)) {
return true;
}
......
......@@ -105,7 +105,8 @@ void XSessionConfigurationWidget::prepareXorgErrorsDescription()
QString text = xorgErrorsDescription->text();
text.append(QLatin1String("<ul style='margin-top:0px;margin-bottom:0px'>"));
foreach (const QString &xorgErrorKeyword, configuration->xorgErrorKeywords()) {
const auto xorgErrorKeywords = configuration->xorgErrorKeywords();
for (const QString &xorgErrorKeyword : xorgErrorKeywords) {
text.append(i18n("<li><b>%1</b>: ...</li>", xorgErrorKeyword));
}
text.append(QLatin1String("</ul>"));
......
......@@ -132,7 +132,7 @@ LogManager *TabLogViewsWidget::findRelatedLogManager(View *view)
TabLogManager *TabLogViewsWidget::findRelatedTabLogManager(View *view)
{
foreach (TabLogManager *tabLogManager, d->tabLogManagers) {
for (TabLogManager *tabLogManager : qAsConst(d->tabLogManagers)) {
if (tabLogManager->logManager()->usedView() == view) {
return tabLogManager;
}
......
......@@ -59,7 +59,7 @@ private Q_SLOTS:
void testRemoveDuplicates();
private:
void compareWithMinTime(QList<LogLine *> lines, const QDateTime &minTime);
void compareWithMinTime(const QList<LogLine *> &lines, const QDateTime &minTime);
private:
TestUtil testUtil;
......@@ -346,11 +346,11 @@ void SystemAnalyzerTest::testMaxLines()
testUtil.destroyReader(systemAnalyzer);
}
void SystemAnalyzerTest::compareWithMinTime(QList<LogLine *> logLines, const QDateTime &minTime)
void SystemAnalyzerTest::compareWithMinTime(const QList<LogLine *> &logLines, const QDateTime &minTime)
{
logDebug() << "Min time : " << minTime.toString();
foreach (LogLine *logLine, logLines) {
for (LogLine *logLine : logLines) {
if (logLine->time() < minTime) {
QFAIL(QString::fromLatin1("The line '%1' has a lesser time than the required min time (%2)")
.arg(logLine->logItems().join(QLatin1Char(' ')))
......
......@@ -121,7 +121,7 @@ void TestUtil::addLogLines(const QString &fileName, const QStringList &addedLine
logDebug() << "Opening " << fileName << " for writing " << addedLines.count() << " line(s).";
QTextStream out(&data);
foreach (const QString &line, addedLines) {
for (const QString &line : addedLines) {
out << line << '\n';
}
......
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