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

port some foreach

parent 0ecea2dc
Pipeline #49570 failed with stage
in 20 minutes and 6 seconds
......@@ -353,7 +353,8 @@ QDateTime Settings::getSyncRangeStart() const
void Settings::buildUrlsList()
{
foreach (const QString &serializedUrl, remoteUrls()) {
const auto remoteUrlsLst = remoteUrls();
for (const QString &serializedUrl : remoteUrlsLst) {
auto urlConfig = new UrlConfiguration(serializedUrl);
const QString key = urlConfig->mUrl + QLatin1Char(',') + KDAV::ProtocolInfo::protocolName(KDAV::Protocol(urlConfig->mProtocol));
const QString pass = loadPassword(key, urlConfig->mUser);
......@@ -536,7 +537,8 @@ void Settings::updateToV3()
{
QStringList updatedUrls;
foreach (const QString &url, remoteUrls()) {
const auto remoteUrlsLst = remoteUrls();
for (const QString &url : remoteUrlsLst) {
QStringList splitUrl = url.split(QLatin1Char('|'));
if (splitUrl.size() == 3) {
......
......@@ -42,7 +42,8 @@ bool EwsEventRequestBase::parseNotificationsResponse(QXmlStreamReader &reader)
if (EWSCLI_REQUEST_LOG().isDebugEnabled()) {
if (resp.isSuccess()) {
int numEv = 0;
Q_FOREACH (const Notification &nfy, resp.notifications()) {
const auto notifications = resp.notifications();
for (const Notification &nfy : notifications) {
numEv += nfy.events().size();
}
qCDebugNC(EWSCLI_REQUEST_LOG)
......
......@@ -31,7 +31,7 @@ void EwsFolderShape::writeProperties(QXmlStreamWriter &writer) const
if (!mProps.isEmpty()) {
writer.writeStartElement(ewsTypeNsUri, QStringLiteral("AdditionalProperties"));
foreach (const EwsPropertyField &prop, mProps) {
for (const EwsPropertyField &prop : qAsConst(mProps)) {
prop.write(writer);
}
......
......@@ -225,7 +225,7 @@ void EwsSubscriptionWidgetPrivate::populateFolderTree()
mFolderTreeModel->clear();
mFolderItemHash.clear();
Q_FOREACH (const EwsFolder &folder, mFolders) {
for (const EwsFolder &folder : qAsConst(mFolders)) {
QStandardItem *item = new QStandardItem(folder[EwsFolderFieldDisplayName].toString());
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
item->setCheckable(true);
......
......@@ -56,7 +56,8 @@ void EwsCreateMailJob::doStart()
msg->changeEncoding(KMime::Headers::CEbase64);
msg->contentTransferEncoding(true)->setEncoding(KMime::Headers::CEbase64);
} else {
Q_FOREACH (KMime::Content *content, msg->contents()) {
const auto contents = msg->contents();
for (KMime::Content *content : contents) {
content->changeEncoding(KMime::Headers::CEbase64);
content->contentTransferEncoding(true)->setEncoding(KMime::Headers::CEbase64);
}
......
......@@ -35,10 +35,12 @@ EwsFetchMailDetailJob::EwsFetchMailDetailJob(EwsClient &client, QObject *parent,
shape << EwsPropertyField(QStringLiteral("message:ReplyTo"));
shape << EwsPropertyField(QStringLiteral("message:InternetMessageId"));
shape << EwsPropertyField(QStringLiteral("item:Size"));
Q_FOREACH (const EwsPropertyField &field, EwsMailHandler::flagsProperties()) {
const auto flagsProperties = EwsMailHandler::flagsProperties();
for (const EwsPropertyField &field : flagsProperties) {
shape << field;
}
Q_FOREACH (const EwsPropertyField &field, EwsItemHandler::tagsProperties()) {
const auto tagsProperties = EwsItemHandler::tagsProperties();
for (const EwsPropertyField &field : tagsProperties) {
shape << field;
}
mRequest->setItemShape(shape);
......
......@@ -90,7 +90,7 @@ bool EwsTagStore::unserializeTag(const QByteArray &data, Akonadi::Tag &tag) cons
tag.setName(name);
tag.setGid(gid);
Q_FOREACH (Attribute *attr, attributes) {
for (Attribute *attr : qAsConst(attributes)) {
tag.addAttribute(attr);
}
......
......@@ -44,7 +44,7 @@ void EwsUpdateItemsTagsJob::start()
* as the uid. If the EWS resource hasn't seen these tags yet it is necessary to fetch them
* first before any further processing.
*/
Q_FOREACH (const Item &item, mItems) {
for (const Item &item : qAsConst(mItems)) {
Q_FOREACH (const Tag &tag, item.tags()) {
if (!mTagStore->containsId(tag.id())) {
unknownTags.append(tag);
......
......@@ -769,7 +769,7 @@ void KAlarmDirResource::retrieveItems(const Akonadi::Collection &collection)
// Retrieve events
Item::List items;
foreach (const EventFile &data, mEvents) {
for (const EventFile &data : qAsConst(mEvents)) {
const KAEvent &event = data.event;
const QString mime = CalEvent::mimeType(event.category());
if (mime.isEmpty()) {
......@@ -820,7 +820,7 @@ void KAlarmDirResource::fileCreated(const QString &path)
// The directory has been created. Load all files in it, and
// tell the Akonadi server to create an Item for each event.
loadFiles(true);
foreach (const EventFile &data, mEvents) {
for (const EventFile &data : qAsConst(mEvents)) {
createItem(data.event);
}
} else {
......@@ -832,7 +832,7 @@ void KAlarmDirResource::fileCreated(const QString &path)
if (createItemAndIndex(path, file)) {
setCompatibility();
}
DEBUG_DATA("fileCreated:");
DEBUG_DATA("fileCreated:")
}
}
}
......
......@@ -239,8 +239,8 @@ Kolab::Role fromRole(KCalendarCore::Attendee::Role r)
template<typename T> QString getCustomProperty(const QString &id, const T &e)
{
std::vector<Kolab::CustomProperty> &props = e.customProperties();
foreach (const Kolab::CustomProperty &p, props) {
const std::vector<Kolab::CustomProperty> &props = e.customProperties();
for (const Kolab::CustomProperty &p : props) {
if (fromStdString(p.identifier) == id) {
return fromStdString(p.value);
}
......@@ -682,7 +682,8 @@ template<typename T, typename I> void getRecurrence(T &i, const I &e)
foreach (const QDateTime &dt, rec->exDateTimes()) {
exdates.push_back(fromDate(dt, e.allDay()));
}
foreach (const QDate &dt, rec->exDates()) {
const auto exDates = rec->exDates();
for (const QDate &dt : exDates) {
exdates.push_back(fromDate(QDateTime(dt, {}), true));
}
i.setExceptionDates(exdates);
......@@ -775,7 +776,8 @@ template<typename T, typename I> void getTodoEvent(T &i, const I &e)
break;
case KCalendarCore::Alarm::Email: {
std::vector<Kolab::ContactReference> receipents;
foreach (const KCalendarCore::Person &p, a->mailAddresses()) {
const auto mailAddresses = a->mailAddresses();
for (const KCalendarCore::Person &p : mailAddresses) {
receipents.push_back(Kolab::ContactReference(toStdString(p.email()), toStdString(p.name())));
}
alarm = Kolab::Alarm(toStdString(a->mailSubject()), toStdString(a->mailText()), receipents);
......
......@@ -183,7 +183,7 @@ Freebusy generateFreeBusy(const QVector<KCalendarCore::Event::Ptr> &events,
// TODO try to merge that with KCalendarCore::Freebusy
std::vector<Kolab::FreebusyPeriod> freebusyPeriods;
Q_FOREACH (const KCalendarCore::Event::Ptr &event, events) {
for (const KCalendarCore::Event::Ptr &event : events) {
// If this event is transparent it shouldn't be in the freebusy list.
if (event->transparency() == KCalendarCore::Event::Transparent) {
continue;
......
......@@ -44,7 +44,8 @@ std::vector<Event> fromICalEvents(const std::string &input)
format.setApplication(QStringLiteral("libkolab"), QStringLiteral(LIBKOLAB_LIB_VERSION_STRING));
format.fromString(calendar, Conversion::fromStdString(input));
std::vector<Event> events;
foreach (const KCalendarCore::Event::Ptr &event, calendar->events()) {
const auto eventsList = calendar->events();
for (const KCalendarCore::Event::Ptr &event : eventsList) {
events.push_back(Conversion::fromKCalendarCore(*event));
}
return events;
......
......@@ -70,7 +70,7 @@ Event XMLObject::readEvent(const std::string &s, Version version)
}
mAttachments.clear();
mAttachments.reserve(attachments.count());
foreach (const QString &attachment, attachments) {
for (const QString &attachment : qAsConst(attachments)) {
mAttachments.push_back(Conversion::toStdString(attachment));
}
return Conversion::fromKCalendarCore(*event);
......@@ -114,7 +114,7 @@ Todo XMLObject::readTodo(const std::string &s, Version version)
}
mAttachments.clear();
mAttachments.reserve(attachments.count());
foreach (const QString &attachment, attachments) {
for (const QString &attachment : qAsConst(attachments)) {
mAttachments.push_back(Conversion::toStdString(attachment));
}
return Conversion::fromKCalendarCore(*event);
......@@ -158,7 +158,7 @@ Journal XMLObject::readJournal(const std::string &s, Version version)
}
mAttachments.clear();
mAttachments.reserve(attachments.count());
foreach (const QString &attachment, attachments) {
for (const QString &attachment : qAsConst(attachments)) {
mAttachments.push_back(Conversion::toStdString(attachment));
}
return Conversion::fromKCalendarCore(*event);
......@@ -316,7 +316,7 @@ Configuration XMLObject::readConfiguration(const std::string &s, Version version
}
std::vector<std::string> entries;
entries.reserve(dict.size());
foreach (const QString &e, dict) {
for (const QString &e : qAsConst(dict)) {
entries.push_back(Conversion::toStdString(e));
}
Kolab::Dictionary dictionary(Conversion::toStdString(lang));
......
......@@ -397,7 +397,7 @@ void CollectionModifyTest::testIndexPreservation()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
for (const Item &item : qAsConst(items)) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
++flagCounts[flag];
}
......@@ -437,8 +437,9 @@ void CollectionModifyTest::testIndexPreservation()
QCOMPARE((int)items.count(), 4);
flagCounts.clear();
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -536,8 +537,9 @@ void CollectionModifyTest::testIndexCacheUpdate()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -554,8 +556,9 @@ void CollectionModifyTest::testIndexCacheUpdate()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -582,8 +585,9 @@ void CollectionModifyTest::testIndexCacheUpdate()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -600,8 +604,9 @@ void CollectionModifyTest::testIndexCacheUpdate()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......
......@@ -154,8 +154,9 @@ void CollectionMoveTest::testMoveToTopLevel()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -201,8 +202,9 @@ void CollectionMoveTest::testMoveToTopLevel()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -253,8 +255,9 @@ void CollectionMoveTest::testMoveToTopLevel()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -300,8 +303,9 @@ void CollectionMoveTest::testMoveToTopLevel()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -451,8 +455,9 @@ void CollectionMoveTest::testMoveToMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -540,8 +545,9 @@ void CollectionMoveTest::testMoveToMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -625,8 +631,9 @@ void CollectionMoveTest::testMoveToMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -664,8 +671,9 @@ void CollectionMoveTest::testMoveToMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -711,8 +719,9 @@ void CollectionMoveTest::testMoveToMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -753,8 +762,9 @@ void CollectionMoveTest::testMoveToMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -795,8 +805,9 @@ void CollectionMoveTest::testMoveToMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -837,8 +848,9 @@ void CollectionMoveTest::testMoveToMaildir()
items = itemFetch->items();
QCOMPARE((int)items.count(), 4);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......
......@@ -421,8 +421,9 @@ void ItemDeleteTest::testCachePreservation()
items = itemFetch->items();
QCOMPARE((int)items.count(), 3);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......@@ -481,8 +482,9 @@ void ItemDeleteTest::testCachePreservation()
items = itemFetch->items();
QCOMPARE((int)items.count(), 3);
Q_FOREACH (const Item &item, items) {
Q_FOREACH (const QByteArray &flag, item.flags()) {
for (const Item &item : qAsConst(items)) {
const auto flags = item.flags();
for (const QByteArray &flag : flags) {
++flagCounts[flag];
}
}
......
......@@ -171,7 +171,7 @@ public:
KMBox::MBoxEntry::List deletedEntries;
deletedEntries.reserve(deleteCount);
Q_FOREACH (quint64 offset, mDeletedOffsets) {
for (quint64 offset : qAsConst(mDeletedOffsets)) {
deletedEntries << KMBox::MBoxEntry(offset);
}
......@@ -1263,7 +1263,7 @@ bool MixedMaildirStore::Private::visit(FileStore::CollectionModifyJob *job)
}
// update collections in MBox contexts so they stay usable for purge
Q_FOREACH (const MBoxPtr &mbox, mMBoxes) {
for (const MBoxPtr &mbox : qAsConst(mMBoxes)) {
if (mbox->mCollection.isValid()) {
MBoxPtr updatedMBox = mbox;
updatedMBox->mCollection = updateMBoxCollectionTree(mbox->mCollection, collection, renamedCollection);
......@@ -1433,7 +1433,7 @@ bool MixedMaildirStore::Private::visit(FileStore::CollectionMoveJob *job)
movedCollection.setParentCollection(targetCollection);
// update collections in MBox contexts so they stay usable for purge
Q_FOREACH (const MBoxPtr &mbox, mMBoxes) {
for (const MBoxPtr &mbox : qAsConst(mMBoxes)) {
if (mbox->mCollection.isValid()) {
MBoxPtr updatedMBox = mbox;
updatedMBox->mCollection = updateMBoxCollectionTree(mbox->mCollection, moveCollection, movedCollection);
......
......@@ -715,7 +715,7 @@ QList<int> POP3Resource::shouldDeleteId(int downloadedId) const
}
// Now save the messages from deletion
//
foreach (int idToSave, mIdsToSave) {
for (int idToSave : qAsConst(mIdsToSave)) {
idsToDeleteFromServer.removeAll(idToSave);
}
if (downloadedId != -1 && !mIdsToSave.contains(downloadedId)) {
......
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