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

Make it compile without foreach

parent f32c524a
......@@ -71,6 +71,10 @@ if (${Qt5Widgets_VERSION} STRGREATER "5.13")
else()
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)
endif()
if (${KF5Config_VERSION} STRGREATER "5.56.0")
add_definitions(-DQT_NO_FOREACH)
MESSAGE(STATUS "compile without foreach")
endif()
########### CMake Config Files ###########
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5EventViews")
......
......@@ -91,7 +91,7 @@ int MarcusBains::Private::todayColumn() const
int col = 0;
const KCalCore::DateList dateList = mAgenda->dateList();
foreach (const QDate &date, dateList) {
for (const QDate &date : dateList) {
if (date == currentDate) {
return QApplication::isRightToLeft() ? mAgenda->columns() - 1 - col : col;
}
......@@ -1471,7 +1471,7 @@ void Agenda::placeSubCells(const AgendaItem::QPtr &placeItem)
#endif
QList<CalendarSupport::CellItem *> cells;
foreach (CalendarSupport::CellItem *item, d->mItems) {
for (CalendarSupport::CellItem *item : qAsConst(d->mItems)) {
if (item) {
cells.append(item);
}
......@@ -1978,13 +1978,13 @@ void Agenda::removeIncidence(const KCalCore::Incidence::Ptr &incidence)
return; // It's already queued for deletion
}
AgendaItem::List agendaItems = d->mAgendaItemsById.values(incidence->uid());
const AgendaItem::List agendaItems = d->mAgendaItemsById.values(incidence->uid());
if (agendaItems.isEmpty()) {
// We're not displaying such item
// qCDebug(CALENDARVIEW_LOG) << "Ignoring";
return;
}
foreach (const AgendaItem::QPtr &agendaItem, agendaItems) {
for (const AgendaItem::QPtr &agendaItem : agendaItems) {
if (agendaItem) {
if (incidence->instanceIdentifier() != agendaItem->incidence()->instanceIdentifier()) {
continue;
......@@ -2097,7 +2097,7 @@ void Agenda::resizeEvent(QResizeEvent *ev)
void Agenda::resizeAllContents()
{
double subCellWidth;
foreach (const AgendaItem::QPtr &item, d->mItems) {
for (const AgendaItem::QPtr &item : qAsConst(d->mItems)) {
if (item) {
subCellWidth = calcSubCellWidth(item);
placeAgendaItem(item, subCellWidth);
......@@ -2233,7 +2233,7 @@ void Agenda::deselectItem()
const KCalCore::Incidence::Ptr selectedItem = d->mSelectedItem->incidence();
foreach (AgendaItem::QPtr item, d->mItems) {
for (AgendaItem::QPtr item : qAsConst(d->mItems)) {
if (item) {
const KCalCore::Incidence::Ptr itemInc = item->incidence();
if (itemInc && selectedItem && itemInc->uid() == selectedItem->uid()) {
......
......@@ -849,7 +849,7 @@ void AgendaView::init(const QDate &start, const QDate &end)
AgendaView::~AgendaView()
{
foreach (const ViewCalendar::Ptr &cal, d->mViewCalendar->mSubCalendars) {
for (const ViewCalendar::Ptr &cal : qAsConst(d->mViewCalendar->mSubCalendars)) {
if (cal->getCalendar()) {
cal->getCalendar()->unregisterObserver(d);
}
......@@ -1133,9 +1133,8 @@ void AgendaView::placeDecorationsFrame(QFrame *frame, bool decorationsFound, boo
void AgendaView::placeDecorations(DecorationList &decoList, const QDate &date, QWidget *labelBox, bool forWeek)
{
foreach (CalendarDecoration::Decoration *deco, decoList) {
CalendarDecoration::Element::List elements;
elements = forWeek ? deco->weekElements(date) : deco->dayElements(date);
for (CalendarDecoration::Decoration *deco : qAsConst(decoList)) {
const CalendarDecoration::Element::List elements = forWeek ? deco->weekElements(date) : deco->dayElements(date);
if (!elements.isEmpty()) {
auto decoHBox = new QFrame(labelBox);
labelBox->layout()->addWidget(decoHBox);
......@@ -1145,7 +1144,7 @@ void AgendaView::placeDecorations(DecorationList &decoList, const QDate &date, Q
decoHBox->setFrameShape(QFrame::StyledPanel);
decoHBox->setMinimumWidth(1);
foreach (CalendarDecoration::Element *it, elements) {
for (CalendarDecoration::Element *it : elements) {
DecorationLabel *label = new DecorationLabel(it, decoHBox);
label->setAlignment(Qt::AlignBottom);
label->setMinimumWidth(1);
......@@ -1220,7 +1219,7 @@ void AgendaView::createDayLabels(bool force)
loadDecorations(botStrDecos, botDecos), false);
#endif
Q_FOREACH (const QDate &date, d->mSelectedDates) {
for (const QDate &date : qAsConst(d->mSelectedDates)) {
auto topDayLabelBox = new QFrame(d->mTopDayLabels);
auto topDayLabelBoxLayout = new QVBoxLayout(topDayLabelBox);
topDayLabelBoxLayout->setContentsMargins(0, 0, 0, 0);
......@@ -1305,7 +1304,7 @@ void AgendaView::updateDayLabelSizes()
}
// Then, set that maximum text type to all the labels
foreach (AlternateLabel *label, d->mDateDayLabels) {
for (AlternateLabel *label : qAsConst(d->mDateDayLabels)) {
label->setFixedType(overallType);
}
}
......@@ -1434,7 +1433,8 @@ void AgendaView::createTimeBarHeaders()
QFont labelFont = d->mTimeLabelsZone->preferences()->agendaTimeLabelsFont();
labelFont.setPointSize(labelFont.pointSize() - SHRINKDOWN);
foreach (QScrollArea *area, d->mTimeLabelsZone->timeLabels()) {
const auto lst = d->mTimeLabelsZone->timeLabels();
for (QScrollArea *area : lst) {
TimeLabels *timeLabel = static_cast<TimeLabels *>(area->widget());
QLabel *label
= new QLabel(timeLabel->header().replace(QLatin1Char('/'), QStringLiteral("/ ")),
......@@ -1465,7 +1465,8 @@ void AgendaView::updateTimeBarWidth()
int width = d->mTimeLabelsZone->preferedTimeLabelsWidth();
for (QLabel *l : qAsConst(d->mTimeBarHeaders)) {
foreach (const QString &word, l->text().split(QLatin1Char(' '))) {
const auto lst = l->text().split(QLatin1Char(' '));
for (const QString &word : lst) {
width = qMax(width, fm.boundingRect(word).width());
}
}
......@@ -1708,7 +1709,7 @@ void AgendaView::showIncidences(const Akonadi::Item::List &incidences, const QDa
KCalCore::CalFilter *filter = calendar()->filter();
bool wehaveall = true;
if (filter) {
Q_FOREACH (const Akonadi::Item &aitem, incidences) {
for (const Akonadi::Item &aitem : incidences) {
if (!(wehaveall = filter->filterIncidence(CalendarSupport::incidence(aitem)))) {
break;
}
......@@ -1723,7 +1724,7 @@ void AgendaView::showIncidences(const Akonadi::Item::List &incidences, const QDa
QDateTime end = CalendarSupport::incidence(incidences.first())->dateTime(
KCalCore::Incidence::RoleEnd).toLocalTime();
Akonadi::Item first = incidences.first();
Q_FOREACH (const Akonadi::Item &aitem, incidences) {
for (const Akonadi::Item &aitem : incidences) {
if (CalendarSupport::incidence(aitem)->dtStart().toLocalTime() < start) {
first = aitem;
}
......@@ -1784,7 +1785,7 @@ void AgendaView::fillAgenda()
bool somethingReselected = false;
const KCalCore::Incidence::List incidences = d->mViewCalendar->incidences();
foreach (const KCalCore::Incidence::Ptr &incidence, incidences) {
for (const KCalCore::Incidence::Ptr &incidence : incidences) {
Q_ASSERT(incidence);
const bool wasSelected = (incidence->uid() == selectedAgendaId)
|| (incidence->uid() == selectedAllDayAgendaId);
......@@ -2018,7 +2019,7 @@ void AgendaView::slotIncidencesDropped(const KCalCore::Incidence::List &incidenc
const QDate day = d->mSelectedDates[gpos.x()];
QDateTime newTime(day, {}, Qt::LocalTime);
Q_FOREACH (const KCalCore::Incidence::Ptr &incidence, incidences) {
for (const KCalCore::Incidence::Ptr &incidence : incidences) {
const Akonadi::Item existingItem = calendar()->item(incidence);
const bool existsInSameCollection
= existingItem.isValid()
......@@ -2211,8 +2212,8 @@ void AgendaView::removeIncidence(const KCalCore::Incidence::Ptr &incidence)
if (!incidence->hasRecurrenceId() && d->mViewCalendar->isValid(incidence->uid())) {
// Deleted incidence is an main incidence
// Delete all exceptions as well
KCalCore::Incidence::List exceptions = calendar2(incidence->uid())->instances(incidence);
foreach (const KCalCore::Incidence::Ptr &exception, exceptions) {
const KCalCore::Incidence::List exceptions = calendar2(incidence->uid())->instances(incidence);
for (const KCalCore::Incidence::Ptr &exception : exceptions) {
if (exception->allDay()) {
d->mAllDayAgenda->removeIncidence(exception);
} else {
......
......@@ -407,7 +407,8 @@ QString TimeLabels::headerToolTip() const
}
auto abbreviations = QStringLiteral("&nbsp;");
foreach (const auto &transition, mTimezone.transitions(now, now.addYears(1))) {
const auto lst = mTimezone.transitions(now, now.addYears(1));
for (const auto &transition : lst) {
abbreviations += transition.abbreviation;
abbreviations += QLatin1String(",&nbsp;");
}
......
......@@ -68,7 +68,8 @@ void TimeLabelsZone::init()
addTimeLabels(mPrefs->timeZone());
foreach (const QString &zoneStr, mPrefs->timeScaleTimezones()) {
const auto lst = mPrefs->timeScaleTimezones();
for (const QString &zoneStr : lst) {
if (!seenTimeZones.contains(zoneStr)) {
auto zone = QTimeZone(zoneStr.toUtf8());
if (zone.isValid()) {
......@@ -154,7 +155,8 @@ void TimeLabelsZone::setAgendaView(AgendaView *agendaView)
void TimeLabelsZone::updateTimeLabelsPosition()
{
if (mAgenda) {
foreach (QScrollArea *area, timeLabels()) {
const auto lst = timeLabels();
for (QScrollArea *area : lst) {
TimeLabels *label = static_cast<TimeLabels *>(area->widget());
const int adjustment = mAgenda->contentsY();
// y() is the offset to our parent (QScrollArea)
......
......@@ -45,7 +45,7 @@ KCalCore::Calendar::Ptr MultiViewCalendar::getCalendar() const
KCalCore::Incidence::List MultiViewCalendar::incidences() const
{
KCalCore::Incidence::List list;
foreach (const ViewCalendar::Ptr &cal, mSubCalendars) {
for (const ViewCalendar::Ptr &cal : qAsConst(mSubCalendars)) {
if (cal->getCalendar()) {
list += cal->getCalendar()->incidences();
}
......
......@@ -114,7 +114,7 @@ void EventView::setHolidayRegions(const QStringList &regions)
Q_D(EventView);
qDeleteAll(d->mHolidayRegions);
d->mHolidayRegions.clear();
foreach (const QString &regionStr, regions) {
for (const QString &regionStr : regions) {
KHolidays::HolidayRegion *region = new KHolidays::HolidayRegion(regionStr);
if (region->isValid()) {
d->mHolidayRegions.append(region);
......
......@@ -178,14 +178,14 @@ void MonthItem::moveBy(int offsetToPreviousDate)
void MonthItem::updateGeometry()
{
foreach (MonthGraphicsItem *item, mMonthGraphicsItemList) {
for (MonthGraphicsItem *item : qAsConst(mMonthGraphicsItemList)) {
item->updateGeometry();
}
}
void MonthItem::setZValue(qreal z)
{
foreach (MonthGraphicsItem *item, mMonthGraphicsItemList) {
for (MonthGraphicsItem *item : qAsConst(mMonthGraphicsItemList)) {
item->setZValue(z);
}
}
......
......@@ -773,7 +773,8 @@ void MonthScene::removeIncidence(const QString &uid)
continue;
}
if (incidence->uid() == uid) {
foreach (MonthGraphicsItem *gitem, imi->monthGraphicsItems()) {
const auto lst = imi->monthGraphicsItems();
for (MonthGraphicsItem *gitem : lst) {
removeItem(gitem);
}
}
......
......@@ -570,7 +570,7 @@ void MonthView::reloadIncidences()
MonthItem::greaterThan);
// build each month's cell event list
foreach (MonthItem *manager, d->scene->mManagerList) {
for (MonthItem *manager : qAsConst(d->scene->mManagerList)) {
for (QDate date = manager->startDate();
date <= manager->endDate(); date = date.addDays(1)) {
MonthCell *cell = d->scene->mMonthCellMap.value(date);
......@@ -580,12 +580,12 @@ void MonthView::reloadIncidences()
}
}
foreach (MonthItem *manager, d->scene->mManagerList) {
for (MonthItem *manager : qAsConst(d->scene->mManagerList)) {
manager->updateMonthGraphicsItems();
manager->updatePosition();
}
foreach (MonthItem *manager, d->scene->mManagerList) {
for (MonthItem *manager : qAsConst(d->scene->mManagerList)) {
manager->updateGeometry();
}
......
......@@ -270,7 +270,8 @@ void MultiAgendaView::recreateViews()
d->addView(d->mCollectionSelectionModels[i], d->mCustomColumnTitles[i]);
}
} else {
Q_FOREACH (const Akonadi::Collection &i, collectionSelection()->selectedCollections()) {
const auto lst = collectionSelection()->selectedCollections();
for (const Akonadi::Collection &i : lst) {
if (i.contentMimeTypes().contains(KCalCore::Event::eventMimeType())) {
d->addView(i);
}
......@@ -306,7 +307,7 @@ void MultiAgendaView::forceRecreateViews()
void MultiAgendaView::Private::deleteViews()
{
Q_FOREACH (AgendaView *const i, mAgendaViews) {
for (AgendaView *const i : qAsConst(mAgendaViews)) {
KCheckableProxyModel *proxy = i->takeCustomCollectionSelectionProxyModel();
if (proxy && !mCollectionSelectionModels.contains(proxy)) {
delete proxy;
......@@ -322,7 +323,7 @@ void MultiAgendaView::Private::deleteViews()
void MultiAgendaView::Private::setupViews()
{
foreach (AgendaView *agenda, mAgendaViews) {
for (AgendaView *agenda : qAsConst(mAgendaViews)) {
q->connect(agenda, SIGNAL(newEventSignal()),
q, SIGNAL(newEventSignal()));
q->connect(agenda, SIGNAL(newEventSignal(QDate)),
......@@ -372,14 +373,14 @@ void MultiAgendaView::Private::setupViews()
}
AgendaView *lastView = mAgendaViews.last();
foreach (AgendaView *agenda, mAgendaViews) {
for (AgendaView *agenda : qAsConst(mAgendaViews)) {
if (agenda != lastView) {
connect(agenda->agenda()->verticalScrollBar(), &QAbstractSlider::valueChanged,
lastView->agenda()->verticalScrollBar(), &QAbstractSlider::setValue);
}
}
foreach (AgendaView *agenda, mAgendaViews) {
for (AgendaView *agenda : qAsConst(mAgendaViews)) {
agenda->readSettings();
}
}
......@@ -392,7 +393,7 @@ MultiAgendaView::~MultiAgendaView()
Akonadi::Item::List MultiAgendaView::selectedIncidences() const
{
Akonadi::Item::List list;
foreach (AgendaView *agendaView, d->mAgendaViews) {
for (AgendaView *agendaView : qAsConst(d->mAgendaViews)) {
list += agendaView->selectedIncidences();
}
return list;
......@@ -401,7 +402,7 @@ Akonadi::Item::List MultiAgendaView::selectedIncidences() const
KCalCore::DateList MultiAgendaView::selectedIncidenceDates() const
{
KCalCore::DateList list;
foreach (AgendaView *agendaView, d->mAgendaViews) {
for (AgendaView *agendaView : qAsConst(d->mAgendaViews)) {
list += agendaView->selectedIncidenceDates();
}
return list;
......@@ -409,7 +410,7 @@ KCalCore::DateList MultiAgendaView::selectedIncidenceDates() const
int MultiAgendaView::currentDateCount() const
{
foreach (AgendaView *agendaView, d->mAgendaViews) {
for (AgendaView *agendaView : qAsConst(d->mAgendaViews)) {
return agendaView->currentDateCount();
}
return 0;
......@@ -422,14 +423,14 @@ void MultiAgendaView::showDates(const QDate &start, const QDate &end, const QDat
d->mEndDate = end;
slotResizeScrollView();
d->mTimeLabelsZone->updateAll();
foreach (AgendaView *agendaView, d->mAgendaViews) {
for (AgendaView *agendaView : qAsConst(d->mAgendaViews)) {
agendaView->showDates(start, end);
}
}
void MultiAgendaView::showIncidences(const Akonadi::Item::List &incidenceList, const QDate &date)
{
foreach (AgendaView *agendaView, d->mAgendaViews) {
for (AgendaView *agendaView : qAsConst(d->mAgendaViews)) {
agendaView->showIncidences(incidenceList, date);
}
}
......@@ -437,7 +438,7 @@ void MultiAgendaView::showIncidences(const Akonadi::Item::List &incidenceList, c
void MultiAgendaView::updateView()
{
recreateViews();
foreach (AgendaView *agendaView, d->mAgendaViews) {
for (AgendaView *agendaView : qAsConst(d->mAgendaViews)) {
agendaView->updateView();
}
}
......@@ -450,7 +451,7 @@ int MultiAgendaView::maxDatesHint() const
void MultiAgendaView::slotSelectionChanged()
{
foreach (AgendaView *agenda, d->mAgendaViews) {
for (AgendaView *agenda : qAsConst(d->mAgendaViews)) {
if (agenda != sender()) {
agenda->clearSelection();
}
......@@ -459,7 +460,7 @@ void MultiAgendaView::slotSelectionChanged()
bool MultiAgendaView::eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay) const
{
foreach (AgendaView *agenda, d->mAgendaViews) {
for (AgendaView *agenda : qAsConst(d->mAgendaViews)) {
bool valid = agenda->eventDurationHint(startDt, endDt, allDay);
if (valid) {
return true;
......@@ -470,7 +471,7 @@ bool MultiAgendaView::eventDurationHint(QDateTime &startDt, QDateTime &endDt, bo
void MultiAgendaView::slotClearTimeSpanSelection()
{
foreach (AgendaView *agenda, d->mAgendaViews) {
for (AgendaView *agenda : qAsConst(d->mAgendaViews)) {
if (agenda != sender()) {
agenda->clearTimeSpanSelection();
} else {
......@@ -560,14 +561,14 @@ void MultiAgendaView::Private::resizeScrollView(const QSize &size)
void MultiAgendaView::setIncidenceChanger(Akonadi::IncidenceChanger *changer)
{
EventView::setIncidenceChanger(changer);
foreach (AgendaView *agenda, d->mAgendaViews) {
for (AgendaView *agenda : qAsConst(d->mAgendaViews)) {
agenda->setIncidenceChanger(changer);
}
}
void MultiAgendaView::setPreferences(const PrefsPtr &prefs)
{
foreach (AgendaView *agenda, d->mAgendaViews) {
for (AgendaView *agenda : qAsConst(d->mAgendaViews)) {
agenda->setPreferences(prefs);
}
EventView::setPreferences(prefs);
......@@ -578,7 +579,7 @@ void MultiAgendaView::updateConfig()
EventView::updateConfig();
d->mTimeLabelsZone->setPreferences(preferences());
d->mTimeLabelsZone->updateAll();
foreach (AgendaView *agenda, d->mAgendaViews) {
for (AgendaView *agenda : qAsConst(d->mAgendaViews)) {
agenda->updateConfig();
}
}
......@@ -593,7 +594,7 @@ void MultiAgendaView::resizeSplitters()
if (!lastMovedSplitter) {
lastMovedSplitter = d->mLeftSplitter;
}
foreach (AgendaView *agenda, d->mAgendaViews) {
for (AgendaView *agenda : qAsConst(d->mAgendaViews)) {
if (agenda->splitter() == lastMovedSplitter) {
continue;
}
......@@ -620,7 +621,7 @@ void MultiAgendaView::zoomView(const int delta, const QPoint &pos, const Qt::Ori
}
}
foreach (AgendaView *agenda, d->mAgendaViews) {
for (AgendaView *agenda : qAsConst(d->mAgendaViews)) {
agenda->zoomView(delta, pos, ori);
}
......@@ -645,7 +646,7 @@ void MultiAgendaView::showEvent(QShowEvent *event)
void MultiAgendaView::setChanges(Changes changes)
{
EventView::setChanges(changes);
foreach (AgendaView *agenda, d->mAgendaViews) {
for (AgendaView *agenda : qAsConst(d->mAgendaViews)) {
agenda->setChanges(changes);
}
}
......@@ -747,7 +748,7 @@ void MultiAgendaView::doSaveConfig(KConfigGroup &configGroup)
configGroup.writeEntry("CustomNumberOfColumns", d->mCustomNumberOfColumns);
configGroup.writeEntry("ColumnTitles", d->mCustomColumnTitles);
int idx = 0;
foreach (KCheckableProxyModel *checkableProxyModel, d->mCollectionSelectionModels) {
for (KCheckableProxyModel *checkableProxyModel : qAsConst(d->mCollectionSelectionModels)) {
const QString groupName = configGroup.name() + QLatin1String("_subView_") + QString::number(
idx);
KConfigGroup group = configGroup.config()->group(groupName);
......
......@@ -358,7 +358,7 @@ void TimelineView::showDates(const QDate &start, const QDate &end, const QDate &
events = calendar()->events(day, QTimeZone::systemTimeZone(),
KCalCore::EventSortStartDate,
KCalCore::SortDirectionAscending);
Q_FOREACH (const KCalCore::Event::Ptr &event, events) {
for (const KCalCore::Event::Ptr &event : qAsConst(events)) {
if (event->hasRecurrenceId()) {
continue;
}
......
......@@ -157,14 +157,14 @@ void TimelineView::Private::insertIncidence(const Akonadi::Item &incidence)
}
for (QDate day = mStartDate; day <= mEndDate; day = day.addDays(1)) {
KCalCore::Event::List events = q->calendar()->events(day,
const KCalCore::Event::List events = q->calendar()->events(day,
QTimeZone::systemTimeZone(),
KCalCore::EventSortStartDate,
KCalCore::SortDirectionAscending);
if (events.contains(event)) {
//PENDING(AKONADI_PORT) check if correct. also check the original if,
//was inside the for loop (unnecessarily)
foreach (const KCalCore::Event::Ptr &i, events) {
for (const KCalCore::Event::Ptr &i : events) {
Akonadi::Item item = q->calendar()->item(i);
insertIncidence(item, day);
}
......
......@@ -32,7 +32,7 @@ static void calculateDepth(const Node::Ptr &node)
{
Q_ASSERT(node);
node->depth = node->parentNode ? 1 + node->parentNode->depth : 0;
foreach (const Node::Ptr &child, node->directChilds) {
for (const Node::Ptr &child : qAsConst(node->directChilds)) {
calculateDepth(child);
}
}
......@@ -60,7 +60,7 @@ static PreNode::List sortedPrenodes(const PreNode::List &nodes)
while (prenodeByUid.count() < count) {
bool foundAtLeastOne = false; // this bool saves us from infinit looping if the parent doesn't exist
foreach (const PreNode::Ptr &node, remainingNodes) {
for (const PreNode::Ptr &node : nodes) {
Q_ASSERT(node);
const QString uid = node->incidence->instanceIdentifier();
const QString parentUid = node->incidence->relatedTo();
......@@ -321,9 +321,9 @@ void IncidenceTreeModel::Private::onRowsInserted(const QModelIndex &parent, int
nodes << node;
}
PreNode::List sortedNodes = sortedPrenodes(nodes);
const PreNode::List sortedNodes = sortedPrenodes(nodes);
foreach (const PreNode::Ptr &node, sortedNodes) {
for (const PreNode::Ptr &node : sortedNodes) {
insertNode(node);
}
......@@ -411,7 +411,7 @@ void IncidenceTreeModel::Private::insertNode(const PreNode::Ptr &prenode, bool s
m_waitingForParent.remove(node->uid);
Q_ASSERT(!childs.isEmpty());
foreach (const Node::Ptr &child, childs) {
for (const Node::Ptr &child : childs) {
const int fromRow = m_toplevelNodeList.indexOf(child);
Q_ASSERT(fromRow != -1);
const QModelIndex toParent = indexForNode(node);
......@@ -447,7 +447,7 @@ Node::List IncidenceTreeModel::Private::sorted(const Node::List &nodes) const
}
// Initialize depths
foreach (const Node::Ptr &topLevelNode, m_toplevelNodeList) {
for (const Node::Ptr &topLevelNode : qAsConst(m_toplevelNodeList)) {
calculateDepth(topLevelNode);
}
......@@ -485,9 +485,9 @@ void IncidenceTreeModel::Private::onRowsAboutToBeRemoved(const QModelIndex &pare
}
// We want to remove childs first, to avoid row moving
Node::List nodesToRemoveSorted = sorted(nodesToRemove);
const Node::List nodesToRemoveSorted = sorted(nodesToRemove);
foreach (const Node::Ptr &node, nodesToRemoveSorted) {
for (const Node::Ptr &node : nodesToRemoveSorted) {
// Go ahead and remove it now. We don't do it in ::onRowsRemoved(), because
// while unparenting childs with moveRows() the view might call data() on the
// item that is already removed from ETM.
......@@ -508,7 +508,7 @@ void IncidenceTreeModel::Private::removeNode(const Node::Ptr &node)
// First, unparent the children
if (!node->directChilds.isEmpty()) {
Node::List childs = node->directChilds;
const Node::List childs = node->directChilds;
const QModelIndex fromParent = indexForNode(node);
Q_ASSERT(fromParent.isValid());
// const int firstSourceRow = 0;
......@@ -518,7 +518,7 @@ void IncidenceTreeModel::Private::removeNode(const Node::Ptr &node)
// /**toParent is root*/QModelIndex(), toRow );
q->beginResetModel();
node->directChilds.clear();
foreach (const Node::Ptr &child, childs) {
for (const Node::Ptr &child : childs) {
//qCDebug(CALENDARVIEW_LOG) << "Dealing with child: " << child.data() << child->uid;
m_toplevelNodeList.append(child);
child->parentNode = Node::Ptr();
......@@ -916,7 +916,7 @@ QDebug operator<<(QDebug s, const Node::Ptr &node)
<< QStringLiteral(";id=") << node->id << QStringLiteral(";parentUid=") << node->parentUid
<< QStringLiteral(";parentNode=") << (void *)(node->parentNode.data()) << '\n';
foreach (const Node::Ptr &child, node->directChilds) {
for (const Node::Ptr &child : qAsConst(node->directChilds)) {
s << child;
}
......
......@@ -181,8 +181,8 @@ void TodoModel::Private::onLayoutAboutToBeChanged()
Q_ASSERT(m_persistentIndexes.isEmpty());
Q_ASSERT(m_layoutChangePersistentIndexes.isEmpty());
Q_ASSERT(m_columns.isEmpty());
QModelIndexList persistentIndexes = q->persistentIndexList();
foreach (const QPersistentModelIndex &persistentIndex, persistentIndexes) {
const QModelIndexList persistentIndexes = q->persistentIndexList();
for (const QPersistentModelIndex &persistentIndex : persistentIndexes) {
m_persistentIndexes << persistentIndex; // Stuff we have to update onLayoutChanged
Q_ASSERT(persistentIndex.isValid());
QModelIndex index_col0 = q->createIndex(persistentIndex.row(), 0,
......
......@@ -98,7 +98,7 @@ public:
{
const QString todoMimeType = QStringLiteral("application/x-vnd.akonadi.calendar.todo");
if (flat) {
foreach (TodoView *view, views) {
for (TodoView *view : qAsConst(views)) {
// In flatview dropping confuses users and it's very easy to drop into a child item
view->mView->setDragDropMode(QAbstractItemView::DragOnly);