diff --git a/src/render/katelayoutcache.cpp b/src/render/katelayoutcache.cpp --- a/src/render/katelayoutcache.cpp +++ b/src/render/katelayoutcache.cpp @@ -508,13 +508,12 @@ void KateLayoutCache::viewCacheDebugOutput() const { qCDebug(LOG_KTE) << "Printing values for " << m_textLayouts.count() << " lines:"; - if (!m_textLayouts.isEmpty()) { - foreach (const KateTextLayout &t, m_textLayouts) - if (t.isValid()) { - t.debugOutput(); - } else { - qCDebug(LOG_KTE) << "Line Invalid."; - } + for (const KateTextLayout &t : m_textLayouts) { + if (t.isValid()) { + t.debugOutput(); + } else { + qCDebug(LOG_KTE) << "Line Invalid."; + } } } diff --git a/src/schema/kateschemaconfig.cpp b/src/schema/kateschemaconfig.cpp --- a/src/schema/kateschemaconfig.cpp +++ b/src/schema/kateschemaconfig.cpp @@ -334,10 +334,9 @@ void KateSchemaConfigColorTab::apply() { schemaChanged(m_currentSchema); - QMap >::Iterator it; - for (it = m_schemas.begin(); it != m_schemas.end(); ++it) { + for (auto it = m_schemas.constBegin(); it != m_schemas.constEnd(); ++it) { KConfigGroup config = KTextEditor::EditorPrivate::self()->schemaManager()->schema(it.key()); - foreach (const KateColorItem &item, m_schemas[it.key()]) { + for (const KateColorItem &item : it.value()) { if (item.useDefault) { config.deleteEntry(item.key); } else { diff --git a/src/script/katescriptmanager.cpp b/src/script/katescriptmanager.cpp --- a/src/script/katescriptmanager.cpp +++ b/src/script/katescriptmanager.cpp @@ -254,7 +254,7 @@ KateIndentScript *script = new KateIndentScript(fileName, indentHeader); script->setGeneralHeader(generalHeader); - foreach (const QString &language, indentHeader.indentLanguages()) { + for (const QString &language : indentHeader.indentLanguages()) { m_languageToIndenters[language.toLower()].push_back(script); } diff --git a/src/search/katematch.cpp b/src/search/katematch.cpp --- a/src/search/katematch.cpp +++ b/src/search/katematch.cpp @@ -82,7 +82,8 @@ QString KateMatch::buildReplacement(const QString &replacement, bool blockMode, int replacementCounter) const { QStringList capturedTexts; - foreach (const KTextEditor::Range &captureRange, m_resultRanges) { + capturedTexts.reserve(m_resultRanges.size()); + for (const KTextEditor::Range &captureRange : m_resultRanges) { // Copy capture content capturedTexts << m_document->text(captureRange, blockMode); } diff --git a/src/spellcheck/ontheflycheck.cpp b/src/spellcheck/ontheflycheck.cpp --- a/src/spellcheck/ontheflycheck.cpp +++ b/src/spellcheck/ontheflycheck.cpp @@ -94,7 +94,7 @@ QPair KateOnTheFlyChecker::getMisspelledItem(const KTextEditor::Cursor &cursor) const { - foreach (const MisspelledItem &item, m_misspelledList) { + for (const MisspelledItem &item : m_misspelledList) { KTextEditor::MovingRange *movingRange = item.first; if (movingRange->contains(cursor)) { return QPair(*movingRange, item.second); @@ -105,7 +105,7 @@ QString KateOnTheFlyChecker::dictionaryForMisspelledRange(const KTextEditor::Range &range) const { - foreach (const MisspelledItem &item, m_misspelledList) { + for (const MisspelledItem &item : m_misspelledList) { KTextEditor::MovingRange *movingRange = item.first; if (*movingRange == range) { return item.second; diff --git a/src/variableeditor/variablelistview.cpp b/src/variableeditor/variablelistview.cpp --- a/src/variableeditor/variablelistview.cpp +++ b/src/variableeditor/variablelistview.cpp @@ -89,7 +89,7 @@ // calculate sum of all editor heights int listHeight = 0; - foreach (QWidget *w, m_editors) { + for (QWidget *w : qAsConst(m_editors)) { listHeight += w->sizeHint().height(); }