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