From 6e3fd69409849bc4803b104a7674139fa630eec5 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Fri, 15 Jan 2016 18:04:36 +0300 Subject: Replace foreach with range-based for Change-Id: Ieb9019b62696479a4e0317a590bceaeb30abf62c Reviewed-by: J-P Nurmi --- src/controls/Private/qquickcontrolsettings.cpp | 12 ++++++++---- src/controls/Private/qquicktreemodeladaptor.cpp | 4 ++-- src/controls/Styles/Android/qquickandroid9patch.cpp | 2 +- src/controls/qquickmenu.cpp | 3 ++- src/controls/qquickmenubar.cpp | 4 ++-- src/controls/qquickmenuitemcontainer_p.h | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src/controls') diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp index 8483830b..0f22f127 100644 --- a/src/controls/Private/qquickcontrolsettings.cpp +++ b/src/controls/Private/qquickcontrolsettings.cpp @@ -86,7 +86,8 @@ bool QQuickControlSettings::hasTouchScreen() const #if defined(Q_OS_ANDROID) return true; #else - foreach (const QTouchDevice *dev, QTouchDevice::devices()) + const auto devices = QTouchDevice::devices(); + for (const QTouchDevice *dev : devices) if (dev->type() == QTouchDevice::TouchScreen) return true; return false; @@ -146,7 +147,8 @@ static QString relativeStyleImportPath(QQmlEngine *engine, const QString &styleN { QString path; bool found = false; - foreach (const QString &import, engine->importPathList()) { + const auto importPathList = engine->importPathList(); + for (const QString &import : importPathList) { QDir dir(import + QStringLiteral("/QtQuick/Controls/Styles")); if (dir.exists(styleName)) { found = true; @@ -182,7 +184,8 @@ QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine) const QString defaultStyle = defaultStyleName(); dir.setPath(relativeStyleImportPath(engine, defaultStyle)); dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); - foreach (const QString &styleDirectory, dir.entryList()) { + const auto list = dir.entryList(); + for (const QString &styleDirectory : list) { findStyle(engine, styleDirectory); } @@ -259,7 +262,8 @@ void QQuickControlSettings::findStyle(QQmlEngine *engine, const QString &styleNa StyleData styleData; - foreach (const QString &fileName, dir.entryList()) { + const auto list = dir.entryList(); + for (const QString &fileName : list) { // This assumes that there is only one library in the style directory, // which should be a safe assumption. If at some point it's determined // not to be safe, we'll have to resolve the init and path functions diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp index 666fafc9..c357939a 100644 --- a/src/controls/Private/qquicktreemodeladaptor.cpp +++ b/src/controls/Private/qquicktreemodeladaptor.cpp @@ -314,7 +314,7 @@ QItemSelection QQuickTreeModelAdaptor::selectionForRowRange(const QModelIndex & QItemSelection sel; sel.reserve(ranges.count()); - foreach (const MIPair &pair, ranges) + for (const MIPair &pair : qAsConst(ranges)) sel.append(QItemSelectionRange(pair.first, pair.second)); return sel; @@ -587,7 +587,7 @@ void QQuickTreeModelAdaptor::modelLayoutChanged(const QListm_containers.insert(o, menuItemContainer); menuItemContainer->setParentMenu(menu); ++menu->m_containersCount; - foreach (QObject *child, o->children()) { + const auto children = o->children(); + for (QObject *child : children) { if (QQuickMenuBase *item = qobject_cast(child)) { menuItemContainer->insertItem(-1, item); menu->setupMenuItem(item); diff --git a/src/controls/qquickmenubar.cpp b/src/controls/qquickmenubar.cpp index efec6510..00cc32d3 100644 --- a/src/controls/qquickmenubar.cpp +++ b/src/controls/qquickmenubar.cpp @@ -101,13 +101,13 @@ void QQuickMenuBar::setNativeNoNotify(bool native) m_platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); if (m_platformMenuBar) { m_platformMenuBar->handleReparent(m_parentWindow); - foreach (QQuickMenu *menu, m_menus) + for (QQuickMenu *menu : qAsConst(m_menus)) m_platformMenuBar->insertMenu(menu->platformMenu(), 0 /* append */); } } } else { if (m_platformMenuBar) { - foreach (QQuickMenu *menu, m_menus) + for (QQuickMenu *menu : qAsConst(m_menus)) m_platformMenuBar->removeMenu(menu->platformMenu()); } delete m_platformMenuBar; diff --git a/src/controls/qquickmenuitemcontainer_p.h b/src/controls/qquickmenuitemcontainer_p.h index a69d219d..02786f51 100644 --- a/src/controls/qquickmenuitemcontainer_p.h +++ b/src/controls/qquickmenuitemcontainer_p.h @@ -59,7 +59,7 @@ public: void setParentMenu(QQuickMenu *parentMenu) { QQuickMenuBase::setParentMenu(parentMenu); - Q_FOREACH (QQuickMenuBase *item, m_menuItems) + for (QQuickMenuBase *item : qAsConst(m_menuItems)) item->setParentMenu(parentMenu); } -- cgit v1.2.1