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>
This commit is contained in:
parent
257cc69bed
commit
d09cfe04b8
@ -127,10 +127,10 @@ void DropArea::clear()
|
|||||||
|
|
||||||
QPixmap DropArea::extractPixmap(const QByteArray &data, const QString &format)
|
QPixmap DropArea::extractPixmap(const QByteArray &data, const QString &format)
|
||||||
{
|
{
|
||||||
QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
|
const QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
|
|
||||||
foreach (const QByteArray &imageFormat, imageFormats) {
|
for (const QByteArray &imageFormat : imageFormats) {
|
||||||
if (format.mid(6) == QString(imageFormat)) {
|
if (format.mid(6) == QString(imageFormat)) {
|
||||||
pixmap.loadFromData(data, imageFormat);
|
pixmap.loadFromData(data, imageFormat);
|
||||||
break;
|
break;
|
||||||
|
@ -412,12 +412,12 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
// a massive amount of file stat (especially if the icon is not there)
|
// a massive amount of file stat (especially if the icon is not there)
|
||||||
auto cache = theme.m_gtkCaches.at(i);
|
auto cache = theme.m_gtkCaches.at(i);
|
||||||
if (cache->isValid()) {
|
if (cache->isValid()) {
|
||||||
auto result = cache->lookup(iconNameFallback);
|
const auto result = cache->lookup(iconNameFallback);
|
||||||
if (cache->isValid()) {
|
if (cache->isValid()) {
|
||||||
const QVector<QIconDirInfo> subDirsCopy = subDirs;
|
const QVector<QIconDirInfo> subDirsCopy = subDirs;
|
||||||
subDirs.clear();
|
subDirs.clear();
|
||||||
subDirs.reserve(result.count());
|
subDirs.reserve(result.count());
|
||||||
foreach (const char *s, result) {
|
for (const char *s : result) {
|
||||||
QString path = QString::fromUtf8(s);
|
QString path = QString::fromUtf8(s);
|
||||||
auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(),
|
auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(),
|
||||||
[&](const QIconDirInfo &info) {
|
[&](const QIconDirInfo &info) {
|
||||||
|
@ -1008,7 +1008,7 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
|
|||||||
QScreen *windowScreen = Q_NULLPTR;
|
QScreen *windowScreen = Q_NULLPTR;
|
||||||
|
|
||||||
// Find the window on the primary virtual desktop first
|
// Find the window on the primary virtual desktop first
|
||||||
foreach (QScreen *screen, primaryScreens) {
|
for (QScreen *screen : primaryScreens) {
|
||||||
if (screen->geometry().contains(pos)) {
|
if (screen->geometry().contains(pos)) {
|
||||||
windowScreen = screen;
|
windowScreen = screen;
|
||||||
break;
|
break;
|
||||||
|
@ -454,7 +454,7 @@ QVector<T> fromNativePixels(const QVector<T> &pixelValues, const QWindow *window
|
|||||||
return pixelValues;
|
return pixelValues;
|
||||||
|
|
||||||
QVector<T> pointValues;
|
QVector<T> pointValues;
|
||||||
foreach (const T& pixelValue, pixelValues)
|
for (const T &pixelValue : pixelValues)
|
||||||
pointValues.append(pixelValue / QHighDpiScaling::factor(window));
|
pointValues.append(pixelValue / QHighDpiScaling::factor(window));
|
||||||
return pointValues;
|
return pointValues;
|
||||||
}
|
}
|
||||||
@ -467,7 +467,7 @@ QVector<T> toNativePixels(const QVector<T> &pointValues, const QWindow *window)
|
|||||||
return pointValues;
|
return pointValues;
|
||||||
|
|
||||||
QVector<T> pixelValues;
|
QVector<T> pixelValues;
|
||||||
foreach (const T& pointValue, pointValues)
|
for (const T &pointValue : pointValues)
|
||||||
pixelValues.append(pointValue * QHighDpiScaling::factor(window));
|
pixelValues.append(pointValue * QHighDpiScaling::factor(window));
|
||||||
return pixelValues;
|
return pixelValues;
|
||||||
}
|
}
|
||||||
|
@ -1565,9 +1565,9 @@ QList<QKeySequence> QKeySequence::listFromString(const QString &str, SequenceFor
|
|||||||
{
|
{
|
||||||
QList<QKeySequence> result;
|
QList<QKeySequence> result;
|
||||||
|
|
||||||
QStringList strings = str.split(QLatin1String("; "));
|
const QStringList strings = str.split(QLatin1String("; "));
|
||||||
result.reserve(strings.count());
|
result.reserve(strings.count());
|
||||||
foreach (const QString &string, strings) {
|
for (const QString &string : strings) {
|
||||||
result << fromString(string, format);
|
result << fromString(string, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1586,7 +1586,7 @@ QString QKeySequence::listToString(const QList<QKeySequence> &list, SequenceForm
|
|||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
foreach (const QKeySequence &sequence, list) {
|
for (const QKeySequence &sequence : list) {
|
||||||
result += sequence.toString(format);
|
result += sequence.toString(format);
|
||||||
result += QLatin1String("; ");
|
result += QLatin1String("; ");
|
||||||
}
|
}
|
||||||
|
@ -554,10 +554,11 @@ static inline const QScreen *effectiveScreen(const QWindow *window)
|
|||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
if (siblings.size() > 1) {
|
if (siblings.size() > 1) {
|
||||||
const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos();
|
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))
|
if (sibling->geometry().contains(referencePoint))
|
||||||
return sibling;
|
return sibling;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
@ -364,10 +364,10 @@ QRect QScreen::availableGeometry() const
|
|||||||
QList<QScreen *> QScreen::virtualSiblings() const
|
QList<QScreen *> QScreen::virtualSiblings() const
|
||||||
{
|
{
|
||||||
Q_D(const QScreen);
|
Q_D(const QScreen);
|
||||||
QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
|
const QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
|
||||||
QList<QScreen *> screens;
|
QList<QScreen *> screens;
|
||||||
screens.reserve(platformScreens.count());
|
screens.reserve(platformScreens.count());
|
||||||
foreach (QPlatformScreen *platformScreen, platformScreens)
|
for (QPlatformScreen *platformScreen : platformScreens)
|
||||||
screens << platformScreen->screen();
|
screens << platformScreen->screen();
|
||||||
return screens;
|
return screens;
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ QList<QWindowSystemInterface::TouchPoint>
|
|||||||
{
|
{
|
||||||
QList<QWindowSystemInterface::TouchPoint> newList;
|
QList<QWindowSystemInterface::TouchPoint> newList;
|
||||||
newList.reserve(pointList.size());
|
newList.reserve(pointList.size());
|
||||||
foreach (const QTouchEvent::TouchPoint &pt, pointList) {
|
for (const QTouchEvent::TouchPoint &pt : pointList) {
|
||||||
QWindowSystemInterface::TouchPoint p;
|
QWindowSystemInterface::TouchPoint p;
|
||||||
p.id = pt.id();
|
p.id = pt.id();
|
||||||
p.flags = pt.flags();
|
p.flags = pt.flags();
|
||||||
@ -928,7 +928,7 @@ static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QLi
|
|||||||
{
|
{
|
||||||
QList<struct QWindowSystemInterface::TouchPoint> newList;
|
QList<struct QWindowSystemInterface::TouchPoint> newList;
|
||||||
|
|
||||||
Q_FOREACH (QTouchEvent::TouchPoint p, pointList)
|
for (const QTouchEvent::TouchPoint &p : pointList)
|
||||||
newList.append(touchPoint(p));
|
newList.append(touchPoint(p));
|
||||||
|
|
||||||
return newList;
|
return newList;
|
||||||
|
@ -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);
|
const QSet<QString> features = QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu::fromContext(), filename);
|
||||||
std::set<QByteArray> *result = new std::set<QByteArray>;
|
std::set<QByteArray> *result = new std::set<QByteArray>;
|
||||||
foreach (const QString &feature, features)
|
for (const QString &feature : features)
|
||||||
result->insert(feature.toUtf8());
|
result->insert(feature.toUtf8());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1156,7 +1156,7 @@ QVector<GLuint> QOpenGLFramebufferObject::textures() const
|
|||||||
if (d->format.samples() != 0)
|
if (d->format.samples() != 0)
|
||||||
return ids;
|
return ids;
|
||||||
ids.reserve(d->colorAttachments.count());
|
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);
|
ids.append(color.guard ? color.guard->id() : 0);
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
@ -1240,7 +1240,7 @@ QVector<QSize> QOpenGLFramebufferObject::sizes() const
|
|||||||
Q_D(const QOpenGLFramebufferObject);
|
Q_D(const QOpenGLFramebufferObject);
|
||||||
QVector<QSize> sz;
|
QVector<QSize> sz;
|
||||||
sz.reserve(d->colorAttachments.size());
|
sz.reserve(d->colorAttachments.size());
|
||||||
foreach (const QOpenGLFramebufferObjectPrivate::ColorAttachment &color, d->colorAttachments)
|
for (const auto &color : d->colorAttachments)
|
||||||
sz.append(color.size);
|
sz.append(color.size);
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
@ -728,7 +728,7 @@ QOpenGLShaderProgramPrivate::~QOpenGLShaderProgramPrivate()
|
|||||||
|
|
||||||
bool QOpenGLShaderProgramPrivate::hasShader(QOpenGLShader::ShaderType type) const
|
bool QOpenGLShaderProgramPrivate::hasShader(QOpenGLShader::ShaderType type) const
|
||||||
{
|
{
|
||||||
foreach (QOpenGLShader *shader, shaders) {
|
for (QOpenGLShader *shader : shaders) {
|
||||||
if (shader->shaderType() == type)
|
if (shader->shaderType() == type)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ static QRegion deviceRegion(const QRegion ®ion, QWindow *window, const QPoint
|
|||||||
QVector<QRect> rects;
|
QVector<QRect> rects;
|
||||||
const QVector<QRect> regionRects = region.rects();
|
const QVector<QRect> regionRects = region.rects();
|
||||||
rects.reserve(regionRects.count());
|
rects.reserve(regionRects.count());
|
||||||
foreach (const QRect &rect, regionRects)
|
for (const QRect &rect : regionRects)
|
||||||
rects.append(deviceRect(rect.translated(offset), window));
|
rects.append(deviceRect(rect.translated(offset), window));
|
||||||
|
|
||||||
QRegion deviceRegion;
|
QRegion deviceRegion;
|
||||||
|
@ -1831,7 +1831,7 @@ void QFont::insertSubstitutions(const QString &familyName,
|
|||||||
QFontSubst *fontSubst = globalFontSubst();
|
QFontSubst *fontSubst = globalFontSubst();
|
||||||
Q_ASSERT(fontSubst != 0);
|
Q_ASSERT(fontSubst != 0);
|
||||||
QStringList &list = (*fontSubst)[familyName.toLower()];
|
QStringList &list = (*fontSubst)[familyName.toLower()];
|
||||||
foreach (const QString &substituteName, substituteNames) {
|
for (const QString &substituteName : substituteNames) {
|
||||||
const QString lowerSubstituteName = substituteName.toLower();
|
const QString lowerSubstituteName = substituteName.toLower();
|
||||||
if (!list.contains(lowerSubstituteName))
|
if (!list.contains(lowerSubstituteName))
|
||||||
list.append(lowerSubstituteName);
|
list.append(lowerSubstituteName);
|
||||||
|
@ -3341,7 +3341,7 @@ void QTextEngine::drawItemDecorationList(QPainter *painter, const ItemDecoration
|
|||||||
if (decorationList.isEmpty())
|
if (decorationList.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (const ItemDecoration &decoration, decorationList) {
|
for (const ItemDecoration &decoration : decorationList) {
|
||||||
painter->setPen(decoration.pen);
|
painter->setPen(decoration.pen);
|
||||||
painter->drawLine(QLineF(decoration.x1, decoration.y, decoration.x2, decoration.y));
|
painter->drawLine(QLineF(decoration.x1, decoration.y, decoration.x2, decoration.y));
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ void QTextOption::setTabArray(const QList<qreal> &tabStops)
|
|||||||
QList<QTextOption::Tab> tabs;
|
QList<QTextOption::Tab> tabs;
|
||||||
QTextOption::Tab tab;
|
QTextOption::Tab tab;
|
||||||
tabs.reserve(tabStops.count());
|
tabs.reserve(tabStops.count());
|
||||||
foreach (qreal pos, tabStops) {
|
for (qreal pos : tabStops) {
|
||||||
tab.position = pos;
|
tab.position = pos;
|
||||||
tabs.append(tab);
|
tabs.append(tab);
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1022,7 @@ bool QZipReader::extractAll(const QString &destinationDir) const
|
|||||||
|
|
||||||
// create directories first
|
// create directories first
|
||||||
const QVector<FileInfo> allFiles = fileInfoList();
|
const QVector<FileInfo> allFiles = fileInfoList();
|
||||||
foreach (const FileInfo &fi, allFiles) {
|
for (const FileInfo &fi : allFiles) {
|
||||||
const QString absPath = destinationDir + QDir::separator() + fi.filePath;
|
const QString absPath = destinationDir + QDir::separator() + fi.filePath;
|
||||||
if (fi.isDir) {
|
if (fi.isDir) {
|
||||||
if (!baseDir.mkpath(fi.filePath))
|
if (!baseDir.mkpath(fi.filePath))
|
||||||
@ -1033,7 +1033,7 @@ bool QZipReader::extractAll(const QString &destinationDir) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set up symlinks
|
// set up symlinks
|
||||||
foreach (const FileInfo &fi, allFiles) {
|
for (const FileInfo &fi : allFiles) {
|
||||||
const QString absPath = destinationDir + QDir::separator() + fi.filePath;
|
const QString absPath = destinationDir + QDir::separator() + fi.filePath;
|
||||||
if (fi.isSymLink) {
|
if (fi.isSymLink) {
|
||||||
QString destination = QFile::decodeName(fileData(fi.filePath));
|
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;
|
const QString absPath = destinationDir + QDir::separator() + fi.filePath;
|
||||||
if (fi.isFile) {
|
if (fi.isFile) {
|
||||||
QFile f(absPath);
|
QFile f(absPath);
|
||||||
|
Loading…
Reference in New Issue
Block a user