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

Port some foreach

parent 22b78f5c
Pipeline #82069 failed with stage
in 24 minutes and 28 seconds
......@@ -942,7 +942,7 @@ void DavGroupwareResource::onMultigetFinished(KJob *job)
const KDAV::DavItemsFetchJob *davJob = qobject_cast<KDAV::DavItemsFetchJob *>(job);
Akonadi::Item::List items;
for (Akonadi::Item item : std::as_const(origItems)) { // krazy:exclude=foreach non-const is intended here
for (Akonadi::Item item : std::as_const(origItems)) {
const KDAV::DavItem davItem = davJob->item(item.remoteId());
// No data was retrieved for this item, maybe because it is not out of date
......
......@@ -190,7 +190,7 @@ bool Utils::parseDavData(const KDAV::DavItem &source, Akonadi::Item &target, Ako
target.setMimeType(mainIncidence->mimeType());
/*
foreach ( const IncidencePtr &incidence, incidences ) {
for ( const IncidencePtr &incidence : incidences ) {
QString rid = item.remoteId() + QLatin1String( "#" ) + incidence->instanceIdentifier();
Akonadi::Item extraItem = item;
extraItem.setRemoteId( rid );
......
......@@ -70,7 +70,7 @@ void EwsFetchCalendarDetailJob::processItems(const EwsGetItemRequest::Response::
EwsId::List addItems;
Q_FOREACH (const EwsGetItemRequest::Response &resp, responses) {
for (const EwsGetItemRequest::Response &resp : responses) {
Item &item = *it;
if (!resp.isSuccess()) {
......@@ -85,7 +85,8 @@ void EwsFetchCalendarDetailJob::processItems(const EwsGetItemRequest::Response::
qCDebugNC(EWSRES_LOG) << QStringLiteral("Found %1 events").arg(memcal->events().count());
KCalendarCore::Incidence::Ptr incidence;
if (memcal->events().count() > 1) {
Q_FOREACH (const KCalendarCore::Event::Ptr &event, memcal->events()) {
const auto memcalEvents{memcal->events()};
for (const KCalendarCore::Event::Ptr &event : memcalEvents) {
qCDebugNC(EWSRES_LOG) << QString::number(event->recurrence()->recurrenceType(), 16) << event->recurrenceId() << event->recurrenceId().isValid();
if (!event->recurrenceId().isValid()) {
incidence = event;
......
......@@ -35,7 +35,8 @@ EwsPoxAutodiscoverRequest::~EwsPoxAutodiscoverRequest()
void EwsPoxAutodiscoverRequest::doSend()
{
Q_FOREACH (KJob *job, subjobs()) {
const auto jobs{subjobs()};
for (KJob *job : jobs) {
job->start();
}
}
......
......@@ -24,7 +24,8 @@ EwsRequest::~EwsRequest()
void EwsRequest::doSend()
{
Q_FOREACH (KJob *job, subjobs()) {
const auto jobs{subjobs()};
for (KJob *job : jobs) {
job->start();
}
}
......
......@@ -144,7 +144,7 @@ bool EwsUpdateFolderRequest::FolderChange::write(QXmlStreamWriter &writer) const
writer.writeStartElement(ewsTypeNsUri, QStringLiteral("Updates"));
Q_FOREACH (const QSharedPointer<const Update> &upd, mUpdates) {
for (const QSharedPointer<const Update> &upd : std::as_const(mUpdates)) {
if (!upd->write(writer, mType)) {
retVal = false;
break;
......
......@@ -196,7 +196,7 @@ bool EwsUpdateItemRequest::ItemChange::write(QXmlStreamWriter &writer) const
writer.writeStartElement(ewsTypeNsUri, QStringLiteral("Updates"));
Q_FOREACH (const QSharedPointer<const Update> &upd, mUpdates) {
for (const QSharedPointer<const Update> &upd : std::as_const(mUpdates)) {
if (!upd->write(writer, mType)) {
retVal = false;
break;
......
......@@ -109,7 +109,7 @@ public:
const QList<T> &keysToWrite = QList<T>()) const
{
bool hasKeysToWrite = !keysToWrite.isEmpty();
Q_FOREACH (const Item &item, mItems) {
for (const Item &item : std::as_const(mItems)) {
if (!hasKeysToWrite || keysToWrite.contains(item.key)) {
typename ValueHash::const_iterator it = values.find(item.key);
if (it != values.end()) {
......@@ -148,7 +148,7 @@ private:
void rebuildItemHash()
{
Q_FOREACH (const Item &item, mItems) {
for (const Item &item : std::as_const(mItems)) {
mItemHash.insert(item.elmName, item);
}
}
......
......@@ -36,7 +36,8 @@ void EwsCreateItemJob::start()
{
/* Before starting check if all Akonadi tags are known to the tag store */
bool syncNeeded = false;
Q_FOREACH (const Akonadi::Tag &tag, mItem.tags()) {
const auto tags{mItem.tags()};
for (const Akonadi::Tag &tag : tags) {
if (!mTagStore->containsId(tag.id())) {
syncNeeded = true;
break;
......
......@@ -238,7 +238,7 @@ void EwsFetchFoldersJobPrivate::processRemoteFolders()
/* mParentMap contains the parent->child map for each collection. */
/* Iterate over all changed folders. */
Q_FOREACH (const EwsFolder &folder, mRemoteChangedFolders) {
for (const EwsFolder &folder : std::as_const(mRemoteChangedFolders)) {
/* Create a collection for each folder. */
Collection c = createFolderCollection(folder);
......
......@@ -360,7 +360,7 @@ void EwsFetchItemsJob::compareItemLists()
}
// In case of an incremental sync deleted items will be given explicitly. */
Q_FOREACH (const EwsId &id, mRemoteDeletedIds) {
for (const EwsId &id : std::as_const(mRemoteDeletedIds)) {
QHash<QString, Item>::iterator it = itemHash.find(id.id());
if (it == itemHash.end()) {
/* If an item is not found locally, it can mean two things:
......
......@@ -749,6 +749,7 @@ void EwsResource::itemDeleteRequestFinished(KJob *job)
EwsId::List foldersToSync;
Item::List::iterator it = items.begin();
Q_FOREACH (const EwsDeleteItemRequest::Response &resp, req->responses()) {
Item &item = *it;
if (resp.isSuccess()) {
......@@ -1190,7 +1191,8 @@ void EwsResource::specialFoldersFetchFinished(KJob *job)
}
auto it = specialFolderList.cbegin();
Q_FOREACH (const EwsGetFolderRequest::Response &resp, req->responses()) {
const auto responses{req->responses()};
for (const EwsGetFolderRequest::Response &resp : responses) {
if (resp.isSuccess()) {
auto fid = resp.folder()[EwsFolderFieldFolderId].value<EwsId>();
QMap<QString, Collection>::iterator mapIt = map.find(fid.id());
......
......@@ -60,11 +60,12 @@ void EwsSubscribedFoldersJob::verifySubFoldersRequestFinished(KJob *job)
auto it = sourceIds.cbegin();
Q_FOREACH (const EwsGetFolderRequest::Response &resp, req->responses()) {
const auto responses{req->responses()};
for (const EwsGetFolderRequest::Response &resp : responses) {
if (resp.isSuccess()) {
// Take just the id without the change key as the actual folder version is irrelevant
// here
QString id = resp.folder()[EwsFolderFieldFolderId].value<EwsId>().id();
const QString id = resp.folder()[EwsFolderFieldFolderId].value<EwsId>().id();
mFolders << EwsId(id);
idList << id;
} else {
......
......@@ -141,7 +141,8 @@ void EwsFetchMailDetailJob::processItems(const EwsGetItemRequest::Response::List
// records flags added and removed. In the latter it sets a flag indicating that flags were
// reset.
// For some strange reason Akonadi is not seeing the flags in the latter case.
Q_FOREACH (const QByteArray &flag, EwsMailHandler::readFlags(ewsItem)) {
const auto flags{EwsMailHandler::readFlags(ewsItem)};
for (const QByteArray &flag : flags) {
item.setFlag(flag);
}
qCDebugNC(EWSRES_LOG) << "EwsFetchMailDetailJob::processItems:" << ewsHash(item.remoteId()) << item.flags();
......
......@@ -285,7 +285,8 @@ bool EwsTagStore::writeEwsProperties(const Akonadi::Item &item, EwsItem &ewsItem
if (!item.tags().isEmpty()) {
QStringList tagList;
QStringList categoryList;
Q_FOREACH (const Tag &tag, item.tags()) {
const auto tags{item.tags()};
for (const Tag &tag : tags) {
if (!containsId(tag.id())) {
return false;
}
......
......@@ -105,7 +105,7 @@ void EwsUpdateItemsTagsJob::doUpdateItemsTags()
QVector<EwsUpdateItemRequest::ItemChange> itemChanges;
itemChanges.reserve(mItems.size());
Q_FOREACH (const Item &item, mItems) {
for (const Item &item : std::as_const(mItems)) {
EwsUpdateItemRequest::ItemChange ic(EwsId(item.remoteId(), item.remoteRevision()), EwsItemHandler::mimeToItemType(item.mimeType()));
if (!item.tags().isEmpty()) {
QStringList tagList;
......
......@@ -356,7 +356,7 @@ QString FakeEwsConnection::prepareEventsResponse(const QStringList &events)
resp += QLatin1String("<m:Notifications><m:Notification><SubscriptionId>") + mStreamingSubId + QLatin1String("<SubscriptionId>");
qCInfoNC(EWSFAKE_LOG) << QStringLiteral("Returning %1 events.").arg(events.size());
Q_FOREACH (const QString &eventXml, events) {
for (const QString &eventXml : std::as_const(events)) {
resp += eventXml;
}
......
......@@ -176,7 +176,8 @@ Attendee *Event::getAttendee(const ContactReference &ref)
Attendee Event::getAttendee(const std::string &s)
{
foreach (const Attendee &a, attendees()) {
const auto atts{attendees()};
for (const Attendee &a : atts) {
if (a.contact().uid() == s || a.contact().email() == s || a.contact().name() == s) {
return a;
}
......
......@@ -256,7 +256,7 @@ void ItemCreateTest::testMBox()
items = itemFetch->items();
QCOMPARE((int)items.count(), 5);
Q_FOREACH (const Item &item, items) {
for (const Item &item : std::as_const(items)) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
++flagCounts[flag];
}
......@@ -300,7 +300,7 @@ void ItemCreateTest::testMBox()
items = itemFetch->items();
QCOMPARE((int)items.count(), 6);
Q_FOREACH (const Item &item, items) {
for (const Item &item : std::as_const(items)) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
++flagCounts[flag];
}
......@@ -465,7 +465,7 @@ void ItemCreateTest::testMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 5);
Q_FOREACH (const Item &item, items) {
for (const Item &item : std::as_const(items)) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
++flagCounts[flag];
}
......@@ -513,7 +513,7 @@ void ItemCreateTest::testMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 6);
Q_FOREACH (const Item &item, items) {
for (const Item &item : std::as_const(items)) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
++flagCounts[flag];
}
......
......@@ -431,7 +431,7 @@ void ItemDeleteTest::testCachePreservation()
// TODO since we don't know which message we've deleted, we can only check if some flags are present
int flagCountTotal = 0;
Q_FOREACH (int count, flagCounts) {
for (int count : std::as_const(flagCounts)) {
flagCountTotal += count;
}
QVERIFY(flagCountTotal > 0);
......
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