QtCore: eradicate all Q_FOREACH loops [itemmodels]
Saves more than 4KiB in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: Ice3fe915622a399d1ed10e0ce364cf54b4b835fe Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
parent
2d2d44a3d1
commit
90484f3901
@ -498,7 +498,7 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel()
|
||||
|
||||
void QAbstractItemModelPrivate::invalidatePersistentIndexes()
|
||||
{
|
||||
foreach (QPersistentModelIndexData *data, persistent.indexes) {
|
||||
for (QPersistentModelIndexData *data : qAsConst(persistent.indexes)) {
|
||||
data->index = QModelIndex();
|
||||
data->model = 0;
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const
|
||||
Q_D(const QAbstractProxyModel);
|
||||
QModelIndexList list;
|
||||
list.reserve(indexes.count());
|
||||
foreach(const QModelIndex &index, indexes)
|
||||
for (const QModelIndex &index : indexes)
|
||||
list << mapToSource(index);
|
||||
return d->model->mimeData(list);
|
||||
}
|
||||
|
@ -490,7 +490,8 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPe
|
||||
{
|
||||
Q_Q(QIdentityProxyModel);
|
||||
|
||||
foreach(const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) {
|
||||
const auto proxyPersistentIndexes = q->persistentIndexList();
|
||||
for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) {
|
||||
proxyIndexes << proxyPersistentIndex;
|
||||
Q_ASSERT(proxyPersistentIndex.isValid());
|
||||
const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
|
||||
@ -500,7 +501,7 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPe
|
||||
|
||||
QList<QPersistentModelIndex> parents;
|
||||
parents.reserve(sourceParents.size());
|
||||
foreach (const QPersistentModelIndex &parent, sourceParents) {
|
||||
for (const QPersistentModelIndex &parent : sourceParents) {
|
||||
if (!parent.isValid()) {
|
||||
parents << QPersistentModelIndex();
|
||||
continue;
|
||||
@ -526,7 +527,7 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersistentM
|
||||
|
||||
QList<QPersistentModelIndex> parents;
|
||||
parents.reserve(sourceParents.size());
|
||||
foreach (const QPersistentModelIndex &parent, sourceParents) {
|
||||
for (const QPersistentModelIndex &parent : sourceParents) {
|
||||
if (!parent.isValid()) {
|
||||
parents << QPersistentModelIndex();
|
||||
continue;
|
||||
|
@ -482,7 +482,7 @@ static QVector<QPersistentModelIndex> qSelectionPersistentindexes(const QItemSel
|
||||
static QVector<QPair<QPersistentModelIndex, uint> > qSelectionPersistentRowLengths(const QItemSelection &sel)
|
||||
{
|
||||
QVector<QPair<QPersistentModelIndex, uint> > result;
|
||||
Q_FOREACH (const QItemSelectionRange &range, sel)
|
||||
for (const QItemSelectionRange &range : sel)
|
||||
rowLengthsFromRange(range, result);
|
||||
return result;
|
||||
}
|
||||
|
@ -1013,7 +1013,7 @@ QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes()
|
||||
Q_Q(QSortFilterProxyModel);
|
||||
QModelIndexPairList source_indexes;
|
||||
source_indexes.reserve(persistent.indexes.count());
|
||||
foreach (QPersistentModelIndexData *data, persistent.indexes) {
|
||||
for (QPersistentModelIndexData *data : qAsConst(persistent.indexes)) {
|
||||
QModelIndex proxy_index = data->index;
|
||||
QModelIndex source_index = q->mapToSource(proxy_index);
|
||||
source_indexes.append(qMakePair(proxy_index, QPersistentModelIndex(source_index)));
|
||||
@ -1325,7 +1325,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<Q
|
||||
saved_persistent_indexes.clear();
|
||||
|
||||
QList<QPersistentModelIndex> parents;
|
||||
foreach (const QPersistentModelIndex &parent, sourceParents) {
|
||||
for (const QPersistentModelIndex &parent : sourceParents) {
|
||||
if (!parent.isValid()) {
|
||||
parents << QPersistentModelIndex();
|
||||
continue;
|
||||
@ -1366,7 +1366,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersisten
|
||||
}
|
||||
|
||||
QList<QPersistentModelIndex> parents;
|
||||
foreach (const QPersistentModelIndex &parent, sourceParents) {
|
||||
for (const QPersistentModelIndex &parent : sourceParents) {
|
||||
if (!parent.isValid()) {
|
||||
parents << QPersistentModelIndex();
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user