Commit c55a8c66 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Compile without foreach

parent 372107d7
......@@ -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)
......
......@@ -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);
}
......
......@@ -1378,7 +1378,8 @@ void KMComposerWin::initializePluginActions()
QHash<QString, QList<QAction *> >::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<MessageComposer::RecipientLineNG *>(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<MessageComposer::RecipientLineNG *>(line_);
// There's still a lookup job running, so wait, slotKeyForMailBoxResult()
......
......@@ -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<KMMainWin *>(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<KMMainWidget *> l = window->findChildren<KMMainWidget *>();
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<KMMainWin *>(window)
|| ::qobject_cast<KMail::SecondaryWindow *>(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<KMail::Composer *>(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<KMMainWin *>(window)) {
return window;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment