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. Task-number: QTBUG-115803 Change-Id: I20890f48a48ca662679f55fa5db759419d4db8c5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 32e8b272858ded710930db7f314794eb2f77d04c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
067adfbb11
commit
aac6ba691f
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user