summaryrefslogtreecommitdiffstats
path: root/filewidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-01-02 23:43:08 +0100
committerArno <arno@disconnect.de>2018-01-02 23:43:08 +0100
commit1186d454bb421fc69c313401dc9542e9510f7e83 (patch)
tree76e00ea4d7507c6142d0f9441f0e4d8fda93c723 /filewidget.cpp
parent54079b4b80af46663590c46109fabeb5cc94a6db (diff)
downloadShemovCleaner-1186d454bb421fc69c313401dc9542e9510f7e83.tar.gz
ShemovCleaner-1186d454bb421fc69c313401dc9542e9510f7e83.tar.bz2
ShemovCleaner-1186d454bb421fc69c313401dc9542e9510f7e83.zip
Optimize deleteFiles
Only remove something from the view if deletion was successful. If it was a file, try to remove it from the cache.
Diffstat (limited to 'filewidget.cpp')
-rw-r--r--filewidget.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/filewidget.cpp b/filewidget.cpp
index d3fe7d9..0ee7d2d 100644
--- a/filewidget.cpp
+++ b/filewidget.cpp
@@ -730,17 +730,22 @@ void FileWidget::deleteFiles(){
for(const QModelIndex& idx : selFiles){
QString path = idx.data(FullPathRole).toString();
QFileInfo fi(path);
+ bool success = false;
if(fi.isDir()){
QDir d(fi.absoluteFilePath());
- d.removeRecursively();
+ success = d.removeRecursively();
}else{
- if(!QFile::remove(path)){
+ success = QFile::remove(path);
+ if(!success){
QFile f(path);
f.setPermissions(QFile::ReadOther | QFile::WriteOther);
- f.remove();
+ success = f.remove();
}
}
- removed << idx.data().toString();
+ if(success){
+ mFileCache.remove(fi.absoluteFilePath());
+ removed << idx.data().toString();
+ }
}
for(const QString& f : removed){
QList<QStandardItem*> res = mModel->findItems(f, Qt::MatchExactly, NameColumn);