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

Port some foreach

parent de2fd09c
......@@ -1676,7 +1676,7 @@ QVector<int> Agenda::minContentsY() const
{
QVector<int> minArray;
minArray.fill(timeToY(QTime(23, 59)), d->mSelectedDates.count());
foreach (AgendaItem::QPtr item, d->mItems) {
for (AgendaItem::QPtr item : qAsConst(d->mItems)) {
if (item) {
int ymin = item->cellYTop();
int index = item->cellXLeft();
......@@ -1695,7 +1695,7 @@ QVector<int> Agenda::maxContentsY() const
{
QVector<int> maxArray;
maxArray.fill(timeToY(QTime(0, 0)), d->mSelectedDates.count());
foreach (AgendaItem::QPtr item, d->mItems) {
for (AgendaItem::QPtr item : qAsConst(d->mItems)) {
if (item) {
int ymax = item->cellYBottom();
......@@ -2175,7 +2175,7 @@ void Agenda::selectItem(const AgendaItem::QPtr &item)
Q_ASSERT(d->mSelectedItem->incidence());
d->mSelectedId = d->mSelectedItem->incidence()->uid();
foreach (AgendaItem::QPtr item, d->mItems) {
for (AgendaItem::QPtr item : qAsConst(d->mItems)) {
if (item && item->incidence()->uid() == d->mSelectedId) {
item->select();
}
......@@ -2185,7 +2185,7 @@ void Agenda::selectItem(const AgendaItem::QPtr &item)
void Agenda::selectIncidenceByUid(const QString &uid)
{
foreach (AgendaItem::QPtr item, d->mItems) {
for (const AgendaItem::QPtr &item : qAsConst(d->mItems)) {
if (item && item->incidence()->uid() == uid) {
selectItem(item);
break;
......
......@@ -449,7 +449,7 @@ void AgendaView::Private::calendarIncidenceChanged(const KCalCore::Incidence::Pt
KCalCore::Incidence::Ptr originalIncidence = agendaItems.first()->incidence();
if (datesEqual(originalIncidence, incidence)) {
foreach (const AgendaItem::QPtr &agendaItem, agendaItems) {
for (const AgendaItem::QPtr &agendaItem : qAsConst(agendaItems)) {
agendaItem->setIncidence(KCalCore::Incidence::Ptr(incidence->clone()));
agendaItem->update();
}
......@@ -1241,7 +1241,7 @@ void AgendaView::createDayLabels(bool force)
d->mDateDayLabels.append(dayLabel);
// if a holiday region is selected, show the holiday name
const QStringList texts = CalendarSupport::holiday(date);
Q_FOREACH (const QString &text, texts) {
for (const QString &text : texts) {
// Compute a small version of the holiday string for AlternateLabel
const KWordWrap ww = KWordWrap::formatText(fm, topDayLabelBox->rect(), 0, text, -1);
AlternateLabel *label = new AlternateLabel(ww.truncatedString(), text, text, topDayLabelBox);
......@@ -1282,7 +1282,7 @@ void AgendaView::updateDayLabelSizes()
{
// First, calculate the maximum text type that fits for all labels
AlternateLabel::TextType overallType = AlternateLabel::Extensive;
foreach (AlternateLabel *label, d->mDateDayLabels) {
for (AlternateLabel *label : qAsConst(d->mDateDayLabels)) {
AlternateLabel::TextType type = label->largestFittingTextType();
if (type < overallType) {
overallType = type;
......
......@@ -317,7 +317,7 @@ void MonthGraphicsItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWi
// assume that all pixmaps have the same height
int pixYPos = icons.isEmpty() ? 0 : (textRect.height() - icons.at(0).height()) / 2;
foreach (const QPixmap &icon, icons) {
for (const QPixmap &icon : qAsConst(icons)) {
p->drawPixmap(curXPos, pixYPos, icon);
curXPos += icon.width();
}
......
......@@ -508,7 +508,7 @@ Akonadi::Item::List TodoView::selectedIncidences() const
Akonadi::Item::List ret;
const QModelIndexList selection = mView->selectionModel()->selectedRows();
ret.reserve(selection.count());
Q_FOREACH (const QModelIndex &mi, selection) {
for (const QModelIndex &mi : selection) {
ret << mi.data(TodoModel::TodoRole).value<Akonadi::Item>();
}
return ret;
......
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