diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,8 +37,8 @@ remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII) - ########### Targets ########### +add_definitions(-DQT_NO_FOREACH) add_subdirectory(src) if(BUILD_TESTING) diff --git a/autotests/testholidayregion.h b/autotests/testholidayregion.h --- a/autotests/testholidayregion.h +++ b/autotests/testholidayregion.h @@ -42,7 +42,7 @@ private: void printMetadata(const KHolidays::HolidayRegion ®ion); - void printHolidays(KHolidays::Holiday::List holidays); + void printHolidays(const KHolidays::Holiday::List &holidays); void parseRegionCalendarYear(const KHolidays::HolidayRegion ®ion, int year, const QString &calendarType = "gregorian"); void parseRegionDateRange(const KHolidays::HolidayRegion ®ion, const QDate &startDate, const QDate &endDate); diff --git a/autotests/testholidayregion.cpp b/autotests/testholidayregion.cpp --- a/autotests/testholidayregion.cpp +++ b/autotests/testholidayregion.cpp @@ -44,10 +44,10 @@ qDebug() << ""; } -void HolidayRegionTest::printHolidays(KHolidays::Holiday::List holidays) +void HolidayRegionTest::printHolidays(const KHolidays::Holiday::List &holidays) { if (!holidays.isEmpty()) { - foreach (const KHolidays::Holiday &holiday, holidays) { + for (const KHolidays::Holiday &holiday : holidays) { qDebug() << "Date = " << holiday.observedStartDate().toString(Qt::ISODate) << " Duration = " << holiday.duration() << " Name = " << holiday.name(); @@ -139,15 +139,15 @@ void HolidayRegionTest::testRegions() { qDebug() << "Available region codes:"; - QStringList regionCodes = KHolidays::HolidayRegion::regionCodes(); - foreach (const QString ®ionCode, regionCodes) { + const QStringList regionCodes = KHolidays::HolidayRegion::regionCodes(); + for (const QString ®ionCode : regionCodes) { KHolidays::HolidayRegion testRegion(regionCode); qDebug() << regionCode << " = " << testRegion.name(); } qDebug() << ""; qDebug() << "This years holidays:"; - foreach (const QString ®ionCode, regionCodes) { + for (const QString ®ionCode : regionCodes) { KHolidays::HolidayRegion testRegion(regionCode); printMetadata(testRegion); parseRegionCalendarYear(testRegion, QDate::currentDate().year()); diff --git a/src/holidayregion.cpp b/src/holidayregion.cpp --- a/src/holidayregion.cpp +++ b/src/holidayregion.cpp @@ -1128,7 +1128,7 @@ languageSubdivisionAndLanguageMatch, languageSubdivisionOnlyMatch; const QStringList regionList = KHolidays::HolidayRegion::regionCodes(); - foreach (const QString ®ionCode, regionList) { + for (const QString ®ionCode : regionList) { QString regionCountry = KHolidays::HolidayRegion::countryCode(regionCode).toLower(); QString regionSubdivisionCountry; if (regionCountry.split(QLatin1Char('-')).count() > 1) { diff --git a/src/parsers/plan2/holidayparserdriverplan.cpp b/src/parsers/plan2/holidayparserdriverplan.cpp --- a/src/parsers/plan2/holidayparserdriverplan.cpp +++ b/src/parsers/plan2/holidayparserdriverplan.cpp @@ -95,7 +95,7 @@ void HolidayParserDriverPlan::parse() { // Parse the file using every calendar system in the file - foreach (const QString &calendarType, m_fileCalendarTypes) { + for (const QString &calendarType : qAsConst(m_fileCalendarTypes)) { // Cater for events defined in other Calendar Systems where request year could cover 2 or 3 event years // Perhaps also parse year before and year after to allow events to span years or shift to other year? @@ -337,7 +337,7 @@ // Return the jd of an existing event, assumes unique names and correct order in file int HolidayParserDriverPlan::julianDayFromEventName(const QString &eventName) { - foreach (const KHolidays::Holiday &thisHoliday, m_resultList) { + for (const KHolidays::Holiday &thisHoliday : qAsConst(m_resultList)) { if (thisHoliday.name() == eventName) { return thisHoliday.observedStartDate().toJulianDay(); }