[kitemmodels] make it compile without foreach

Summary: make it compile without foreach

Test Plan: autotest ok

Reviewers: dfaure

Reviewed By: dfaure

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D19778
wilder
Laurent Montel 7 years ago
parent 3c869d240e
commit 8327e0e065
  1. 2
      CMakeLists.txt
  2. 23
      autotests/proxymodeltestsuite/dynamictreemodel.cpp
  3. 4
      autotests/proxymodeltestsuite/modeleventlogger.cpp
  4. 4
      autotests/proxymodeltestsuite/modeleventlogger.h
  5. 10
      autotests/proxymodeltestsuite/modelspy.cpp
  6. 4
      autotests/proxymodeltestsuite/modelspy.h
  7. 7
      autotests/proxymodeltestsuite/proxymodeltest.cpp
  8. 3
      autotests/proxymodeltestsuite/proxymodeltest.h
  9. 2
      autotests/test_model_helpers.h
  10. 8
      src/kbreadcrumbselectionmodel.cpp
  11. 6
      src/kcheckableproxymodel.cpp
  12. 10
      src/kconcatenaterowsproxymodel.cpp
  13. 5
      src/kdescendantsproxymodel.cpp
  14. 6
      src/kextracolumnsproxymodel.cpp
  15. 2
      src/klinkitemselectionmodel.cpp
  16. 6
      src/kmodelindexproxymapper.cpp
  17. 3
      src/krecursivefilterproxymodel.cpp
  18. 23
      src/kselectionproxymodel.cpp
  19. 4
      tests/proxymodeltestapp/breadcrumbswidget.cpp
  20. 8
      tests/proxymodeltestapp/kreparentingproxymodel.cpp
  21. 4
      tests/proxymodeltestapp/matchcheckingwidget.cpp
  22. 2
      tests/proxymodeltestapp/modelcommanderwidget.cpp

@ -33,7 +33,7 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX KITEMMODELS
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kitemmodels_version.h"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5ItemModelsConfigVersion.cmake"
SOVERSION 5)
add_definitions(-DQT_NO_FOREACH)
add_subdirectory(src)
if (BUILD_TESTING)
add_subdirectory(autotests)

