QtGui: eradicate Q_FOREACH loops [const-& returns]

... by replacing them with C++11 range-for loops.

The function QObject::children() returns by const-reference,
so they can be passed to range-for without further changes.

Change-Id: I8cd2921165c45020914dd3a23b1f18b519fe7900
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
Marc Mutz 2016-01-26 14:38:54 +01:00
parent 37a933c2b1
commit 10742cf894
3 changed files with 9 additions and 5 deletions

View File

@ -719,9 +719,10 @@ static void updateBlockedStatusRecursion(QWindow *window, bool shouldBeBlocked)
p->blockedByModalWindow = shouldBeBlocked;
QEvent e(shouldBeBlocked ? QEvent::WindowBlocked : QEvent::WindowUnblocked);
QGuiApplication::sendEvent(window, &e);
foreach (QObject *c, window->children())
for (QObject *c : window->children()) {
if (c->isWindowType())
updateBlockedStatusRecursion(static_cast<QWindow *>(c), shouldBeBlocked);
}
}
}

View File

@ -365,7 +365,7 @@ void QWindowPrivate::emitScreenChangedRecursion(QScreen *newScreen)
{
Q_Q(QWindow);
emit q->screenChanged(newScreen);
foreach (QObject *child, q->children()) {
for (QObject *child : q->children()) {
if (child->isWindowType())
static_cast<QWindow *>(child)->d_func()->emitScreenChangedRecursion(newScreen);
}

View File

@ -851,7 +851,7 @@ QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx)
int tableHeaderRowCount = 0;
QVector<int> rowNodes;
rowNodes.reserve(at(tableNodeIdx).children.count());
foreach (int row, at(tableNodeIdx).children)
for (int row : at(tableNodeIdx).children) {
switch (at(row).id) {
case Html_tr:
rowNodes += row;
@ -859,15 +859,17 @@ QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx)
case Html_thead:
case Html_tbody:
case Html_tfoot:
foreach (int potentialRow, at(row).children)
for (int potentialRow : at(row).children) {
if (at(potentialRow).id == Html_tr) {
rowNodes += potentialRow;
if (at(row).id == Html_thead)
++tableHeaderRowCount;
}
}
break;
default: break;
}
}
QVector<RowColSpanInfo> rowColSpans;
QVector<RowColSpanInfo> rowColSpanForColumn;
@ -876,7 +878,7 @@ QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx)
for (int row : qAsConst(rowNodes)) {
int colsInRow = 0;
foreach (int cell, at(row).children)
for (int cell : at(row).children) {
if (at(cell).isTableCell()) {
// skip all columns with spans from previous rows
while (colsInRow < rowColSpanForColumn.size()) {
@ -913,6 +915,7 @@ QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx)
rowColSpanForColumn[i] = spanInfo;
}
}
}
table.columns = qMax(table.columns, colsInRow);