forked from qt-creator/qt-creator
FakeVim: Replace foreach with ranged for loop
Change-Id: I0de9620ebf837be25e153bfd282b6564d4d2b115 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1002,7 +1002,7 @@ QDebug operator<<(QDebug ts, const ExCommand &cmd)
|
||||
|
||||
QDebug operator<<(QDebug ts, const QList<QTextEdit::ExtraSelection> &sels)
|
||||
{
|
||||
foreach (const QTextEdit::ExtraSelection &sel, sels)
|
||||
for (const QTextEdit::ExtraSelection &sel : sels)
|
||||
ts << "SEL: " << sel.cursor.anchor() << sel.cursor.position();
|
||||
return ts;
|
||||
}
|
||||
@@ -3049,7 +3049,7 @@ void FakeVimHandler::Private::clearPendingInput()
|
||||
void FakeVimHandler::Private::waitForMapping()
|
||||
{
|
||||
g.currentCommand.clear();
|
||||
foreach (const Input &input, g.currentMap.currentInputs())
|
||||
for (const Input &input : g.currentMap.currentInputs())
|
||||
g.currentCommand.append(input.toString());
|
||||
|
||||
// wait for user to press any key or trigger complete mapping after interval
|
||||
@@ -6070,13 +6070,13 @@ bool FakeVimHandler::Private::handleExMapCommand(const ExCommand &cmd0) // :map
|
||||
//qDebug() << "MAPPING: " << modes << lhs << rhs;
|
||||
switch (type) {
|
||||
case Unmap:
|
||||
foreach (char c, modes)
|
||||
for (char c : qAsConst(modes))
|
||||
MappingsIterator(&g.mappings, c, key).remove();
|
||||
break;
|
||||
case Map: Q_FALLTHROUGH();
|
||||
case Noremap: {
|
||||
Inputs inputs(rhs, type == Noremap, silent);
|
||||
foreach (char c, modes)
|
||||
const Inputs inputs(rhs, type == Noremap, silent);
|
||||
for (char c : qAsConst(modes))
|
||||
MappingsIterator(&g.mappings, c).setInputs(key, inputs, unique);
|
||||
break;
|
||||
}
|
||||
@@ -6094,7 +6094,7 @@ bool FakeVimHandler::Private::handleExHistoryCommand(const ExCommand &cmd)
|
||||
QString info;
|
||||
info += "# command history\n";
|
||||
int i = 0;
|
||||
foreach (const QString &item, g.commandBuffer.historyItems()) {
|
||||
for (const QString &item : g.commandBuffer.historyItems()) {
|
||||
++i;
|
||||
info += QString("%1 %2\n").arg(i, -8).arg(item);
|
||||
}
|
||||
|
@@ -689,7 +689,8 @@ void FakeVimExCommandsWidget::initialize()
|
||||
{
|
||||
QMap<QString, QTreeWidgetItem *> sections;
|
||||
|
||||
foreach (Command *c, ActionManager::commands()) {
|
||||
const QList<Command *> commands = ActionManager::commands();
|
||||
for (Command *c : commands) {
|
||||
if (c->action() && c->action()->isSeparator())
|
||||
continue;
|
||||
|
||||
@@ -1881,7 +1882,7 @@ void FakeVimPluginPrivate::documentRenamed(
|
||||
|
||||
void FakeVimPluginPrivate::renameFileNameInEditors(const FilePath &oldPath, const FilePath &newPath)
|
||||
{
|
||||
foreach (FakeVimHandler *handler, m_editorToHandler.values()) {
|
||||
for (FakeVimHandler *handler : m_editorToHandler) {
|
||||
if (handler->currentFileName() == oldPath.toString())
|
||||
handler->setCurrentFileName(newPath.toString());
|
||||
}
|
||||
@@ -1902,16 +1903,16 @@ void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
|
||||
//ICore *core = ICore::instance();
|
||||
//core->updateAdditionalContexts(Context(FAKEVIM_CONTEXT),
|
||||
// Context());
|
||||
foreach (IEditor *editor, m_editorToHandler.keys())
|
||||
m_editorToHandler[editor]->setupWidget();
|
||||
for (FakeVimHandler *handler : m_editorToHandler)
|
||||
handler->setupWidget();
|
||||
} else {
|
||||
//ICore *core = ICore::instance();
|
||||
//core->updateAdditionalContexts(Context(),
|
||||
// Context(FAKEVIM_CONTEXT));
|
||||
resetCommandBuffer();
|
||||
foreach (IEditor *editor, m_editorToHandler.keys()) {
|
||||
if (auto textDocument = qobject_cast<const TextDocument *>(editor->document()))
|
||||
m_editorToHandler[editor]->restoreWidget(textDocument->tabSettings().m_tabSize);
|
||||
for (auto it = m_editorToHandler.constBegin(); it != m_editorToHandler.constEnd(); ++it) {
|
||||
if (auto textDocument = qobject_cast<const TextDocument *>(it.key()->document()))
|
||||
it.value()->restoreWidget(textDocument->tabSettings().m_tabSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1919,8 +1920,8 @@ void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
|
||||
void FakeVimPluginPrivate::setShowRelativeLineNumbers(bool on)
|
||||
{
|
||||
if (on && fakeVimSettings()->useFakeVim.value()) {
|
||||
foreach (IEditor *editor, m_editorToHandler.keys())
|
||||
createRelativeNumberWidget(editor);
|
||||
for (auto it = m_editorToHandler.constBegin(); it != m_editorToHandler.constEnd(); ++it)
|
||||
createRelativeNumberWidget(it.key());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user