QDirListing: add getters for iterator flags and name filters
Task-number: QTBUG-125859 Change-Id: I2c60503f37db4668c867760e1fcf061cb4e23faa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ffc7c4543e6ae3f4c7c520addaa0875e171c2bee) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
db480e8cd5
commit
7f3b17b3a6
@ -635,6 +635,23 @@ QString QDirListing::iteratorPath() const
|
||||
return d->initialEntryInfo.filePath();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the set of IteratorFlags used to construct this QDirListing.
|
||||
*/
|
||||
QDirListing::IteratorFlags QDirListing::iteratorFlags() const
|
||||
{
|
||||
return d->iteratorFlags;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the list of file name glob filters used to construct this
|
||||
QDirListing.
|
||||
*/
|
||||
QStringList QDirListing::nameFilters() const
|
||||
{
|
||||
return d->nameFilters;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QDirListing::const_iterator QDirListing::begin() const
|
||||
\fn QDirListing::const_iterator QDirListing::cbegin() const
|
||||
|
@ -50,6 +50,8 @@ public:
|
||||
~QDirListing();
|
||||
|
||||
QString iteratorPath() const;
|
||||
IteratorFlags iteratorFlags() const;
|
||||
QStringList nameFilters() const;
|
||||
|
||||
class Q_CORE_EXPORT DirEntry
|
||||
{
|
||||
|
@ -377,9 +377,19 @@ void tst_QDirListing::iterateRelativeDirectory()
|
||||
QFETCH(QStringList, nameFilters);
|
||||
QFETCH(const QStringList, entries);
|
||||
|
||||
const QDirListing lister(dirName, nameFilters, flags);
|
||||
|
||||
if (nameFilters.isEmpty() || nameFilters == QStringList("*"_L1))
|
||||
QVERIFY(lister.nameFilters().isEmpty());
|
||||
else
|
||||
QCOMPARE_EQ(lister.nameFilters(), nameFilters);
|
||||
|
||||
QCOMPARE(lister.iteratorFlags(), flags);
|
||||
QCOMPARE(lister.iteratorPath(), dirName);
|
||||
|
||||
// If canonicalFilePath is empty (e.g. for broken symlinks), use absoluteFilePath()
|
||||
QStringList list;
|
||||
for (const auto &dirEntry : QDirListing(dirName, nameFilters, flags)) {
|
||||
for (const auto &dirEntry : lister) {
|
||||
QString filePath = dirEntry.canonicalFilePath();
|
||||
list.emplace_back(!filePath.isEmpty()? filePath : dirEntry.absoluteFilePath());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user