diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-01-26 14:38:54 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-05-29 07:21:18 +0000 |
commit | 0f9e48d6f4e6f4976c7dc68c70ec8f4850e79e1d (patch) | |
tree | 79ed5029f814ef48f2dde3df8372f682c43a6a91 /src | |
parent | 0574d5dc8a10cb4281c6f53c3d2d3e49f2109a6a (diff) |
QtWidgets: eradicate some indexed loops [needing qAsConst()]
... by replacing them with C++11 range-for loops.
To avoid detaches of these mutable Qt containers,
wrap the container in qAsConst().
Change-Id: I9b5c23c723be024b314a7ad873e21ad63b44b348
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 13 | ||||
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel.cpp | 3 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index fcac12068d..2f45635298 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -3675,12 +3675,13 @@ void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text) if (oldFiles.removeAll(idx) == 0) newFiles.append(idx); } - for (int i = 0; i < newFiles.count(); ++i) - select(newFiles.at(i)); - if (lineEdit()->hasFocus()) - for (int i = 0; i < oldFiles.count(); ++i) - qFileDialogUi->listView->selectionModel()->select(oldFiles.at(i), - QItemSelectionModel::Toggle | QItemSelectionModel::Rows); + for (const auto &newFile : qAsConst(newFiles)) + select(newFile); + if (lineEdit()->hasFocus()) { + auto *sm = qFileDialogUi->listView->selectionModel(); + for (const auto &oldFile : qAsConst(oldFiles)) + sm->select(oldFile, QItemSelectionModel::Toggle | QItemSelectionModel::Rows); + } } } diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index e486037e08..a778fd3a45 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1847,8 +1847,7 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QV std::sort(rowsToUpdate.begin(), rowsToUpdate.end()); QString min; QString max; - for (int i = 0; i < rowsToUpdate.count(); ++i) { - QString value = rowsToUpdate.at(i); + for (const QString &value : qAsConst(rowsToUpdate)) { //##TODO is there a way to bundle signals with QString as the content of the list? /*if (min.isEmpty()) { min = value; |