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

port foreach => for(...:...)

parent e31b3036
Pipeline #82075 failed with stage
in 25 minutes and 20 seconds
......@@ -287,7 +287,8 @@ void EwsFetchFoldersIncrJobPrivate::localFolderFetchDone(KJob *job)
auto fetchJob = qobject_cast<CollectionFetchJob *>(job);
Q_ASSERT(fetchJob);
Q_FOREACH (const Collection &col, fetchJob->collections()) {
const auto collections{fetchJob->collections()};
for (const Collection &col : collections) {
/* Retrieve the folder descriptor for this collection. Note that a new descriptor will be
* created if it does not yet exist. */
FolderDescr &fd = mFolderHash[col.remoteId()];
......
......@@ -48,7 +48,8 @@ void EwsUpdateItemsTagsJob::start()
* first before any further processing.
*/
for (const Item &item : std::as_const(mItems)) {
Q_FOREACH (const Tag &tag, item.tags()) {
const auto tags{item.tags()};
for (const Tag &tag : tags) {
if (!mTagStore->containsId(tag.id())) {
unknownTags.append(tag);
}
......@@ -111,7 +112,8 @@ void EwsUpdateItemsTagsJob::doUpdateItemsTags()
QStringList tagList;
QStringList categoryList;
tagList.reserve(item.tags().count());
Q_FOREACH (const Tag &tag, item.tags()) {
const auto tags{item.tags()};
for (const Tag &tag : tags) {
Q_ASSERT(mTagStore->containsId(tag.id()));
tagList.append(QString::fromLatin1(mTagStore->tagRemoteId(tag.id())));
QString name = mTagStore->tagName(tag.id());
......
......@@ -131,7 +131,8 @@ void UtEwsDeleteItemRequest::twoItems()
QCOMPARE(req->error(), 0);
QCOMPARE(req->responses().size(), 2);
Q_FOREACH (const EwsDeleteItemRequest::Response &resp, req->responses()) {
const auto responses{req->responses()};
for (const EwsDeleteItemRequest::Response &resp : responses) {
QCOMPARE(resp.responseClass(), EwsResponseSuccess);
}
}
......@@ -195,7 +196,8 @@ void UtEwsDeleteItemRequest::twoItemsOneFailed()
static const QList<EwsResponseClass> respClasses = {EwsResponseError, EwsResponseSuccess};
QList<EwsResponseClass>::const_iterator respClassesIt = respClasses.begin();
unsigned i = 0;
Q_FOREACH (const EwsDeleteItemRequest::Response &resp, req->responses()) {
const auto responses{req->responses()};
for (const EwsDeleteItemRequest::Response &resp : responses) {
qDebug() << "Verifying response" << i++;
QCOMPARE(resp.responseClass(), *respClassesIt);
respClassesIt++;
......@@ -261,7 +263,8 @@ void UtEwsDeleteItemRequest::twoItemsSecondFailed()
static const QList<EwsResponseClass> respClasses = {EwsResponseError, EwsResponseSuccess};
QList<EwsResponseClass>::const_iterator respClassesIt = respClasses.begin();
unsigned i = 0;
Q_FOREACH (const EwsDeleteItemRequest::Response &resp, req->responses()) {
const auto responses{req->responses()};
for (const EwsDeleteItemRequest::Response &resp : responses) {
qDebug() << "Verifying response" << i++;
QCOMPARE(resp.responseClass(), *respClassesIt);
respClassesIt++;
......
......@@ -117,7 +117,8 @@ void UtEwsGetItemRequest::twoFailures()
QList<EwsResponseClass>::const_iterator respClassesIt = respClasses.begin();
EwsId::List::const_iterator idsIt = ids.cbegin();
unsigned i = 0;
Q_FOREACH (const EwsGetItemRequest::Response &resp, req->responses()) {
const auto responses{req->responses()};
for (const EwsGetItemRequest::Response &resp : responses) {
qDebug() << "Verifying response" << i++;
QCOMPARE(resp.responseClass(), *respClassesIt);
if (resp.isSuccess()) {
......
......@@ -297,7 +297,8 @@ template<typename T> void setIncidence(KCalendarCore::Incidence &i, const T &e)
}
i.addAttendee(attendee);
}
foreach (const Kolab::Attachment &a, e.attachments()) {
const auto attachments{e.attachments()};
for (const Kolab::Attachment &a : attachments) {
KCalendarCore::Attachment att;
if (!a.uri().empty()) {
att = KCalendarCore::Attachment(fromStdString(a.uri()), fromStdString(a.mimetype()));
......@@ -534,7 +535,8 @@ template<typename T> void setRecurrence(KCalendarCore::Incidence &e, const T &ev
}
if (!rrule.byday().empty()) {
QList<KCalendarCore::RecurrenceRule::WDayPos> daypos;
foreach (const Kolab::DayPos &dp, rrule.byday()) {
const auto bydays{rrule.byday()};
for (const Kolab::DayPos &dp : bydays) {
daypos.append(toWeekDayPos(dp));
}
defaultRR->setByDays(daypos);
......
......@@ -260,7 +260,8 @@ Freebusy aggregateFreeBusy(const std::vector<Freebusy> &fbList, const std::strin
allDay |= fb.start().isDateOnly();
}
Q_FOREACH (const Kolab::FreebusyPeriod &period, fb.periods()) {
const auto fbPeriods{fb.periods()};
for (const Kolab::FreebusyPeriod &period : fbPeriods) {
Kolab::FreebusyPeriod simplifiedPeriod;
simplifiedPeriod.setPeriods(period.periods());
simplifiedPeriod.setType(period.type());
......@@ -286,7 +287,8 @@ std::string toIFB(const Kolab::Freebusy &freebusy)
{
KCalendarCore::FreeBusy::Ptr fb(new KCalendarCore::FreeBusy(Kolab::Conversion::toDate(freebusy.start()), Kolab::Conversion::toDate(freebusy.end())));
KCalendarCore::FreeBusyPeriod::List list;
Q_FOREACH (const Kolab::FreebusyPeriod &fbPeriod, freebusy.periods()) {
const auto freePeriods{freebusy.periods()};
for (const Kolab::FreebusyPeriod &fbPeriod : freePeriods) {
Q_FOREACH (const Kolab::Period &p, fbPeriod.periods()) {
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
......
......@@ -181,7 +181,8 @@ KOLAB_EXPORT QString generateMemberUrl(const RelationMember &member)
} else {
path << "shared";
}
Q_FOREACH (const QByteArray &mb, member.mailbox) {
const auto memberMailbox{member.mailbox};
for (const QByteArray &mb : memberMailbox) {
path << QUrl::toPercentEncoding(QString::fromUtf8(mb));
}
path << QByteArray::number(member.uid);
......
......@@ -269,7 +269,7 @@ QVariant MIMEObject::Private::readKolabV2(const KMime::Message::Ptr &msg, Kolab:
Kolab::Dictionary dictionary(Conversion::toStdString(dictionaryLanguage));
std::vector<std::string> convertedEntries;
convertedEntries.reserve(entries.count());
foreach (const QString &value, entries) {
for (const QString &value : entries) {
convertedEntries.push_back(Conversion::toStdString(value));
}
dictionary.setEntries(convertedEntries);
......
......@@ -190,12 +190,12 @@ public:
// delete index data for changed entries
// re-added below in an extra loop to handled cases where a new index is equal to an
// old index of a different entry
Q_FOREACH (const KMBox::MBoxEntry::Pair &entry, movedEntries) {
for (const KMBox::MBoxEntry::Pair &entry : std::as_const(movedEntries)) {
mIndexData.remove(entry.first.messageOffset());
}
// re-add index data for changed entries at their new position
Q_FOREACH (const KMBox::MBoxEntry::Pair &entry, movedEntries) {
for (const KMBox::MBoxEntry::Pair &entry : std::as_const(movedEntries)) {
const KMIndexDataPtr data = indexData.value(entry.first.messageOffset());
mIndexData.insert(entry.second.messageOffset(), data);
}
......
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