Commit 860b94df authored by Laurent Montel's avatar Laurent Montel 😁

Port some others Q_FOREACH

parent 02a5274e
...@@ -121,7 +121,7 @@ void MainWindow::slotFetchJobFinished(KGAPI2::Job *job) ...@@ -121,7 +121,7 @@ void MainWindow::slotFetchJobFinished(KGAPI2::Job *job)
/* Get all items the job has retrieved */ /* Get all items the job has retrieved */
const KGAPI2::ObjectsList objects = fetchJob->items(); const KGAPI2::ObjectsList objects = fetchJob->items();
Q_FOREACH (const KGAPI2::ObjectPtr &object, objects) { for (const KGAPI2::ObjectPtr &object : objects) {
const KGAPI2::ContactPtr contact = object.dynamicCast<KGAPI2::Contact>(); const KGAPI2::ContactPtr contact = object.dynamicCast<KGAPI2::Contact>();
/* Convert the contact to QListWidget item */ /* Convert the contact to QListWidget item */
......
...@@ -304,7 +304,7 @@ QVariant Post::Private::toJSON(const PostPtr &post) ...@@ -304,7 +304,7 @@ QVariant Post::Private::toJSON(const PostPtr &post)
} }
if (!post->d->images.isEmpty()) { if (!post->d->images.isEmpty()) {
QVariantList images; QVariantList images;
Q_FOREACH (const QUrl &url, post->d->images) { for (const QUrl &url : qAsConst(post->d->images)) {
QVariantMap image; QVariantMap image;
image[QStringLiteral("url")] = url.toString(); image[QStringLiteral("url")] = url.toString();
images << image; images << image;
......
...@@ -263,7 +263,7 @@ ObjectsList parseCalendarJSONFeed(const QByteArray& jsonFeed, FeedData& feedData ...@@ -263,7 +263,7 @@ ObjectsList parseCalendarJSONFeed(const QByteArray& jsonFeed, FeedData& feedData
const QVariantList items = data.value(QStringLiteral("items")).toList(); const QVariantList items = data.value(QStringLiteral("items")).toList();
list.reserve(items.size()); list.reserve(items.size());
Q_FOREACH(const QVariant &i, items) { for (const QVariant &i : items) {
list.append(Private::JSONToCalendar(i.toMap())); list.append(Private::JSONToCalendar(i.toMap()));
} }
...@@ -454,8 +454,8 @@ ObjectPtr Private::JSONToEvent(const QVariantMap& data, const QString &timezone) ...@@ -454,8 +454,8 @@ ObjectPtr Private::JSONToEvent(const QVariantMap& data, const QString &timezone)
event->setUseDefaultReminders(false); event->setUseDefaultReminders(false);
} }
QVariantList overrides = reminders.value(QStringLiteral("overrides")).toList(); const QVariantList overrides = reminders.value(QStringLiteral("overrides")).toList();
Q_FOREACH(const QVariant & r, overrides) { for (const QVariant & r : overrides) {
QVariantMap override = r.toMap(); QVariantMap override = r.toMap();
KCalCore::Alarm::Ptr alarm(new KCalCore::Alarm(static_cast<KCalCore::Incidence*>(event.data()))); KCalCore::Alarm::Ptr alarm(new KCalCore::Alarm(static_cast<KCalCore::Incidence*>(event.data())));
alarm->setTime(event->dtStart()); alarm->setTime(event->dtStart());
...@@ -547,7 +547,7 @@ QByteArray eventToJSON(const EventPtr& event) ...@@ -547,7 +547,7 @@ QByteArray eventToJSON(const EventPtr& event)
QStringList dates; QStringList dates;
const auto rDates = event->recurrence()->rDates(); const auto rDates = event->recurrence()->rDates();
dates.reserve(rDates.size()); dates.reserve(rDates.size());
Q_FOREACH(const QDate & rDate, rDates) { for (const QDate & rDate : rDates) {
dates << rDate.toString(QStringLiteral("yyyyMMdd")); dates << rDate.toString(QStringLiteral("yyyyMMdd"));
} }
...@@ -558,7 +558,7 @@ QByteArray eventToJSON(const EventPtr& event) ...@@ -558,7 +558,7 @@ QByteArray eventToJSON(const EventPtr& event)
dates.clear(); dates.clear();
const auto exDates = event->recurrence()->exDates(); const auto exDates = event->recurrence()->exDates();
dates.reserve(exDates.size()); dates.reserve(exDates.size());
Q_FOREACH(const QDate & exDate, exDates) { for (const QDate & exDate : exDates) {
dates << exDate.toString(QStringLiteral("yyyyMMdd")); dates << exDate.toString(QStringLiteral("yyyyMMdd"));
} }
...@@ -720,7 +720,7 @@ ObjectsList parseEventJSONFeed(const QByteArray& jsonFeed, FeedData& feedData) ...@@ -720,7 +720,7 @@ ObjectsList parseEventJSONFeed(const QByteArray& jsonFeed, FeedData& feedData)
ObjectsList list; ObjectsList list;
const QVariantList items = data.value(QStringLiteral("items")).toList(); const QVariantList items = data.value(QStringLiteral("items")).toList();
list.reserve(items.size()); list.reserve(items.size());
Q_FOREACH(const QVariant &i, items) { for (const QVariant &i : items) {
list.append(Private::JSONToEvent(i.toMap(), timezone)); list.append(Private::JSONToEvent(i.toMap(), timezone));
} }
...@@ -736,8 +736,8 @@ KCalCore::DateList Private::parseRDate(const QString& rule) ...@@ -736,8 +736,8 @@ KCalCore::DateList Private::parseRDate(const QString& rule)
KTimeZone tz; KTimeZone tz;
QString left = rule.left(rule.indexOf(QLatin1Char(':'))); QString left = rule.left(rule.indexOf(QLatin1Char(':')));
QStringList params = left.split(QLatin1Char(';')); const QStringList params = left.split(QLatin1Char(';'));
Q_FOREACH(const QString & param, params) { for (const QString &param : params) {
if (param.startsWith(QLatin1String("VALUE"))) { if (param.startsWith(QLatin1String("VALUE"))) {
value = param.mid(param.indexOf(QLatin1Char('=')) + 1); value = param.mid(param.indexOf(QLatin1Char('=')) + 1);
} else if (param.startsWith(QLatin1String("TZID"))) { } else if (param.startsWith(QLatin1String("TZID"))) {
...@@ -1005,7 +1005,7 @@ QString Private::checkAndConverCDOTZID(const QString& tzid, const EventPtr& even ...@@ -1005,7 +1005,7 @@ QString Private::checkAndConverCDOTZID(const QString& tzid, const EventPtr& even
const QString vcard = format.toICalString(incidence); const QString vcard = format.toICalString(incidence);
const QStringList properties = vcard.split(QLatin1Char('\n')); const QStringList properties = vcard.split(QLatin1Char('\n'));
int CDOId = -1; int CDOId = -1;
Q_FOREACH(const QString &property, properties) { for (const QString &property : properties) {
if (property.startsWith(QStringLiteral("X-MICROSOFT-CDO-TZID"))) { if (property.startsWith(QStringLiteral("X-MICROSOFT-CDO-TZID"))) {
QStringList parsed = property.split(QLatin1Char(':')); QStringList parsed = property.split(QLatin1Char(':'));
if (parsed.length() != 2) { if (parsed.length() != 2) {
......
...@@ -50,7 +50,7 @@ EventDeleteJob::EventDeleteJob(const EventsList& events, const QString& calendar ...@@ -50,7 +50,7 @@ EventDeleteJob::EventDeleteJob(const EventsList& events, const QString& calendar
DeleteJob(account, parent), DeleteJob(account, parent),
d(new Private) d(new Private)
{ {
Q_FOREACH(const EventPtr &event, events) { for (const EventPtr &event : events) {
d->eventsIds << event->uid(); d->eventsIds << event->uid();
} }
d->calendarId = calendarId; d->calendarId = calendarId;
......
...@@ -73,7 +73,7 @@ ContactsGroupDeleteJob::ContactsGroupDeleteJob(const ContactsGroupsList& groups, ...@@ -73,7 +73,7 @@ ContactsGroupDeleteJob::ContactsGroupDeleteJob(const ContactsGroupsList& groups,
d(new Private(this)) d(new Private(this))
{ {
d->groupsIds.reserve(groups.size()); d->groupsIds.reserve(groups.size());
Q_FOREACH(const ContactsGroupPtr &group, groups) { for(const ContactsGroupPtr &group : groups) {
d->groupsIds << group->id(); d->groupsIds << group->id();
} }
} }
......
...@@ -164,7 +164,7 @@ typedef QList<PostPtr> PostsList; ...@@ -164,7 +164,7 @@ typedef QList<PostPtr> PostsList;
template<class T> template<class T>
ObjectsList operator<<(ObjectsList &objectsList, const QList< QSharedPointer<T> > &list) ObjectsList operator<<(ObjectsList &objectsList, const QList< QSharedPointer<T> > &list)
{ {
Q_FOREACH (const QSharedPointer<T> &item, list) { for (const QSharedPointer<T> &item : list) {
objectsList << item; objectsList << item;
} }
......
...@@ -476,7 +476,7 @@ AboutPtr About::fromJSON(const QByteArray &jsonData) ...@@ -476,7 +476,7 @@ AboutPtr About::fromJSON(const QByteArray &jsonData)
} }
const QVariantList exportFormats = map.value(QStringLiteral("exportFormats")).toList(); const QVariantList exportFormats = map.value(QStringLiteral("exportFormats")).toList();
Q_FOREACH (const QVariant &v, exportFormats) { for (const QVariant &v : exportFormats) {
const QVariantMap exportFormat = v.toMap(); const QVariantMap exportFormat = v.toMap();
FormatPtr format(new Format()); FormatPtr format(new Format());
format->d->source = exportFormat.value(QStringLiteral("source")).toString(); format->d->source = exportFormat.value(QStringLiteral("source")).toString();
...@@ -486,13 +486,13 @@ AboutPtr About::fromJSON(const QByteArray &jsonData) ...@@ -486,13 +486,13 @@ AboutPtr About::fromJSON(const QByteArray &jsonData)
} }
const QVariantList additionalRoleInfos = map.value(QStringLiteral("additionalRoleInfo")).toList(); const QVariantList additionalRoleInfos = map.value(QStringLiteral("additionalRoleInfo")).toList();
Q_FOREACH (const QVariant &v, additionalRoleInfos) { for (const QVariant &v : additionalRoleInfos) {
const QVariantMap additionalRoleInfo = v.toMap(); const QVariantMap additionalRoleInfo = v.toMap();
AdditionalRoleInfoPtr info(new AdditionalRoleInfo()); AdditionalRoleInfoPtr info(new AdditionalRoleInfo());
info->d->type = additionalRoleInfo.value(QStringLiteral("type")).toString(); info->d->type = additionalRoleInfo.value(QStringLiteral("type")).toString();
const QVariantList roleSets = additionalRoleInfo.value(QStringLiteral("roleSets")).toList(); const QVariantList roleSets = additionalRoleInfo.value(QStringLiteral("roleSets")).toList();
Q_FOREACH (const QVariant &vv, roleSets) { for (const QVariant &vv : roleSets) {
const QVariantMap roleSetData = vv.toMap(); const QVariantMap roleSetData = vv.toMap();
AdditionalRoleInfo::RoleSetPtr roleSet(new AdditionalRoleInfo::RoleSet()); AdditionalRoleInfo::RoleSetPtr roleSet(new AdditionalRoleInfo::RoleSet());
roleSet->d->primaryRole = roleSetData.value(QStringLiteral("primaryRole")).toString(); roleSet->d->primaryRole = roleSetData.value(QStringLiteral("primaryRole")).toString();
...@@ -505,7 +505,7 @@ AboutPtr About::fromJSON(const QByteArray &jsonData) ...@@ -505,7 +505,7 @@ AboutPtr About::fromJSON(const QByteArray &jsonData)
} }
const QVariantList features = map.value(QStringLiteral("features")).toList(); const QVariantList features = map.value(QStringLiteral("features")).toList();
Q_FOREACH (const QVariant &v, features) { for (const QVariant &v : features) {
const QVariantMap featureData = v.toMap(); const QVariantMap featureData = v.toMap();
FeaturePtr feature(new Feature()); FeaturePtr feature(new Feature());
feature->d->featureName = featureData.value(QStringLiteral("featureName")).toString(); feature->d->featureName = featureData.value(QStringLiteral("featureName")).toString();
...@@ -515,7 +515,7 @@ AboutPtr About::fromJSON(const QByteArray &jsonData) ...@@ -515,7 +515,7 @@ AboutPtr About::fromJSON(const QByteArray &jsonData)
} }
const QVariantList maxUploadSizes = map.value(QStringLiteral("maxUploadSizes")).toList(); const QVariantList maxUploadSizes = map.value(QStringLiteral("maxUploadSizes")).toList();
Q_FOREACH (const QVariant &v, maxUploadSizes) { for (const QVariant &v : maxUploadSizes) {
const QVariantMap maxUploadSizeData = v.toMap(); const QVariantMap maxUploadSizeData = v.toMap();
MaxUploadSizePtr maxUploadSize(new MaxUploadSize()); MaxUploadSizePtr maxUploadSize(new MaxUploadSize());
maxUploadSize->d->type = maxUploadSizeData.value(QStringLiteral("type")).toString(); maxUploadSize->d->type = maxUploadSizeData.value(QStringLiteral("type")).toString();
......
...@@ -78,7 +78,7 @@ ChildReferenceDeleteJob::ChildReferenceDeleteJob(const QString &folderId, ...@@ -78,7 +78,7 @@ ChildReferenceDeleteJob::ChildReferenceDeleteJob(const QString &folderId,
d(new Private) d(new Private)
{ {
d->folderId = folderId; d->folderId = folderId;
Q_FOREACH(const ChildReferencePtr & reference, references) { for (const ChildReferencePtr & reference : references) {
d->childrenIds << reference->id(); d->childrenIds << reference->id();
} }
} }
......
...@@ -632,7 +632,7 @@ FilePtr File::Private::fromJSON(const QVariantMap &map) ...@@ -632,7 +632,7 @@ FilePtr File::Private::fromJSON(const QVariantMap &map)
file->d->shared = map[QStringLiteral("shared")].toBool(); file->d->shared = map[QStringLiteral("shared")].toBool();
const QVariantList ownersList = map[QStringLiteral("owners")].toList(); const QVariantList ownersList = map[QStringLiteral("owners")].toList();
Q_FOREACH (const QVariant &owner, ownersList) { for (const QVariant &owner : ownersList) {
file->d->owners << User::fromJSON(owner.toMap()); file->d->owners << User::fromJSON(owner.toMap());
} }
......
...@@ -104,7 +104,7 @@ PermissionPtr Permission::Private::fromJSON(const QVariantMap &map) ...@@ -104,7 +104,7 @@ PermissionPtr Permission::Private::fromJSON(const QVariantMap &map)
permission->d->role = Private::roleFromName(map[QStringLiteral("role")].toString()); permission->d->role = Private::roleFromName(map[QStringLiteral("role")].toString());
const QStringList additionalRoles = map[QStringLiteral("additionalRoles")].toStringList(); const QStringList additionalRoles = map[QStringLiteral("additionalRoles")].toStringList();
Q_FOREACH(const QString & additionalRole, additionalRoles) { for (const QString & additionalRole : additionalRoles) {
permission->d->additionalRoles << Private::roleFromName(additionalRole); permission->d->additionalRoles << Private::roleFromName(additionalRole);
} }
...@@ -262,7 +262,7 @@ PermissionsList Permission::fromJSONFeed(const QByteArray &jsonData) ...@@ -262,7 +262,7 @@ PermissionsList Permission::fromJSONFeed(const QByteArray &jsonData)
PermissionsList permissions; PermissionsList permissions;
const QVariantList items = map[QStringLiteral("items")].toList(); const QVariantList items = map[QStringLiteral("items")].toList();
Q_FOREACH(const QVariant & item, items) { for (const QVariant & item : items) {
const PermissionPtr permission = Private::fromJSON(item.toMap()); const PermissionPtr permission = Private::fromJSON(item.toMap());
if (!permission.isNull()) { if (!permission.isNull()) {
permissions << permission; permissions << permission;
......
...@@ -94,7 +94,7 @@ ObjectsList parseLocationJSONFeed(const QByteArray & jsonFeed, FeedData & feedDa ...@@ -94,7 +94,7 @@ ObjectsList parseLocationJSONFeed(const QByteArray & jsonFeed, FeedData & feedDa
const QVariantMap data = map.value(QStringLiteral("data")).toMap(); const QVariantMap data = map.value(QStringLiteral("data")).toMap();
const QVariantList items = data.value(QStringLiteral("items")).toList(); const QVariantList items = data.value(QStringLiteral("items")).toList();
output.reserve(items.size()); output.reserve(items.size());
Q_FOREACH(const QVariant &c, items) { for (const QVariant &c : items) {
QVariantMap location = c.toMap(); QVariantMap location = c.toMap();
output << Private::parseLocation(location).dynamicCast<Object>(); output << Private::parseLocation(location).dynamicCast<Object>();
} }
......
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