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