Commit b7d24f37 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some foreach

parent 2b4d2b41
......@@ -220,7 +220,7 @@ void KOAlarmClient::checkAlarms()
KDateTime(mLastChecked, KDateTime::LocalZone),
true /* exclude blocked alarms */);
foreach (const Alarm::Ptr &alarm, alarms) {
for (const Alarm::Ptr &alarm : alarms) {
const QString uid = alarm->customProperty("ETMCalendar", "parentUid");
const Akonadi::Item::Id id = mCalendar->item(uid).id();
const Akonadi::Item item = mCalendar->item(id);
......
......@@ -1068,9 +1068,9 @@ void ActionManager::exportHTML(KOrg::HTMLExportSettings *settings, bool autoMode
KOrg::HtmlExportJob *exportJob = new KOrg::HtmlExportJob(calendar(), settings, autoMode, mMainWindow, view());
if (KOGlobals::self()->holidays()) {
KHolidays::Holiday::List holidays = KOGlobals::self()->holidays()->holidays(
const KHolidays::Holiday::List holidays = KOGlobals::self()->holidays()->holidays(
settings->dateStart().date(), settings->dateEnd().date());
foreach (const KHolidays::Holiday &holiday, holidays) {
for (const KHolidays::Holiday &holiday : holidays) {
exportJob->addHoliday(holiday.observedStartDate(), holiday.name());
}
}
......@@ -1404,9 +1404,9 @@ void ActionManager::downloadNewStuff()
KMessageBox::error(mCalendarView, i18n("Could not load calendar %1.", file));
} else {
QStringList eventSummaries;
KCalCore::Event::List events = calendar()->events();
const KCalCore::Event::List events = calendar()->events();
eventSummaries.reserve(events.count());
foreach (const KCalCore::Event::Ptr &event, events) {
for (const KCalCore::Event::Ptr &event : events) {
eventSummaries.append(event->summary());
}
......
......@@ -721,7 +721,7 @@ void CalendarView::slotDeleteFinished(int changeId,
{
Q_UNUSED(changeId);
if (resultCode == Akonadi::IncidenceChanger::ResultCodeSuccess) {
foreach (Akonadi::Item::Id id, itemIdList) {
for (Akonadi::Item::Id id : itemIdList) {
Akonadi::Item item = mCalendar->item(id);
if (item.isValid()) {
changeIncidenceDisplay(item, Akonadi::IncidenceChanger::ChangeTypeDelete);
......@@ -1331,7 +1331,7 @@ bool CalendarView::makeChildrenIndependent(const Akonadi::Item &item)
{
const KCalCore::Incidence::Ptr inc = CalendarSupport::incidence(item);
Akonadi::Item::List subIncs = mCalendar->childItems(item.id());
const Akonadi::Item::List subIncs = mCalendar->childItems(item.id());
if (!inc || subIncs.isEmpty()) {
qCDebug(KORGANIZER_LOG) << "Refusing to make children independent" << inc;
......@@ -1339,7 +1339,7 @@ bool CalendarView::makeChildrenIndependent(const Akonadi::Item &item)
}
startMultiModify(i18n("Make sub-to-dos independent"));
foreach (const Akonadi::Item &item, subIncs) {
for (const Akonadi::Item &item : subIncs) {
incidence_unsub(item);
}
......@@ -1782,8 +1782,8 @@ void CalendarView::print()
KCalCore::Incidence::List selectedIncidences;
if (currentView) {
printType = currentView->printType();
Akonadi::Item::List selectedViewIncidences = currentView->selectedIncidences();
foreach (const Akonadi::Item &item, selectedViewIncidences) {
const Akonadi::Item::List selectedViewIncidences = currentView->selectedIncidences();
for (const Akonadi::Item &item : selectedViewIncidences) {
if (item.hasPayload<KCalCore::Incidence::Ptr>()) {
selectedIncidences.append(item.payload<KCalCore::Incidence::Ptr>());
}
......@@ -1805,8 +1805,8 @@ void CalendarView::printPreview()
KCalCore::Incidence::List selectedIncidences;
if (currentView) {
printType = currentView->printType();
Akonadi::Item::List selectedViewIncidences = currentView->selectedIncidences();
foreach (const Akonadi::Item &item, selectedViewIncidences) {
const Akonadi::Item::List selectedViewIncidences = currentView->selectedIncidences();
for (const Akonadi::Item &item : selectedViewIncidences) {
if (item.hasPayload<KCalCore::Incidence::Ptr>()) {
selectedIncidences.append(item.payload<KCalCore::Incidence::Ptr>());
}
......@@ -2727,8 +2727,8 @@ Akonadi::Collection CalendarView::defaultCollection(const QLatin1String &mimeTyp
}
// 5. Try the checked collections
Akonadi::Collection::List collections = checkedCollections();
foreach (const Akonadi::Collection &checkedCollection, collections) {
const Akonadi::Collection::List collections = checkedCollections();
for (const Akonadi::Collection &checkedCollection : collections) {
supportsMimeType = checkedCollection.contentMimeTypes().contains(mimeType) || mimeType == QLatin1String("");
hasRights = checkedCollection.rights() & Akonadi::Collection::CanCreateItem;
if (checkedCollection.isValid() && supportsMimeType && hasRights) {
......
......@@ -93,7 +93,7 @@ void HtmlExportJob::start()
bool canExportItem = false;
// first collect the email addresses of all organisators
const KCalCore::Event::List events = d->mCalendar->events();
foreach (const KCalCore::Event::Ptr &event, events) {
for (const KCalCore::Event::Ptr &event : events) {
Q_ASSERT(event);
const KCalCore::Attendee::List attendees = event->attendees();
if (!attendees.isEmpty()) {
......@@ -109,7 +109,7 @@ void HtmlExportJob::start()
}
const KCalCore::Todo::List todos = d->mCalendar->todos();
foreach (const KCalCore::Todo::Ptr &todo, todos) {
for (const KCalCore::Todo::Ptr &todo : todos) {
Q_ASSERT(todo);
const KCalCore::Attendee::List attendees = todo->attendees();
if (!attendees.isEmpty()) {
......
......@@ -274,7 +274,7 @@ void KODayMatrix::updateJournals()
{
const KCalCore::Incidence::List incidences = mCalendar->incidences();
foreach (const KCalCore::Incidence::Ptr &inc, incidences) {
for (const KCalCore::Incidence::Ptr &inc : incidences) {
Q_ASSERT(inc);
QDate d = inc->dtStart().toTimeSpec(mCalendar->timeSpec()).date();
if (inc->type() == KCalCore::Incidence::TypeJournal &&
......@@ -303,7 +303,7 @@ void KODayMatrix::updateTodos()
{
const KCalCore::Todo::List incidences = mCalendar->todos();
QDate d;
foreach (const KCalCore::Todo::Ptr &t, incidences) {
for (const KCalCore::Todo::Ptr &t : incidences) {
if (mEvents.count() == NUMDAYS) {
// No point in wasting cpu, all days are bold already
break;
......
......@@ -146,8 +146,8 @@ void SummaryEventTester::test_Multiday()
QCOMPARE(ev1->makeBold, false);
// Make sure multiday is only displayed once
for (int i = 1; i < 30; ++i) {
SummaryEventInfo::List events3 = SummaryEventInfo::eventsForDate(today.addDays(multiDayFuture + i), cal);
foreach (SummaryEventInfo *ev, events3) {
const SummaryEventInfo::List events3 = SummaryEventInfo::eventsForDate(today.addDays(multiDayFuture + i), cal);
for (SummaryEventInfo *ev : events3) {
QVERIFY(ev->summaryText.contains(multiDayAllDayInFuture));
}
qDeleteAll(events3);
......
......@@ -277,10 +277,10 @@ void SDSummaryWidget::createLabels()
for (dt = QDate::currentDate();
dt <= QDate::currentDate().addDays(mDaysAhead - 1);
dt = dt.addDays(1)) {
KCalCore::Event::List events = mCalendar->events(dt, mCalendar->timeSpec(),
const KCalCore::Event::List events = mCalendar->events(dt, mCalendar->timeSpec(),
KCalCore::EventSortStartDate,
KCalCore::SortDirectionAscending);
foreach (const KCalCore::Event::Ptr &ev, events) {
for (const KCalCore::Event::Ptr &ev : events) {
// Optionally, show only my Events
/* if ( mShowMineOnly &&
!KCalCore::CalHelper::isMyCalendarIncidence( mCalendarAdaptor, ev. ) ) {
......
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