ItemViews: use range-based for instead of foreach

Change-Id: I250b3e3db4d44a622a20ca42baac819a17efdd94
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Anton Kudryavtsev 2018-04-12 18:36:44 +03:00 committed by Anton Kudryavtsev
parent c6af7cf666
commit 302a1bc7b7
6 changed files with 8 additions and 8 deletions

View File

@ -4086,7 +4086,7 @@ bool QHeaderViewPrivate::read(QDataStream &in)
}
int sectionItemsLengthTotal = 0;
foreach (const SectionItem &section, newSectionItems)
for (const SectionItem &section : qAsConst(newSectionItems))
sectionItemsLengthTotal += section.size;
if (sectionItemsLengthTotal != lengthIn)
return false;

View File

@ -2601,7 +2601,7 @@ int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wr
positions = segmentPositions;
else if (!flowPositions.isEmpty()) {
positions.reserve(scrollValueMap.size());
foreach (int itemShown, scrollValueMap)
for (int itemShown : scrollValueMap)
positions.append(flowPositions.at(itemShown));
}
if (positions.isEmpty() || bounds <= length)
@ -2782,7 +2782,7 @@ bool QIconModeViewBase::filterDropEvent(QDropEvent *e)
if (qq->acceptDrops()) {
const Qt::ItemFlags dropableFlags = Qt::ItemIsDropEnabled|Qt::ItemIsEnabled;
const QVector<QModelIndex> &dropIndices = intersectingSet(QRect(end, QSize(1, 1)));
foreach (const QModelIndex &index, dropIndices)
for (const QModelIndex &index : dropIndices)
if ((index.flags() & dropableFlags) == dropableFlags)
return false;
}

View File

@ -1844,7 +1844,7 @@ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*> items) const
// if non empty, it's called from the model's own mimeData
if (cachedIndexes.isEmpty()) {
cachedIndexes.reserve(items.count());
foreach (QListWidgetItem *item, items)
for (QListWidgetItem *item : items)
cachedIndexes << indexFromItem(item);
QMimeData *result = d->listModel()->internalMimeData();

View File

@ -74,7 +74,7 @@ void QSpanCollection::addSpan(QSpanCollection::Span *span)
//the previouslist is the list of spans that sarts _before_ the row of the span.
// and which may intersect this row.
const SubIndex previousList = it_y.value();
foreach(Span *s, previousList) {
for (Span *s : previousList) {
//If a subspans intersect the row, we need to split it into subspans
if(s->bottom() >= span->top())
sub_index.insert(-s->left(), s);
@ -817,7 +817,7 @@ void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter,
visibleSpans = set.toList();
}
foreach (QSpanCollection::Span *span, visibleSpans) {
for (QSpanCollection::Span *span : qAsConst(visibleSpans)) {
int row = span->top();
int col = span->left();
QModelIndex index = model->index(row, col, root);

View File

@ -2595,7 +2595,7 @@ QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem*> items) const
// if non empty, it's called from the model's own mimeData
if (cachedIndexes.isEmpty()) {
cachedIndexes.reserve(items.count());
foreach (QTableWidgetItem *item, items)
for (QTableWidgetItem *item : items)
cachedIndexes << indexFromItem(item);
QMimeData *result = d->tableModel()->internalMimeData();

View File

@ -1411,7 +1411,7 @@ QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList
if (spanningIndexes.isEmpty())
return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r);
QModelIndexList list;
foreach (const QModelIndex &idx, indexes) {
for (const QModelIndex &idx : indexes) {
if (idx.column() > 0 && q->isFirstColumnSpanned(idx.row(), idx.parent()))
continue;
list << idx;