diff options
author | Alberto Mardegan <info@mardy.it> | 2012-12-26 13:59:52 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-25 20:53:52 +0200 |
commit | 6ad5400c54302ee5e099e478e91de53386b62902 (patch) | |
tree | b93b4141d6d1f527c6cbab0fd3bdcec4af2c1c5c /src/imports/folderlistmodel/fileinfothread.cpp | |
parent | 0f97dd8b3d86d60897fed0e87d95de2e3ed59206 (diff) |
Add "showFiles" property to FolderListModel
This property, if set to "false", causes the FolderListModel not to show
regular files. This can be useful when someone wants to list only the
directories; for instance, one can have a ListView showing only the
directories (with "showDirs: true" and "showFiles: false") and another
for showing the directory contents ("showFiles: true" and "showDirs:
false").
Since by default this property is "true", the behavior of applications
who don't use this property is unchanged.
Change-Id: I6eaa9c4a6a582ea81fa07bad129a4c9b15fdcaea
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'src/imports/folderlistmodel/fileinfothread.cpp')
-rw-r--r-- | src/imports/folderlistmodel/fileinfothread.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp index ad09f54381..4aa43b2d3f 100644 --- a/src/imports/folderlistmodel/fileinfothread.cpp +++ b/src/imports/folderlistmodel/fileinfothread.cpp @@ -55,6 +55,7 @@ FileInfoThread::FileInfoThread(QObject *parent) needUpdate(true), folderUpdate(false), sortUpdate(false), + showFiles(true), showDirs(true), showDirsFirst(false), showDotAndDotDot(false), @@ -142,6 +143,14 @@ void FileInfoThread::setNameFilters(const QStringList & filters) condition.wakeAll(); } +void FileInfoThread::setShowFiles(bool show) +{ + QMutexLocker locker(&mutex); + showFiles = show; + folderUpdate = true; + condition.wakeAll(); +} + void FileInfoThread::setShowDirs(bool showFolders) { QMutexLocker locker(&mutex); @@ -213,7 +222,9 @@ void FileInfoThread::run() void FileInfoThread::getFileInfos(const QString &path) { QDir::Filters filter; - filter = QDir::Files | QDir::CaseSensitive; + filter = QDir::CaseSensitive; + if (showFiles) + filter = filter | QDir::Files; if (showDirs) filter = filter | QDir::AllDirs | QDir::Drives; if (!showDotAndDotDot) |