diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2016-03-01 15:44:06 +0300 |
---|---|---|
committer | Alexander Volkov <a.volkov@rusbitech.ru> | 2016-05-10 20:51:15 +0000 |
commit | acf43c17b647cdbfc3186bb8bf7e183df67a090b (patch) | |
tree | 9edaf0165ec2afed95dea25ee0742251c3f7f1c6 /tests/auto/widgets/dialogs/qfiledialog | |
parent | ab3a8443faa36799ab8142e48d25d8ff10f9d0bf (diff) |
QFileSystemModel: create nodes with correct QFileInfos
Create parent nodes with the corresponding paths, not with
the absolute path of the child node. Otherwise we will get
incorrect QFileInfo at least in the following case:
QFileSystemModel model;
model.setRootPath("/usr/bin");
QModelIndex idx = model.setRootPath("/usr");
qDebug() << model.fileInfo(idx).absoluteFilePath();
Without the fix it prints "/usr/bin".
It's a regression triggered by 61cefb2f7a7cb16dfa2732e26d2319017039ef62
(De-inline QFileSystemModel::fileInfo() and implement it efficiently).
Change-Id: I3b4e5f5b256711e27ad50824eaa8492dbc096808
Task-number: QTBUG-51586
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'tests/auto/widgets/dialogs/qfiledialog')
-rw-r--r-- | tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 42e2bd09a5..05f42cf685 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -569,6 +569,22 @@ void tst_QFiledialog::completer() if (expectedFile.startsWith(input, caseSensitivity)) ++expected; } + // The temporary dir may create a node in QFileSystemModel + // which will bypass filters. If the path to the temporary + // dir contains an element which should be a subdirectory + // of x dir, but which is not listed, then take it into + // accont. + if (!tempDir.isNull()) { + QString xPath = x.absolutePath(); + if (!xPath.endsWith(QLatin1Char('/'))) + xPath.append(QLatin1Char('/')); + QString tmpPath = tempDir->path(); + if (tmpPath.startsWith(xPath)) { + QString bypassedDirName = tmpPath.mid(xPath.size()).section(QLatin1Char('/'), 0, 0); + if (!expectedFiles.contains(bypassedDirName)) + ++expected; + } + } } QTRY_COMPARE(cModel->rowCount(), expected); |