aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qtsupport/exampleslistmodel.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-11-23 22:27:42 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-11-24 16:02:28 +0000
commit6a20c52cc9cfb8850dae4e3c868a5445c00684b9 (patch)
tree80b0b82e005dab4d75af3fbc73a120650093961c /src/plugins/qtsupport/exampleslistmodel.cpp
parent849c902971642d25908ea27dd79972c0ce585003 (diff)
QtSupport: Replace foreach with range-based for loops
Change-Id: Ia941c8dec41a73ca126c91304223d1fe98bc2972 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/qtsupport/exampleslistmodel.cpp')
-rw-r--r--src/plugins/qtsupport/exampleslistmodel.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp
index 1eba8d2598..11f99be8f1 100644
--- a/src/plugins/qtsupport/exampleslistmodel.cpp
+++ b/src/plugins/qtsupport/exampleslistmodel.cpp
@@ -126,7 +126,7 @@ void ExampleSetModel::recreateModel(const QtVersions &qtVersions)
extraManifestDirs.insert(set.manifestPath);
}
- foreach (QtVersion *version, qtVersions) {
+ for (QtVersion *version : qtVersions) {
// sanitize away qt versions that have already been added through extra sets
if (extraManifestDirs.contains(version->docsPath().toString())) {
if (debugExamples()) {
@@ -446,13 +446,13 @@ void ExamplesListModel::updateExamples()
QString examplesInstallPath;
QString demosInstallPath;
- QStringList sources = m_exampleSetModel.exampleSources(&examplesInstallPath, &demosInstallPath);
-
+ const QStringList sources = m_exampleSetModel.exampleSources(&examplesInstallPath,
+ &demosInstallPath);
beginResetModel();
qDeleteAll(m_items);
m_items.clear();
- foreach (const QString &exampleSource, sources) {
+ for (const QString &exampleSource : sources) {
QFile exampleFile(exampleSource);
if (!exampleFile.open(QIODevice::ReadOnly)) {
if (debugExamples())
@@ -604,8 +604,9 @@ QStringList ExampleSetModel::exampleSources(QString *examplesInstallPath, QStrin
examplesPath = exampleSet.examplesPath;
demosPath = exampleSet.examplesPath;
} else if (currentType == ExampleSetModel::QtExampleSet) {
- int qtId = getQtId(m_selectedExampleSetIndex);
- foreach (QtVersion *version, QtVersionManager::versions()) {
+ const int qtId = getQtId(m_selectedExampleSetIndex);
+ const QtVersions versions = QtVersionManager::versions();
+ for (QtVersion *version : versions) {
if (version->uniqueId() == qtId) {
manifestScanPath = version->docsPath().toString();
examplesPath = version->examplesPath().toString();
@@ -620,11 +621,12 @@ QStringList ExampleSetModel::exampleSources(QString *examplesInstallPath, QStrin
const QStringList examplesPattern(QLatin1String("examples-manifest.xml"));
const QStringList demosPattern(QLatin1String("demos-manifest.xml"));
QFileInfoList fis;
- foreach (QFileInfo subDir, dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
+ const QFileInfoList subDirs = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ for (QFileInfo subDir : subDirs) {
fis << QDir(subDir.absoluteFilePath()).entryInfoList(examplesPattern);
fis << QDir(subDir.absoluteFilePath()).entryInfoList(demosPattern);
}
- foreach (const QFileInfo &fi, fis)
+ for (const QFileInfo &fi : std::as_const(fis))
sources.append(fi.filePath());
}
if (examplesInstallPath)