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>
This commit is contained in:
parent
b8881ff280
commit
32e8b27285
@ -517,7 +517,6 @@ void tst_QFiledialog::completer()
|
|||||||
for (int i = 0; i < input.size(); ++i)
|
for (int i = 0; i < input.size(); ++i)
|
||||||
QTest::keyPress(lineEdit, input[i].toLatin1());
|
QTest::keyPress(lineEdit, input[i].toLatin1());
|
||||||
|
|
||||||
QStringList expectedFiles;
|
|
||||||
if (expected == -1) {
|
if (expected == -1) {
|
||||||
QString fullPath = startPath;
|
QString fullPath = startPath;
|
||||||
if (!fullPath.endsWith(QLatin1Char('/')))
|
if (!fullPath.endsWith(QLatin1Char('/')))
|
||||||
@ -530,11 +529,11 @@ void tst_QFiledialog::completer()
|
|||||||
|
|
||||||
QFileInfo fi(fullPath);
|
QFileInfo fi(fullPath);
|
||||||
QDir x(fi.absolutePath());
|
QDir x(fi.absolutePath());
|
||||||
expectedFiles = x.entryList(model->filter());
|
const QStringList expectedFiles = x.entryList(model->filter());
|
||||||
expected = 0;
|
expected = 0;
|
||||||
if (input.startsWith(".."))
|
if (input.startsWith(".."))
|
||||||
input.clear();
|
input.clear();
|
||||||
foreach (const QString &expectedFile, expectedFiles) {
|
for (const QString &expectedFile : expectedFiles) {
|
||||||
if (expectedFile.startsWith(input, caseSensitivity))
|
if (expectedFile.startsWith(input, caseSensitivity))
|
||||||
++expected;
|
++expected;
|
||||||
}
|
}
|
||||||
|
@ -682,13 +682,13 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
|
|||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
fd.setDirectory("C:/");
|
fd.setDirectory("C:/");
|
||||||
QDir current = fd.directory();
|
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:
|
// Find a suitable test dir under c:-root:
|
||||||
// - At least 6 characters long
|
// - At least 6 characters long
|
||||||
// - Ascii, letters only
|
// - Ascii, letters only
|
||||||
// - No another dir with same start
|
// - No another dir with same start
|
||||||
QString testDir;
|
QString testDir;
|
||||||
foreach (const QString &entry, entryList) {
|
for (const QString &entry : entryList) {
|
||||||
if (entry.size() > 5 && QString(entry.toLatin1()).compare(entry) == 0) {
|
if (entry.size() > 5 && QString(entry.toLatin1()).compare(entry) == 0) {
|
||||||
bool invalid = false;
|
bool invalid = false;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
@ -698,7 +698,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
foreach (const QString &check, entryList) {
|
for (const QString &check : entryList) {
|
||||||
if (check.startsWith(entry.left(5), Qt::CaseInsensitive) && check != entry) {
|
if (check.startsWith(entry.left(5), Qt::CaseInsensitive) && check != entry) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
break;
|
break;
|
||||||
@ -948,9 +948,9 @@ void tst_QFileDialog2::task239706_editableFilterCombo()
|
|||||||
d.show();
|
d.show();
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(&d));
|
QVERIFY(QTest::qWaitForWindowExposed(&d));
|
||||||
|
|
||||||
QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
|
const QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
|
||||||
QComboBox *filterCombo = nullptr;
|
QComboBox *filterCombo = nullptr;
|
||||||
foreach (QComboBox *combo, comboList) {
|
for (QComboBox *combo : comboList) {
|
||||||
if (combo->objectName() == QString("fileTypeCombo")) {
|
if (combo->objectName() == QString("fileTypeCombo")) {
|
||||||
filterCombo = combo;
|
filterCombo = combo;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user