From 7b7ef1e0d88bbec407de65eac59304bcc01a9c75 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 3 Jan 2018 00:02:32 +0100 Subject: Update the cache when copying or moving files --- filewidget.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'filewidget.cpp') diff --git a/filewidget.cpp b/filewidget.cpp index 0ee7d2d..b637e4c 100644 --- a/filewidget.cpp +++ b/filewidget.cpp @@ -525,22 +525,33 @@ void FileWidget::paste(){ int count = 0; mProgressBar->reset(); mProgressBar->setMaximum(urls.count() - 1); - foreach (QUrl u, urls){ + for(QUrl u : urls){ QString path = u.toLocalFile(); QString newDir = mDir->text(); QFileInfo fi(path); QString newFile = QString("%1/%2").arg(newDir).arg(fi.fileName()); mProgressBar->setValue(++count); + CachedFileData *fd = mFileCache[path]; if(mFileAction == Copy){ QString msg = QString(tr("Copying %1").arg(path)); emit statusMessage(msg); qApp->processEvents(); - QFile::copy(path, newFile); + if(QFile::copy(path, newFile)){ + CachedFileData *fdNew = new CachedFileData(*fd); + fdNew->fullPath = newFile; + mFileCache.insert(newFile, fdNew); + } }else if(mFileAction == Cut){ QString msg = QString(tr("Moving %1").arg(path)); emit statusMessage(msg); qApp->processEvents(); - QFile::rename(path, newFile); + if(QFile::rename(path, newFile)){ + CachedFileData *fd = mFileCache.take(path); + if(fd){ + mFileCache.remove(path); + mFileCache.insert(newFile, fd); + } + } } emit statusMessage("Finished Paste!"); } -- cgit v1.2.3-70-g09d2