Commit 46100744 authored by Laurent Montel's avatar Laurent Montel 😁

Port to for(...:...)

parent 860b94df
......@@ -49,6 +49,9 @@ find_package(KF5 ${KF5_VERSION} REQUIRED COMPONENTS
find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED)
add_definitions( -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT )
add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII")
############## Targets ##############
add_subdirectory(src)
add_subdirectory(examples)
......
......@@ -202,8 +202,8 @@ ObjectPtr Private::JSONToCalendar(const QVariantMap& data)
calendar->setEditable(false);
}
QVariantList reminders = data.value(QStringLiteral("defaultReminders")).toList();
Q_FOREACH(const QVariant & r, reminders) {
const QVariantList reminders = data.value(QStringLiteral("defaultReminders")).toList();
for (const QVariant &r : reminders) {
QVariantMap reminder = r.toMap();
ReminderPtr rem(new Reminder());
......@@ -390,8 +390,8 @@ ObjectPtr Private::JSONToEvent(const QVariantMap& data, const QString &timezone)
}
/* Attendees */
QVariantList attendees = data.value(QStringLiteral("attendees")).toList();
Q_FOREACH(const QVariant & a, attendees) {
const QVariantList attendees = data.value(QStringLiteral("attendees")).toList();
for (const QVariant & a : attendees) {
QVariantMap att = a.toMap();
KCalCore::Attendee::Ptr attendee(
new KCalCore::Attendee(
......@@ -425,8 +425,8 @@ ObjectPtr Private::JSONToEvent(const QVariantMap& data, const QString &timezone)
}
/* Recurrence */
QStringList recrs = data.value(QStringLiteral("recurrence")).toStringList();
Q_FOREACH(const QString & rec, recrs) {
const QStringList recrs = data.value(QStringLiteral("recurrence")).toStringList();
for (const QString & rec : recrs) {
KCalCore::ICalFormat format;
if (rec.left(5) == QLatin1String("RRULE")) {
KCalCore::RecurrenceRule *recurrenceRule = new KCalCore::RecurrenceRule();
......@@ -536,11 +536,11 @@ QByteArray eventToJSON(const EventPtr& event)
const auto exRules = event->recurrence()->exRules();
const auto rRules = event->recurrence()->rRules();
recurrence.reserve(rRules.size() + rRules.size() + 2);
Q_FOREACH(KCalCore::RecurrenceRule * rRule, rRules) {
for (KCalCore::RecurrenceRule *rRule : rRules) {
recurrence << format.toString(rRule).remove(QStringLiteral("\r\n"));
}
Q_FOREACH(KCalCore::RecurrenceRule * rRule, exRules) {
for (KCalCore::RecurrenceRule *rRule : exRules) {
recurrence << format.toString(rRule).remove(QStringLiteral("\r\n"));
}
......@@ -747,8 +747,8 @@ KCalCore::DateList Private::parseRDate(const QString& rule)
}
QString datesStr = rule.mid(rule.lastIndexOf(QLatin1Char(':')) + 1);
QStringList dates = datesStr.split(QLatin1Char(','));
Q_FOREACH(const QString &date, dates) {
const QStringList dates = datesStr.split(QLatin1Char(','));
for (const QString &date : dates) {
QDate dt;
if (value == QLatin1String("DATE")) {
......
......@@ -60,7 +60,7 @@ ObjectsList parseJSONFeed(const QByteArray& jsonFeed, FeedData& feedData)
const QVariantMap head = document.toVariant().toMap();
const QVariantMap feed = head.value(QStringLiteral("feed")).toMap();
const QVariantList categories = feed.value(QStringLiteral("category")).toList();
Q_FOREACH(const QVariant &c, categories) {
for (const QVariant &c : categories) {
const QVariantMap category = c.toMap();
bool groups = false;
......@@ -69,7 +69,7 @@ ObjectsList parseJSONFeed(const QByteArray& jsonFeed, FeedData& feedData)
}
const QVariantList entries = feed.value(QStringLiteral("entry")).toList();
Q_FOREACH(const QVariant &e, entries) {
for (const QVariant &e : entries) {
if (groups) {
output << Private::JSONToContactsGroup(e.toMap());
} else {
......@@ -267,7 +267,7 @@ ContactsGroupPtr JSONToContactsGroup(const QByteArray& jsonData)
const QVariantList categories = entry.value(QStringLiteral("category")).toList();
bool isGroup = false;
Q_FOREACH(const QVariant &c, categories) {
for (const QVariant &c : categories) {
const QVariantMap category = c.toMap();
if (category.value(QStringLiteral("term")).toString() == QLatin1String("http://schemas.google.com/contact/2008#group")) {
......@@ -398,7 +398,7 @@ ObjectPtr Private::JSONToContact(const QVariantMap& data)
/* Anniversary */
if (data.contains(QStringLiteral("gContact$event"))) {
const QVariantList events = data.value(QStringLiteral("gContact$event")).toList();
Q_FOREACH(const QVariant &e, events) {
for (const QVariant &e : events) {
const QVariantMap event = e.toMap();
if (event.value(QStringLiteral("rel")).toString() == QLatin1String("anniversary")) {
......@@ -438,7 +438,7 @@ ObjectPtr Private::JSONToContact(const QVariantMap& data)
/* IMs */
const QVariantList ims = data.value(QStringLiteral("gd$im")).toList();
Q_FOREACH(const QVariant & i, ims) {
for (const QVariant & i : ims) {
const QVariantMap im = i.toMap();
const QString protocol = Contact::IMSchemeToProtocolName(im.value(QStringLiteral("protocol")).toString());
contact->insertCustom(QLatin1String("messaging/") + protocol,
......@@ -448,7 +448,7 @@ ObjectPtr Private::JSONToContact(const QVariantMap& data)
/* Phone numbers */
const QVariantList phones = data.value(QStringLiteral("gd$phoneNumber")).toList();
Q_FOREACH(const QVariant & p, phones) {
for (const QVariant & p : phones) {
const QVariantMap phone = p.toMap();
contact->insertPhoneNumber(KContacts::PhoneNumber(phone.value(QStringLiteral("$t")).toString(),
Contact::phoneSchemeToType(phone.value(QStringLiteral("rel")).toString())));
......@@ -456,7 +456,7 @@ ObjectPtr Private::JSONToContact(const QVariantMap& data)
/* Addresses */
const QVariantList addresses = data.value(QStringLiteral("gd$structuredPostalAddress")).toList();
Q_FOREACH(const QVariant & a, addresses) {
for (const QVariant &a : addresses) {
const QVariantMap address = a.toMap();
KContacts::Address addr;
if (!address.contains(QStringLiteral("gd$city")) &&
......@@ -506,7 +506,7 @@ ObjectPtr Private::JSONToContact(const QVariantMap& data)
/* User-defined fields */
const QVariantList userDefined = data.value(QStringLiteral("gContact$userDefinedField")).toList();
Q_FOREACH(const QVariant & u, userDefined) {
for (const QVariant & u : userDefined) {
const QVariantMap field = u.toMap();
contact->insertCustom(QStringLiteral("KADDRESSBOOK"),
field.value(QStringLiteral("key")).toString(),
......@@ -516,7 +516,7 @@ ObjectPtr Private::JSONToContact(const QVariantMap& data)
/* Groups */
const QVariantList groups = data.value(QStringLiteral("gContact$groupMembershipInfo")).toList();
QStringList groupsList;
Q_FOREACH(const QVariant & g, groups) {
for (const QVariant & g : groups) {
const QVariantMap group = g.toMap();
if (group.value(QStringLiteral("deleted")).toBool() == false) {
groupsList.append(group.value(QStringLiteral("href")).toString());
......@@ -536,7 +536,7 @@ ContactPtr JSONToContact(const QByteArray& jsonData)
const QVariantList categories = entry.value(QStringLiteral("category")).toList();
bool isContact = false;
Q_FOREACH(const QVariant &c, categories) {
for (const QVariant &c : categories) {
const QVariantMap category = c.toMap();
if (category.value(QStringLiteral("term")).toString() == QLatin1String("http://schemas.google.com/contact/2008#contact")) {
......
......@@ -1074,7 +1074,7 @@ QByteArray File::toJSON(const FilePtr &file, SerializationOptions options)
file->d->userPermission = Permission::Private::fromJSON(userPermissionData);
const QVariantList parents = map[QLatin1String("parents")].toList();
Q_FOREACH (const QVariant &parent, parents)
for (const QVariant &parent : parents)
{
file->d->parents << ParentReference::Private::fromJSON(parent.toMap());
}
......@@ -1096,7 +1096,7 @@ QByteArray File::toJSON(const FilePtr &file, SerializationOptions options)
const QVariantList ownersList = map[QLatin1String("owners")].toList();
Q_FOREACH (const QVariant &owner, ownersList) {
for (const QVariant &owner : ownersList) {
file->d->owners << User::fromJSON(owner.toMap());
}
......
......@@ -285,7 +285,7 @@ QByteArray Permission::toJSON(const PermissionPtr &permission)
QVariantList additionalRoles;
const auto roles = permission->additionalRoles();
additionalRoles.reserve(roles.size());
Q_FOREACH(Permission::Role additionalRole, roles) { // krazy:exclude=foreach it's POD
for (Permission::Role additionalRole : roles) {
additionalRoles << Private::roleToName(additionalRole);
}
if (!additionalRoles.isEmpty()) {
......
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