diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a0c38e7b..ee58ba287 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,7 +143,10 @@ include_directories(${kmail_SOURCE_DIR} ${kmail_BINARY_DIR}) configure_file(kmail-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kmail-version.h @ONLY) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000) - +if (${KF5Config_VERSION} STRGREATER "5.56.0") + add_definitions(-DQT_NO_FOREACH) + MESSAGE(STATUS "compile without foreach") +endif() add_subdirectory(src) add_subdirectory(agents) add_subdirectory(ktnef) diff --git a/agents/archivemailagent/archivemailmanager.cpp b/agents/archivemailagent/archivemailmanager.cpp index 772d70c79..2be623713 100644 --- a/agents/archivemailagent/archivemailmanager.cpp +++ b/agents/archivemailagent/archivemailmanager.cpp @@ -105,7 +105,8 @@ void ArchiveMailManager::removeCollectionId(Akonadi::Collection::Id id) group.deleteGroup(); mConfig->sync(); mConfig->reparseConfiguration(); - foreach (ArchiveMailInfo *info, mListArchiveInfo) { //Don't port to for(...:...) + const auto lst = mListArchiveInfo; + for (ArchiveMailInfo *info : lst) { if (info->saveCollectionId() == id) { mListArchiveInfo.removeAll(info); } diff --git a/src/editor/kmcomposerwin.cpp b/src/editor/kmcomposerwin.cpp index 21af0845b..80a99ed46 100644 --- a/src/editor/kmcomposerwin.cpp +++ b/src/editor/kmcomposerwin.cpp @@ -1378,7 +1378,8 @@ void KMComposerWin::initializePluginActions() QHash >::const_iterator i = hashActions.constBegin(); while (i != hashActions.constEnd()) { - Q_FOREACH (KXMLGUIClient *client, guiFactory()->clients()) { + const auto lst = guiFactory()->clients(); + for (KXMLGUIClient *client : lst) { client->unplugActionList(i.key()); client->plugActionList(i.key(), i.value()); } @@ -2340,7 +2341,8 @@ void KMComposerWin::setEncryption(bool encrypt, bool setByUser) if (setByUser) { // User has toggled encryption, go over all recipients - Q_FOREACH (auto line, mComposerBase->recipientsEditor()->lines()) { + const auto lst = mComposerBase->recipientsEditor()->lines(); + for (auto line : lst) { if (encrypt) { // Encryption was enabled, update encryption status of all recipients slotRecipientAdded(qobject_cast(line)); @@ -3420,7 +3422,8 @@ void KMComposerWin::slotRecipientEditorFocusChanged() // (unless user enabled it manually), because we want to encrypt by default, // but not by force bool encrypt = false; - Q_FOREACH (auto line_, mComposerBase->recipientsEditor()->lines()) { + const auto lst = mComposerBase->recipientsEditor()->lines(); + for (auto line_ : lst) { auto line = qobject_cast(line_); // There's still a lookup job running, so wait, slotKeyForMailBoxResult() diff --git a/src/kmkernel.cpp b/src/kmkernel.cpp index 08196f1dd..f0c2b2c78 100644 --- a/src/kmkernel.cpp +++ b/src/kmkernel.cpp @@ -536,7 +536,8 @@ void KMKernel::openReader(bool onlyCheck, bool startInTray) { KMainWindow *ktmw = nullptr; - foreach (KMainWindow *window, KMainWindow::memberList()) { + const auto lst = KMainWindow::memberList(); + for (KMainWindow *window : lst) { if (::qobject_cast(window)) { ktmw = window; break; @@ -685,7 +686,8 @@ bool KMKernel::showMail(qint64 serialNumber) KMMainWidget *mainWidget = nullptr; // First look for a KMainWindow. - foreach (KMainWindow *window, KMainWindow::memberList()) { + const auto lst = KMainWindow::memberList(); + for (KMainWindow *window : lst) { // Then look for a KMMainWidget. QList l = window->findChildren(); if (!l.isEmpty() && l.first()) { @@ -1078,7 +1080,8 @@ void KMKernel::setFirstInstance(bool value) void KMKernel::closeAllKMailWindows() { - foreach (KMainWindow *window, KMainWindow::memberList()) { + const auto lst = KMainWindow::memberList(); + for (KMainWindow *window : lst) { if (::qobject_cast(window) || ::qobject_cast(window)) { // close and delete the window @@ -1139,7 +1142,8 @@ void KMKernel::dumpDeadLetters() } // make all composer windows autosave their contents - foreach (KMainWindow *window, KMainWindow::memberList()) { + const auto lst = KMainWindow::memberList(); + for (KMainWindow *window : lst) { if (KMail::Composer *win = ::qobject_cast(window)) { win->autoSaveMessage(true); @@ -1274,7 +1278,8 @@ JobScheduler *KMKernel::jobScheduler() const KMainWindow *KMKernel::mainWin() { // First look for a KMMainWin. - foreach (KMainWindow *window, KMainWindow::memberList()) { + const auto lst = KMainWindow::memberList(); + for (KMainWindow *window : lst) { if (::qobject_cast(window)) { return window; }