summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-05 10:43:43 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-08-07 13:28:20 +0200
commit32e8b272858ded710930db7f314794eb2f77d04c (patch)
tree257a2582e06efd7b39175d06126941d37c453626
parentb8881ff2806f58f6da0027470663aac790bfae73 (diff)
tst_QFileDialog/2: port away from Q_FOREACH
These are all trivial: all are over (already or newly-made) const local variables. The only noteworthy point here is that, in order to mark it as const, I had to move a container definition to the more narrow scope in which it was actually initialized. There are no references to the container outside the narrow scope that would require it to be defined in the larger scope. Pick-to: 6.6 6.5 Task-number: QTBUG-115803 Change-Id: I20890f48a48ca662679f55fa5db759419d4db8c5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp5
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp10
2 files changed, 7 insertions, 8 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index d7faf8a76b..4424ecec62 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -517,7 +517,6 @@ void tst_QFiledialog::completer()
for (int i = 0; i < input.size(); ++i)
QTest::keyPress(lineEdit, input[i].toLatin1());
- QStringList expectedFiles;
if (expected == -1) {
QString fullPath = startPath;
if (!fullPath.endsWith(QLatin1Char('/')))
@@ -530,11 +529,11 @@ void tst_QFiledialog::completer()
QFileInfo fi(fullPath);
QDir x(fi.absolutePath());
- expectedFiles = x.entryList(model->filter());
+ const QStringList expectedFiles = x.entryList(model->filter());
expected = 0;
if (input.startsWith(".."))
input.clear();
- foreach (const QString &expectedFile, expectedFiles) {
+ for (const QString &expectedFile : expectedFiles) {
if (expectedFile.startsWith(input, caseSensitivity))
++expected;
}
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index e54839cdd4..a8d3c5fe1e 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -682,13 +682,13 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
#if defined(Q_OS_WIN)
fd.setDirectory("C:/");
QDir current = fd.directory();
- QStringList entryList = current.entryList(QStringList(), QDir::Dirs);
+ const QStringList entryList = current.entryList(QStringList(), QDir::Dirs);
// Find a suitable test dir under c:-root:
// - At least 6 characters long
// - Ascii, letters only
// - No another dir with same start
QString testDir;
- foreach (const QString &entry, entryList) {
+ for (const QString &entry : entryList) {
if (entry.size() > 5 && QString(entry.toLatin1()).compare(entry) == 0) {
bool invalid = false;
for (int i = 0; i < 5; i++) {
@@ -698,7 +698,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
}
}
if (!invalid) {
- foreach (const QString &check, entryList) {
+ for (const QString &check : entryList) {
if (check.startsWith(entry.left(5), Qt::CaseInsensitive) && check != entry) {
invalid = true;
break;
@@ -948,9 +948,9 @@ void tst_QFileDialog2::task239706_editableFilterCombo()
d.show();
QVERIFY(QTest::qWaitForWindowExposed(&d));
- QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
+ const QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
QComboBox *filterCombo = nullptr;
- foreach (QComboBox *combo, comboList) {
+ for (QComboBox *combo : comboList) {
if (combo->objectName() == QString("fileTypeCombo")) {
filterCombo = combo;
break;