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()
|
void QAbstractItemModelPrivate::invalidatePersistentIndexes()
|
||||||
{
|
{
|
||||||
foreach (QPersistentModelIndexData *data, persistent.indexes) {
|
for (QPersistentModelIndexData *data : qAsConst(persistent.indexes)) {
|
||||||
data->index = QModelIndex();
|
data->index = QModelIndex();
|
||||||
data->model = 0;
|
data->model = 0;
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const
|
|||||||
Q_D(const QAbstractProxyModel);
|
Q_D(const QAbstractProxyModel);
|
||||||
QModelIndexList list;
|
QModelIndexList list;
|
||||||
list.reserve(indexes.count());
|
list.reserve(indexes.count());
|
||||||
foreach(const QModelIndex &index, indexes)
|
for (const QModelIndex &index : indexes)
|
||||||
list << mapToSource(index);
|
list << mapToSource(index);
|
||||||
return d->model->mimeData(list);
|
return d->model->mimeData(list);
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,8 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPe
|
|||||||
{
|
{
|
||||||
Q_Q(QIdentityProxyModel);
|
Q_Q(QIdentityProxyModel);
|
||||||
|
|
||||||
foreach(const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) {
|
const auto proxyPersistentIndexes = q->persistentIndexList();
|
||||||
|
for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) {
|
||||||
proxyIndexes << proxyPersistentIndex;
|
proxyIndexes << proxyPersistentIndex;
|
||||||
Q_ASSERT(proxyPersistentIndex.isValid());
|
Q_ASSERT(proxyPersistentIndex.isValid());
|
||||||
const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
|
const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
|
||||||
@ -500,7 +501,7 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPe
|
|||||||
|
|
||||||
QList<QPersistentModelIndex> parents;
|
QList<QPersistentModelIndex> parents;
|
||||||
parents.reserve(sourceParents.size());
|
parents.reserve(sourceParents.size());
|
||||||
foreach (const QPersistentModelIndex &parent, sourceParents) {
|
for (const QPersistentModelIndex &parent : sourceParents) {
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
parents << QPersistentModelIndex();
|
parents << QPersistentModelIndex();
|
||||||
continue;
|
continue;
|
||||||
@ -526,7 +527,7 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersistentM
|
|||||||
|
|
||||||
QList<QPersistentModelIndex> parents;
|
QList<QPersistentModelIndex> parents;
|
||||||
parents.reserve(sourceParents.size());
|
parents.reserve(sourceParents.size());
|
||||||
foreach (const QPersistentModelIndex &parent, sourceParents) {
|
for (const QPersistentModelIndex &parent : sourceParents) {
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
parents << QPersistentModelIndex();
|
parents << QPersistentModelIndex();
|
||||||
continue;
|
continue;
|
||||||
|
@ -482,7 +482,7 @@ static QVector<QPersistentModelIndex> qSelectionPersistentindexes(const QItemSel
|
|||||||
static QVector<QPair<QPersistentModelIndex, uint> > qSelectionPersistentRowLengths(const QItemSelection &sel)
|
static QVector<QPair<QPersistentModelIndex, uint> > qSelectionPersistentRowLengths(const QItemSelection &sel)
|
||||||
{
|
{
|
||||||
QVector<QPair<QPersistentModelIndex, uint> > result;
|
QVector<QPair<QPersistentModelIndex, uint> > result;
|
||||||
Q_FOREACH (const QItemSelectionRange &range, sel)
|
for (const QItemSelectionRange &range : sel)
|
||||||
rowLengthsFromRange(range, result);
|
rowLengthsFromRange(range, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1013,7 +1013,7 @@ QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes()
|
|||||||
Q_Q(QSortFilterProxyModel);
|
Q_Q(QSortFilterProxyModel);
|
||||||
QModelIndexPairList source_indexes;
|
QModelIndexPairList source_indexes;
|
||||||
source_indexes.reserve(persistent.indexes.count());
|
source_indexes.reserve(persistent.indexes.count());
|
||||||
foreach (QPersistentModelIndexData *data, persistent.indexes) {
|
for (QPersistentModelIndexData *data : qAsConst(persistent.indexes)) {
|
||||||
QModelIndex proxy_index = data->index;
|
QModelIndex proxy_index = data->index;
|
||||||
QModelIndex source_index = q->mapToSource(proxy_index);
|
QModelIndex source_index = q->mapToSource(proxy_index);
|
||||||
source_indexes.append(qMakePair(proxy_index, QPersistentModelIndex(source_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();
|
saved_persistent_indexes.clear();
|
||||||
|
|
||||||
QList<QPersistentModelIndex> parents;
|
QList<QPersistentModelIndex> parents;
|
||||||
foreach (const QPersistentModelIndex &parent, sourceParents) {
|
for (const QPersistentModelIndex &parent : sourceParents) {
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
parents << QPersistentModelIndex();
|
parents << QPersistentModelIndex();
|
||||||
continue;
|
continue;
|
||||||
@ -1366,7 +1366,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersisten
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<QPersistentModelIndex> parents;
|
QList<QPersistentModelIndex> parents;
|
||||||
foreach (const QPersistentModelIndex &parent, sourceParents) {
|
for (const QPersistentModelIndex &parent : sourceParents) {
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
parents << QPersistentModelIndex();
|
parents << QPersistentModelIndex();
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user