Commit 534fa387 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some Q_FOREACH

parent 6f1bb9b7
......@@ -111,7 +111,7 @@ EwsFolder::EwsFolder(QXmlStreamReader &reader)
// Check what item type are we
uint i = 0;
d->mType = EwsFolderTypeUnknown;
Q_FOREACH (const QString &name, folderTypeNames) {
for (const QString &name : qAsConst(folderTypeNames)) {
if (name == reader.name()) {
d->mType = static_cast<EwsFolderType>(i);
break;
......
......@@ -135,7 +135,7 @@ QString EwsServerVersion::toString() const
version.append(QStringLiteral(".%1.%2").arg(mMajorBuild).arg(mMinorBuild));
}
Q_FOREACH (const EwsServerVersion &ver, knownVersions) {
for (const EwsServerVersion &ver : knownVersions) {
if (*this == ver) {
version.append(QStringLiteral(" (") + ver.mFriendlyName + QStringLiteral(")"));
}
......
......@@ -76,13 +76,13 @@ void EwsSubscribeRequest::start()
}
writer.writeStartElement(ewsTypeNsUri, QStringLiteral("FolderIds"));
Q_FOREACH (const EwsId &id, mFolderIds) {
for (const EwsId &id : qAsConst(mFolderIds)) {
id.writeFolderIds(writer);
}
writer.writeEndElement();
writer.writeStartElement(ewsTypeNsUri, QStringLiteral("EventTypes"));
Q_FOREACH (const EwsEventType type, mEventTypes) {
for (const EwsEventType type : qAsConst(mEventTypes)) {
writer.writeTextElement(ewsTypeNsUri, QStringLiteral("EventType"), eventTypeNames[type]);
}
writer.writeEndElement(); // EventTypes
......
......@@ -53,7 +53,7 @@ void EwsUpdateFolderRequest::start()
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("UpdateFolder"));
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("FolderChanges"));
Q_FOREACH (const FolderChange &ch, mChanges) {
for (const FolderChange &ch : qAsConst(mChanges)) {
ch.write(writer);
}
writer.writeEndElement();
......
......@@ -85,7 +85,7 @@ void EwsUpdateItemRequest::start()
}
writer.writeStartElement(ewsMsgNsUri, QStringLiteral("ItemChanges"));
Q_FOREACH (const ItemChange &ch, mChanges) {
for (const ItemChange &ch : qAsConst(mChanges)) {
ch.write(writer);
}
writer.writeEndElement();
......
......@@ -139,7 +139,7 @@ EwsConfigDialog::EwsConfigDialog(EwsResource *parentResource, EwsClient &client,
int selectedIndex = -1;
int i = 0;
Q_FOREACH (const StringPair &item, userAgents) {
for (const StringPair &item : qAsConst(userAgents)) {
mUi->userAgentCombo->addItem(item.first, item.second);
if (mSettings->userAgent() == item.second) {
selectedIndex = i;
......
......@@ -428,7 +428,7 @@ bool EwsFetchFoldersIncrJobPrivate::processRemoteFolders()
if (reparentPassNeeded) {
qCDebugNC(EWSRES_LOG) << QStringLiteral("Executing reparent pass") << topLevelList;
Q_FOREACH (const QString &id, topLevelList) {
for (const QString &id : qAsConst(topLevelList)) {
reparentRemoteFolder(id);
}
}
......@@ -451,9 +451,9 @@ bool EwsFetchFoldersIncrJobPrivate::processRemoteFolders()
void EwsFetchFoldersIncrJobPrivate::reparentRemoteFolder(const QString &id)
{
qCDebugNC(EWSRES_LOG) << QStringLiteral("Reparenting") << id;
QStringList children = mParentMap.values(id);
const QStringList children = mParentMap.values(id);
FolderDescr &fd = mFolderHash[id];
Q_FOREACH (const QString &childId, children) {
for (const QString &childId : children) {
FolderDescr &childFd = mFolderHash[childId];
if (!childFd.isProcessed() && childFd.isModified()
&& childFd.parent() != childFd.collection.parentCollection().remoteId()) {
......
......@@ -287,8 +287,8 @@ void EwsFetchFoldersJobPrivate::buildChildCollectionList(const Collection &col)
{
Q_Q(EwsFetchFoldersJob);
QStringList children = mParentMap.values(col.remoteId());
Q_FOREACH (const QString &childId, children) {
const QStringList children = mParentMap.values(col.remoteId());
for (const QString &childId : children) {
Collection child(mCollectionMap.take(childId));
child.setParentCollection(col);
q->mFolders.append(child);
......
......@@ -44,7 +44,7 @@ void EwsFetchItemDetailJob::setItemLists(const Akonadi::Item::List &changedItems
EwsId::List ids;
ids.reserve(changedItems.count());
Q_FOREACH (const Akonadi::Item &item, changedItems) {
for (const Akonadi::Item &item : changedItems) {
EwsId id(item.remoteId(), item.remoteRevision());
ids.append(id);
}
......
......@@ -259,7 +259,7 @@ void EwsFetchItemsJob::compareItemLists()
Q_EMIT percent(0);
QHash<QString, Item> itemHash;
Q_FOREACH (const Item &item, mLocalItems) {
for (const Item &item : qAsConst(mLocalItems)) {
itemHash.insert(item.remoteId(), item);
}
......@@ -426,7 +426,7 @@ void EwsFetchItemsJob::itemDetailFetchDone(KJob *job)
void EwsFetchItemsJob::setQueuedUpdates(const QueuedUpdateList &updates)
{
mQueuedUpdates.clear();
Q_FOREACH (const QueuedUpdate &upd, updates) {
for (const QueuedUpdate &upd : updates) {
mQueuedUpdates[upd.type].insert(upd.id, upd.changeKey);
qCDebugNC(EWSRES_LOG) << QStringLiteral("Queued update %1 for item %2").arg(upd.type).arg(ewsHash(upd.id));
}
......
......@@ -1075,7 +1075,7 @@ void EwsResource::messageSendRequestFinished(KJob *job)
void EwsResource::foldersModifiedEvent(const EwsId::List &folders)
{
Q_FOREACH (const EwsId &id, folders) {
for (const EwsId &id : folders) {
Collection c;
c.setRemoteId(id.id());
CollectionFetchJob *job = new CollectionFetchJob(c, CollectionFetchJob::Base);
......@@ -1142,7 +1142,7 @@ void EwsResource::specialFoldersCollectionsRetrieved(const Collection::List &fol
EwsId::List queryItems;
queryItems.reserve(specialFolderList.count());
Q_FOREACH (const SpecialFolders &sf, specialFolderList) {
for (const SpecialFolders &sf : qAsConst(specialFolderList)) {
queryItems.append(EwsId(sf.did));
}
......
......@@ -41,11 +41,12 @@ void EwsSubscribedFoldersJob::start()
// Before subscribing make sure the subscription list doesn't contain invalid folders.
// Do this also for the default list in order to transform the distinguished IDs into real ones.
if (mSettings->serverSubscriptionList() == QStringList() << QStringLiteral("default")) {
const auto serverSubscriptionList = mSettings->serverSubscriptionList();
if (serverSubscriptionList == QStringList() << QStringLiteral("default")) {
ids = defaultSubscriptionFolders();
} else {
ids.reserve(mSettings->serverSubscriptionList().count());
Q_FOREACH (const QString &id, mSettings->serverSubscriptionList()) {
ids.reserve(serverSubscriptionList.count());
for (const QString &id : serverSubscriptionList) {
ids << EwsId(id);
}
}
......
......@@ -51,10 +51,10 @@ QByteArray EwsTagStore::serializeTag(const Akonadi::Tag &tag) const
stream.setVersion(TagDataVer1StreamVer);
stream << TagDataVer1;
stream << tag.name() << tag.gid();
Attribute::List attrs = tag.attributes();
const Attribute::List attrs = tag.attributes();
stream << static_cast<int>(attrs.size());
Q_FOREACH (const Attribute *attr, attrs) {
for (const Attribute *attr : attrs) {
stream << attr->type();
stream << attr->serialized();
}
......@@ -123,7 +123,7 @@ bool EwsTagStore::readTags(const QStringList &taglist, int version)
mTagData.clear();
Q_FOREACH (const QString &tag, taglist) {
for (const QString &tag : taglist) {
QByteArray tagdata = qUncompress(QByteArray::fromBase64(tag.toLatin1()));
if (tagdata.isNull()) {
qCDebugNC(EWSRES_LOG) << QStringLiteral("Incorrect tag data");
......@@ -204,7 +204,7 @@ bool EwsTagStore::syncTags(const Akonadi::Tag::List &tags)
bool changed = false;
QList<QByteArray> tagIds = mTagData.keys();
Q_FOREACH (const Tag &tag, tags) {
for (const Tag &tag : tags) {
QByteArray serialized = serializeTag(tag);
auto it = mTagData.find(tag.gid());
/* First check if the tag exists or if it has been changed. Only once that is done
......@@ -234,7 +234,7 @@ bool EwsTagStore::syncTags(const Akonadi::Tag::List &tags)
}
}
Q_FOREACH (const QByteArray &tagId, tagIds) {
for (const QByteArray &tagId : qAsConst(tagIds)) {
mTagData.remove(tagId);
}
......@@ -274,9 +274,9 @@ bool EwsTagStore::readEwsProperties(Akonadi::Item &item, const EwsItem &ewsItem,
{
QVariant tagProp = ewsItem[EwsResource::tagsProperty];
if (tagProp.isValid() && tagProp.canConvert<QStringList>()) {
QStringList tagRids = tagProp.toStringList();
Q_FOREACH (const QString &tagRid, tagRids) {
Tag::Id tagId = tagIdForRid(tagRid.toLatin1());
const QStringList tagRids = tagProp.toStringList();
for (const QString &tagRid : tagRids) {
const Tag::Id tagId = tagIdForRid(tagRid.toLatin1());
if (tagId == -1) {
/* Tag not found. */
qCDebug(EWSRES_LOG) << QStringLiteral("Found missing tag: %1").arg(tagRid);
......
......@@ -323,7 +323,7 @@ FakeEwsServer::DialogEntry::HttpResponse FakeEwsConnection::handleGetEventsReque
FakeEwsServer *server = qobject_cast<FakeEwsServer *>(parent());
const QStringList events = server->retrieveEventsXml();
qCInfoNC(EWSFAKE_LOG) << QStringLiteral("Returning %1 events.").arg(events.size());
Q_FOREACH (const QString &eventXml, events) {
for (const QString &eventXml : events) {
resp += eventXml;
}
......
......@@ -209,7 +209,7 @@ Freebusy generateFreeBusy(const QList<KCalCore::Event::Ptr> &events, const QDate
if (event->recurs()) {
const KCalCore::Duration duration(eventStart, eventEnd);
const auto list = event->recurrence()->timesInInterval(start, end);
Q_FOREACH (const auto &dt, list) {
for (const auto &dt : list) {
const auto utc = dt.toUTC();
const Kolab::Period &period = addLocalPeriod(utc, duration.end(utc), start, end, allDay);
if (period.isValid()) {
......
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