diff options
author | Zeno Albisser <zeno.albisser@nokia.com> | 2010-05-12 12:41:49 (GMT) |
---|---|---|
committer | Qt Commercial Integration <QtCommercial@digia.com> | 2012-01-31 10:24:39 (GMT) |
commit | bed275599ff44809372af99b9b6cbe492f5fdec8 (patch) | |
tree | fcc8fdde12af7567a08b5e69c1c10b55b340a182 /src/gui | |
parent | 0cc309d2dd0469bc8997154455b91fba4697ccc5 (diff) | |
download | Qt-bed275599ff44809372af99b9b6cbe492f5fdec8.zip Qt-bed275599ff44809372af99b9b6cbe492f5fdec8.tar.gz Qt-bed275599ff44809372af99b9b6cbe492f5fdec8.tar.bz2 |
make QFileSystemModel::rmdir(dir) remove dir from fileInfoGatherer
Otherwise directories cannot be deleted as long as they are watched,
since the fileInfoGatherer keeps a QFileInfo object with open file
handles.
Reviewed-by: Joao
Task-number: QTBUG-8241
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/dialogs/qfilesystemmodel.cpp | 8 | ||||
-rw-r--r-- | src/gui/dialogs/qfilesystemmodel.h | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index f9f9df8..86f2920 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1631,6 +1631,14 @@ bool QFileSystemModel::event(QEvent *event) return QAbstractItemModel::event(event); } +bool QFileSystemModel::rmdir(const QModelIndex &aindex) const +{ + QString path = filePath(aindex); + QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func()); + d->fileInfoGatherer.removePath(path); + return QDir().rmdir(path); +} + /*! \internal diff --git a/src/gui/dialogs/qfilesystemmodel.h b/src/gui/dialogs/qfilesystemmodel.h index 1e4d673..0b1fa47 100644 --- a/src/gui/dialogs/qfilesystemmodel.h +++ b/src/gui/dialogs/qfilesystemmodel.h @@ -139,7 +139,7 @@ public: QDateTime lastModified(const QModelIndex &index) const; QModelIndex mkdir(const QModelIndex &parent, const QString &name); - inline bool rmdir(const QModelIndex &index) const; + bool rmdir(const QModelIndex &index) const; // ### Qt5: should not be const inline QString fileName(const QModelIndex &index) const; inline QIcon fileIcon(const QModelIndex &index) const; QFile::Permissions permissions(const QModelIndex &index) const; @@ -163,8 +163,6 @@ private: friend class QFileDialogPrivate; }; -inline bool QFileSystemModel::rmdir(const QModelIndex &aindex) const -{ QDir dir; return dir.rmdir(filePath(aindex)); } inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const { return aindex.data(Qt::DisplayRole).toString(); } inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const |