uic: eradicate all Q_FOREACH loops [non-generated code]

... by replacing them with C++11 range-for loops, or, in one case,
qDeleteAll().

Change-Id: If6980f6c12ac1d359a1f0e062dcc2a86e9685d1e
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
Marc Mutz 2016-01-25 14:14:08 +01:00
parent bc9645064a
commit 3d9ccce7d5
2 changed files with 10 additions and 10 deletions

View File

@ -2221,8 +2221,8 @@ QList<WriteInitialization::Item *> WriteInitialization::initializeTreeWidgetItem
// AbstractFromBuilder saves flags last, so they always end up in the last column's map.
addQtFlagsInitializer(item, map, QLatin1String("flags"));
QList<Item *> subItems = initializeTreeWidgetItems(domItem->elementItem());
foreach (Item *subItem, subItems)
const QList<Item *> subItems = initializeTreeWidgetItems(domItem->elementItem());
for (Item *subItem : subItems)
item->addChild(subItem);
}
return items;
@ -2465,7 +2465,7 @@ void WriteInitialization::acceptWidgetScripts(const DomScripts &widgetScripts, D
// concatenate script snippets
QString script;
foreach (const DomScript *domScript, scripts) {
for (const DomScript *domScript : qAsConst(scripts)) {
const QString snippet = domScript->text();
if (!snippet.isEmpty()) {
script += snippet.trimmed();
@ -2479,9 +2479,8 @@ void WriteInitialization::acceptWidgetScripts(const DomScripts &widgetScripts, D
m_output << m_indent << "childWidgets.clear();\n";
if (!childWidgets.empty()) {
m_output << m_indent << "childWidgets";
foreach (DomWidget *child, childWidgets) {
for (DomWidget *child : childWidgets)
m_output << " << " << m_driver->findOrInsertWidget(child);
}
m_output << ";\n";
}
m_output << m_indent << "scriptContext.run("
@ -2529,8 +2528,7 @@ WriteInitialization::Item::Item(const QString &itemClassName, const QString &ind
WriteInitialization::Item::~Item()
{
foreach (Item *child, m_children)
delete child;
qDeleteAll(m_children);
}
QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::EmptyItemPolicy emptyItemPolicy)
@ -2567,7 +2565,7 @@ QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::Emp
closeIfndef(m_setupUiStream, it.key());
++it;
}
foreach (Item *child, m_children)
for (Item *child : qAsConst(m_children))
child->writeSetupUi(uniqueName);
return uniqueName;
}

View File

@ -85,7 +85,8 @@ bool Uic::printDependencies()
}
if (DomIncludes *includes = ui->elementIncludes()) {
foreach (DomInclude *incl, includes->elementInclude()) {
const auto incls = includes->elementInclude();
for (DomInclude *incl : incls) {
QString file = incl->text();
if (file.isEmpty())
continue;
@ -95,7 +96,8 @@ bool Uic::printDependencies()
}
if (DomCustomWidgets *customWidgets = ui->elementCustomWidgets()) {
foreach (DomCustomWidget *customWidget, customWidgets->elementCustomWidget()) {
const auto elementCustomWidget = customWidgets->elementCustomWidget();
for (DomCustomWidget *customWidget : elementCustomWidget) {
if (DomHeader *header = customWidget->elementHeader()) {
QString file = header->text();
if (file.isEmpty())