diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-01-26 14:38:54 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-02-11 23:18:44 +0000 |
commit | 10742cf8949497b83b87133ed66ec119cb3ab08f (patch) | |
tree | 7cd1f26379840d1768d86851725465cde06455c9 /src | |
parent | 37a933c2b14a4a1aad54af0eba0bc210ae5b549a (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentfragment.cpp | 9 |
3 files changed, 9 insertions, 5 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 9b64c32533..e4d7ad8fcd 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -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); + } } } diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index c1bba59140..0c7e0e5816 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -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); } diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index 9325f78ba0..f8f4e454e0 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -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); |