diff --git a/autotests/src/katedocument_test.cpp b/autotests/src/katedocument_test.cpp --- a/autotests/src/katedocument_test.cpp +++ b/autotests/src/katedocument_test.cpp @@ -226,8 +226,7 @@ QBENCHMARK { // init doc.setText(text); - foreach (const Range &range, ranges) - { + for (const Range &range : qAsConst(ranges)) { invalidator.addRange(doc.newMovingRange(range)); } QCOMPARE(invalidator.ranges().size(), ranges.size()); diff --git a/autotests/src/vimode/emulatedcommandbar.cpp b/autotests/src/vimode/emulatedcommandbar.cpp --- a/autotests/src/vimode/emulatedcommandbar.cpp +++ b/autotests/src/vimode/emulatedcommandbar.cpp @@ -3213,12 +3213,11 @@ qDebug() << "Emulated command bar completer not visible."; QStringListModel *completionModel = qobject_cast(emulatedCommandBarCompleter()->model()); Q_ASSERT(completionModel); - QStringList allAvailableCompletions = completionModel->stringList(); + const QStringList allAvailableCompletions = completionModel->stringList(); qDebug() << " Completion list: " << allAvailableCompletions; qDebug() << " Completion prefix: " << emulatedCommandBarCompleter()->completionPrefix(); bool candidateCompletionFound = false; - foreach (const QString& availableCompletion, allAvailableCompletions) - { + for (const QString &availableCompletion : allAvailableCompletions) { if (availableCompletion.startsWith(emulatedCommandBarCompleter()->completionPrefix())) { candidateCompletionFound = true; @@ -3261,8 +3260,7 @@ actualCompletionList << emulatedCommandBarCompleter()->currentCompletion(); } - foreach(const QString& expectedCompletion, expectedCompletionList) - { + for (const QString &expectedCompletion : expectedCompletionList) { if (!actualCompletionList.contains(expectedCompletion)) { qDebug() << "Whoops: " << actualCompletionList << " does not contain " << expectedCompletion; diff --git a/src/buffer/katetextbuffer.cpp b/src/buffer/katetextbuffer.cpp --- a/src/buffer/katetextbuffer.cpp +++ b/src/buffer/katetextbuffer.cpp @@ -115,8 +115,8 @@ void TextBuffer::invalidateRanges() { // invalidate all ranges, work on copy, they might delete themself... - QSet copyRanges = m_ranges; - foreach (TextRange *range, copyRanges) { + const QSet copyRanges = m_ranges; + for (TextRange *range : copyRanges) { range->setRange(KTextEditor::Cursor::invalid(), KTextEditor::Cursor::invalid()); } } @@ -1004,8 +1004,8 @@ * update all views, this IS ugly and could be a signal, but I profiled and a signal is TOO slow, really * just create 20k ranges in a go and you wait seconds on a decent machine */ - const QList &views = m_document->views(); - foreach (KTextEditor::View *curView, views) { + const QList views = m_document->views(); + for (KTextEditor::View *curView : views) { // filter wrong views if (view && view != curView) { continue; @@ -1030,8 +1030,9 @@ // get the ranges of the right block QList rightRanges; - foreach (const QSet &ranges, m_blocks.at(blockIndex)->rangesForLine(line)) { - foreach (TextRange *const range, ranges) { + const auto blockRanges = m_blocks.at(blockIndex)->rangesForLine(line); + for (const QSet &ranges : blockRanges) { + for (TextRange *const range : ranges) { /** * we want only ranges with attributes, but this one has none */ diff --git a/src/completion/katecompletionmodel.cpp b/src/completion/katecompletionmodel.cpp --- a/src/completion/katecompletionmodel.cpp +++ b/src/completion/katecompletionmodel.cpp @@ -707,7 +707,7 @@ affectedGroups += deleteItems(index); } - foreach (Group *g, affectedGroups) { + for (Group *g : qAsConst(affectedGroups)) { hideOrShowGroup(g, true); } } @@ -1032,7 +1032,7 @@ QList< Group * > groups = m_rowTable; groups += m_ungrouped; - foreach (Group *g, groups) { + for (Group *g : qAsConst(groups)) { foreach (const Item &item, g->filtered) { uint startPos = m_currentMatch[item.sourceRow().first].length(); const QString candidate = item.name().mid(startPos); diff --git a/src/completion/katecompletionwidget.cpp b/src/completion/katecompletionwidget.cpp --- a/src/completion/katecompletionwidget.cpp +++ b/src/completion/katecompletionwidget.cpp @@ -375,7 +375,7 @@ deleteCompletionRanges(); } - foreach (KTextEditor::CodeCompletionModel *model, models) { + for (KTextEditor::CodeCompletionModel *model : qAsConst(models)) { KTextEditor::Range range; if (word.isValid()) { range = word; diff --git a/src/dialogs/katedialogs.cpp b/src/dialogs/katedialogs.cpp --- a/src/dialogs/katedialogs.cpp +++ b/src/dialogs/katedialogs.cpp @@ -448,8 +448,8 @@ ui = new Ui::EditConfigWidget(); ui->setupUi(newWidget); - QList inputModes = KTextEditor::EditorPrivate::self()->inputModeFactories(); - Q_FOREACH(KateAbstractInputModeFactory *fact, inputModes) { + const QList inputModes = KTextEditor::EditorPrivate::self()->inputModeFactories(); + for (KateAbstractInputModeFactory *fact : inputModes) { ui->cmbInputMode->addItem(fact->name(), static_cast(fact->inputMode())); } diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp --- a/src/document/katedocument.cpp +++ b/src/document/katedocument.cpp @@ -670,7 +670,7 @@ editEnd(); - foreach (KTextEditor::Mark mark, msave) { + for (KTextEditor::Mark mark : qAsConst(msave)) { setMark(mark.line, mark.type); } @@ -699,7 +699,7 @@ editEnd(); - foreach (KTextEditor::Mark mark, msave) { + for (KTextEditor::Mark mark : qAsConst(msave)) { setMark(mark.line, mark.type); } @@ -1694,11 +1694,11 @@ } } - foreach (int line, rmark) { + for (int line : qAsConst(rmark)) { delete m_marks.take(line); } - foreach (int line, list) { + for (int line : qAsConst(list)) { KTextEditor::Mark *mark = m_marks.take(line); mark->line -= to - from + 1; m_marks.insert(mark->line, mark); @@ -4660,7 +4660,7 @@ const QString nameOfFile = url().fileName(); bool found = false; - foreach (const QString &pattern, wildcards) { + for (const QString &pattern : wildcards) { QRegExp wildcard(pattern, Qt::CaseSensitive, QRegExp::Wildcard); found = wildcard.exactMatch(nameOfFile); diff --git a/src/export/exporter.cpp b/src/export/exporter.cpp --- a/src/export/exporter.cpp +++ b/src/export/exporter.cpp @@ -87,7 +87,7 @@ for (int i = range.start().line(); (i <= range.end().line()) && (i < m_view->document()->lines()); ++i) { const QString &line = m_view->document()->line(i); - QList attribs = m_view->lineAttributes(i); + const QList attribs = m_view->lineAttributes(i); int lineStart = 0; int remainingChars = line.length(); @@ -102,7 +102,7 @@ int handledUntil = lineStart; - foreach (const KTextEditor::AttributeBlock & block, attribs) { + for (const KTextEditor::AttributeBlock &block : attribs) { // honor (block-) selections if (block.start + block.length <= lineStart) { continue; diff --git a/src/mode/katemodemanager.cpp b/src/mode/katemodemanager.cpp --- a/src/mode/katemodemanager.cpp +++ b/src/mode/katemodemanager.cpp @@ -259,7 +259,7 @@ int pri = -1; QString name; - foreach (KateFileType *type, types) { + for (KateFileType *type : qAsConst(types)) { if (type->priority > pri) { pri = type->priority; name = type->name; diff --git a/src/printing/printpainter.cpp b/src/printing/printpainter.cpp --- a/src/printing/printpainter.cpp +++ b/src/printing/printpainter.cpp @@ -535,7 +535,7 @@ y += 1 + pl.innerMargin; int _widest(0); - foreach (const KTextEditor::Attribute::Ptr &attribute, _attributes) { + for (const KTextEditor::Attribute::Ptr &attribute : qAsConst(_attributes)) { _widest = qMax(QFontMetrics(attribute->font()).width(attribute->name().section(QLatin1Char(':'), 1, 1)), _widest); } @@ -547,7 +547,7 @@ _titleFont.setUnderline(true); QString _currentHlName; - foreach (const KTextEditor::Attribute::Ptr &attribute, _attributes) { + for (const KTextEditor::Attribute::Ptr &attribute : qAsConst(_attributes)) { QString _hl = attribute->name().section(QLatin1Char(':'), 0, 0); QString _name = attribute->name().section(QLatin1Char(':'), 1, 1); if (_hl != _hlName && _hl != _currentHlName) { diff --git a/src/schema/kateschemaconfig.cpp b/src/schema/kateschemaconfig.cpp --- a/src/schema/kateschemaconfig.cpp +++ b/src/schema/kateschemaconfig.cpp @@ -324,8 +324,8 @@ void KateSchemaConfigColorTab::exportSchema(KConfigGroup &config) { - QVector items = ui->colorItems(); - foreach (const KateColorItem &item, items) { + const QVector items = ui->colorItems(); + for (const KateColorItem &item : items) { QColor c = item.useDefault ? item.defaultColor : item.color; config.writeEntry(item.key, c); } @@ -1008,12 +1008,12 @@ QStringList hlList; m_highlightTab->loadAllHlsForSchema(m_currentSchema); - QList hls = m_highlightTab->hlsForSchema(m_currentSchema); + const QList hls = m_highlightTab->hlsForSchema(m_currentSchema); int cnt = 0; QProgressDialog progress(i18n("Exporting schema"), QString(), 0, hls.count(), this); progress.setWindowModality(Qt::WindowModal); - foreach (int hl, hls) { + for (int hl : hls) { hlList << KateHlManager::self()->getHl(hl)->name(); m_highlightTab->exportHl(m_currentSchema, hl, &cfg); progress.setValue(++cnt); @@ -1180,7 +1180,7 @@ int cnt = 0; QProgressDialog progress(i18n("Importing schema"), QString(), 0, highlightings.count(), this); progress.setWindowModality(Qt::WindowModal); - foreach (const QString &hl, highlightings) { + for (const QString &hl : highlightings) { if (nameToId.contains(hl)) { const int i = nameToId[hl]; m_highlightTab->importHl(fromSchemaName, schemaName, i, &cfg); @@ -1250,8 +1250,8 @@ // reinitialize combo boxes schemaCombo->clear(); defaultSchemaCombo->clear(); - QList schemaList = KTextEditor::EditorPrivate::self()->schemaManager()->list(); - foreach (const KateSchema &s, schemaList) { + const QList schemaList = KTextEditor::EditorPrivate::self()->schemaManager()->list(); + for (const KateSchema &s : schemaList) { schemaCombo->addItem(s.translatedName(), s.rawName); defaultSchemaCombo->addItem(s.translatedName(), s.rawName); } diff --git a/src/script/katescriptaction.cpp b/src/script/katescriptaction.cpp --- a/src/script/katescriptaction.cpp +++ b/src/script/katescriptaction.cpp @@ -108,12 +108,12 @@ cleanup(); // now add all command line script commands - QVector scripts = + const QVector scripts = KTextEditor::EditorPrivate::self()->scriptManager()->commandLineScripts(); QHash menus; - foreach (KateCommandLineScript *script, scripts) { + for (KateCommandLineScript *script : scripts) { /** * traverse actions */ diff --git a/src/spellcheck/ontheflycheck.cpp b/src/spellcheck/ontheflycheck.cpp --- a/src/spellcheck/ontheflycheck.cpp +++ b/src/spellcheck/ontheflycheck.cpp @@ -115,8 +115,8 @@ void KateOnTheFlyChecker::clearMisspellingForWord(const QString &word) { - MisspelledList misspelledList = m_misspelledList; // make a copy - foreach (const MisspelledItem &item, misspelledList) { + const MisspelledList misspelledList = m_misspelledList; // make a copy + for (const MisspelledItem &item : misspelledList) { KTextEditor::MovingRange *movingRange = item.first; if (m_document->text(*movingRange) == word) { deleteMovingRange(movingRange); @@ -358,8 +358,8 @@ } stopCurrentSpellCheck(); - MisspelledList misspelledList = m_misspelledList; // make a copy! - foreach (const MisspelledItem &i, misspelledList) { + const MisspelledList misspelledList = m_misspelledList; // make a copy! + for (const MisspelledItem &i : misspelledList) { deleteMovingRange(i.first); } m_misspelledList.clear(); diff --git a/src/syntax/katehighlight.cpp b/src/syntax/katehighlight.cpp --- a/src/syntax/katehighlight.cpp +++ b/src/syntax/katehighlight.cpp @@ -387,7 +387,7 @@ list.clear(); - foreach (const KTextEditor::Attribute::Ptr &attribute, attributes) { + for (const KTextEditor::Attribute::Ptr &attribute : qAsConst(attributes)) { list.append(KTextEditor::Attribute::Ptr(new KTextEditor::Attribute(*attribute.data()))); } } diff --git a/src/utils/katesedcmd.cpp b/src/utils/katesedcmd.cpp --- a/src/utils/katesedcmd.cpp +++ b/src/utils/katesedcmd.cpp @@ -295,7 +295,7 @@ { const QVector captureRanges = fullCurrentMatch(); QStringList captureTexts; - foreach (KTextEditor::Range captureRange, captureRanges) { + for (KTextEditor::Range captureRange : captureRanges) { captureTexts << m_doc->text(captureRange); } const QString replacementText = m_regExpSearch.buildReplacement(m_replacePattern, captureTexts, 0); diff --git a/src/utils/katetemplatehandler.cpp b/src/utils/katetemplatehandler.cpp --- a/src/utils/katetemplatehandler.cpp +++ b/src/utils/katetemplatehandler.cpp @@ -348,7 +348,7 @@ } // remove escape characters - Q_FOREACH ( const auto& backslash, stripBackslashes ) { + for (const auto& backslash : stripBackslashes) { doc()->removeText(KTextEditor::Range(backslash, backslash + Cursor(0, 1))); } } diff --git a/src/view/kateview.cpp b/src/view/kateview.cpp --- a/src/view/kateview.cpp +++ b/src/view/kateview.cpp @@ -1537,7 +1537,7 @@ , QStringLiteral("tools_spelling_selection") }; - foreach (const auto &action, l) { + for (const auto &action : l) { QAction *a = actionCollection()->action(action); if (a) { a->setEnabled(doc()->isReadWrite()); @@ -3198,8 +3198,8 @@ //qCDebug(LOG_KTE) << "looking up all menu containers"; if (client->factory()) { - QList conts = client->factory()->containers(QStringLiteral("menu")); - foreach (QWidget *w, conts) { + const QList menuContainers = client->factory()->containers(QStringLiteral("menu")); + for (QWidget *w : menuContainers) { if (w->objectName() == QLatin1String("ktexteditor_popup")) { //perhaps optimize this block QMenu *menu = (QMenu *)w; @@ -3500,7 +3500,7 @@ // update from relevant widgets opt.state &= ~(QStyle::State_HasFocus|QStyle::State_MouseOver); const QList widgets = QList() << m_viewInternal << m_viewInternal->m_leftBorder << m_viewInternal->m_lineScroll << m_viewInternal->m_columnScroll; - foreach (const QWidget *w, widgets) { + for (const QWidget *w : widgets) { if (w->hasFocus()) opt.state |= QStyle::State_HasFocus; if (w->underMouse()) opt.state |= QStyle::State_MouseOver; } @@ -3619,10 +3619,10 @@ // cursor valid? else no new ranges can be found if (currentCursor.isValid() && currentCursor.line() < doc()->buffer().lines()) { // now: get current ranges for the line of cursor with an attribute - QList rangesForCurrentCursor = doc()->buffer().rangesForLine(currentCursor.line(), this, false); + const QList rangesForCurrentCursor = doc()->buffer().rangesForLine(currentCursor.line(), this, false); // match which ranges really fit the given cursor - foreach (Kate::TextRange *range, rangesForCurrentCursor) { + for (Kate::TextRange *range : rangesForCurrentCursor) { // range has no dynamic attribute of right type and no feedback object if ((!range->attribute() || !range->attribute()->dynamicAttribute(activationType)) && !range->feedback()) { continue; @@ -3672,7 +3672,7 @@ } // now: notify for left ranges! - foreach (Kate::TextRange *range, validRanges) { + for (Kate::TextRange *range : qAsConst(validRanges)) { // range valid + right dynamic attribute, trigger update if (range->toRange().isValid() && range->attribute() && range->attribute()->dynamicAttribute(activationType)) { notifyAboutRangeChange(range->start().line(), range->end().line(), true); diff --git a/src/view/kateviewhelpers.cpp b/src/view/kateviewhelpers.cpp --- a/src/view/kateviewhelpers.cpp +++ b/src/view/kateviewhelpers.cpp @@ -2723,7 +2723,7 @@ actions << tmp; } std::sort(actions.begin(), actions.end(), lessThanAction); - foreach (KSelectAction *action, actions) { + for (KSelectAction *action : qAsConst(actions)) { q->addAction(action); } } diff --git a/src/view/kateviewinternal.cpp b/src/view/kateviewinternal.cpp --- a/src/view/kateviewinternal.cpp +++ b/src/view/kateviewinternal.cpp @@ -154,8 +154,8 @@ , m_textHintPos(-1, -1) , m_imPreeditRange(nullptr) { - QList factories = KTextEditor::EditorPrivate::self()->inputModeFactories(); - Q_FOREACH(KateAbstractInputModeFactory *factory, factories) { + const QList factories = KTextEditor::EditorPrivate::self()->inputModeFactories(); + for (KateAbstractInputModeFactory *factory : factories) { KateAbstractInputMode *m = factory->createInputMode(this); m_inputModes.insert(m->viewInputMode(), m); } @@ -3199,7 +3199,7 @@ if (!textHints.isEmpty()) { qCDebug(LOG_KTE) << "Hint text: " << textHints; QString hint; - foreach(const QString & str, textHints) { + for (const QString &str : qAsConst(textHints)) { hint += QStringLiteral("

%1

").arg(str); } QPoint pos(startX() + m_textHintPos.x(), m_textHintPos.y()); @@ -3892,7 +3892,7 @@ const int line = coordinatesToCursor(mapFromGlobal(globalPos)).line(); const auto inlineNotes = view()->inlineNotes(line); // loop over all notes and check if the point is inside it - foreach (const auto& note, inlineNotes) { + for (const auto& note : inlineNotes) { auto globalNoteRect = inlineNoteRect(note); if (globalNoteRect.contains(globalPos)) { return note; diff --git a/src/vimode/appcommands.cpp b/src/vimode/appcommands.cpp --- a/src/vimode/appcommands.cpp +++ b/src/vimode/appcommands.cpp @@ -396,7 +396,7 @@ // string argument: switch to the given file KTextEditor::Document *doc = nullptr; - Q_FOREACH(KTextEditor::Document *it, docs) { + for (KTextEditor::Document *it : docs) { if (it->documentName() == address) { doc = it; break; @@ -411,7 +411,7 @@ void BufferCommands::prevBuffer(KTextEditor::View *view) { - QList docs = documents(); + const QList docs = documents(); const int idx = docs.indexOf(view->document()); if (idx > 0) { diff --git a/src/vimode/commandrangeexpressionparser.cpp b/src/vimode/commandrangeexpressionparser.cpp --- a/src/vimode/commandrangeexpressionparser.cpp +++ b/src/vimode/commandrangeexpressionparser.cpp @@ -134,10 +134,10 @@ { int pos = 0; QList operators_list; - QStringList split = string.split(RE_CalculatePositionSplit()); + const QStringList split = string.split(RE_CalculatePositionSplit()); QList values; - Q_FOREACH (const QString &line, split) { + for (const QString &line : split) { pos += line.size(); if (pos < string.size()) { diff --git a/src/vimode/config/configtab.cpp b/src/vimode/config/configtab.cpp --- a/src/vimode/config/configtab.cpp +++ b/src/vimode/config/configtab.cpp @@ -93,11 +93,11 @@ void ConfigTab::reloadTab(QTableWidget *mappingsTable, Mappings::MappingMode mode) { - const QStringList &l = m_mappings->getAll(mode); + const QStringList l = m_mappings->getAll(mode); mappingsTable->setRowCount(l.size()); int i = 0; - foreach (const QString &f, l) { + for (const QString &f : l) { QTableWidgetItem *from = new QTableWidgetItem(KeyParser::self()->decodeKeySequence(f)); QString s = m_mappings->get(mode, f); QTableWidgetItem *to = new QTableWidgetItem(KeyParser::self()->decodeKeySequence(s)); @@ -195,8 +195,8 @@ } // And remove the selected rows. - QList l = mappingsTable->selectedRanges(); - foreach (const QTableWidgetSelectionRange &range, l) { + const QList l = mappingsTable->selectedRanges(); + for (const QTableWidgetSelectionRange &range : l) { for (int i = 0; i < range.bottomRow() - range.topRow() + 1; i++) { mappingsTable->removeRow(range.topRow()); } diff --git a/src/vimode/emulatedcommandbar/commandmode.cpp b/src/vimode/emulatedcommandbar/commandmode.cpp --- a/src/vimode/emulatedcommandbar/commandmode.cpp +++ b/src/vimode/emulatedcommandbar/commandmode.cpp @@ -60,7 +60,7 @@ cmds.push_back(cmd); } - Q_FOREACH (KTextEditor::Command *cmd, cmds) { + for (KTextEditor::Command *cmd : qAsConst(cmds)) { QStringList l = cmd->cmds(); for (int z = 0; z < l.count(); z++) { diff --git a/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp b/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp --- a/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp +++ b/src/vimode/emulatedcommandbar/emulatedcommandbar.cpp @@ -388,13 +388,11 @@ void EmulatedCommandBar::hideAllWidgetsExcept(QWidget* widgetToKeepVisible) { - QList widgets = centralWidget()->findChildren(); - foreach(QWidget* widget, widgets) - { + const QList widgets = centralWidget()->findChildren(); + for (QWidget *widget : widgets) { if (widget != widgetToKeepVisible) widget->hide(); } - } void EmulatedCommandBar::createAndAddBarTypeIndicator(QLayout* layout) diff --git a/src/vimode/emulatedcommandbar/searchmode.cpp b/src/vimode/emulatedcommandbar/searchmode.cpp --- a/src/vimode/emulatedcommandbar/searchmode.cpp +++ b/src/vimode/emulatedcommandbar/searchmode.cpp @@ -151,7 +151,7 @@ int previousNonMatchingClosedCurlyPos = 0; // i.e. the position of the last character which is either // not a curly closing bracket, or is a curly closing bracket // that is not matched. - foreach (int matchingClosedCurlyPos, matchingClosedCurlyBracketPositions) { + for (int matchingClosedCurlyPos : qAsConst(matchingClosedCurlyBracketPositions)) { QString chunkExcludingMatchingCurlyClosed = qtRegexPattern.mid(previousNonMatchingClosedCurlyPos, matchingClosedCurlyPos - previousNonMatchingClosedCurlyPos); chunkExcludingMatchingCurlyClosed = toggledEscaped(chunkExcludingMatchingCurlyClosed, QLatin1Char('{')); chunkExcludingMatchingCurlyClosed = toggledEscaped(chunkExcludingMatchingCurlyClosed, QLatin1Char('}')); @@ -197,7 +197,7 @@ int previousNonMatchingSquareBracketPos = 0; // i.e. the position of the last character which is // either not a square bracket, or is a square bracket but // which is not matched. - foreach (int matchingSquareBracketPos, matchingSquareBracketPositions) { + for (int matchingSquareBracketPos : qAsConst(matchingSquareBracketPositions)) { QString chunkExcludingMatchingSquareBrackets = qtRegexPattern.mid(previousNonMatchingSquareBracketPos, matchingSquareBracketPos - previousNonMatchingSquareBracketPos); chunkExcludingMatchingSquareBrackets = ensuredCharEscaped(chunkExcludingMatchingSquareBrackets, QLatin1Char('[')); chunkExcludingMatchingSquareBrackets = ensuredCharEscaped(chunkExcludingMatchingSquareBrackets, QLatin1Char(']')); diff --git a/src/vimode/keyparser.cpp b/src/vimode/keyparser.cpp --- a/src/vimode/keyparser.cpp +++ b/src/vimode/keyparser.cpp @@ -550,7 +550,7 @@ } tokens << untilClosing.mid(currentPos); - foreach (const QString &str, tokens) { + for (const QString &str : qAsConst(tokens)) { if (str == QLatin1String("s-") && (keyCodeTemp & 0x01) != 0x1) { keyCodeTemp += 0x1; } else if (str == QLatin1String("c-") && (keyCodeTemp & 0x02) != 0x2) { diff --git a/src/vimode/macros.cpp b/src/vimode/macros.cpp --- a/src/vimode/macros.cpp +++ b/src/vimode/macros.cpp @@ -84,7 +84,7 @@ QList withoutClosingQ = macroKeyEventLog; Q_ASSERT(!macroKeyEventLog.isEmpty() && macroKeyEventLog.last().key() == Qt::Key_Q); withoutClosingQ.pop_back(); - foreach (const QKeyEvent &keyEvent, withoutClosingQ) { + for (const QKeyEvent &keyEvent : qAsConst(withoutClosingQ)) { const QChar key = KeyParser::self()->KeyEventToQChar(keyEvent); m_macros[reg].append(key); } diff --git a/src/vimode/modes/modebase.cpp b/src/vimode/modes/modebase.cpp --- a/src/vimode/modes/modebase.cpp +++ b/src/vimode/modes/modebase.cpp @@ -1264,7 +1264,7 @@ } } } else { - foreach (KTextEditor::ViewPrivate *view, visible_views) { + for (KTextEditor::ViewPrivate *view : qAsConst(visible_views)) { QPoint point = view->mapToGlobal(view->pos()); int x1 = point.x(); int x2 = point.x() + view->width(); diff --git a/src/vimode/searcher.cpp b/src/vimode/searcher.cpp --- a/src/vimode/searcher.cpp +++ b/src/vimode/searcher.cpp @@ -184,7 +184,7 @@ std::sort(matchesUnfiltered.begin(), matchesUnfiltered.end()); QVector filteredMatches; - foreach (KTextEditor::Range unfilteredMatch, matchesUnfiltered) { + for (KTextEditor::Range unfilteredMatch : qAsConst(matchesUnfiltered)) { if (unfilteredMatch.start() < searchBegin) { filteredMatches.append(unfilteredMatch); }