diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() - +add_definitions(-DQT_NO_FOREACH) add_subdirectory(src) diff --git a/src/kcmultidialog.cpp b/src/kcmultidialog.cpp --- a/src/kcmultidialog.cpp +++ b/src/kcmultidialog.cpp @@ -380,7 +380,7 @@ Q_Q(KCMultiDialog); QStringList updatedComponents; - foreach (const CreatedModule &module, modules) { + for (const CreatedModule &module : qAsConst(modules)) { KCModuleProxy *proxy = module.kcm; if (proxy->changed()) { @@ -390,16 +390,16 @@ * of updated components. */ const QStringList componentNames = module.componentNames; - foreach (const QString &componentName, module.componentNames) { + for (const QString &componentName : componentNames) { if (!updatedComponents.contains(componentName)) { updatedComponents.append(componentName); } } } } // Send the configCommitted signal for every updated component. - foreach (const QString &name, updatedComponents) { + for (const QString &name : qAsConst(updatedComponents)) { emit q->configCommitted(name.toLatin1()); } @@ -458,7 +458,7 @@ * in other situations will lead to "module already loaded in Foo," while to the user * doesn't appear so(the dialog is hidden) */ - Q_FOREACH(auto &proxy, d->modules) { + for(auto &proxy : qAsConst(d->modules)) { proxy.kcm->deleteClient(); } } diff --git a/src/kpluginselector.cpp b/src/kpluginselector.cpp --- a/src/kpluginselector.cpp +++ b/src/kpluginselector.cpp @@ -206,7 +206,8 @@ void KPluginSelector::Private::DependenciesWidget::showDependencyDetails() { QString message = i18n("Automatic changes have been performed in order to satisfy plugin dependencies:\n"); - foreach (const QString &dependency, dependencyMap.keys()) { + const auto lstKeys = dependencyMap.keys(); + for (const QString &dependency : lstKeys) { if (dependencyMap[dependency].added) { message += i18n("\n %1 plugin has been automatically checked because of the dependency of %2 plugin", dependency, dependencyMap[dependency].pluginCausant); } else { @@ -448,7 +449,7 @@ { QList listToAdd; - foreach (const KPluginInfo &pluginInfo, pluginList) { + for (const KPluginInfo &pluginInfo : pluginList) { PluginEntry pluginEntry; pluginEntry.category = categoryName; pluginEntry.pluginInfo = pluginInfo; @@ -802,7 +803,7 @@ const QStringList emails = email.split(QLatin1Char(',')); if (authors.count() == emails.count()) { int i = 0; - foreach (const QString &author, authors) { + for (const QString &author : authors) { if (!author.isEmpty()) { aboutData.addAuthor(author, QString(), emails[i]); } @@ -837,7 +838,8 @@ // The first proxy is owned by the dialog itself QWidget *moduleProxyParentWidget = &configDialog; - foreach (const KService::Ptr &servicePtr, pluginInfo.kcmServices()) { + const auto lstServices = pluginInfo.kcmServices(); + for (const KService::Ptr &servicePtr : lstServices) { if (!servicePtr->noDisplay()) { KCModuleInfo moduleInfo(servicePtr); KCModuleProxy *currentModuleProxy = new KCModuleProxy(moduleInfo, moduleProxyParentWidget, pluginSelector_d->kcmArguments); @@ -893,15 +895,15 @@ configDialog.setLayout(layout); if (configDialog.exec() == QDialog::Accepted) { - foreach (KCModuleProxy *moduleProxy, moduleProxyList) { - QStringList parentComponents = moduleProxy->moduleInfo().service()->property(QStringLiteral("X-KDE-ParentComponents")).toStringList(); + for (KCModuleProxy *moduleProxy : qAsConst(moduleProxyList)) { + const QStringList parentComponents = moduleProxy->moduleInfo().service()->property(QStringLiteral("X-KDE-ParentComponents")).toStringList(); moduleProxy->save(); - foreach (const QString &parentComponent, parentComponents) { + for (const QString &parentComponent : parentComponents) { emit configCommitted(parentComponent.toLatin1()); } } } else { - foreach (KCModuleProxy *moduleProxy, moduleProxyList) { + for (KCModuleProxy *moduleProxy : qAsConst(moduleProxyList)) { moduleProxy->load(); } } @@ -913,7 +915,7 @@ void KPluginSelector::Private::PluginDelegate::slotDefaultClicked() { - foreach (KCModuleProxy *moduleProxy, moduleProxyList) { + for (KCModuleProxy *moduleProxy : qAsConst(moduleProxyList)) { moduleProxy->defaults(); } } diff --git a/src/ksettings/dialog.cpp b/src/ksettings/dialog.cpp --- a/src/ksettings/dialog.cpp +++ b/src/ksettings/dialog.cpp @@ -96,7 +96,8 @@ d->kcmInfos << KCModuleInfo(service); continue; } - foreach (const KService::Ptr &service, it->kcmServices()) { + const auto lst = it->kcmServices(); + for (const KService::Ptr &service : lst) { d->kcmInfos << KCModuleInfo(service); } } @@ -177,7 +178,7 @@ const QList services = KServiceTypeTrader::self()->query(QStringLiteral("KCModule"), constraint); QSet ret; ret.reserve(services.count()); - foreach (const KService::Ptr &service, services) { + for (const KService::Ptr &service : services) { ret << KCModuleInfo(service); } return ret; @@ -321,10 +322,10 @@ } //qDebug() << kcmInfos.count(); - foreach (const KCModuleInfo &info, kcmInfos) { + for (const KCModuleInfo &info : qAsConst(kcmInfos)) { const QStringList parentComponents = info.service()->property(QStringLiteral("X-KDE-ParentComponents")).toStringList(); bool blacklisted = false; - foreach (const QString &parentComponent, parentComponents) { + for (const QString &parentComponent : parentComponents) { if (componentBlacklist.contains(parentComponent)) { blacklisted = true; break; @@ -338,7 +339,7 @@ if (!parent) { // dummy kcm bool foundPlugin = false; - foreach (const KPluginInfo &pinfo, plugininfos) { + for (KPluginInfo pinfo : qAsConst(plugininfos)) { if (pinfo.service() == info.service()) { if (pinfo.kcmServices().isEmpty()) { const KService::Ptr service = info.service(); @@ -357,7 +358,7 @@ } KPageWidgetItem *item = q->addModule(info, parent, arguments); // qDebug() << "added KCM '" << info.moduleName() << "'"; - foreach (KPluginInfo pinfo, plugininfos) { + for (KPluginInfo pinfo : qAsConst(plugininfos)) { // qDebug() << pinfo.pluginName(); if (pinfo.kcmServices().contains(info.service())) { const bool isEnabled = isPluginForKCMEnabled(&info, pinfo); @@ -397,7 +398,7 @@ for (; it != end; ++it) { const QModelIndex index = model->index(it.value()); KPluginInfo pinfo; - foreach (const KPluginInfo &p, plugininfos) { + for (const KPluginInfo &p : qAsConst(plugininfos)) { if (p.name() == it.key()) { pinfo = p; break; diff --git a/src/ksettings/dispatcher.cpp b/src/ksettings/dispatcher.cpp --- a/src/ksettings/dispatcher.cpp +++ b/src/ksettings/dispatcher.cpp @@ -70,7 +70,8 @@ KSharedConfig::Ptr config = configForComponentName(componentName); config->reparseConfiguration(); - foreach (const ComponentInfo::Slot &slot, d()->m_componentInfo[componentName].slotList) { + const auto lstSlot = d()->m_componentInfo[componentName].slotList; + for (const ComponentInfo::Slot &slot : lstSlot) { QMetaObject::invokeMethod(slot.first, slot.second); } }