diff options
author | Ken Moore <ken@pcbsd.org> | 2015-03-26 10:23:14 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-03-26 10:23:14 -0400 |
commit | f8ae4fcc57e5c4020646a0237c0279b2bd0e1780 (patch) | |
tree | 2c2d98270722edee26d8c879865e72f196389fa3 /lumina-fm/FODialog.cpp | |
parent | Merge branch 'master' of github.com:pcbsd/lumina (diff) | |
download | lumina-f8ae4fcc57e5c4020646a0237c0279b2bd0e1780.tar.gz lumina-f8ae4fcc57e5c4020646a0237c0279b2bd0e1780.tar.bz2 lumina-f8ae4fcc57e5c4020646a0237c0279b2bd0e1780.zip |
Clean up a couple things in lumina-fm:
1) Fix the double-run of the background dir checker when changing directories.
2) Add the file overwrite checks to the cut procedures in the backend.
3) If a file/dir is copied onto itself, just skip it rather than erroring.
Diffstat (limited to 'lumina-fm/FODialog.cpp')
-rw-r--r-- | lumina-fm/FODialog.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lumina-fm/FODialog.cpp b/lumina-fm/FODialog.cpp index 165733e3..416404ee 100644 --- a/lumina-fm/FODialog.cpp +++ b/lumina-fm/FODialog.cpp @@ -219,6 +219,7 @@ QStringList FOWorker::removeItem(QString path, bool recursive){ QStringList FOWorker::copyItem(QString oldpath, QString newpath){ QStringList err; + if(oldpath == newpath){ return err; } //copy something onto itself - just skip it if(QFileInfo(oldpath).isDir()){ //Create a new directory with the same name (no way to copy dir+contents) QDir dir; @@ -287,6 +288,12 @@ void FOWorker::slotStartOperations(){ QStringList err; err << tr("Invalid Move") << QString(tr("It is not possible to move a directory into itself. Please make a copy of the directory instead.\n\nOld Location: %1\nNew Location: %2")).arg(ofiles[i], nfiles[i]); emit finished(err); return; }else{ + //Check for existance of the new name + if(QFile::exists(nfiles[i])){ + if(!overwrite){ + nfiles[i] = newFileName(nfiles[i]); //prompt for new file name up front before anything starts + } + } //no changes necessary olist << ofiles[i]; nlist << nfiles[i]; @@ -319,8 +326,17 @@ void FOWorker::slotStartOperations(){ /*ui->label->setText( QString(tr("Moving: %1 to %2")).arg(ofiles[i].section("/",-1), nfiles[i].section("/",-1)) ); QApplication::processEvents();*/ emit startingItem(i+1,olist.length(), olist[i], nlist[i]); - if( !QFile::rename(ofiles[i], nfiles[i]) ){ - errlist << ofiles[i]; + //Clean up any overwritten files/dirs + if(QFile::exists(nlist[i])){ + if(overwrite){ + errlist << removeItem(nlist[i], true); //recursively remove the file/dir since we are supposed to overwrite it + } + } + //Perform the move if no error yet (including skipping all children) + if( !errlist.contains(olist[i].section("/",0,-1)) ){ + if( !QFile::rename(ofiles[i], nfiles[i]) ){ + errlist << ofiles[i]; + } } } //ui->progressBar->setValue(i+1); |