diff options
author | william <william.os4y@gmail.com> | 2015-03-26 19:11:23 +0100 |
---|---|---|
committer | william <william.os4y@gmail.com> | 2015-03-26 19:11:23 +0100 |
commit | 82f05b571362bd52748c1fe1b1cd6ea2ef07f771 (patch) | |
tree | 6eda92367dc7e22f701b070d14b28ed82163934d /lumina-fm | |
parent | display some filesystem's information on the statusbar in a thread safe manier (diff) | |
parent | Actually move the file/dir copy onto itself check earlier in the procedure, t... (diff) | |
download | lumina-82f05b571362bd52748c1fe1b1cd6ea2ef07f771.tar.gz lumina-82f05b571362bd52748c1fe1b1cd6ea2ef07f771.tar.bz2 lumina-82f05b571362bd52748c1fe1b1cd6ea2ef07f771.zip |
Merge remote-tracking branch 'upstream/master' into fmNumbers
Diffstat (limited to 'lumina-fm')
-rw-r--r-- | lumina-fm/FODialog.cpp | 24 | ||||
-rw-r--r-- | lumina-fm/MainUI.cpp | 11 |
2 files changed, 29 insertions, 6 deletions
diff --git a/lumina-fm/FODialog.cpp b/lumina-fm/FODialog.cpp index 165733e3..d182ed06 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; @@ -268,6 +269,10 @@ void FOWorker::slotStartOperations(){ if(isRM){ //only old files olist << subfiles(ofiles[i], false); //dirs need to be last for removals }else if(isCP || isRESTORE){ + if(nfiles[i] == ofiles[i]){ + //Trying to copy a file/dir to itself - skip it + continue; + } if(QFile::exists(nfiles[i])){ if(!overwrite){ nfiles[i] = newFileName(nfiles[i]); //prompt for new file name up front before anything starts @@ -287,6 +292,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 +330,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); diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index 59cb09bf..c4b74dbd 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -448,10 +448,12 @@ void MainUI::setCurrentDir(QString dir){ ui->tool_goToPlayer->setVisible(false); ui->tool_goToRestore->setVisible(false); ui->tool_goToImages->setVisible(false); - //if(olddir!=rawdir){ + //Make sure the shortcut buttons are enabled as necessary + // If the dir is already loaded into the fsmodel cache it will not emit the directoryLoaded() signal + if(rawdir == olddir){ emit DirChanged(rawdir); //This will be automatically run when a new dir is loaded - emit Si_AdaptStatusBar(fsmod->rootDirectory().entryInfoList(), rawdir, tr("Items")); - //} + } + emit Si_AdaptStatusBar(fsmod->rootDirectory().entryInfoList(), rawdir, tr("Items")); if(isUserWritable){ ui->label_dir_stats->setText(""); } else{ ui->label_dir_stats->setText(tr("Limited Access Directory")); } @@ -549,7 +551,7 @@ void MainUI::AvailableBackups(QString basedir, QStringList snapdirs){ } void MainUI::DisplayStatusBar(QString msg){ - qDebug() << "in main thread:" << msg; + qDebug() << "message to show in the status bar:" << msg; ui->statusbar->showMessage(msg); } @@ -839,6 +841,7 @@ void MainUI::reloadDirectory(){ void MainUI::currentDirectoryLoaded(){ //The directory was just loaded: refresh the action buttons as neccesary + // NOTE: This is only "caught" when a *new* directory is loaded into the model ui->tool_goToPlayer->setVisible(false); ui->tool_goToRestore->setVisible(false); ui->tool_goToImages->setVisible(false); |