summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2013-09-10 23:04:07 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-16 12:12:09 +0200
commitaabbd27dda898cfb87998b81c28512c2f8907847 (patch)
tree215fab426a51953bdaaa253b6b1d8cf507851b07 /src/widgets/dialogs
parent104debb6627d71f5540bb2c3347ce56dddc63594 (diff)
Simplify QFileSystemModel::remove by using QDir::removeRecursively
This also fixes it in case of hidden or system files, which were missing from the filter (found by Denis Kovalskiy). Change-Id: Ic12de12ec51c20de52d040514e90be5e783add43 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp26
1 files changed, 2 insertions, 24 deletions
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 81fa40f0e7..9c6d972baa 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -199,32 +199,10 @@ QT_BEGIN_NAMESPACE
bool QFileSystemModel::remove(const QModelIndex &aindex)
{
- //### TODO optim
- QString path = filePath(aindex);
+ const QString path = filePath(aindex);
QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
d->fileInfoGatherer.removePath(path);
- QDirIterator it(path,
- QDir::AllDirs | QDir:: Files | QDir::NoDotAndDotDot,
- QDirIterator::Subdirectories);
- QStringList children;
- while (it.hasNext())
- children.prepend(it.next());
- children.append(path);
-
- bool error = false;
- for (int i = 0; i < children.count(); ++i) {
- QFileInfo info(children.at(i));
- QModelIndex modelIndex = index(children.at(i));
- if (info.isDir()) {
- QDir dir;
- if (children.at(i) != path)
- error |= remove(modelIndex);
- error |= rmdir(modelIndex);
- } else {
- error |= QFile::remove(filePath(modelIndex));
- }
- }
- return error;
+ return QDir(path).removeRecursively();
}
/*!