@ -195,7 +195,8 @@ bool DynamicTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action
int _row;
static const int column = 0;
QHash<qint64, QList<QList<qint64> > >::const_iterator it;
Q_FOREACH (const QByteArray &ba, encoded.split('\0')) {
const auto lst = encoded.split('\0');
for (const QByteArray &ba : lst) {
id = ba.toInt(&ok);
if (!ok) {
qDebug() << ba;
@ -281,7 +282,7 @@ bool DynamicTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action
}
int offset = firstCommand->endRow() - firstCommand->startRow() + 1;
Q_FOREACH (ModelMoveCommand *moveCommand, moveCommands) {
for (ModelMoveCommand *moveCommand : qAsConst(moveCommands)) {
moveCommand->setDestAncestors(indexToPath(destParent));
moveCommand->setDestRow(destRowIndex.row() + offset);
moveCommand->doCommand();
@ -601,8 +602,8 @@ void ModelInsertAndRemoveQueuedCommand::purgeItem(qint64 parent)
if (!childItemRows.isEmpty()) {
for (int col = 0; col < m_numCols; col++) {
QList<qint64> childItems = childItemRows[col];
Q_FOREACH (qint64 item, childItems) {
const QList<qint64> childItems = childItemRows[col];
for (qint64 item : childItems) {
purgeItem(item);
m_model->m_childItems[parent][col].removeOne(item);
}
@ -679,12 +680,12 @@ void ModelRemoveCommand::doCommand()
void ModelRemoveCommand::purgeItem(qint64 parent)
{
QList<QList<qint64> > childItemRows = m_model->m_childItems.value(parent);
const QList<QList<qint64> > childItemRows = m_model->m_childItems.value(parent);
if (!childItemRows.isEmpty()) {
for (int col = 0; col < m_numCols; col++) {
QList<qint64> childItems = childItemRows[col];
Q_FOREACH (qint64 item, childItems) {
const QList<qint64> childItems = childItemRows[col];
for (qint64 item : childItems) {
purgeItem(item);
m_model->m_childItems[parent][col].removeOne(item);
}
@ -737,7 +738,7 @@ void ModelMoveCommand::doCommand()
}
for (int column = 0; column < m_numCols; ++column) {
QList<qint64> l = m_model->m_childItems.value(srcParent.internalId())[column].mid(m_startRow, m_endRow - m_startRow + 1);
const QList<qint64> l = m_model->m_childItems.value(srcParent.internalId())[column].mid(m_startRow, m_endRow - m_startRow + 1);
for (int i = m_startRow; i <= m_endRow; i++) {
m_model->m_childItems[srcParent.internalId()][column].removeAt(m_startRow);
@ -753,7 +754,7 @@ void ModelMoveCommand::doCommand()
}
}
Q_FOREACH (const qint64 id, l) {
for (const qint64 id : l) {
if (!m_model->m_childItems.contains(destParent.internalId())) {
m_model->m_childItems[destParent.internalId()].append(QList<qint64>());
@ -926,7 +927,7 @@ void ModelLayoutChangeCommand::doCommand()
m_model->layoutAboutToBeChanged();
QModelIndexList oldList;
Q_FOREACH (const PersistentChange &change, m_changes) {
for (const PersistentChange &change : qAsConst(m_changes)) {
const IndexFinder oldFinder(m_model, change.oldPath);
oldList << oldFinder.getIndex();
}
@ -941,7 +942,7 @@ void ModelLayoutChangeCommand::doCommand()
}
QModelIndexList newList;
Q_FOREACH (const PersistentChange &change, m_changes) {
for (const PersistentChange &change : qAsConst(m_changes)) {
const IndexFinder newFinder(m_model, change.newPath);
newList << newFinder.getIndex();
}

@ -155,7 +155,7 @@ QString ModelEvent::rowAncestors() const
{
QString result(QStringLiteral("QList<int>()"));
Q_FOREACH (const int row, m_rowAncestors) {
for (const int row : qAsConst(m_rowAncestors)) {
result.append(" << ");
result.append(QString::number(row));
}
@ -271,7 +271,7 @@ void ModelEventLogger::layoutAboutToBeChanged()
m_oldPaths.clear();
m_persistentIndexes.clear();
const QModelIndexList list = static_cast<const ModelWrapper *>(m_model)->per();
Q_FOREACH (const QPersistentModelIndex &idx, list) {
for (const QPersistentModelIndex &idx : list) {
m_persistentIndexes.append(idx);
m_oldPaths.append(IndexFinder::indexToIndexFinder(idx).rows());
}

@ -45,7 +45,7 @@ public:
QString getPath(const QList<int> &path) const
{
QString result(QStringLiteral("QList<int>()"));
Q_FOREACH (const int part, path) {
for (const int part : path) {
result.append(QLatin1String(" << "));
result.append(QString::number(part));
}
@ -123,7 +123,7 @@ public:
QVariantList changes() const
{
QVariantList list;
Q_FOREACH (PersistentChange *change, m_changedPaths) {
for (PersistentChange *change : qAsConst(m_changedPaths)) {
list.append(QVariant::fromValue(static_cast<QObject *>(change)));
}
return list;

@ -203,16 +203,16 @@ QModelIndexList ModelSpy::getDescendantIndexes(const QModelIndex &parent)
return list;
}
QList< QPersistentModelIndex > ModelSpy::toPersistent(QModelIndexList list)
QList< QPersistentModelIndex > ModelSpy::toPersistent(const QModelIndexList &list)
{
QList<QPersistentModelIndex > persistentList;
Q_FOREACH (const QModelIndex &idx, list) {
for (const QModelIndex &idx : list) {
persistentList << QPersistentModelIndex(idx);
}
return persistentList;
}
QModelIndexList ModelSpy::getUnchangedIndexes(const QModelIndex &parent, QList<QItemSelectionRange> ignoredRanges)
QModelIndexList ModelSpy::getUnchangedIndexes(const QModelIndex &parent, const QList<QItemSelectionRange> &ignoredRanges)
{
QModelIndexList list;
int rowCount = m_model->rowCount(parent);
@ -221,7 +221,7 @@ QModelIndexList ModelSpy::getUnchangedIndexes(const QModelIndex &parent, QList<Q
QModelIndex idx = m_model->index(row, column, parent);
Q_ASSERT(idx.isValid());
bool found = false;
Q_FOREACH (const QItemSelectionRange &range, ignoredRanges) {
for (const QItemSelectionRange &range : ignoredRanges) {
if (range.topLeft().parent() == parent && range.topLeft().row() == idx.row()) {
row = range.bottomRight().row() + 1;
found = true;
@ -320,7 +320,7 @@ static const char *const signaltypes[] = {
QDebug operator<<(QDebug d, ModelSpy *modelSpy)
{
d << "ModelSpy(";
Q_FOREACH (const QVariantList &list, (QList<QVariantList>)(*modelSpy)) {
for (const QVariantList &list : qAsConst(*modelSpy)) {
d << "SIGNAL(";
int sigType = list.first().toInt();
d << signaltypes[sigType];

@ -99,9 +99,9 @@ protected Q_SLOTS:
private:
void doPersist();
QModelIndexList getUnchangedIndexes(const QModelIndex &parent, QList< QItemSelectionRange > ignoredRanges);
QModelIndexList getUnchangedIndexes(const QModelIndex &parent, const QList<QItemSelectionRange> &ignoredRanges);
QModelIndexList getDescendantIndexes(const QModelIndex &index);
QList< QPersistentModelIndex > toPersistent(QModelIndexList list);
QList< QPersistentModelIndex > toPersistent(const QModelIndexList &list);
private:
QAbstractItemModel *m_model;

@ -86,9 +86,9 @@ void ProxyModelTest::verifyExecutedTests()
if (m_dataTags.contains(ProxyModelTestData::failTag())) {
return;
}
QSet<QString> unimplemented = m_modelCommanderTags.toSet().subtract(m_dataTags.toSet());
const QSet<QString> unimplemented = m_modelCommanderTags.toSet().subtract(m_dataTags.toSet());
QString unimplementedTestsString(QStringLiteral("("));
Q_FOREACH (const QString &test, unimplemented) {
for (const QString &test : unimplemented) {
unimplementedTestsString.append(test + ",");
}
unimplementedTestsString.append(")");
@ -586,7 +586,8 @@ void ProxyModelTest::doTest()
QVERIFY(m_modelSpy->isEmpty());
// Persistent indexes should change by the amount described in change objects.
Q_FOREACH (PersistentIndexChange change, m_modelSpy->getChangeList()) {
const auto lst = m_modelSpy->getChangeList();
for (PersistentIndexChange change : lst) {
for (int i = 0; i < change.indexes.size(); i++) {
QModelIndex idx = change.indexes.at(i);
QPersistentModelIndex persistentIndex = change.persistentIndexes.at(i);

@ -756,7 +756,8 @@ PROXYMODELTESTSUITE_EXPORT uint qHash(const QVariant &var);
QList<int> testObjects; \
QStringList arguments; \
bool ok; \
Q_FOREACH(const QString &arg, app.arguments()) \
const auto lst = app.arguments(); \
for (const QString &arg : lst) \
{ \
int testObject = arg.toInt(&ok); \
if (arg == "-count") \

@ -32,7 +32,7 @@ namespace TestModelHelpers
inline QList<QStandardItem *> makeStandardItems(const QStringList &texts)
{
QList<QStandardItem *> items;
foreach (const QString &txt, texts) {
for (const QString &txt : texts) {
items << new QStandardItem(txt);
}
return items;

@ -164,16 +164,16 @@ QItemSelection KBreadcrumbSelectionModelPrivate::getBreadcrumbSelection(const QI
void KBreadcrumbSelectionModelPrivate::sourceSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
Q_Q(KBreadcrumbSelectionModel);
QItemSelection deselectedCrumbs = getBreadcrumbSelection(deselected);
QItemSelection selectedCrumbs = getBreadcrumbSelection(selected);
const QItemSelection deselectedCrumbs = getBreadcrumbSelection(deselected);
const QItemSelection selectedCrumbs = getBreadcrumbSelection(selected);
QItemSelection removed = deselectedCrumbs;
Q_FOREACH (const QItemSelectionRange &range, selectedCrumbs) {
for (const QItemSelectionRange &range : selectedCrumbs) {
removed.removeAll(range);
}
QItemSelection added = selectedCrumbs;
Q_FOREACH (const QItemSelectionRange &range, deselectedCrumbs) {
for (const QItemSelectionRange &range : deselectedCrumbs) {
added.removeAll(range);
}

@ -117,10 +117,12 @@ void KCheckableProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
void KCheckableProxyModelPrivate::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
Q_Q(KCheckableProxyModel);
Q_FOREACH (const QItemSelectionRange &range, q->mapSelectionFromSource(selected)) {
const auto lstSelected = q->mapSelectionFromSource(selected);
for (const QItemSelectionRange &range : lstSelected) {
emit q->dataChanged(range.topLeft(), range.bottomRight());
}
Q_FOREACH (const QItemSelectionRange &range, q->mapSelectionFromSource(deselected)) {
const auto lstDeselected = q->mapSelectionFromSource(deselected);
for (const QItemSelectionRange &range : lstDeselected) {
emit q->dataChanged(range.topLeft(), range.bottomRight());
}
}

@ -314,7 +314,7 @@ void KConcatenateRowsProxyModelPrivate::slotSourceLayoutAboutToBeChanged(const Q
{
QList<QPersistentModelIndex> parents;
parents.reserve(sourceParents.size());
foreach (const QPersistentModelIndex &parent, sourceParents) {
for (const QPersistentModelIndex &parent : sourceParents) {
if (!parent.isValid()) {
parents << QPersistentModelIndex();
continue;
@ -329,7 +329,7 @@ void KConcatenateRowsProxyModelPrivate::slotSourceLayoutAboutToBeChanged(const Q
const QModelIndexList persistentIndexList = q->persistentIndexList();
layoutChangePersistentIndexes.reserve(persistentIndexList.size());
foreach (const QPersistentModelIndex &proxyPersistentIndex, persistentIndexList) {
for (const QPersistentModelIndex &proxyPersistentIndex : persistentIndexList) {
proxyIndexes << proxyPersistentIndex;
Q_ASSERT(proxyPersistentIndex.isValid());
const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
@ -351,7 +351,7 @@ void KConcatenateRowsProxyModelPrivate::slotSourceLayoutChanged(const QList<QPer
QList<QPersistentModelIndex> parents;
parents.reserve(sourceParents.size());
foreach (const QPersistentModelIndex &parent, sourceParents) {
for (const QPersistentModelIndex &parent : sourceParents) {
if (!parent.isValid()) {
parents << QPersistentModelIndex();
continue;
@ -394,7 +394,7 @@ void KConcatenateRowsProxyModelPrivate::slotModelReset()
int KConcatenateRowsProxyModelPrivate::computeRowsPrior(const QAbstractItemModel *sourceModel) const
{
int rowsPrior = 0;
foreach (const QAbstractItemModel *model, m_models) {
for (const QAbstractItemModel *model : qAsConst(m_models)) {
if (model == sourceModel) {
break;
}
@ -407,7 +407,7 @@ QAbstractItemModel *KConcatenateRowsProxyModelPrivate::sourceModelForRow(int row
{
int rowCount = 0;
QAbstractItemModel *selection = nullptr;
foreach (QAbstractItemModel *model, m_models) {
for (QAbstractItemModel *model : qAsConst(m_models)) {
const int subRowCount = model->rowCount();
if (rowCount + subRowCount > row) {
selection = model;

@ -904,7 +904,8 @@ void KDescendantsProxyModelPrivate::sourceLayoutAboutToBeChanged()
emit q->layoutAboutToBeChanged();
QPersistentModelIndex srcPersistentIndex;
Q_FOREACH (const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) {
const auto lst = q->persistentIndexList();
for (const QPersistentModelIndex &proxyPersistentIndex : lst) {
m_proxyIndexes << proxyPersistentIndex;
Q_ASSERT(proxyPersistentIndex.isValid());
srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
@ -975,7 +976,7 @@ QMimeData *KDescendantsProxyModel::mimeData(const QModelIndexList &indexes) cons
}
Q_ASSERT(sourceModel());
QModelIndexList sourceIndexes;
Q_FOREACH (const QModelIndex &index, indexes) {
for (const QModelIndex &index : indexes) {
sourceIndexes << mapToSource(index);
}
return sourceModel()->mimeData(sourceIndexes);

@ -275,7 +275,7 @@ void KExtraColumnsProxyModelPrivate::_ec_sourceLayoutAboutToBeChanged(const QLis
QList<QPersistentModelIndex> parents;
parents.reserve(sourceParents.size());
foreach (const QPersistentModelIndex &parent, sourceParents) {
for (const QPersistentModelIndex &parent : sourceParents) {
if (!parent.isValid()) {
parents << QPersistentModelIndex();
continue;
@ -291,7 +291,7 @@ void KExtraColumnsProxyModelPrivate::_ec_sourceLayoutAboutToBeChanged(const QLis
layoutChangePersistentIndexes.reserve(persistentIndexList.size());
layoutChangeProxyColumns.reserve(persistentIndexList.size());
foreach (QPersistentModelIndex proxyPersistentIndex, persistentIndexList) {
for (QPersistentModelIndex proxyPersistentIndex : persistentIndexList) {
proxyIndexes << proxyPersistentIndex;
Q_ASSERT(proxyPersistentIndex.isValid());
const int column = proxyPersistentIndex.column();
@ -323,7 +323,7 @@ void KExtraColumnsProxyModelPrivate::_ec_sourceLayoutChanged(const QList<QPersis
QList<QPersistentModelIndex> parents;
parents.reserve(sourceParents.size());
foreach (const QPersistentModelIndex &parent, sourceParents) {
for (const QPersistentModelIndex &parent : sourceParents) {
if (!parent.isValid()) {
parents << QPersistentModelIndex();
continue;

@ -46,7 +46,7 @@ public:
bool assertSelectionValid(const QItemSelection &selection) const
{
Q_FOREACH (const QItemSelectionRange &range, selection) {
for (const QItemSelectionRange &range : selection) {
if (!range.isValid()) {
qCDebug(KITEMMODELS_LOG) << selection;
}

@ -43,7 +43,7 @@ class KModelIndexProxyMapperPrivate
bool assertSelectionValid(const QItemSelection &selection) const
{
Q_FOREACH (const QItemSelectionRange &range, selection) {
for (const QItemSelectionRange &range : selection) {
if (!range.isValid()) {
qCDebug(KITEMMODELS_LOG) << selection << m_leftModel << m_rightModel << m_proxyChainDown << m_proxyChainUp;
}
@ -102,10 +102,10 @@ class KModelIndexProxyMapperPrivate
void KModelIndexProxyMapperPrivate::createProxyChain()
{
Q_FOREACH (auto p, m_proxyChainUp) {
for (auto p : qAsConst(m_proxyChainUp)) {
p->disconnect(q_ptr);
}
Q_FOREACH (auto p, m_proxyChainDown) {
for (auto p : qAsConst(m_proxyChainDown)) {
p->disconnect(q_ptr);
}
m_proxyChainUp.clear();

@ -285,7 +285,8 @@ QModelIndexList KRecursiveFilterProxyModel::match(const QModelIndex &start, int
return list;
QModelIndex proxyIndex;
Q_FOREACH (const QModelIndex &idx, sourceModel()->match(mapToSource(start), role, value, hits, flags)) {
const auto lst = sourceModel()->match(mapToSource(start), role, value, hits, flags);
for (const QModelIndex &idx : lst) {
proxyIndex = mapFromSource(idx);
if (proxyIndex.isValid()) {
list << proxyIndex;

@ -251,7 +251,7 @@ static int getRootListRow(const QList<ModelIndex> &list, const QModelIndex &inde
// i.e., new items are inserted in the expected location.
QList<QModelIndexList> rootAncestors;
Q_FOREACH (const QModelIndex &root, list) {
for (const QModelIndex &root : list) {
QModelIndexList ancestors;
ancestors << root;
QModelIndex parent = root.parent();
@ -768,7 +768,7 @@ void KSelectionProxyModelPrivate::sourceLayoutAboutToBeChanged()
emit q->layoutAboutToBeChanged();
QItemSelection selection;
Q_FOREACH (const QModelIndex &rootIndex, m_rootIndexList) {
for (const QModelIndex &rootIndex : qAsConst(m_rootIndexList)) {
// This will be optimized later.
emit q->rootIndexAboutToBeRemoved(rootIndex);
selection.append(QItemSelectionRange(rootIndex, rootIndex));
@ -778,7 +778,8 @@ void KSelectionProxyModelPrivate::sourceLayoutAboutToBeChanged()
emit q->rootSelectionAboutToBeRemoved(selection);
QPersistentModelIndex srcPersistentIndex;
Q_FOREACH (const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) {
const auto lst = q->persistentIndexList();
for (const QPersistentModelIndex &proxyPersistentIndex : lst) {
m_proxyIndexes << proxyPersistentIndex;
Q_ASSERT(proxyPersistentIndex.isValid());
srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
@ -1083,7 +1084,7 @@ void KSelectionProxyModelPrivate::sourceRowsInserted(const QModelIndex &parent,
m_rowsInserted = false;
endInsertRows(parent, start, end);
q->endInsertRows();
Q_FOREACH (const PendingSelectionChange &pendingChange, m_pendingSelectionChanges) {
for (const PendingSelectionChange &pendingChange : qAsConst(m_pendingSelectionChanges)) {
selectionChanged(pendingChange.selected, pendingChange.deselected);
}
m_pendingSelectionChanges.clear();
@ -1861,7 +1862,7 @@ void KSelectionProxyModelPrivate::selectionChanged(const QItemSelection &_select
// range is not a descendant of the selection, but maybe the selection is a descendant of range.
// no need to check selected here. That's already in newRootRanges.
// existingRootRanges and newRootRanges do not overlap.
Q_FOREACH (const QItemSelectionRange &selectedRange, existingRootRanges) {
for (const QItemSelectionRange &selectedRange : existingRootRanges) {
const QModelIndex selectedRangeTopLeft = selectedRange.topLeft();
// existingSelection (and selectedRangeTopLeft) is D.
// D is a descendant of B, so when B was removed, D might have been exposed as a root.
@ -1940,7 +1941,8 @@ void KSelectionProxyModelPrivate::insertSelectionIntoProxy(const QItemSelection
return;
}
Q_FOREACH (const QModelIndex &newIndex, selection.indexes()) {
const auto lst = selection.indexes();
for (const QModelIndex &newIndex : lst) {
Q_ASSERT(newIndex.model() == q->sourceModel());
if (newIndex.column() > 0) {
continue;
@ -2307,7 +2309,7 @@ QMimeData *KSelectionProxyModel::mimeData(const QModelIndexList &indexes) const
return QAbstractProxyModel::mimeData(indexes);
}
QModelIndexList sourceIndexes;
Q_FOREACH (const QModelIndex &index, indexes) {
for (const QModelIndex &index : indexes) {
sourceIndexes << mapToSource(index);
}
return sourceModel()->mimeData(sourceIndexes);
@ -2465,7 +2467,8 @@ QModelIndexList KSelectionProxyModel::match(const QModelIndex &start, int role,
QModelIndexList list;
QModelIndex proxyIndex;
Q_FOREACH (const QModelIndex &idx, sourceModel()->match(mapToSource(start), role, value, hits, flags)) {
const auto lst = sourceModel()->match(mapToSource(start), role, value, hits, flags);
for (const QModelIndex &idx : lst) {
proxyIndex = mapFromSource(idx);
if (proxyIndex.isValid()) {
list << proxyIndex;
@ -2481,7 +2484,7 @@ QItemSelection KSelectionProxyModel::mapSelectionFromSource(const QItemSelection
// QAbstractProxyModel::mapSelectionFromSource puts invalid ranges in the result
// without checking. We can't have that.
QItemSelection proxySelection;
Q_FOREACH (const QItemSelectionRange &range, selection) {
for (const QItemSelectionRange &range : selection) {
QModelIndex proxyTopLeft = mapFromSource(range.topLeft());
if (!proxyTopLeft.isValid()) {
continue;
@ -2523,7 +2526,7 @@ QItemSelection KSelectionProxyModel::mapSelectionToSource(const QItemSelection &
// QAbstractProxyModel::mapSelectionFromSource puts invalid ranges in the result
// without checking. We can't have that.
QItemSelection sourceSelection;
Q_FOREACH (const QItemSelectionRange &range, selection) {
for (const QItemSelectionRange &range : selection) {
QModelIndex sourceTopLeft = mapToSource(range.topLeft());
Q_ASSERT(sourceTopLeft.isValid());

@ -40,7 +40,7 @@ MultiSelectionModel::MultiSelectionModel(QAbstractItemModel *model, QList< QItem
void MultiSelectionModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
{
Q_FOREACH (QItemSelectionModel *selectionModel, m_selectionModels) {
for (QItemSelectionModel *selectionModel : qAsConst(m_selectionModels)) {
selectionModel->select(index, command);
}
QItemSelectionModel::select(index, command);
@ -48,7 +48,7 @@ void MultiSelectionModel::select(const QModelIndex &index, QItemSelectionModel::
void MultiSelectionModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
{
Q_FOREACH (QItemSelectionModel *selectionModel, m_selectionModels) {
for (QItemSelectionModel *selectionModel : qAsConst(m_selectionModels)) {
selectionModel->select(selection, command);
}
QItemSelectionModel::select(selection, command);

@ -539,7 +539,7 @@ QModelIndex KReparentingProxyModel::mapToSource(const QModelIndex &proxyIndex) c
if (d->m_pendingRemovalChildIndexes.contains(sourceParent)) {
// qDebug() << "#############";
Q_FOREACH (const KReparentingProxyModelPrivate::PendingRemoval &pendingRemoval, d->m_pendingRemovals) {
for (const KReparentingProxyModelPrivate::PendingRemoval &pendingRemoval : qAsConst(d->m_pendingRemovals)) {
// qDebug() << "In" << pendingRemoval.index << pendingRemoval.sourceIndex << sourceParent;
if (pendingRemoval.sourceIndex == sourceParent) {
// qDebug() << "Out" << pendingRemoval.sourceIndex << sourceParent;
@ -666,7 +666,7 @@ QModelIndex KReparentingProxyModel::parent(const QModelIndex &child) const
int KReparentingProxyModelPrivate::pendingRemovalRowCount(const QModelIndex &sourceIndex) const
{
Q_FOREACH (const PendingRemoval &pendingRemoval, m_pendingRemovals) {
for (const PendingRemoval &pendingRemoval : qAsConst(m_pendingRemovals)) {
// qDebug() << pendingRemoval.sourceIndex;
if (pendingRemoval.sourceIndex == sourceIndex) {
return pendingRemoval.end - pendingRemoval.start + 1;
@ -782,7 +782,7 @@ void KReparentingProxyModelPrivate::sourceRowsAboutToBeInserted(const QModelInde
QHash<QModelIndex, QModelIndexList> KReparentingProxyModelPrivate::mergeDescendants(QHash<QModelIndex, QModelIndexList> mappings, const QModelIndex &parent, int start)
{
QModelIndexList childIndexes = mappings.take(parent);
const QModelIndexList childIndexes = mappings.take(parent);
// qDebug() << childIndexes;
if (!childIndexes.isEmpty()) {
if (!m_parents.values().contains(parent)) {
@ -790,7 +790,7 @@ QHash<QModelIndex, QModelIndexList> KReparentingProxyModelPrivate::mergeDescenda
}
}
int row = start;
Q_FOREACH (const QModelIndex &idx, childIndexes) {
for (const QModelIndex &idx : childIndexes) {
m_childIndexes[parent].insert(row++, QPersistentModelIndex(idx));
mappings = mergeDescendants(mappings, idx, 0);
}

@ -77,14 +77,14 @@ void MatchCheckingWidget::matchChanged(const QString &matchData)
m_dynamicTreeWidget->treeView()->selectionModel()->clearSelection();
list = m_dynamicTreeWidget->model()->match(m_dynamicTreeWidget->model()->index(0, 0), DynamicTreeModel::DynamicTreeModelId, id);
qDebug() << list;
Q_FOREACH (const QModelIndex &idx, list) {
for (const QModelIndex &idx : qAsConst(list)) {
m_dynamicTreeWidget->treeView()->selectionModel()->select(idx, QItemSelectionModel::SelectCurrent);
}
} else if (m_selectionModelRadioButton->isChecked()) {
m_selectionTreeView->selectionModel()->clearSelection();
list = m_selectionTreeView->model()->match(m_selectionTreeView->model()->index(0, 0), DynamicTreeModel::DynamicTreeModelId, id);
qDebug() << list;
Q_FOREACH (const QModelIndex &idx, list) {
for (const QModelIndex &idx : qAsConst(list)) {
m_selectionTreeView->selectionModel()->select(idx, QItemSelectionModel::SelectCurrent);
}
}

@ -62,7 +62,7 @@ void ModelCommanderWidget::init()
Q_RETURN_ARG(QStringList, testData),
Q_ARG(QString, QString()));
Q_FOREACH (const QString &testRun, testData) {
for (const QString &testRun : qAsConst(testData)) {
new QTreeWidgetItem(testFunctionItem, QStringList() << testRun);
}
}

Loading…
Cancel
Save