diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ -DQT_NO_KEYWORDS) add_definitions(-DTRANSLATION_DOMAIN=\"kaccounts-integration\") +add_definitions(-DQT_NO_FOREACH) include(KDEInstallDirs) include(KDECMakeSettings) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -42,23 +42,23 @@ QStringList pluginPaths; - QStringList paths = QCoreApplication::libraryPaths(); - Q_FOREACH (const QString &libraryPath, paths) { + const QStringList paths = QCoreApplication::libraryPaths(); + for (const QString &libraryPath : paths) { QString path(libraryPath + QStringLiteral("/kaccounts/daemonplugins")); QDir dir(path); if (!dir.exists()) { continue; } - QStringList dirEntries = dir.entryList(QDir::Files | QDir::NoDotAndDotDot); + const QStringList dirEntries = dir.entryList(QDir::Files | QDir::NoDotAndDotDot); - Q_FOREACH(const QString &file, dirEntries) { + for (const QString &file : dirEntries) { pluginPaths.append(path + '/' + file); } } - Q_FOREACH (const QString &pluginPath, pluginPaths) { + for (const QString &pluginPath : qAsConst(pluginPaths)) { QPluginLoader loader(pluginPath); if (!loader.load()) { @@ -91,18 +91,18 @@ void AccountsDaemon::startDaemon() { qDebug(); - Accounts::AccountIdList accList = KAccounts::accountsManager()->accountList(); - Q_FOREACH(const Accounts::AccountId &id, accList) { + const Accounts::AccountIdList accList = KAccounts::accountsManager()->accountList(); + for (const Accounts::AccountId &id : accList) { monitorAccount(id); } } void AccountsDaemon::monitorAccount(const Accounts::AccountId id) { qDebug() << id; Accounts::Account *acc = KAccounts::accountsManager()->account(id); - Accounts::ServiceList services = acc->services(); - Q_FOREACH(const Accounts::Service &service, services) { + const Accounts::ServiceList services = acc->services(); + for (const Accounts::Service &service : services) { acc->selectService(service); } acc->selectService(); @@ -115,19 +115,19 @@ qDebug() << id; monitorAccount(id); - Accounts::Account *acc = KAccounts::accountsManager()->account(id); - Accounts::ServiceList services = acc->enabledServices(); + const Accounts::Account *acc = KAccounts::accountsManager()->account(id); + const Accounts::ServiceList services = acc->enabledServices(); - Q_FOREACH(KAccountsDPlugin *plugin, m_plugins) { + for (KAccountsDPlugin *plugin : qAsConst(m_plugins)) { plugin->onAccountCreated(id, services); } } void AccountsDaemon::accountRemoved(const Accounts::AccountId id) { qDebug() << id; - Q_FOREACH(KAccountsDPlugin *plugin, m_plugins) { + for (KAccountsDPlugin *plugin : qAsConst(m_plugins)) { plugin->onAccountRemoved(id); } } @@ -140,15 +140,15 @@ return; } - Accounts::AccountId accId = qobject_cast(sender())->id(); + const Accounts::AccountId accId = qobject_cast(sender())->id(); - Accounts::Service service = KAccounts::accountsManager()->service(serviceName); + const Accounts::Service service = KAccounts::accountsManager()->service(serviceName); if (!enabled) { - Q_FOREACH(KAccountsDPlugin *plugin, m_plugins) { + for (KAccountsDPlugin *plugin : qAsConst(m_plugins)) { plugin->onServiceDisabled(accId, service); } } else { - Q_FOREACH(KAccountsDPlugin *plugin, m_plugins) { + for (KAccountsDPlugin *plugin : qAsConst(m_plugins)) { plugin->onServiceEnabled(accId, service); } } diff --git a/src/daemon/kio-webdav/kioservices.cpp b/src/daemon/kio-webdav/kioservices.cpp --- a/src/daemon/kio-webdav/kioservices.cpp +++ b/src/daemon/kio-webdav/kioservices.cpp @@ -34,7 +34,7 @@ void KIOServices::onAccountCreated(const Accounts::AccountId accId, const Accounts::ServiceList &serviceList) { qDebug(); - Q_FOREACH(const Accounts::Service &service, serviceList) { + for (const Accounts::Service &service : serviceList) { if (service.serviceType() != QLatin1String("dav-storage")) { qDebug() << "Ignoring: " << service.serviceType(); continue; diff --git a/src/daemon/kio-webdav/removenetattachjob.cpp b/src/daemon/kio-webdav/removenetattachjob.cpp --- a/src/daemon/kio-webdav/removenetattachjob.cpp +++ b/src/daemon/kio-webdav/removenetattachjob.cpp @@ -92,8 +92,8 @@ walletUrl.append(":-1");//Overwrite the first option m_wallet->setFolder("Passwords"); - QStringList entries = m_wallet->entryList(); - Q_FOREACH(const QString &entry, entries) { + const QStringList entries = m_wallet->entryList(); + for (const QString &entry : entries) { if (!entry.startsWith(walletUrl)) { continue; } diff --git a/src/jobs/createaccount.cpp b/src/jobs/createaccount.cpp --- a/src/jobs/createaccount.cpp +++ b/src/jobs/createaccount.cpp @@ -126,7 +126,8 @@ info.setAccessControlList(QStringList(QLatin1String("*"))); info.setType(SignOn::IdentityInfo::Application); - Q_FOREACH (const QString &key, data.keys()) { + const auto keys = data.keys(); + for (const QString &key : keys) { // If a key with __service/ prefix exists and its value is false, // add it to m_disabledServices which will later be used for disabling // the services contained in that list @@ -203,8 +204,8 @@ } - Accounts::ServiceList services = m_account->services(); - Q_FOREACH(const Accounts::Service &service, services) { + const Accounts::ServiceList services = m_account->services(); + for (const Accounts::Service &service : services) { m_account->selectService(service); m_account->setEnabled(m_disabledServices.contains(service.name()) ? false : true); } diff --git a/src/lib/uipluginsmanager.cpp b/src/lib/uipluginsmanager.cpp --- a/src/lib/uipluginsmanager.cpp +++ b/src/lib/uipluginsmanager.cpp @@ -61,17 +61,17 @@ { QString pluginPath; - QStringList paths = QCoreApplication::libraryPaths(); - Q_FOREACH (const QString &libraryPath, paths) { + const QStringList paths = QCoreApplication::libraryPaths(); + for (const QString &libraryPath : paths) { QString path(libraryPath + QStringLiteral("/kaccounts/ui")); QDir dir(path); if (!dir.exists()) { continue; } - QStringList entryList = dir.entryList(QDir::Files | QDir::NoDotAndDotDot); - Q_FOREACH (const QString &fileName, entryList) { + const QStringList entryList = dir.entryList(QDir::Files | QDir::NoDotAndDotDot); + for (const QString &fileName : entryList) { QPluginLoader loader(dir.absoluteFilePath(fileName)); if (!loader.load()) { @@ -102,7 +102,8 @@ QObject::connect(ui, &KAccountsUiPlugin::uiReady, ui, &KAccountsUiPlugin::showNewAccountDialog, Qt::UniqueConnection); pluginsForNames.insert(fileName, ui); - Q_FOREACH (const QString &service, ui->supportedServicesForConfig()) { + const auto services = ui->supportedServicesForConfig(); + for (const QString &service : services) { qDebug() << " Adding service" << service; pluginsForServices.insert(service, ui); }