diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp index 135ffa2494..83a9343a6a 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp @@ -101,7 +101,8 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices() // check for input devices if (m_types & Device_InputMask) { dir.setPath(QString::fromLatin1(QT_EVDEV_DEVICE_PATH)); - foreach (const QString &deviceFile, dir.entryList()) { + const auto deviceFiles = dir.entryList(); + for (const QString &deviceFile : deviceFiles) { QString absoluteFilePath = dir.absolutePath() + QLatin1Char('/') + deviceFile; if (checkDeviceType(absoluteFilePath)) devices << absoluteFilePath; @@ -111,7 +112,8 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices() // check for drm devices if (m_types & Device_VideoMask) { dir.setPath(QString::fromLatin1(QT_DRM_DEVICE_PATH)); - foreach (const QString &deviceFile, dir.entryList()) { + const auto deviceFiles = dir.entryList(); + for (const QString &deviceFile : deviceFiles) { QString absoluteFilePath = dir.absolutePath() + QLatin1Char('/') + deviceFile; if (checkDeviceType(absoluteFilePath)) devices << absoluteFilePath; diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp index 01de2a59b2..216f2722a4 100644 --- a/src/platformsupport/fbconvenience/qfbscreen.cpp +++ b/src/platformsupport/fbconvenience/qfbscreen.cpp @@ -138,15 +138,16 @@ void QFbScreen::lower(QFbWindow *window) QWindow *QFbScreen::topWindow() const { - foreach (QFbWindow *fbw, mWindowStack) + for (QFbWindow *fbw : mWindowStack) { if (fbw->window()->type() == Qt::Window || fbw->window()->type() == Qt::Dialog) return fbw->window(); + } return 0; } QWindow *QFbScreen::topLevelAt(const QPoint & p) const { - foreach (QFbWindow *fbw, mWindowStack) { + for (QFbWindow *fbw : mWindowStack) { if (fbw->geometry().contains(p, false) && fbw->window()->isVisible()) return fbw->window(); } diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp index 4b9d4690f3..60ddc9fa23 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp @@ -77,7 +77,8 @@ void QBasicFontDatabase::populateFontDatabase() << QLatin1String("*.pfb") << QLatin1String("*.otf"); - foreach (const QFileInfo &fi, dir.entryInfoList(nameFilters, QDir::Files)) { + const auto fis = dir.entryInfoList(nameFilters, QDir::Files); + for (const QFileInfo &fi : fis) { const QByteArray file = QFile::encodeName(fi.absoluteFilePath()); QBasicFontDatabase::addTTFile(QByteArray(), file); } diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp index ad5908dcc7..7574f9f9e6 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp @@ -50,7 +50,7 @@ QFontEngineMultiFontConfig::QFontEngineMultiFontConfig(QFontEngine *fe, int scri QFontEngineMultiFontConfig::~QFontEngineMultiFontConfig() { - Q_FOREACH (FcPattern *pattern, cachedMatchPatterns) { + for (FcPattern *pattern : qAsConst(cachedMatchPatterns)) { if (pattern) FcPatternDestroy(pattern); } diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 6b73134c8b..16d65caf86 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -183,7 +183,7 @@ QCoreTextFontDatabase::QCoreTextFontDatabase(bool useFreeType) QCoreTextFontDatabase::~QCoreTextFontDatabase() { - foreach (CTFontDescriptorRef ref, m_systemFontDescriptors) + for (CTFontDescriptorRef ref : qAsConst(m_systemFontDescriptors)) CFRelease(ref); } @@ -877,7 +877,7 @@ void QCoreTextFontDatabase::removeApplicationFonts() if (m_applicationFonts.isEmpty()) return; - foreach (const QVariant &font, m_applicationFonts) { + for (const QVariant &font : qAsConst(m_applicationFonts)) { CFErrorRef error; if (font.canConvert(qMetaTypeId >())) { CTFontManagerUnregisterGraphicsFont(font.value >(), &error); diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp index ffe9f82325..94ebae8f42 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -84,10 +84,9 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString & m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Keyboard, this); if (m_deviceDiscovery) { // scan and add already connected keyboards - QStringList devices = m_deviceDiscovery->scanConnectedDevices(); - foreach (const QString &device, devices) { + const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); + for (const QString &device : devices) addKeyboard(device); - } connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addKeyboard(QString))); connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeKeyboard(QString))); diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp index 129654c99b..2d96691b09 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp @@ -90,10 +90,9 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse | QDeviceDiscovery::Device_Touchpad, this); if (m_deviceDiscovery) { // scan and add already connected keyboards - QStringList devices = m_deviceDiscovery->scanConnectedDevices(); - foreach (const QString &device, devices) { + const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); + for (const QString &device : devices) addMouse(device); - } connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addMouse(QString))); connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeMouse(QString))); diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp index 00a8c7a65d..89a60df98d 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp @@ -85,8 +85,8 @@ QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &spec qCDebug(qLcEvdevTablet) << "evdevtablet: Using device discovery"; m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this); if (m_deviceDiscovery) { - QStringList devices = m_deviceDiscovery->scanConnectedDevices(); - foreach (const QString &device, devices) + const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); + for (const QString &device : devices) addDevice(device); connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString))); connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString))); diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp index 2de0816ef5..d0c6c10224 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp @@ -85,8 +85,8 @@ QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specif qCDebug(qLcEvdevTouch) << "evdevtouch: Using device discovery"; m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Touchpad | QDeviceDiscovery::Device_Touchscreen, this); if (m_deviceDiscovery) { - QStringList devices = m_deviceDiscovery->scanConnectedDevices(); - foreach (const QString &device, devices) + const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); + for (const QString &device : devices) addDevice(device); connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString))); connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString))); diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index a5001f6e80..296c282a47 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -368,7 +368,7 @@ void QKdeThemePrivate::refresh() QVariant QKdeThemePrivate::readKdeSetting(const QString &key, const QStringList &kdeDirs, int kdeVersion, QHash &kdeSettings) { - foreach (const QString &kdeDir, kdeDirs) { + for (const QString &kdeDir : kdeDirs) { QSettings *settings = kdeSettings.value(kdeDir); if (!settings) { const QString kdeGlobalsPath = kdeGlobals(kdeDir, kdeVersion); @@ -501,7 +501,7 @@ QStringList QKdeThemePrivate::kdeIconThemeSearchPaths(const QStringList &kdeDirs { QStringList paths = QGenericUnixTheme::xdgIconThemePaths(); const QString iconPath = QStringLiteral("/share/icons"); - foreach (const QString &candidate, kdeDirs) { + for (const QString &candidate : kdeDirs) { const QFileInfo fi(candidate + iconPath); if (fi.isDir()) paths.append(fi.absoluteFilePath()); @@ -798,8 +798,8 @@ QStringList QGenericUnixTheme::themeNames() << "MATE" << "XFCE" << "LXDE"; - QList desktopNames = desktopEnvironment.split(':'); - Q_FOREACH (const QByteArray &desktopName, desktopNames) { + const QList desktopNames = desktopEnvironment.split(':'); + for (const QByteArray &desktopName : desktopNames) { if (desktopEnvironment == "KDE") { #ifndef QT_NO_SETTINGS result.push_back(QLatin1String(QKdeTheme::name));