forked from qt-creator/qt-creator
macros: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: Id779aaf869406571288519083883ab57e5c29cec Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -116,13 +116,13 @@ void AutotoolsBuildSystem::makefileParsingFinished()
|
|||||||
const QFileInfo fileInfo = projectFilePath().toFileInfo();
|
const QFileInfo fileInfo = projectFilePath().toFileInfo();
|
||||||
const QDir dir = fileInfo.absoluteDir();
|
const QDir dir = fileInfo.absoluteDir();
|
||||||
const QStringList files = m_makefileParserThread->sources();
|
const QStringList files = m_makefileParserThread->sources();
|
||||||
foreach (const QString& file, files)
|
for (const QString& file : files)
|
||||||
m_files.append(dir.absoluteFilePath(file));
|
m_files.append(dir.absoluteFilePath(file));
|
||||||
|
|
||||||
// Watch for changes of Makefile.am files. If a Makefile.am file
|
// Watch for changes of Makefile.am files. If a Makefile.am file
|
||||||
// has been changed, the project tree must be reparsed.
|
// has been changed, the project tree must be reparsed.
|
||||||
const QStringList makefiles = m_makefileParserThread->makefiles();
|
const QStringList makefiles = m_makefileParserThread->makefiles();
|
||||||
foreach (const QString &makefile, makefiles) {
|
for (const QString &makefile : makefiles) {
|
||||||
const QString absMakefile = dir.absoluteFilePath(makefile);
|
const QString absMakefile = dir.absoluteFilePath(makefile);
|
||||||
|
|
||||||
m_files.append(absMakefile);
|
m_files.append(absMakefile);
|
||||||
@@ -161,7 +161,7 @@ static QStringList filterIncludes(const QString &absSrc, const QString &absBuild
|
|||||||
const QStringList &in)
|
const QStringList &in)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
foreach (const QString i, in) {
|
for (const QString &i : in) {
|
||||||
QString out = i;
|
QString out = i;
|
||||||
out.replace(QLatin1String("$(top_srcdir)"), absSrc);
|
out.replace(QLatin1String("$(top_srcdir)"), absSrc);
|
||||||
out.replace(QLatin1String("$(abs_top_srcdir)"), absSrc);
|
out.replace(QLatin1String("$(abs_top_srcdir)"), absSrc);
|
||||||
|
@@ -905,7 +905,7 @@ void BinEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
int item_x = -xoffset + m_margin + c * m_columnWidth + m_labelWidth;
|
int item_x = -xoffset + m_margin + c * m_columnWidth + m_labelWidth;
|
||||||
|
|
||||||
QColor color;
|
QColor color;
|
||||||
foreach (const Markup &m, m_markup) {
|
for (const Markup &m : qAsConst(m_markup)) {
|
||||||
if (m.covers(lineAddress + c)) {
|
if (m.covers(lineAddress + c)) {
|
||||||
color = m.color;
|
color = m.color;
|
||||||
break;
|
break;
|
||||||
@@ -1236,7 +1236,7 @@ QString BinEditorWidget::toolTip(const QHelpEvent *helpEvent) const
|
|||||||
str << "<html><head/><body><p align=\"center\"><b>"
|
str << "<html><head/><body><p align=\"center\"><b>"
|
||||||
<< tr("Memory at 0x%1").arg(address, 0, 16) << "</b></p>";
|
<< tr("Memory at 0x%1").arg(address, 0, 16) << "</b></p>";
|
||||||
|
|
||||||
foreach (const Markup &m, m_markup) {
|
for (const Markup &m : qAsConst(m_markup)) {
|
||||||
if (m.covers(address) && !m.toolTip.isEmpty()) {
|
if (m.covers(address) && !m.toolTip.isEmpty()) {
|
||||||
str << "<p>" << m.toolTip << "</p><br>";
|
str << "<p>" << m.toolTip << "</p><br>";
|
||||||
break;
|
break;
|
||||||
|
@@ -43,7 +43,7 @@ namespace Internal {
|
|||||||
QSet<SymbolLocation> roleToLocations(const QList<QVariant> &locationsVar)
|
QSet<SymbolLocation> roleToLocations(const QList<QVariant> &locationsVar)
|
||||||
{
|
{
|
||||||
QSet<SymbolLocation> locations;
|
QSet<SymbolLocation> locations;
|
||||||
foreach (const QVariant &loc, locationsVar) {
|
for (const QVariant &loc : locationsVar) {
|
||||||
if (loc.canConvert<SymbolLocation>())
|
if (loc.canConvert<SymbolLocation>())
|
||||||
locations.insert(loc.value<SymbolLocation>());
|
locations.insert(loc.value<SymbolLocation>());
|
||||||
}
|
}
|
||||||
|
@@ -77,9 +77,9 @@ void ActivitySelector::userChanged()
|
|||||||
bool ActivitySelector::refresh()
|
bool ActivitySelector::refresh()
|
||||||
{
|
{
|
||||||
int current;
|
int current;
|
||||||
QList<QStringPair> activities = ClearCasePlugin::activities(¤t);
|
const QList<QStringPair> activities = ClearCasePlugin::activities(¤t);
|
||||||
m_cmbActivity->clear();
|
m_cmbActivity->clear();
|
||||||
foreach (const QStringPair &activity, activities)
|
for (const QStringPair &activity : activities)
|
||||||
m_cmbActivity->addItem(activity.second, activity.first);
|
m_cmbActivity->addItem(activity.second, activity.first);
|
||||||
m_cmbActivity->setCurrentIndex(current);
|
m_cmbActivity->setCurrentIndex(current);
|
||||||
m_cmbActivity->updateGeometry();
|
m_cmbActivity->updateGeometry();
|
||||||
|
@@ -88,7 +88,8 @@ void ClearCaseSettings::fromSettings(QSettings *settings)
|
|||||||
indexOnlyVOBs = settings->value(QLatin1String(indexOnlyVOBsC), QString()).toString();
|
indexOnlyVOBs = settings->value(QLatin1String(indexOnlyVOBsC), QString()).toString();
|
||||||
extDiffAvailable = !Utils::Environment::systemEnvironment().searchInPath(QLatin1String("diff")).isEmpty();
|
extDiffAvailable = !Utils::Environment::systemEnvironment().searchInPath(QLatin1String("diff")).isEmpty();
|
||||||
settings->beginGroup(QLatin1String(totalFilesKeyC));
|
settings->beginGroup(QLatin1String(totalFilesKeyC));
|
||||||
foreach (const QString &view, settings->childKeys())
|
const QStringList views = settings->childKeys();
|
||||||
|
for (const QString &view : views)
|
||||||
totalFiles[view] = settings->value(view).toInt();
|
totalFiles[view] = settings->value(view).toInt();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
@@ -53,8 +53,8 @@ ActionMacroHandler::ActionMacroHandler()
|
|||||||
this, &ActionMacroHandler::addCommand);
|
this, &ActionMacroHandler::addCommand);
|
||||||
|
|
||||||
// Register all existing scriptable actions
|
// Register all existing scriptable actions
|
||||||
QList<Command *> commands = ActionManager::commands();
|
const QList<Command *> commands = ActionManager::commands();
|
||||||
foreach (Command *command, commands) {
|
for (Command *command : commands) {
|
||||||
if (command->isScriptable())
|
if (command->isScriptable())
|
||||||
registerCommand(command->id());
|
registerCommand(command->id());
|
||||||
}
|
}
|
||||||
|
@@ -143,7 +143,7 @@ bool Macro::save(const QString &fileName, QWidget *parent)
|
|||||||
QDataStream stream(saver.file());
|
QDataStream stream(saver.file());
|
||||||
stream << d->version;
|
stream << d->version;
|
||||||
stream << d->description;
|
stream << d->description;
|
||||||
foreach (const MacroEvent &event, d->events) {
|
for (const MacroEvent &event : qAsConst(d->events)) {
|
||||||
event.save(stream);
|
event.save(stream);
|
||||||
}
|
}
|
||||||
saver.setResult(&stream);
|
saver.setResult(&stream);
|
||||||
|
@@ -131,9 +131,9 @@ void MacroManagerPrivate::initialize()
|
|||||||
const QDir dir(MacroManager::macrosDirectory());
|
const QDir dir(MacroManager::macrosDirectory());
|
||||||
QStringList filter;
|
QStringList filter;
|
||||||
filter << QLatin1String("*.") + QLatin1String(Constants::M_EXTENSION);
|
filter << QLatin1String("*.") + QLatin1String(Constants::M_EXTENSION);
|
||||||
QStringList files = dir.entryList(filter, QDir::Files);
|
const QStringList files = dir.entryList(filter, QDir::Files);
|
||||||
|
|
||||||
foreach (const QString &name, files) {
|
for (const QString &name : files) {
|
||||||
QString fileName = dir.absolutePath() + QLatin1Char('/') + name;
|
QString fileName = dir.absolutePath() + QLatin1Char('/') + name;
|
||||||
auto macro = new Macro;
|
auto macro = new Macro;
|
||||||
if (macro->loadHeader(fileName))
|
if (macro->loadHeader(fileName))
|
||||||
@@ -196,10 +196,11 @@ void MacroManagerPrivate::changeMacroDescription(Macro *macro, const QString &de
|
|||||||
bool MacroManagerPrivate::executeMacro(Macro *macro)
|
bool MacroManagerPrivate::executeMacro(Macro *macro)
|
||||||
{
|
{
|
||||||
bool error = !macro->load();
|
bool error = !macro->load();
|
||||||
foreach (const MacroEvent ¯oEvent, macro->events()) {
|
const QList<MacroEvent> macroEvents = macro->events();
|
||||||
|
for (const MacroEvent ¯oEvent : macroEvents) {
|
||||||
if (error)
|
if (error)
|
||||||
break;
|
break;
|
||||||
foreach (IMacroHandler *handler, handlers) {
|
for (IMacroHandler *handler : qAsConst(handlers)) {
|
||||||
if (handler->canExecuteEvent(macroEvent)) {
|
if (handler->canExecuteEvent(macroEvent)) {
|
||||||
if (!handler->executeEvent(macroEvent))
|
if (!handler->executeEvent(macroEvent))
|
||||||
error = true;
|
error = true;
|
||||||
@@ -255,8 +256,8 @@ MacroManager::MacroManager() :
|
|||||||
MacroManager::~MacroManager()
|
MacroManager::~MacroManager()
|
||||||
{
|
{
|
||||||
// Cleanup macro
|
// Cleanup macro
|
||||||
QStringList macroList = d->macros.keys();
|
const QStringList macroList = d->macros.keys();
|
||||||
foreach (const QString &name, macroList)
|
for (const QString &name : macroList)
|
||||||
d->removeMacro(name);
|
d->removeMacro(name);
|
||||||
|
|
||||||
// Cleanup handlers
|
// Cleanup handlers
|
||||||
@@ -277,7 +278,7 @@ void MacroManager::startMacro()
|
|||||||
Core::ActionManager::command(Constants::END_MACRO)->action()->setEnabled(true);
|
Core::ActionManager::command(Constants::END_MACRO)->action()->setEnabled(true);
|
||||||
Core::ActionManager::command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(false);
|
Core::ActionManager::command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(false);
|
||||||
Core::ActionManager::command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(false);
|
Core::ActionManager::command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(false);
|
||||||
foreach (IMacroHandler *handler, d->handlers)
|
for (IMacroHandler *handler : qAsConst(d->handlers))
|
||||||
handler->startRecording(d->currentMacro);
|
handler->startRecording(d->currentMacro);
|
||||||
|
|
||||||
const QString endShortcut = Core::ActionManager::command(Constants::END_MACRO)
|
const QString endShortcut = Core::ActionManager::command(Constants::END_MACRO)
|
||||||
@@ -302,7 +303,7 @@ void MacroManager::endMacro()
|
|||||||
Core::ActionManager::command(Constants::END_MACRO)->action()->setEnabled(false);
|
Core::ActionManager::command(Constants::END_MACRO)->action()->setEnabled(false);
|
||||||
Core::ActionManager::command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(true);
|
Core::ActionManager::command(Constants::EXECUTE_LAST_MACRO)->action()->setEnabled(true);
|
||||||
Core::ActionManager::command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(true);
|
Core::ActionManager::command(Constants::SAVE_LAST_MACRO)->action()->setEnabled(true);
|
||||||
foreach (IMacroHandler *handler, d->handlers)
|
for (IMacroHandler *handler : qAsConst(d->handlers))
|
||||||
handler->endRecordingMacro(d->currentMacro);
|
handler->endRecordingMacro(d->currentMacro);
|
||||||
|
|
||||||
d->isRecording = false;
|
d->isRecording = false;
|
||||||
|
@@ -130,7 +130,7 @@ void MacroOptionsWidget::remove()
|
|||||||
void MacroOptionsWidget::apply()
|
void MacroOptionsWidget::apply()
|
||||||
{
|
{
|
||||||
// Remove macro
|
// Remove macro
|
||||||
foreach (const QString &name, m_macroToRemove) {
|
for (const QString &name : qAsConst(m_macroToRemove)) {
|
||||||
MacroManager::instance()->deleteMacro(name);
|
MacroManager::instance()->deleteMacro(name);
|
||||||
m_macroToChange.remove(name);
|
m_macroToChange.remove(name);
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,7 @@ void CommitEditor::setFields(const QFileInfo &repositoryRoot, const QString &bra
|
|||||||
|
|
||||||
QStringList shouldTrack;
|
QStringList shouldTrack;
|
||||||
|
|
||||||
foreach (const VcsBaseClient::StatusItem &item, repoStatus) {
|
for (const VcsBaseClient::StatusItem &item : repoStatus) {
|
||||||
if (item.flags == QLatin1String("Untracked"))
|
if (item.flags == QLatin1String("Untracked"))
|
||||||
shouldTrack.append(item.file);
|
shouldTrack.append(item.file);
|
||||||
else
|
else
|
||||||
@@ -71,8 +71,8 @@ void CommitEditor::setFields(const QFileInfo &repositoryRoot, const QString &bra
|
|||||||
|
|
||||||
VcsBaseSubmitEditor::filterUntrackedFilesOfProject(fileModel->repositoryRoot(), &shouldTrack);
|
VcsBaseSubmitEditor::filterUntrackedFilesOfProject(fileModel->repositoryRoot(), &shouldTrack);
|
||||||
|
|
||||||
foreach (const QString &track, shouldTrack) {
|
for (const QString &track : qAsConst(shouldTrack)) {
|
||||||
foreach (const VcsBaseClient::StatusItem &item, repoStatus) {
|
for (const VcsBaseClient::StatusItem &item : repoStatus) {
|
||||||
if (item.file == track)
|
if (item.file == track)
|
||||||
fileModel->addFile(item.file, item.flags, Unchecked);
|
fileModel->addFile(item.file, item.flags, Unchecked);
|
||||||
}
|
}
|
||||||
|
@@ -104,7 +104,7 @@ bool MercurialClient::manifestSync(const FilePath &repository, const QString &re
|
|||||||
const QFileInfo needle = QFileInfo(repositoryDir, relativeFilename);
|
const QFileInfo needle = QFileInfo(repositoryDir, relativeFilename);
|
||||||
|
|
||||||
const QStringList files = proc.stdOut().split(QLatin1Char('\n'));
|
const QStringList files = proc.stdOut().split(QLatin1Char('\n'));
|
||||||
foreach (const QString &fileName, files) {
|
for (const QString &fileName : files) {
|
||||||
const QFileInfo managedFile(repositoryDir, fileName);
|
const QFileInfo managedFile(repositoryDir, fileName);
|
||||||
if (needle == managedFile)
|
if (needle == managedFile)
|
||||||
return true;
|
return true;
|
||||||
|
@@ -732,7 +732,7 @@ void MercurialPluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
|
|||||||
revertFile->setParameter(filename);
|
revertFile->setParameter(filename);
|
||||||
statusFile->setParameter(filename);
|
statusFile->setParameter(filename);
|
||||||
|
|
||||||
foreach (QAction *repoAction, m_repositoryActionList)
|
for (QAction *repoAction : qAsConst(m_repositoryActionList))
|
||||||
repoAction->setEnabled(repoEnabled);
|
repoAction->setEnabled(repoEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -724,7 +724,8 @@ void PerforcePluginPrivate::printOpenedFileList()
|
|||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
QString mapped;
|
QString mapped;
|
||||||
const QChar delimiter = QLatin1Char('#');
|
const QChar delimiter = QLatin1Char('#');
|
||||||
foreach (const QString &line, perforceResponse.stdOut.split(QLatin1Char('\n'))) {
|
const QStringList lines = perforceResponse.stdOut.split(QLatin1Char('\n'));
|
||||||
|
for (const QString &line : lines) {
|
||||||
mapped.clear();
|
mapped.clear();
|
||||||
const int delimiterPos = line.indexOf(delimiter);
|
const int delimiterPos = line.indexOf(delimiter);
|
||||||
if (delimiterPos > 0)
|
if (delimiterPos > 0)
|
||||||
@@ -787,9 +788,9 @@ void PerforcePluginPrivate::startSubmitProject()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList filesLines = filesResult.stdOut.split(QLatin1Char('\n'));
|
const QStringList filesLines = filesResult.stdOut.split(QLatin1Char('\n'));
|
||||||
QStringList depotFileNames;
|
QStringList depotFileNames;
|
||||||
foreach (const QString &line, filesLines) {
|
for (const QString &line : filesLines) {
|
||||||
depotFileNames.append(line.left(line.lastIndexOf(QRegularExpression("#[0-9]+\\s-\\s"))));
|
depotFileNames.append(line.left(line.lastIndexOf(QRegularExpression("#[0-9]+\\s-\\s"))));
|
||||||
}
|
}
|
||||||
if (depotFileNames.isEmpty()) {
|
if (depotFileNames.isEmpty()) {
|
||||||
|
@@ -125,7 +125,7 @@ void PerforceSubmitEditor::updateFields()
|
|||||||
|
|
||||||
lines = m_entries.value(QLatin1String("Files")).split(newLine);
|
lines = m_entries.value(QLatin1String("Files")).split(newLine);
|
||||||
// split up "file#add" and store complete spec line as user data
|
// split up "file#add" and store complete spec line as user data
|
||||||
foreach (const QString &specLine, lines) {
|
for (const QString &specLine : qAsConst(lines)) {
|
||||||
const QStringList list = specLine.split(QLatin1Char('#'));
|
const QStringList list = specLine.split(QLatin1Char('#'));
|
||||||
if (list.size() == 2) {
|
if (list.size() == 2) {
|
||||||
const QString file = list.at(0).trimmed();
|
const QString file = list.at(0).trimmed();
|
||||||
|
Reference in New Issue
Block a user