diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ add_definitions(-DTRANSLATION_DOMAIN=\"knewstuff5\") add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) +add_definitions(-DQT_NO_FOREACH) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() diff --git a/autotests/kmoretools/kmoretoolstest.cpp b/autotests/kmoretools/kmoretoolstest.cpp --- a/autotests/kmoretools/kmoretoolstest.cpp +++ b/autotests/kmoretools/kmoretoolstest.cpp @@ -199,7 +199,8 @@ bool menuAtLeastOneActionWithText(const QMenu* menu, const QString& text) { - Q_FOREACH(auto a, menu->actions()) + const auto lstActions = menu->actions(); + for (auto a : lstActions) { if (a->text() == text) { return true; @@ -211,7 +212,8 @@ bool menuAtLeastNoActionWithText(const QMenu* menu, const QString& text) { - Q_FOREACH(auto a, menu->actions()) + const auto lstActions = menu->actions(); + for (auto a : lstActions) { if (a->text() == text) { qDebug() << a->text(); diff --git a/autotests/kmoretools/kmoretoolstest2.cpp b/autotests/kmoretools/kmoretoolstest2.cpp --- a/autotests/kmoretools/kmoretoolstest2.cpp +++ b/autotests/kmoretools/kmoretoolstest2.cpp @@ -88,7 +88,8 @@ bool menuAtLeastOneActionWithText(const QMenu* menu, const QString& text) { - Q_FOREACH(auto a, menu->actions()) + const auto lstActions = menu->actions(); + for (auto a : lstActions) { if (a->text() == text) { return true; @@ -100,7 +101,8 @@ bool menuAtLeastNoActionWithText(const QMenu* menu, const QString& text) { - Q_FOREACH(auto a, menu->actions()) + const auto lstActions = menu->actions(); + for (auto a : lstActions) { if (a->text() == text) { qDebug() << a->text(); diff --git a/src/attica/atticaprovider.cpp b/src/attica/atticaprovider.cpp --- a/src/attica/atticaprovider.cpp +++ b/src/attica/atticaprovider.cpp @@ -42,7 +42,7 @@ , mInitialized(false) { // init categories map with invalid categories - foreach (const QString &category, categories) { + for (const QString &category : categories) { mCategoryMap.insert(category, Attica::Category()); } @@ -56,7 +56,7 @@ , mInitialized(false) { // init categories map with invalid categories - foreach (const QString &category, categories) { + for (const QString &category : categories) { mCategoryMap.insert(category, Attica::Category()); } providerLoaded(provider); @@ -122,10 +122,10 @@ qCDebug(KNEWSTUFFCORE) << "loading categories: " << mCategoryMap.keys(); Attica::ListJob *job = static_cast*>(listJob); - Category::List categoryList = job->itemList(); + const Category::List categoryList = job->itemList(); QList categoryMetadataList; - foreach (const Category &category, categoryList) { + for (const Category &category : categoryList) { if (mCategoryMap.contains(category.name())) { qCDebug(KNEWSTUFFCORE) << "Adding category: " << category.name() << category.displayName(); //If there is only the placeholder category, replace it @@ -209,7 +209,7 @@ categoriesToSearch = mCategoryMap.values(); } else { categoriesToSearch.reserve(request.categories.size()); - foreach (const QString &categoryName, request.categories) { + for (const QString &categoryName : qAsConst(request.categories)) { categoriesToSearch.append(mCategoryMap.values(categoryName)); } } @@ -223,7 +223,7 @@ void AtticaProvider::checkForUpdates() { - foreach (const EntryInternal &e, mCachedEntries) { + for (const EntryInternal &e : qAsConst(mCachedEntries)) { ItemJob *job = m_provider.requestContent(e.uniqueId()); connect(job, &BaseJob::finished, this, &AtticaProvider::detailsLoaded); m_updateJobs.insert(job); @@ -252,7 +252,7 @@ if (m_updateJobs.remove(job) && m_updateJobs.isEmpty()) { qCDebug(KNEWSTUFFCORE) << "check update finished."; QList updatable; - foreach (const EntryInternal &entry, mCachedEntries) { + for (const EntryInternal &entry : qAsConst(mCachedEntries)) { if (entry.status() == KNS3::Entry::Updateable) { updatable.append(entry); } @@ -395,7 +395,7 @@ EntryInternal::List AtticaProvider::installedEntries() const { EntryInternal::List entries; - foreach (const EntryInternal &entry, mCachedEntries) { + for (const EntryInternal &entry : qAsConst(mCachedEntries)) { if (entry.status() == KNS3::Entry::Installed || entry.status() == KNS3::Entry::Updateable) { entries.append(entry); } @@ -510,8 +510,8 @@ entry.setTags(content.tags()); entry.clearDownloadLinkInformation(); - QList descs = content.downloadUrlDescriptions(); - foreach (const Attica::DownloadDescription &desc, descs) { + const QList descs = content.downloadUrlDescriptions(); + for (const Attica::DownloadDescription &desc : descs) { EntryInternal::DownloadLinkInformation info; info.name = desc.name(); info.priceAmount = desc.priceAmount(); diff --git a/src/core/cache.cpp b/src/core/cache.cpp --- a/src/core/cache.cpp +++ b/src/core/cache.cpp @@ -197,7 +197,7 @@ EntryInternal::List Cache::registryForProvider(const QString &providerId) { EntryInternal::List entries; - foreach (const EntryInternal &e, cache) { + for (const EntryInternal &e : qAsConst(cache)) { if (e.providerId() == providerId) { entries.append(e); } @@ -223,7 +223,7 @@ QDomElement root = doc.createElement(QStringLiteral("hotnewstuffregistry")); doc.appendChild(root); - foreach (const EntryInternal &entry, cache) { + for (const EntryInternal &entry : qAsConst(cache)) { // Write the entry, unless the policy is CacheNever and the entry is not installed. if (entry.status() == KNS3::Entry::Installed || entry.status() == KNS3::Entry::Updateable) { QDomElement exml = entry.entryXML(); diff --git a/src/core/engine.cpp b/src/core/engine.cpp --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -290,7 +290,7 @@ p->setCachedEntries(m_cache->registryForProvider(p->id())); updateStatus(); - foreach (const QSharedPointer &p, m_providers) { + for (const QSharedPointer &p : qAsConst(m_providers)) { if (!p->isInitialized()) { return; } @@ -322,7 +322,7 @@ m_currentRequest.page = 0; m_numDataJobs = 0; - foreach (const QSharedPointer &p, m_providers) { + for (const QSharedPointer &p : qAsConst(m_providers)) { if (p->isInitialized()) { if (m_currentRequest.filter == Provider::Installed) { // when asking for installed entries, never use the cache @@ -412,7 +412,7 @@ void Engine::setTagFilter(const QStringList &filter) { d->tagFilter = filter; - foreach (const QSharedPointer &p, m_providers) { + for (const QSharedPointer &p : qAsConst(m_providers)) { p->setTagFilter(d->tagFilter); } } @@ -425,15 +425,15 @@ void KNSCore::Engine::addTagFilter(const QString &filter) { d->tagFilter << filter; - foreach (const QSharedPointer &p, m_providers) { + for (const QSharedPointer &p : qAsConst(m_providers)) { p->setTagFilter(d->tagFilter); } } void Engine::setDownloadTagFilter(const QStringList &filter) { d->downloadTagFilter = filter; - foreach (const QSharedPointer &p, m_providers) { + for (const QSharedPointer &p : qAsConst(m_providers)) { p->setDownloadTagFilter(d->downloadTagFilter); } } @@ -446,7 +446,7 @@ void Engine::addDownloadTagFilter(const QString &filter) { d->downloadTagFilter << filter; - foreach (const QSharedPointer &p, m_providers) { + for (const QSharedPointer &p : qAsConst(m_providers)) { p->setDownloadTagFilter(d->downloadTagFilter); } } @@ -477,7 +477,7 @@ void Engine::doRequest() { - foreach (const QSharedPointer &p, m_providers) { + for (const QSharedPointer &p : qAsConst(m_providers)) { if (p->isInitialized()) { p->loadEntries(m_currentRequest); ++m_numDataJobs; @@ -530,11 +530,11 @@ void Engine::uninstall(KNSCore::EntryInternal entry) { - KNSCore::EntryInternal::List list = m_cache->registryForProvider(entry.providerId()); + const KNSCore::EntryInternal::List list = m_cache->registryForProvider(entry.providerId()); //we have to use the cached entry here, not the entry from the provider //since that does not contain the list of installed files KNSCore::EntryInternal actualEntryForUninstall; - foreach (const KNSCore::EntryInternal &eInt, list) { + for (const KNSCore::EntryInternal &eInt : list) { if (eInt.uniqueId() == entry.uniqueId()) { actualEntryForUninstall = eInt; break; @@ -651,15 +651,15 @@ void Engine::checkForUpdates() { - foreach (QSharedPointer p, m_providers) { + for (const QSharedPointer &p : qAsConst(m_providers)) { Provider::SearchRequest request(KNSCore::Provider::Newest, KNSCore::Provider::Updates); p->loadEntries(request); } } void KNSCore::Engine::checkForInstalled() { - foreach (QSharedPointer p, m_providers) { + for (const QSharedPointer &p : qAsConst(m_providers)) { Provider::SearchRequest request(KNSCore::Provider::Newest, KNSCore::Provider::Installed); request.page = 0; request.pageSize = m_pageSize; diff --git a/src/core/entryinternal.cpp b/src/core/entryinternal.cpp --- a/src/core/entryinternal.cpp +++ b/src/core/entryinternal.cpp @@ -724,7 +724,7 @@ if (!d->mChecksum.isEmpty()) { (void)addElement(doc, el, QStringLiteral("checksum"), d->mChecksum); } - foreach (const QString &file, d->mInstalledFiles) { + for (const QString &file : qAsConst(d->mInstalledFiles)) { (void)addElement(doc, el, QStringLiteral("installedfile"), file); } if (!d->mUniqueId.isEmpty()) { diff --git a/src/core/installation.cpp b/src/core/installation.cpp --- a/src/core/installation.cpp +++ b/src/core/installation.cpp @@ -592,7 +592,8 @@ entry.setStatus(KNS3::Entry::Deleted); if (!uninstallCommand.isEmpty()) { - foreach (const QString &file, entry.installedFiles()) { + const auto lst = entry.installedFiles(); + for (const QString &file : lst) { QFileInfo info(file); if (info.isFile()) { QString fileArg(KShell::quoteArg(file)); @@ -610,7 +611,8 @@ } } - foreach (const QString &file, entry.installedFiles()) { + const auto lst = entry.installedFiles(); + for (const QString &file : lst) { if (file.endsWith(QLatin1Char('/'))) { QDir dir; bool worked = dir.rmdir(file); @@ -653,7 +655,8 @@ QStringList Installation::archiveEntries(const QString &path, const KArchiveDirectory *dir) { QStringList files; - foreach (const QString &entry, dir->entries()) { + const auto lst = dir->entries(); + for (const QString &entry : lst) { const auto currentEntry = dir->entry(entry); const QString childPath = path + QLatin1Char('/') + entry; diff --git a/src/downloadwidget.cpp b/src/downloadwidget.cpp --- a/src/downloadwidget.cpp +++ b/src/downloadwidget.cpp @@ -88,16 +88,16 @@ { Entry::List entries; entries.reserve(d->changedEntries.count()); - foreach (const KNSCore::EntryInternal &e, d->changedEntries) { + for (const KNSCore::EntryInternal &e : qAsConst(d->changedEntries)) { entries.append(EntryPrivate::fromInternal(&e)); } return entries; } Entry::List DownloadWidget::installedEntries() { Entry::List entries; - foreach (const KNSCore::EntryInternal &e, d->changedEntries) { + for (const KNSCore::EntryInternal &e : qAsConst(d->changedEntries)) { if (e.status() == Entry::Installed) { entries.append(EntryPrivate::fromInternal(&e)); } diff --git a/src/kmoretools/kmoretools.cpp b/src/kmoretools/kmoretools.cpp --- a/src/kmoretools/kmoretools.cpp +++ b/src/kmoretools/kmoretools.cpp @@ -410,7 +410,7 @@ void deleteAndClearMenuItems() { - Q_FOREACH (auto item, menuItems) + for (auto item : qAsConst(menuItems)) { //qDebug() << item; delete item; @@ -491,7 +491,7 @@ // presort as in configuredStructure // - Q_FOREACH (const auto& item, configuredStructure.list) { + for (const auto& item : qAsConst(configuredStructure.list)) { auto foundItem = std::find_if(menuItemsSource.begin(), menuItemsSource.end(), [item](const KMoreToolsMenuItem* kMenuItem) { return kMenuItem->id() == item.id; @@ -509,7 +509,7 @@ // build MenuStructure from presorted list // - Q_FOREACH (auto item, menuItemsSortedAsConfigured) { + for (auto item : qAsConst(menuItemsSortedAsConfigured)) { const auto registeredService = item->registeredService(); @@ -560,7 +560,7 @@ */ void createMoreMenu(const KmtMenuStructure &mstruct, QMenu *parent) { - Q_FOREACH (auto item, mstruct.moreItems) { + for (auto item : qAsConst(mstruct.moreItems)) { const auto action = item->action(); action->setParent(parent); parent->addAction(action); @@ -570,7 +570,7 @@ //qDebug() << "notInstalledItems not empty => build 'Not installed' section"; parent->addSection(i18nc("@action:inmenu", "Not installed:")); - Q_FOREACH (auto registeredService, mstruct.notInstalledServices) { + for (auto registeredService : qAsConst(mstruct.notInstalledServices)) { QMenu* submenuForNotInstalled = KmtNotInstalledUtil::createSubmenuForNotInstalledApp( registeredService->formatString(QStringLiteral("$Name")), parent, registeredService->icon(), registeredService->homepageUrl(), registeredService->appstreamId()); @@ -635,15 +635,15 @@ : KMoreToolsMenuBuilderPrivate::CreateMenuStructure_Default); QString s; s += QLatin1String("|main|:"); - Q_FOREACH (auto item, mstruct.mainItems) { + for (auto item : qAsConst(mstruct.mainItems)) { s += item->registeredService()->desktopEntryName() + QLatin1Char('.'); } s += QLatin1String("|more|:"); - Q_FOREACH (auto item, mstruct.moreItems) { + for (auto item : qAsConst(mstruct.moreItems)) { s += item->registeredService()->desktopEntryName() + QLatin1Char('.'); } s += QLatin1String("|notinstalled|:"); - Q_FOREACH (auto regService, mstruct.notInstalledServices) { + for (auto regService : qAsConst(mstruct.notInstalledServices)) { s += regService->desktopEntryName() + QLatin1Char('.'); } return s; @@ -660,7 +660,7 @@ { KmtMenuStructure mstruct = d->createMenuStructure(KMoreToolsMenuBuilderPrivate::CreateMenuStructure_MergeWithUserConfig); - Q_FOREACH (auto item, mstruct.mainItems) { + for (auto item : qAsConst(mstruct.mainItems)) { const auto action = item->action(); if (!action->parent()) { // if the action has no parent, set it to the menu to be filled action->setParent(menu); diff --git a/src/kmoretools/kmoretools_p.h b/src/kmoretools/kmoretools_p.h --- a/src/kmoretools/kmoretools_p.h +++ b/src/kmoretools/kmoretools_p.h @@ -134,7 +134,7 @@ { QList r; - Q_FOREACH (const auto& item, list) { + for (const auto& item : qAsConst(list)) { if (item.menuSection == menuSection) { r.append(&item); } @@ -195,7 +195,7 @@ void jsonWrite(QJsonObject &json) const { QJsonArray jArr; - Q_FOREACH (const auto item, list) { + for (const auto item : qAsConst(list)) { QJsonObject jObj; item.jsonWrite(jObj); jArr.append(jObj); @@ -327,7 +327,7 @@ { KmtMenuStructureDto result; - Q_FOREACH (auto item, mainItems) { + for (auto item : qAsConst(mainItems)) { const auto a = item->action(); KmtMenuItemDto dto; dto.id = item->id(); @@ -338,7 +338,7 @@ result.list << dto; } - Q_FOREACH (auto item, moreItems) { + for (auto item : qAsConst(moreItems)) { const auto a = item->action(); KmtMenuItemDto dto; dto.id = item->id(); @@ -349,7 +349,7 @@ result.list << dto; } - Q_FOREACH (auto registeredService, notInstalledServices) { + for (auto registeredService : qAsConst(notInstalledServices)) { KmtMenuItemDto dto; //dto.id = item->id(); // not used in this case dto.text = registeredService->formatString(_("$Name")); diff --git a/src/kmoretools/kmoretoolsconfigdialog_p.cpp b/src/kmoretools/kmoretoolsconfigdialog_p.cpp --- a/src/kmoretools/kmoretoolsconfigdialog_p.cpp +++ b/src/kmoretools/kmoretoolsconfigdialog_p.cpp @@ -121,7 +121,7 @@ QListWidgetItem* mainSelItem = nullptr; QListWidgetItem* moreSelItem = nullptr; - foreach (auto item, currentStructure.list) { + for (auto item : qAsConst(currentStructure.list)) { QIcon icon = item.icon; if (icon.isNull()) { QPixmap pix(16, 16); // TODO: should same size as other icons in the listview diff --git a/src/kmoretools/kmoretoolsmenufactory.cpp b/src/kmoretools/kmoretoolsmenufactory.cpp --- a/src/kmoretools/kmoretoolsmenufactory.cpp +++ b/src/kmoretools/kmoretoolsmenufactory.cpp @@ -234,7 +234,7 @@ menuBuilder->setInitialItemTextTemplate(QStringLiteral("$Name")); // just use the application name - Q_FOREACH(auto kmtService, kmtServiceList) { + for (auto kmtService : qAsConst(kmtServiceList)) { // Check the pointer just in case a null pointer got in somewhere if (!kmtService) continue; QUrl argUrl = url; diff --git a/src/kmoretools/kmoretoolspresets.cpp b/src/kmoretools/kmoretoolspresets.cpp --- a/src/kmoretools/kmoretoolspresets.cpp +++ b/src/kmoretools/kmoretoolspresets.cpp @@ -169,7 +169,7 @@ for (const QString &groupingName : groupingNames) { auto iter = dict.constFind(groupingName); if (iter != dict.constEnd()) { - Q_FOREACH(const QString &desktopEntryName, *iter) { + for (const QString &desktopEntryName : qAsConst(*iter)) { if (!alreadyUsedDesktopEntryNames.contains(desktopEntryName)) { if (desktopEntryName == _("more:")) { nextIsMore = true; diff --git a/src/qtquick/quickitemsmodel.cpp b/src/qtquick/quickitemsmodel.cpp --- a/src/qtquick/quickitemsmodel.cpp +++ b/src/qtquick/quickitemsmodel.cpp @@ -236,9 +236,9 @@ case DownloadLinksRole: { // This would be good to cache... but it also needs marking as dirty, somehow... - QList dllinks = entry.downloadLinkInformationList(); + const QList dllinks = entry.downloadLinkInformationList(); QObjectList list; - Q_FOREACH(const KNSCore::EntryInternal::DownloadLinkInformation& link, dllinks) + for(const KNSCore::EntryInternal::DownloadLinkInformation& link : dllinks) { DownloadLinkInfo* info = new DownloadLinkInfo(); info->setData(link); diff --git a/src/staticxml/staticxmlprovider.cpp b/src/staticxml/staticxmlprovider.cpp --- a/src/staticxml/staticxmlprovider.cpp +++ b/src/staticxml/staticxmlprovider.cpp @@ -305,7 +305,7 @@ EntryInternal::List StaticXmlProvider::installedEntries() const { EntryInternal::List entries; - foreach (const EntryInternal &entry, mCachedEntries) { + for (const EntryInternal &entry : qAsConst(mCachedEntries)) { if (entry.status() == KNS3::Entry::Installed || entry.status() == KNS3::Entry::Updateable) { entries.append(entry); } diff --git a/src/ui/entrydetailsdialog.cpp b/src/ui/entrydetailsdialog.cpp --- a/src/ui/entrydetailsdialog.cpp +++ b/src/ui/entrydetailsdialog.cpp @@ -221,7 +221,8 @@ } if (ui->installButton->isVisible() && m_entry.downloadLinkCount() > 1) { QMenu *installMenu = new QMenu(ui->installButton); - foreach (KNSCore::EntryInternal::DownloadLinkInformation info, m_entry.downloadLinkInformationList()) { + const auto lst = m_entry.downloadLinkInformationList(); + for (const KNSCore::EntryInternal::DownloadLinkInformation &info : lst) { QString text = info.name; if (!info.distributionType.trimmed().isEmpty()) { text + QStringLiteral(" (") + info.distributionType.trimmed() + QLatin1Char(')'); diff --git a/src/ui/itemsgridviewdelegate.cpp b/src/ui/itemsgridviewdelegate.cpp --- a/src/ui/itemsgridviewdelegate.cpp +++ b/src/ui/itemsgridviewdelegate.cpp @@ -367,7 +367,8 @@ m_installButton->setEnabled(enabled); if (installable && entry.downloadLinkCount() > 1) { QMenu *installMenu = new QMenu(m_installButton); - foreach (const KNSCore::EntryInternal::DownloadLinkInformation &info, entry.downloadLinkInformationList()) { + const auto lst = entry.downloadLinkInformationList(); + for (const KNSCore::EntryInternal::DownloadLinkInformation &info : lst) { QString text = info.name; if (!info.distributionType.trimmed().isEmpty()) { text + " (" + info.distributionType.trimmed() + QLatin1Char(')'); diff --git a/src/ui/itemsviewdelegate.cpp b/src/ui/itemsviewdelegate.cpp --- a/src/ui/itemsviewdelegate.cpp +++ b/src/ui/itemsviewdelegate.cpp @@ -160,7 +160,8 @@ if (installable && entry.downloadLinkCount() > 1) { QMenu *installMenu = new QMenu(installButton); - foreach (const KNSCore::EntryInternal::DownloadLinkInformation &info, entry.downloadLinkInformationList()) { + const auto lst = entry.downloadLinkInformationList(); + for (const KNSCore::EntryInternal::DownloadLinkInformation &info : lst) { QString text = info.name; if (!info.distributionType.trimmed().isEmpty()) { text += QStringLiteral(" (") + info.distributionType.trimmed() + QLatin1Char(')'); diff --git a/src/upload/atticahelper.cpp b/src/upload/atticahelper.cpp --- a/src/upload/atticahelper.cpp +++ b/src/upload/atticahelper.cpp @@ -41,7 +41,8 @@ { if (! providerManager.providerFiles().contains(file)) { // If a custom provider file is added, remove all the default ones. - foreach (const QUrl &url, providerManager.defaultProviderFiles()) { + const auto lstUrl = providerManager.defaultProviderFiles(); + for (const QUrl &url : lstUrl) { providerManager.removeProviderFileFromDefaultProviders(url); } providerManager.addProviderFile(file); @@ -51,7 +52,8 @@ void AtticaHelper::defaultProvidersLoaded() { QStringList providers; - foreach (const Attica::Provider &p, providerManager.providers()) { + const auto lst = providerManager.providers(); + for (const Attica::Provider &p : lst) { if (p.isEnabled()) { providers.append(p.name()); } @@ -61,7 +63,8 @@ void AtticaHelper::setCurrentProvider(const QString &provider) { - foreach (const Attica::Provider &p, providerManager.providers()) { + const auto lst = providerManager.providers(); + for (const Attica::Provider &p : lst) { if (p.name() == provider) { currentProvider = p; break; @@ -114,15 +117,15 @@ void AtticaHelper::categoriesLoaded(Attica::BaseJob *baseJob) { Attica::ListJob *listJob = static_cast*>(baseJob); - Attica::Category::List newCategories = listJob->itemList(); + const Attica::Category::List newCategories = listJob->itemList(); if (m_configuredCategories.isEmpty()) { qWarning() << "No category was set in knsrc file. Adding all categories."; - Q_FOREACH (const Attica::Category &category, newCategories) { + for (const Attica::Category &category : newCategories) { m_validCategories.append(category); } } else { - Q_FOREACH (const Attica::Category &category, newCategories) { + for (const Attica::Category &category : newCategories) { if (m_configuredCategories.contains(category.name())) { m_validCategories.append(category); } diff --git a/src/uploaddialog.cpp b/src/uploaddialog.cpp --- a/src/uploaddialog.cpp +++ b/src/uploaddialog.cpp @@ -363,7 +363,7 @@ { setIdle(i18n("Fetching your previously updated content finished.")); - foreach (const Attica::Content &content, contentList) { + for (const Attica::Content &content : contentList) { QListWidgetItem *contentItem = new QListWidgetItem(content.name()); contentItem->setData(Qt::UserRole, content.id()); ui.userContentList->addItem(contentItem); @@ -579,7 +579,7 @@ q->reject(); return; } - foreach (const Attica::Category &c, categories) { + for (const Attica::Category &c : qAsConst(categories)) { ui.mCategoryCombo->addItem(c.name(), c.id()); } atticaHelper->loadContentByCurrentUser(); diff --git a/tests/khotnewstuff.cpp b/tests/khotnewstuff.cpp --- a/tests/khotnewstuff.cpp +++ b/tests/khotnewstuff.cpp @@ -43,7 +43,8 @@ QString configfile = QLatin1String(argv[1]); QPointer dialog = new KNS3::DownloadDialog(configfile); dialog->exec(); - foreach (const KNS3::Entry& e, dialog->changedEntries()) { + const auto lst = dialog->changedEntries(); + for (const KNS3::Entry& e : lst) { qCDebug(KNEWSTUFF) << "Changed Entry: " << e.name(); } delete dialog; diff --git a/tests/khotnewstuff_test.cpp b/tests/khotnewstuff_test.cpp --- a/tests/khotnewstuff_test.cpp +++ b/tests/khotnewstuff_test.cpp @@ -167,7 +167,7 @@ if (m_testall) { addMessage(QString::fromUtf8("-- now, download the entries' previews and payload files"), QStringLiteral("msg_info")); - Q_FOREACH(const KNSCore::EntryInternal &entry, entries) { + for (const KNSCore::EntryInternal &entry : entries) { addMessage(QString::fromUtf8("-- entry: %1").arg(entry.name()), QStringLiteral("msg_info")); if (!entry.previewUrl(KNSCore::EntryInternal::PreviewSmall1).isEmpty()) { m_engine->loadPreview(entry, KNSCore::EntryInternal::PreviewSmall1); diff --git a/tests/kmoretools/kmoretoolstest_interactive.cpp b/tests/kmoretools/kmoretoolstest_interactive.cpp --- a/tests/kmoretools/kmoretoolstest_interactive.cpp +++ b/tests/kmoretools/kmoretoolstest_interactive.cpp @@ -71,7 +71,8 @@ bool menuAtLeastOneActionWithText(const QMenu* menu, const QString& text) { - Q_FOREACH(auto a, menu->actions()) + const auto lstActions = menu->actions(); + for (auto a : lstActions) { if (a->text() == text) { return true; @@ -183,7 +184,7 @@ urlLineEdit->setText(_("file:///etc/bash.bashrc")); auto menuButton = new QPushButton(_(""), dlg); - auto groupingNamesList = { + const auto groupingNamesList = { _("disk-usage"), _("disk-partitions"), _("files-find"), @@ -204,7 +205,7 @@ auto groupingNamesMenu = new QMenu(dlg); QMenu* moreToolsMenu = nullptr; - Q_FOREACH(auto groupingName, groupingNamesList) { + for (auto groupingName : groupingNamesList) { auto action = new QAction(groupingName, groupingNamesMenu); action->setData(groupingName); groupingNamesMenu->addAction(action);