diff options
author | Bernhard Rosenkraenzer <br@blankpage.ch> | 2010-03-23 15:27:42 (GMT) |
---|---|---|
committer | Benjamin Poulain <benjamin.poulain@nokia.com> | 2010-03-23 15:27:42 (GMT) |
commit | c6ef7c0cbd2ad7ac486cd6bcabaac4d090df0c03 (patch) | |
tree | a01625662210a0d2ce629463bb52be5e164d9852 /src/corelib/io | |
parent | b4996ab8e3a26d45ee55593da281e4b798c04dd2 (diff) | |
download | Qt-c6ef7c0cbd2ad7ac486cd6bcabaac4d090df0c03.zip Qt-c6ef7c0cbd2ad7ac486cd6bcabaac4d090df0c03.tar.gz Qt-c6ef7c0cbd2ad7ac486cd6bcabaac4d090df0c03.tar.bz2 |
Split QDir::NoDotAndDotDot into QDir::NoDot and QDir::NoDotDot
This creates QDir::NoDot and QDir::NoDotDot filters -- in many cases,
one may want the .. entry (e.g. to navigate to the parent directory)
but not the . entry (useless for navigation).
Reviewed-by: Benjamin Poulain <benjamin.poulain@nokia.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qdir.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qdir.h | 4 | ||||
-rw-r--r-- | src/corelib/io/qdiriterator.cpp | 6 |
3 files changed, 13 insertions, 3 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 505889e..1b60936 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1079,6 +1079,8 @@ QDir::Filters QDir::filter() const \value NoSymLinks Do not list symbolic links (ignored by operating systems that don't support symbolic links). \value NoDotAndDotDot Do not list the special entries "." and "..". + \value NoDot Do not list the special entry ".". + \value NoDotDot Do not list the special entry "..". \value AllEntries List directories, files, drives and symlinks (this does not list broken symlinks unless you specify System). \value Readable List files for which the application has read @@ -2367,7 +2369,9 @@ QDebug operator<<(QDebug debug, QDir::Filters filters) if (filters & QDir::Files) flags << QLatin1String("Files"); if (filters & QDir::Drives) flags << QLatin1String("Drives"); if (filters & QDir::NoSymLinks) flags << QLatin1String("NoSymLinks"); - if (filters & QDir::NoDotAndDotDot) flags << QLatin1String("NoDotAndDotDot"); + if (filters & QDir::NoDotAndDotDot) flags << QLatin1String("NoDotAndDotDot"); // ### Qt5: remove (because NoDotAndDotDot=NoDot|NoDotDot) + if (filters & QDir::NoDot) flags << QLatin1String("NoDot"); + if (filters & QDir::NoDotDot) flags << QLatin1String("NoDotDot"); if ((filters & QDir::AllEntries) == QDir::AllEntries) flags << QLatin1String("AllEntries"); if (filters & QDir::Readable) flags << QLatin1String("Readable"); if (filters & QDir::Writable) flags << QLatin1String("Writable"); diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index 186dd2f..28da271 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -88,7 +88,9 @@ public: AllDirs = 0x400, CaseSensitive = 0x800, - NoDotAndDotDot = 0x1000, + NoDotAndDotDot = 0x1000, // ### Qt5 NoDotAndDotDot = NoDot|NoDotDot + NoDot = 0x2000, + NoDotDot = 0x4000, NoFilter = -1 #ifdef QT3_SUPPORT diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 860fb63..fd4b9c1 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -287,7 +287,11 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf const bool dotOrDotDot = fileName[0] == QLatin1Char('.') && ((fileNameSize == 1) ||(fileNameSize == 2 && fileName[1] == QLatin1Char('.'))); - if ((filters & QDir::NoDotAndDotDot) && dotOrDotDot) + if ((filters & QDir::NoDot) && dotOrDotDot && fileNameSize == 1) + return false; + if ((filters & QDir::NoDotDot) && dotOrDotDot && fileNameSize == 2) + return false; + if ((filters & QDir::NoDotAndDotDot) && dotOrDotDot) // ### Qt5 remove (NoDotAndDotDot == NoDot|NoDotDot) return false; // name filter |