summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-01-26 14:38:54 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-11 23:18:35 +0000
commitd09cfe04b82c1bd0738bca24def1e9c3bfdaaa4b (patch)
tree3553f876e10d7a30e75c488ede82c4a09db8e03e /src/gui
parent257cc69bedebf924bcabf0ff24e237b8705260ad (diff)
QtGui: eradicate Q_FOREACH loops [already const]
(or trivially marked const) ... by replacing them with C++11 range-for loops. Change-Id: I3cce92b9d77a3ff96fad877d1d989145e530646f Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/doc/snippets/droparea.cpp4
-rw-r--r--src/gui/image/qiconloader.cpp4
-rw-r--r--src/gui/kernel/qguiapplication.cpp2
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h4
-rw-r--r--src/gui/kernel/qkeysequence.cpp6
-rw-r--r--src/gui/kernel/qplatformwindow.cpp3
-rw-r--r--src/gui/kernel/qscreen.cpp4
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp4
-rw-r--r--src/gui/opengl/qopengl.cpp2
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp4
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp2
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp2
-rw-r--r--src/gui/text/qfont.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp2
-rw-r--r--src/gui/text/qtextoption.cpp2
-rw-r--r--src/gui/text/qzip.cpp6
16 files changed, 27 insertions, 26 deletions
diff --git a/src/gui/doc/snippets/droparea.cpp b/src/gui/doc/snippets/droparea.cpp
index 13cf540d5e..ff77a1609e 100644
--- a/src/gui/doc/snippets/droparea.cpp
+++ b/src/gui/doc/snippets/droparea.cpp
@@ -127,10 +127,10 @@ void DropArea::clear()
QPixmap DropArea::extractPixmap(const QByteArray &data, const QString &format)
{
- QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
+ const QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
QPixmap pixmap;
- foreach (const QByteArray &imageFormat, imageFormats) {
+ for (const QByteArray &imageFormat : imageFormats) {
if (format.mid(6) == QString(imageFormat)) {
pixmap.loadFromData(data, imageFormat);
break;
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 8cc1dfa7d0..a600aa3299 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -412,12 +412,12 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
// a massive amount of file stat (especially if the icon is not there)
auto cache = theme.m_gtkCaches.at(i);
if (cache->isValid()) {
- auto result = cache->lookup(iconNameFallback);
+ const auto result = cache->lookup(iconNameFallback);
if (cache->isValid()) {
const QVector<QIconDirInfo> subDirsCopy = subDirs;
subDirs.clear();
subDirs.reserve(result.count());
- foreach (const char *s, result) {
+ for (const char *s : result) {
QString path = QString::fromUtf8(s);
auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(),
[&](const QIconDirInfo &info) {
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 46518e4701..632fe874a6 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1008,7 +1008,7 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
QScreen *windowScreen = Q_NULLPTR;
// Find the window on the primary virtual desktop first
- foreach (QScreen *screen, primaryScreens) {
+ for (QScreen *screen : primaryScreens) {
if (screen->geometry().contains(pos)) {
windowScreen = screen;
break;
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 8540460a54..50fb4d73ea 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -454,7 +454,7 @@ QVector<T> fromNativePixels(const QVector<T> &pixelValues, const QWindow *window
return pixelValues;
QVector<T> pointValues;
- foreach (const T& pixelValue, pixelValues)
+ for (const T &pixelValue : pixelValues)
pointValues.append(pixelValue / QHighDpiScaling::factor(window));
return pointValues;
}
@@ -467,7 +467,7 @@ QVector<T> toNativePixels(const QVector<T> &pointValues, const QWindow *window)
return pointValues;
QVector<T> pixelValues;
- foreach (const T& pointValue, pointValues)
+ for (const T &pointValue : pointValues)
pixelValues.append(pointValue * QHighDpiScaling::factor(window));
return pixelValues;
}
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index c23dbbb3be..8a6eeb4cc9 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1565,9 +1565,9 @@ QList<QKeySequence> QKeySequence::listFromString(const QString &str, SequenceFor
{
QList<QKeySequence> result;
- QStringList strings = str.split(QLatin1String("; "));
+ const QStringList strings = str.split(QLatin1String("; "));
result.reserve(strings.count());
- foreach (const QString &string, strings) {
+ for (const QString &string : strings) {
result << fromString(string, format);
}
@@ -1586,7 +1586,7 @@ QString QKeySequence::listToString(const QList<QKeySequence> &list, SequenceForm
{
QString result;
- foreach (const QKeySequence &sequence, list) {
+ for (const QKeySequence &sequence : list) {
result += sequence.toString(format);
result += QLatin1String("; ");
}
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index f5ddaa4bb7..abbd1fe999 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -554,9 +554,10 @@ static inline const QScreen *effectiveScreen(const QWindow *window)
#ifndef QT_NO_CURSOR
if (siblings.size() > 1) {
const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos();
- foreach (const QScreen *sibling, siblings)
+ for (const QScreen *sibling : siblings) {
if (sibling->geometry().contains(referencePoint))
return sibling;
+ }
}
#endif
return screen;
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index ae6879cf84..0e17b2d803 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -364,10 +364,10 @@ QRect QScreen::availableGeometry() const
QList<QScreen *> QScreen::virtualSiblings() const
{
Q_D(const QScreen);
- QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
+ const QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
QList<QScreen *> screens;
screens.reserve(platformScreens.count());
- foreach (QPlatformScreen *platformScreen, platformScreens)
+ for (QPlatformScreen *platformScreen : platformScreens)
screens << platformScreen->screen();
return screens;
}
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index d17c9c08a8..2489974bb3 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -504,7 +504,7 @@ QList<QWindowSystemInterface::TouchPoint>
{
QList<QWindowSystemInterface::TouchPoint> newList;
newList.reserve(pointList.size());
- foreach (const QTouchEvent::TouchPoint &pt, pointList) {
+ for (const QTouchEvent::TouchPoint &pt : pointList) {
QWindowSystemInterface::TouchPoint p;
p.id = pt.id();
p.flags = pt.flags();
@@ -928,7 +928,7 @@ static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QLi
{
QList<struct QWindowSystemInterface::TouchPoint> newList;
- Q_FOREACH (QTouchEvent::TouchPoint p, pointList)
+ for (const QTouchEvent::TouchPoint &p : pointList)
newList.append(touchPoint(p));
return newList;
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp
index eadca7cedf..35b1ec3bcf 100644
--- a/src/gui/opengl/qopengl.cpp
+++ b/src/gui/opengl/qopengl.cpp
@@ -548,7 +548,7 @@ Q_GUI_EXPORT std::set<QByteArray> *qgpu_features(const QString &filename)
{
const QSet<QString> features = QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu::fromContext(), filename);
std::set<QByteArray> *result = new std::set<QByteArray>;
- foreach (const QString &feature, features)
+ for (const QString &feature : features)
result->insert(feature.toUtf8());
return result;
}
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index e35db51e01..c1b2e10785 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -1156,7 +1156,7 @@ QVector<GLuint> QOpenGLFramebufferObject::textures() const
if (d->format.samples() != 0)
return ids;
ids.reserve(d->colorAttachments.count());
- foreach (const QOpenGLFramebufferObjectPrivate::ColorAttachment &color, d->colorAttachments)
+ for (const auto &color : d->colorAttachments)
ids.append(color.guard ? color.guard->id() : 0);
return ids;
}
@@ -1240,7 +1240,7 @@ QVector<QSize> QOpenGLFramebufferObject::sizes() const
Q_D(const QOpenGLFramebufferObject);
QVector<QSize> sz;
sz.reserve(d->colorAttachments.size());
- foreach (const QOpenGLFramebufferObjectPrivate::ColorAttachment &color, d->colorAttachments)
+ for (const auto &color : d->colorAttachments)
sz.append(color.size);
return sz;
}
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index afdb1133ea..1e0abbfab9 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -728,7 +728,7 @@ QOpenGLShaderProgramPrivate::~QOpenGLShaderProgramPrivate()
bool QOpenGLShaderProgramPrivate::hasShader(QOpenGLShader::ShaderType type) const
{
- foreach (QOpenGLShader *shader, shaders) {
+ for (QOpenGLShader *shader : shaders) {
if (shader->shaderType() == type)
return true;
}
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index d35f1d00d1..9a3bde3fa3 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -252,7 +252,7 @@ static QRegion deviceRegion(const QRegion &region, QWindow *window, const QPoint
QVector<QRect> rects;
const QVector<QRect> regionRects = region.rects();
rects.reserve(regionRects.count());
- foreach (const QRect &rect, regionRects)
+ for (const QRect &rect : regionRects)
rects.append(deviceRect(rect.translated(offset), window));
QRegion deviceRegion;
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 089104665f..898b268070 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1831,7 +1831,7 @@ void QFont::insertSubstitutions(const QString &familyName,
QFontSubst *fontSubst = globalFontSubst();
Q_ASSERT(fontSubst != 0);
QStringList &list = (*fontSubst)[familyName.toLower()];
- foreach (const QString &substituteName, substituteNames) {
+ for (const QString &substituteName : substituteNames) {
const QString lowerSubstituteName = substituteName.toLower();
if (!list.contains(lowerSubstituteName))
list.append(lowerSubstituteName);
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 81df8027a1..b15fc4c047 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -3341,7 +3341,7 @@ void QTextEngine::drawItemDecorationList(QPainter *painter, const ItemDecoration
if (decorationList.isEmpty())
return;
- foreach (const ItemDecoration &decoration, decorationList) {
+ for (const ItemDecoration &decoration : decorationList) {
painter->setPen(decoration.pen);
painter->drawLine(QLineF(decoration.x1, decoration.y, decoration.x2, decoration.y));
}
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp
index de466f7672..2eb025f412 100644
--- a/src/gui/text/qtextoption.cpp
+++ b/src/gui/text/qtextoption.cpp
@@ -153,7 +153,7 @@ void QTextOption::setTabArray(const QList<qreal> &tabStops)
QList<QTextOption::Tab> tabs;
QTextOption::Tab tab;
tabs.reserve(tabStops.count());
- foreach (qreal pos, tabStops) {
+ for (qreal pos : tabStops) {
tab.position = pos;
tabs.append(tab);
}
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index ca787d7136..4f43f73d41 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -1022,7 +1022,7 @@ bool QZipReader::extractAll(const QString &destinationDir) const
// create directories first
const QVector<FileInfo> allFiles = fileInfoList();
- foreach (const FileInfo &fi, allFiles) {
+ for (const FileInfo &fi : allFiles) {
const QString absPath = destinationDir + QDir::separator() + fi.filePath;
if (fi.isDir) {
if (!baseDir.mkpath(fi.filePath))
@@ -1033,7 +1033,7 @@ bool QZipReader::extractAll(const QString &destinationDir) const
}
// set up symlinks
- foreach (const FileInfo &fi, allFiles) {
+ for (const FileInfo &fi : allFiles) {
const QString absPath = destinationDir + QDir::separator() + fi.filePath;
if (fi.isSymLink) {
QString destination = QFile::decodeName(fileData(fi.filePath));
@@ -1051,7 +1051,7 @@ bool QZipReader::extractAll(const QString &destinationDir) const
}
}
- foreach (const FileInfo &fi, allFiles) {
+ for (const FileInfo &fi : allFiles) {
const QString absPath = destinationDir + QDir::separator() + fi.filePath;
if (fi.isFile) {
QFile f(absPath);