From cdfc62b2878772655b4ab3ba71df379ba3f15f0b Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 28 May 2020 07:46:41 +0200 Subject: FakeVim: Modernize a bit Some ranged-for and const. Change-Id: I6ff521393166aa4c61289de88e8c31320887b1b4 Reviewed-by: Lukas Holecek Reviewed-by: Christian Stenger --- src/plugins/fakevim/fakevimhandler.cpp | 20 ++++++++++---------- src/plugins/fakevim/fakevimplugin.cpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 542c558cf7..d6c79c175e 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -1595,7 +1595,7 @@ public: bool walk(const Inputs &inputs) { - foreach (const Input &input, inputs) { + for (const Input &input : inputs) { if (!walk(input)) return false; } @@ -1633,7 +1633,7 @@ public: void setInputs(const Inputs &key, const Inputs &inputs, bool unique = false) { ModeMapping *current = &(*m_parent)[m_mode]; - foreach (const Input &input, key) + for (const Input &input : key) current = &(*current)[input]; if (!unique || current->value().isEmpty()) current->setValue(inputs); @@ -2855,7 +2855,7 @@ void FakeVimHandler::Private::prependMapping(const Inputs &inputs) // FIXME: Implement Vim option maxmapdepth (default value is 1000). if (g.mapDepth >= 1000) { const int i = qMax(0, g.pendingInput.lastIndexOf(Input())); - QList inputs = g.pendingInput.mid(i); + const QList inputs = g.pendingInput.mid(i); clearPendingInput(); g.pendingInput.append(inputs); showMessage(MessageError, Tr::tr("Recursive mapping")); @@ -5740,7 +5740,7 @@ bool FakeVimHandler::Private::handleExRegisterCommand(const ExCommand &cmd) } QString info; info += "--- Registers ---\n"; - foreach (char reg, regs) { + for (char reg : qAsConst(regs)) { QString value = quoteUnprintable(registerContents(reg)); info += QString("\"%1 %2\n").arg(reg).arg(value); } @@ -6689,7 +6689,7 @@ void FakeVimHandler::Private::setupCharClass() m_charClass[i] = c.isSpace() ? 0 : 1; } const QString conf = config(ConfigIsKeyword).toString(); - foreach (const QString &part, conf.split(',')) { + for (const QString &part : conf.split(',')) { if (part.contains('-')) { const int from = someInt(part.section('-', 0, 0)); const int to = someInt(part.section('-', 1, 1)); @@ -7182,7 +7182,7 @@ void FakeVimHandler::Private::insertText(QTextCursor &tc, const QString &text) passEventToEditor(event, tc); } - foreach (QChar c, text) { + for (QChar c : text) { QKeyEvent event(QEvent::KeyPress, -1, Qt::NoModifier, QString(c)); passEventToEditor(event, tc); } @@ -8134,9 +8134,9 @@ void FakeVimHandler::Private::replay(const QString &command, int repeat) //qDebug() << "REPLAY: " << quoteUnprintable(command); clearCurrentMode(); - Inputs inputs(command); + const Inputs inputs(command); for (int i = 0; i < repeat; ++i) { - foreach (const Input &in, inputs) { + for (const Input &in : inputs) { if (handleDefaultKey(in) != EventHandled) return; } @@ -8765,9 +8765,9 @@ void FakeVimHandler::handleReplay(const QString &keys) void FakeVimHandler::handleInput(const QString &keys) { - Inputs inputs(keys); + const Inputs inputs(keys); d->enterFakeVim(); - foreach (const Input &input, inputs) + for (const Input &input : inputs) d->handleKey(input); d->leaveFakeVim(); } diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index b0a0e9c9c6..77f4e753c6 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -1409,7 +1409,7 @@ void FakeVimPluginPrivate::moveSomewhere(FakeVimHandler *handler, DistFunction f while (repeat < 0 || repeat-- > 0) { editors.removeOne(currentEditor); int bestValue = -1; - foreach (IEditor *editor, editors) { + for (IEditor *editor : qAsConst(editors)) { QWidget *w = editor->widget(); QRect editorRect(w->mapToGlobal(w->geometry().topLeft()), w->mapToGlobal(w->geometry().bottomRight())); @@ -1441,7 +1441,7 @@ void FakeVimPluginPrivate::keepOnlyWindow() QList editors = EditorManager::visibleEditors(); editors.removeOne(currentEditor); - foreach (IEditor *editor, editors) { + for (IEditor *editor : qAsConst(editors)) { EditorManager::activateEditor(editor); triggerAction(Core::Constants::REMOVE_CURRENT_SPLIT); } -- cgit v1.2.1