Commit 3451c7bd authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port more for(...:...)

parent f3964dfb
Pipeline #82124 failed with stage
in 54 seconds
......@@ -806,7 +806,8 @@ void DavGroupwareResource::onRetrieveCollectionsFinished(KJob *job)
}
}
foreach (const QString &rid, mEtagCaches.keys()) {
const auto keys{mEtagCaches.keys()};
for (const QString &rid : keys) {
if (!seenCollectionsUrls.contains(rid)) {
qCDebug(DAVRESOURCE_LOG) << "DavGroupwareResource::onRetrieveCollectionsFinished: Collection disappeared. " << rid;
mEtagCaches[rid]->deleteLater();
......@@ -849,7 +850,8 @@ void DavGroupwareResource::onRetrieveItemsFinished(KJob *job)
QSet<QString> seenRids;
QStringList changedRids;
changedItems.reserve(listJob->changedItems().count());
foreach (const KDAV::DavItem &davItem, listJob->changedItems()) {
const auto listJobChangedItems{listJob->changedItems()};
for (const KDAV::DavItem &davItem : listJobChangedItems) {
seenRids.insert(davItem.url().toDisplayString());
Akonadi::Item item;
......
......@@ -161,7 +161,8 @@ void EwsFetchCalendarDetailJob::exceptionItemsFetched(KJob *job)
}
KCalendarCore::ICalFormat format;
Q_FOREACH (const EwsGetItemRequest::Response &resp, req->responses()) {
const auto responses{req->responses()};
for (const EwsGetItemRequest::Response &resp : responses) {
if (!resp.isSuccess()) {
qCWarningNC(EWSRES_LOG) << QStringLiteral("Failed to fetch item.");
continue;
......
......@@ -209,7 +209,8 @@ void EwsFetchFoldersIncrJobPrivate::remoteFolderIncrFetchDone(KJob *job)
* Use a hash to auto-eliminate duplicates. */
QHash<QString, Collection> localFetchHash;
Q_FOREACH (const EwsSyncFolderHierarchyRequest::Change &ch, req->changes()) {
const auto reqChanges{req->changes()};
for (const EwsSyncFolderHierarchyRequest::Change &ch : reqChanges) {
FolderDescr fd;
Collection c;
......
......@@ -104,7 +104,8 @@ void EwsFetchFoldersJobPrivate::remoteFolderFullFetchDone(KJob *job)
return;
}
Q_FOREACH (const EwsSyncFolderHierarchyRequest::Change &ch, req->changes()) {
const auto reqChanges{req->changes()};
for (const EwsSyncFolderHierarchyRequest::Change &ch : reqChanges) {
if (ch.type() == EwsSyncFolderHierarchyRequest::Create) {
mRemoteChangedFolders.append(ch.folder());
} else {
......@@ -152,7 +153,8 @@ void EwsFetchFoldersJobPrivate::remoteFolderIdFullFetchDone(KJob *job)
return;
}
Q_FOREACH (const EwsSyncFolderHierarchyRequest::Change &ch, req->changes()) {
const auto reqChanges{req->changes()};
for (const EwsSyncFolderHierarchyRequest::Change &ch : reqChanges) {
if (ch.type() == EwsSyncFolderHierarchyRequest::Create) {
mRemoteFolderIds.append(ch.folder()[EwsFolderFieldFolderId].value<EwsId>());
} else {
......@@ -210,7 +212,8 @@ void EwsFetchFoldersJobPrivate::remoteFolderDetailFetchDone(KJob *job)
return;
}
Q_FOREACH (const EwsGetFolderRequest::Response &resp, req->responses()) {
const auto reqResponses{req->responses()};
for (const EwsGetFolderRequest::Response &resp : reqResponses) {
if (resp.isSuccess()) {
mRemoteChangedFolders.append(resp.folder());
} else {
......
......@@ -172,7 +172,8 @@ void EwsFetchItemsJob::remoteItemFetchDone(KJob *job)
if (!itemReq->error()) {
removeSubjob(job);
Q_FOREACH (const EwsSyncFolderItemsRequest::Change &change, itemReq->changes()) {
const auto reqChanges{itemReq->changes()};
for (const EwsSyncFolderItemsRequest::Change &change : reqChanges) {
switch (change.type()) {
case EwsSyncFolderItemsRequest::Create:
mRemoteAddedItems.append(change.item());
......@@ -237,7 +238,8 @@ void EwsFetchItemsJob::checkedItemsFetchFinished(KJob *job)
Q_ASSERT(mItemsToCheck.size() == req->responses().size());
EwsId::List::const_iterator it = mItemsToCheck.cbegin();
Q_FOREACH (const EwsGetItemRequest::Response &resp, req->responses()) {
const auto reqResponses{req->responses()};
for (const EwsGetItemRequest::Response &resp : reqResponses) {
if (resp.isSuccess()) {
qCDebugNC(EWSRES_LOG) << QStringLiteral("Checked item %1 found - readding").arg(ewsHash(it->id()));
mRemoteAddedItems.append(resp.item());
......@@ -258,7 +260,7 @@ bool EwsFetchItemsJob::processIncrementalRemoteItemUpdates(const EwsItem::List &
QHash<QString, Item> &itemHash,
QHash<EwsItemType, Item::List> &toFetchItems)
{
Q_FOREACH (const EwsItem &ewsItem, items) {
for (const EwsItem &ewsItem : items) {
auto id(ewsItem[EwsItemFieldItemId].value<EwsId>());
auto it = itemHash.find(id.id());
if (it == itemHash.end()) {
......@@ -302,7 +304,7 @@ void EwsFetchItemsJob::compareItemLists()
itemHash.insert(item.remoteId(), item);
}
Q_FOREACH (const EwsItem &ewsItem, mRemoteAddedItems) {
for (const EwsItem &ewsItem : std::as_const(mRemoteAddedItems)) {
/* In case of a full sync all existing items appear as added on the remote side. Therefore
* look for the item in the local list before creating a new copy. */
auto id(ewsItem[EwsItemFieldItemId].value<EwsId>());
......
......@@ -669,7 +669,8 @@ void EwsResource::itemMoveRequestFinished(KJob *job)
auto srcCol = req->property("sourceCollection").value<Collection>();
auto dstCol = req->property("destinationCollection").value<Collection>();
Item::List::iterator it = items.begin();
Q_FOREACH (const EwsMoveItemRequest::Response &resp, req->responses()) {
const auto reqResponses{req->responses()};
for (const EwsMoveItemRequest::Response &resp : reqResponses) {
Item &item = *it;
if (resp.isSuccess()) {
qCDebugNC(EWSRES_AGENTIF_LOG)
......@@ -750,7 +751,8 @@ void EwsResource::itemDeleteRequestFinished(KJob *job)
Item::List::iterator it = items.begin();
Q_FOREACH (const EwsDeleteItemRequest::Response &resp, req->responses()) {
const auto reqResponses{req->responses()};
for (const EwsDeleteItemRequest::Response &resp : reqResponses) {
Item &item = *it;
if (resp.isSuccess()) {
qCDebugNC(EWSRES_AGENTIF_LOG) << QStringLiteral("itemsRemoved: succeeded for item %1").arg(ewsHash(item.remoteId()));
......
......@@ -153,7 +153,8 @@ void UtEwsMoveItemRequest::twoItems()
static const EwsId::List newIds = {EwsId(QStringLiteral("Xnn2DwwaXQUhbn7U"), QStringLiteral("JoFvRwDP")),
EwsId(QStringLiteral("ntTNOncESwiyAXog"), QStringLiteral("4qbAwd3y"))};
EwsId::List::const_iterator newIdsIt = newIds.begin();
Q_FOREACH (const EwsMoveItemRequest::Response &resp, req->responses()) {
const auto reqResponses{req->responses()};
for (const EwsMoveItemRequest::Response &resp : reqResponses) {
QCOMPARE(resp.responseClass(), EwsResponseSuccess);
QCOMPARE(resp.itemId(), *newIdsIt);
newIdsIt++;
......@@ -230,7 +231,8 @@ void UtEwsMoveItemRequest::twoItemsOneFailed()
EwsId::List::const_iterator newIdsIt = newIds.begin();
QList<EwsResponseClass>::const_iterator respClassesIt = respClasses.begin();
unsigned i = 0;
Q_FOREACH (const EwsMoveItemRequest::Response &resp, req->responses()) {
const auto reqResponses{req->responses()};
for (const EwsMoveItemRequest::Response &resp : reqResponses) {
qDebug() << "Verifying response" << i++;
QCOMPARE(resp.responseClass(), *respClassesIt);
if (resp.isSuccess()) {
......@@ -313,7 +315,8 @@ void UtEwsMoveItemRequest::twoItemsSecondFailed()
EwsId::List::const_iterator newIdsIt = newIds.begin();
QList<EwsResponseClass>::const_iterator respClassesIt = respClasses.begin();
unsigned i = 0;
Q_FOREACH (const EwsMoveItemRequest::Response &resp, req->responses()) {
const auto reqResponses{req->responses()};
for (const EwsMoveItemRequest::Response &resp : reqResponses) {
qDebug() << "Verifying response" << i++;
QCOMPARE(resp.responseClass(), *respClassesIt);
if (resp.isSuccess()) {
......
......@@ -28,10 +28,12 @@ void KolabChangeItemsTagsTask::startRelationTask(KIMAP::Session *session)
// It's entirely possible that we don't have an rid yet
// compile a set of changed tags
Q_FOREACH (const Akonadi::Tag &tag, resourceState()->addedTags()) {
const auto addedTags{resourceState()->addedTags()};
for (const Akonadi::Tag &tag : addedTags) {
mChangedTags.append(tag);
}
Q_FOREACH (const Akonadi::Tag &tag, resourceState()->removedTags()) {
const auto removedTags{resourceState()->removedTags()};
for (const Akonadi::Tag &tag : removedTags) {
mChangedTags.append(tag);
}
qCDebug(KOLABRESOURCE_LOG) << mChangedTags;
......
......@@ -29,7 +29,8 @@ bool KolabHelpers::checkForErrors(const Akonadi::Item &item)
}
QString errorMsg;
foreach (const Kolab::ErrorHandler::Err &error, Kolab::ErrorHandler::instance().getErrors()) {
const auto errors{Kolab::ErrorHandler::instance().getErrors()};
for (const Kolab::ErrorHandler::Err &error : errors) {
errorMsg.append(error.message);
errorMsg.append(QLatin1Char('\n'));
}
......
......@@ -465,7 +465,8 @@ void KolabRetrieveCollectionsTask::applyRights(const QHash<QString, KIMAP::Acl::
void KolabRetrieveCollectionsTask::applyMetadata(const QHash<QString, QMap<QByteArray, QByteArray>> &metadataMap)
{
// qCDebug(KOLABRESOURCE_LOG) << metadataMap;
Q_FOREACH (const QString &mailbox, metadataMap.keys()) {
const auto keys{metadataMap.keys()};
for (const QString &mailbox : keys) {
const QMap<QByteArray, QByteArray> metadata = metadataMap.value(mailbox);
if (mMailCollections.contains(mailbox)) {
Akonadi::Collection &collection = mMailCollections[mailbox];
......
......@@ -446,8 +446,9 @@ KContacts::Addressee toKABC(const Kolab::Contact &contact)
if (!contact.emailAddresses().empty()) {
QStringList emails;
emails.reserve(contact.emailAddresses().size());
foreach (const Kolab::Email &email, contact.emailAddresses()) {
const auto contactEmailAddresses{contact.emailAddresses()};
emails.reserve(contactEmailAddresses.size());
for (const Kolab::Email &email : contactEmailAddresses) {
emails << fromStdString(email.address());
const QString types = emailTypesToStringList(email.types());
if (!types.isEmpty()) {
......
......@@ -289,7 +289,8 @@ std::string toIFB(const Kolab::Freebusy &freebusy)
KCalendarCore::FreeBusyPeriod::List list;
const auto freePeriods{freebusy.periods()};
for (const Kolab::FreebusyPeriod &fbPeriod : freePeriods) {
Q_FOREACH (const Kolab::Period &p, fbPeriod.periods()) {
const auto fbPeriodPeriods{fbPeriod.periods()};
for (const Kolab::Period &p : fbPeriodPeriods) {
KCalendarCore::FreeBusyPeriod period(Kolab::Conversion::toDate(p.start), Kolab::Conversion::toDate(p.end));
// period.setSummary("summary"); Doesn't even work. X-SUMMARY is read though (just not written out)s
// TODO
......
......@@ -338,7 +338,8 @@ ObjectType KolabObjectReader::parseMimeMessage(const KMime::Message::Ptr &msg)
d->mTag.setType(Akonadi::Tag::GENERIC);
d->mTagMembers.reserve(relation.members().size());
foreach (const std::string &member, relation.members()) {
const auto members{relation.members()};
for (const std::string &member : members) {
d->mTagMembers << Conversion::fromStdString(member);
}
} else if (relation.type() == "generic") {
......@@ -348,7 +349,8 @@ ObjectType KolabObjectReader::parseMimeMessage(const KMime::Message::Ptr &msg)
d->mRelation.setType(Akonadi::Relation::GENERIC);
d->mTagMembers.reserve(relation.members().size());
foreach (const std::string &member, relation.members()) {
const auto members{relation.members()};
for (const std::string &member : members) {
d->mTagMembers << Conversion::fromStdString(member);
}
} else {
......
......@@ -186,7 +186,8 @@ static QByteArray getMimeType(Kolab::ObjectType type)
static Kolab::ObjectType detectType(const KMime::Message::Ptr &msg)
{
Q_FOREACH (const QByteArray &type, Mime::getContentMimeTypeList(msg)) {
const auto mimetypes{Mime::getContentMimeTypeList(msg)};
for (const QByteArray &type : mimetypes) {
Kolab::ObjectType t = getObjectType(type.toStdString()); // works for v2 types
if (t != InvalidObject) {
return t;
......
......@@ -204,14 +204,14 @@ void Incidence::saveAttendeeAttribute(QDomElement &element, const Attendee &atte
void Incidence::saveAttendees(QDomElement &element) const
{
foreach (const Attendee &attendee, mAttendees) {
for (const Attendee &attendee : std::as_const(mAttendees)) {
saveAttendeeAttribute(element, attendee);
}
}
void Incidence::saveAttachments(QDomElement &element) const
{
foreach (const KCalendarCore::Attachment &a, mAttachments) {
for (const KCalendarCore::Attachment &a : std::as_const(mAttachments)) {
if (a.isUri()) {
writeString(element, QStringLiteral("link-attachment"), a.uri());
} else if (a.isBinary()) {
......@@ -576,7 +576,7 @@ bool Incidence::saveAttributes(QDomElement &element) const
void Incidence::saveCustomAttributes(QDomElement &element) const
{
foreach (const Custom &custom, mCustomList) {
for (const Custom &custom : std::as_const(mCustomList)) {
QString key(QString::fromUtf8(custom.key));
Q_ASSERT(!key.isEmpty());
if (key.startsWith(QLatin1String("X-KDE-KolabUnhandled-"))) {
......@@ -830,7 +830,7 @@ void Incidence::setFields(const KCalendarCore::Incidence::Ptr &incidence)
// Attendees:
const KCalendarCore::Attendee::List attendees = incidence->attendees();
foreach (const KCalendarCore::Attendee &kcalAttendee, attendees) {
for (const KCalendarCore::Attendee &kcalAttendee : attendees) {
Attendee attendee;
attendee.displayName = kcalAttendee.name();
......@@ -898,7 +898,7 @@ static QBitArray daysListToBitArray(const QStringList &days)
{
QBitArray arr(7);
arr.fill(false);
foreach (const QString &day, days) {
for (const QString &day : days) {
for (int i = 0; i < 7; ++i) {
if (day == QLatin1String(s_weekDayName[i])) {
arr.setBit(i, true);
......@@ -954,7 +954,7 @@ void Incidence::saveTo(const KCalendarCore::Incidence::Ptr &incidence)
}
incidence->clearAttachments();
foreach (const KCalendarCore::Attachment &a, mAttachments) {
for (const KCalendarCore::Attachment &a : std::as_const(mAttachments)) {
incidence->addAttachment(a);
}
......@@ -1021,7 +1021,7 @@ void Incidence::saveTo(const KCalendarCore::Incidence::Ptr &incidence)
incidence->setSchedulingID(uid());
}
foreach (const Custom &custom, mCustomList) {
for (const Custom &custom : std::as_const(mCustomList)) {
incidence->setNonKDECustomProperty(custom.key, custom.value);
}
}
......
......@@ -557,7 +557,8 @@ void POP3Resource::messageDownloadProgress(KJob *job, KJob::Unit unit, qulonglon
QString statusMessage;
const int totalMessages = mIdsToDownload.size() + mDownloadedIDs.size();
int bytesRemainingOnServer = 0;
foreach (const QString &alreadyDownloadedUID, mSettings.seenUidList()) {
const auto seenUidList{mSettings.seenUidList()};
for (const QString &alreadyDownloadedUID : seenUidList) {
const int alreadyDownloadedID = mUidsToIdsMap.value(alreadyDownloadedUID, -1);
if (alreadyDownloadedID != -1) {
bytesRemainingOnServer += mIdsToSizeMap.value(alreadyDownloadedID);
......
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