Commit 517b6921 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some more foreach

parent e70fb96f
......@@ -22,7 +22,7 @@
#include "job/archivejob.h"
#include "archivemailkernel.h"
#include "archivemailagentutil.h"
#include "helper_p.h"
#include <MailCommon/MailKernel>
#include <MailCommon/MailUtil>
......@@ -166,7 +166,7 @@ QString ArchiveMailManager::printCurrentListInfo()
if (mListArchiveInfo.isEmpty()) {
infoStr = QStringLiteral("No archive in queue");
} else {
Q_FOREACH (ArchiveMailInfo *info, mListArchiveInfo) {
for (ArchiveMailInfo *info : qAsConst(mListArchiveInfo)) {
if (!infoStr.isEmpty()) {
infoStr += QLatin1Char('\n');
}
......
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
template <typename... Args>
struct QNonConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
template <typename... Args>
struct QConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
template <typename... Args>
struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
{
using QConstOverload<Args...>::of;
using QConstOverload<Args...>::operator();
using QNonConstOverload<Args...>::of;
using QNonConstOverload<Args...>::operator();
template <typename R>
Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R>
static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
#endif
......@@ -121,7 +121,7 @@ void FollowUpReminderManager::checkFollowUp(const Akonadi::Item &item, const Ako
void FollowUpReminderManager::slotCheckFollowUpFinished(const QString &messageId, Akonadi::Item::Id id)
{
Q_FOREACH (FollowUpReminderInfo *info, mFollowUpReminderInfoList) {
for (FollowUpReminderInfo *info : qAsConst(mFollowUpReminderInfoList)) {
qCDebug(FOLLOWUPREMINDERAGENT_LOG) << "FollowUpReminderManager::slotCheckFollowUpFinished info:" << info;
if (!info) {
continue;
......@@ -171,7 +171,7 @@ QString FollowUpReminderManager::printDebugInfo()
if (mFollowUpReminderInfoList.isEmpty()) {
infoStr = QStringLiteral("No mail");
} else {
Q_FOREACH (FollowUpReminder::FollowUpReminderInfo *info, mFollowUpReminderInfoList) {
for (FollowUpReminder::FollowUpReminderInfo *info : qAsConst(mFollowUpReminderInfoList)) {
if (!infoStr.isEmpty()) {
infoStr += QLatin1Char('\n');
}
......
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
template <typename... Args>
struct QNonConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
template <typename... Args>
struct QConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
template <typename... Args>
struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
{
using QConstOverload<Args...>::of;
using QConstOverload<Args...>::operator();
using QNonConstOverload<Args...>::of;
using QNonConstOverload<Args...>::operator();
template <typename R>
Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R>
static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
#endif
......@@ -49,6 +49,7 @@
#include <errno.h>
#include <KSharedConfig>
#include <QLocale>
#include "helper_p.h"
using namespace MailCommon;
......@@ -100,7 +101,7 @@ void FilterManager::Private::slotItemsFetchedForFilter(const Akonadi::Item::List
const QStringList listFilters = q->sender()->property("listFilters").toStringList();
//TODO improve it
for (const QString &filterId : listFilters) {
foreach (MailCommon::MailFilter *filter, mFilters) {
for (MailCommon::MailFilter *filter : qAsConst(mFilters)) {
if (filter->identifier() == filterId) {
listMailFilters << filter;
break;
......@@ -115,7 +116,7 @@ void FilterManager::Private::slotItemsFetchedForFilter(const Akonadi::Item::List
bool needsFullPayload = q->sender()->property("needsFullPayload").toBool();
foreach (const Akonadi::Item &item, items) {
for (const Akonadi::Item &item : qAsConst(items)) {
++mCurrentProgressCount;
if ((mTotalProgressCount > 0) && (mCurrentProgressCount != mTotalProgressCount)) {
......@@ -172,7 +173,7 @@ void FilterManager::Private::itemFetchJobForFilterDone(KJob *job)
// find correct filter object
MailCommon::MailFilter *wantedFilter = nullptr;
foreach (MailCommon::MailFilter *filter, mFilters) {
for (MailCommon::MailFilter *filter : qAsConst(mFilters)) {
if (filter->identifier() == filterId) {
wantedFilter = filter;
break;
......@@ -280,7 +281,7 @@ void FilterManager::Private::endFiltering(const Akonadi::Item &/*item*/) const
bool FilterManager::Private::atLeastOneFilterAppliesTo(const QString &accountId) const
{
foreach (const MailCommon::MailFilter *filter, mFilters) {
for (const MailCommon::MailFilter *filter : qAsConst(mFilters)) {
if (filter->applyOnAccount(accountId)) {
return true;
}
......@@ -291,7 +292,7 @@ bool FilterManager::Private::atLeastOneFilterAppliesTo(const QString &accountId)
bool FilterManager::Private::atLeastOneIncomingFilterAppliesTo(const QString &accountId) const
{
foreach (const MailCommon::MailFilter *filter, mFilters) {
for (const MailCommon::MailFilter *filter : qAsConst(mFilters)) {
if (filter->applyOnInbound() && filter->applyOnAccount(accountId)) {
return true;
}
......@@ -331,8 +332,8 @@ void FilterManager::readConfig()
d->mRequiredPartsBasedOnAll = SearchRule::Envelope;
if (!d->mFilters.isEmpty()) {
Akonadi::AgentInstance::List agents = Akonadi::AgentManager::self()->instances();
foreach (const Akonadi::AgentInstance &agent, agents) {
const Akonadi::AgentInstance::List agents = Akonadi::AgentManager::self()->instances();
for (const Akonadi::AgentInstance &agent : agents) {
const QString id = agent.identifier();
auto it = std::max_element(d->mFilters.constBegin(), d->mFilters.constEnd(),
......@@ -577,7 +578,7 @@ MailCommon::SearchRule::RequiredPart FilterManager::requiredPart(const QString &
#ifndef NDEBUG
void FilterManager::dump() const
{
foreach (const MailCommon::MailFilter *filter, d->mFilters) {
for (const MailCommon::MailFilter *filter : qAsConst(d->mFilters)) {
qCDebug(MAILFILTERAGENT_LOG) << filter->asString();
}
}
......
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
template <typename... Args>
struct QNonConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
template <typename... Args>
struct QConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
template <typename... Args>
struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
{
using QConstOverload<Args...>::of;
using QConstOverload<Args...>::operator();
using QNonConstOverload<Args...>::of;
using QNonConstOverload<Args...>::operator();
template <typename R>
Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R>
static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
#endif
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
template <typename... Args>
struct QNonConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
template <typename... Args>
struct QConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
template <typename... Args>
struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
{
using QConstOverload<Args...>::of;
using QConstOverload<Args...>::operator();
using QNonConstOverload<Args...>::of;
using QNonConstOverload<Args...>::operator();
template <typename R>
Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
template <typename R>
static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
{ return ptr; }
};
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
#endif
......@@ -21,6 +21,7 @@
#include "sendlaterinfo.h"
#include "sendlaterutil.h"
#include "sendlaterjob.h"
#include "helper_p.h"
#include "MessageComposer/AkonadiSender"
#include <MessageComposer/Util>
......@@ -123,7 +124,7 @@ void SendLaterManager::stopTimer()
SendLater::SendLaterInfo *SendLaterManager::searchInfo(Akonadi::Item::Id id)
{
Q_FOREACH (SendLater::SendLaterInfo *info, mListSendLaterInfo) {
for (SendLater::SendLaterInfo *info : qAsConst(mListSendLaterInfo)) {
if (info->itemId() == id) {
return info;
}
......@@ -233,7 +234,7 @@ QString SendLaterManager::printDebugInfo()
if (mListSendLaterInfo.isEmpty()) {
infoStr = QStringLiteral("No mail");
} else {
Q_FOREACH (SendLater::SendLaterInfo *info, mListSendLaterInfo) {
for (SendLater::SendLaterInfo *info : qAsConst(mListSendLaterInfo)) {
if (!infoStr.isEmpty()) {
infoStr += QLatin1Char('\n');
}
......
......@@ -17,6 +17,7 @@ using KPIM::BroadcastStatus;
#include "kmreadermainwin.h"
#include "undostack.h"
#include "kmmainwidget.h"
#include "helper_p.h"
#include "search/checkindexingmanager.h"
#include "libkdepimakonadi/recentaddresses.h"
using KPIM::RecentAddresses;
......@@ -1775,7 +1776,7 @@ void KMKernel::checkFolderFromResources(const Akonadi::Collection::List &collect
} else if (typeIdentifier.contains(POP3_RESOURCE_IDENTIFIER)) {
OrgKdeAkonadiPOP3SettingsInterface *iface = MailCommon::Util::createPop3SettingsInterface(typeIdentifier);
if (iface->isValid()) {
foreach (const Akonadi::Collection &collection, collectionList) {
for (const Akonadi::Collection &collection : qAsConst(collectionList)) {
const Akonadi::Collection::Id collectionId = collection.id();
if (iface->targetCollection() == collectionId) {
//Use default inbox
......
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