diff options
Diffstat (limited to 'src/imports/folderlistmodel')
-rw-r--r-- | src/imports/folderlistmodel/fileinfothread.cpp | 13 | ||||
-rw-r--r-- | src/imports/folderlistmodel/fileinfothread_p.h | 4 | ||||
-rw-r--r-- | src/imports/folderlistmodel/plugins.qmltypes | 8 | ||||
-rw-r--r-- | src/imports/folderlistmodel/qquickfolderlistmodel.cpp | 32 |
4 files changed, 42 insertions, 15 deletions
diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp index 64a4b02e91..ad09f54381 100644 --- a/src/imports/folderlistmodel/fileinfothread.cpp +++ b/src/imports/folderlistmodel/fileinfothread.cpp @@ -57,7 +57,7 @@ FileInfoThread::FileInfoThread(QObject *parent) sortUpdate(false), showDirs(true), showDirsFirst(false), - showDotDot(false), + showDotAndDotDot(false), showOnlyReadable(false) { #ifndef QT_NO_FILESYSTEMWATCHER @@ -158,11 +158,12 @@ void FileInfoThread::setShowDirsFirst(bool show) condition.wakeAll(); } -void FileInfoThread::setShowDotDot(bool on) +void FileInfoThread::setShowDotAndDotDot(bool on) { QMutexLocker locker(&mutex); - showDotDot = on; + showDotAndDotDot = on; folderUpdate = true; + needUpdate = true; condition.wakeAll(); } @@ -212,10 +213,12 @@ void FileInfoThread::run() void FileInfoThread::getFileInfos(const QString &path) { QDir::Filters filter; - filter = QDir::Files | QDir::NoDot | QDir::CaseSensitive; + filter = QDir::Files | QDir::CaseSensitive; if (showDirs) filter = filter | QDir::AllDirs | QDir::Drives; - if ((path == rootPath) || !showDotDot) + if (!showDotAndDotDot) + filter = filter | QDir::NoDot | QDir::NoDotDot; + else if (path == rootPath) filter = filter | QDir::NoDotDot; if (showOnlyReadable) filter = filter | QDir::Readable; diff --git a/src/imports/folderlistmodel/fileinfothread_p.h b/src/imports/folderlistmodel/fileinfothread_p.h index f9340ca75d..cf6572a279 100644 --- a/src/imports/folderlistmodel/fileinfothread_p.h +++ b/src/imports/folderlistmodel/fileinfothread_p.h @@ -72,7 +72,7 @@ public: void setNameFilters(const QStringList & nameFilters); void setShowDirs(bool showFolders); void setShowDirsFirst(bool show); - void setShowDotDot(bool on); + void setShowDotAndDotDot(bool on); void setShowOnlyReadable(bool on); public Q_SLOTS: @@ -104,7 +104,7 @@ private: bool sortUpdate; bool showDirs; bool showDirsFirst; - bool showDotDot; + bool showDotAndDotDot; bool showOnlyReadable; }; diff --git a/src/imports/folderlistmodel/plugins.qmltypes b/src/imports/folderlistmodel/plugins.qmltypes index fabeb9e4b1..20914f4108 100644 --- a/src/imports/folderlistmodel/plugins.qmltypes +++ b/src/imports/folderlistmodel/plugins.qmltypes @@ -3,13 +3,17 @@ import QtQuick.tooling 1.1 // This file describes the plugin-supplied types contained in the library. // It is used for QML tooling purposes only. // -// This file was auto-generated with the command 'qmlplugindump Qt.labs.folderlistmodel 2.0'. +// This file was auto-generated with the command 'qmlplugindump -notrelocatable Qt.labs.folderlistmodel 2.0'. Module { Component { name: "QQuickFolderListModel" prototype: "QAbstractListModel" - exports: ["FolderListModel 1.0", "FolderListModel 2.0"] + exports: [ + "Qt.labs.folderlistmodel/FolderListModel 1.0", + "Qt.labs.folderlistmodel/FolderListModel 2.0" + ] + exportMetaObjectRevisions: [0, 0] Enum { name: "SortField" values: { diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index 421e215066..85b59e9c73 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -55,7 +55,7 @@ class QQuickFolderListModelPrivate public: QQuickFolderListModelPrivate(QQuickFolderListModel *q) : q_ptr(q), - sortField(QQuickFolderListModel::Name), sortReversed(false), showDirs(true), showDirsFirst(false), showDots(false), showOnlyReadable(false) + sortField(QQuickFolderListModel::Name), sortReversed(false), showDirs(true), showDirsFirst(false), showDotAndDotDot(false), showOnlyReadable(false) { nameFilters << QLatin1String("*"); } @@ -72,7 +72,7 @@ public: bool sortReversed; bool showDirs; bool showDirsFirst; - bool showDots; + bool showDotAndDotDot; bool showOnlyReadable; ~QQuickFolderListModelPrivate() {} @@ -279,7 +279,27 @@ QString QQuickFolderListModelPrivate::resolvePath(const QUrl &path) The following example shows a FolderListModel being used to provide a list of QML files in a \l ListView: - \snippet qml/folderlistmodel.qml 0 + \qml + import QtQuick 2.0 + import Qt.labs.folderlistmodel 1.0 + + ListView { + width: 200; height: 400 + + FolderListModel { + id: folderModel + nameFilters: ["*.qml"] + } + + Component { + id: fileDelegate + Text { text: fileName } + } + + model: folderModel + delegate: fileDelegate + } + \endqml \section1 Path Separators @@ -661,15 +681,15 @@ void QQuickFolderListModel::setShowDirsFirst(bool on) bool QQuickFolderListModel::showDotAndDotDot() const { Q_D(const QQuickFolderListModel); - return d->showDots; + return d->showDotAndDotDot; } void QQuickFolderListModel::setShowDotAndDotDot(bool on) { Q_D(QQuickFolderListModel); - if (on != d->showDots) { - d->fileInfoThread.setShowDotDot(on); + if (on != d->showDotAndDotDot) { + d->fileInfoThread.setShowDotAndDotDot(on); } } |