Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 114 |
1 files changed, 81 insertions, 33 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index c0be948..90c887f 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -70,4 +70,4 @@ void AdvancedFm::showMenuHidden() { } - rePopulate(); b = !b; + populateView(); } @@ -82,3 +82,3 @@ void AdvancedFm::showHidden() { } - rePopulate(); + populateView(); } @@ -148,3 +148,3 @@ void AdvancedFm::makeDir() { } - populateView(); + populateView(); } @@ -193,3 +193,3 @@ void AdvancedFm::doDelete() { startProcess( (const QString)cmd.latin1() ); - populateView(); + populateView(); } @@ -230,3 +230,3 @@ void AdvancedFm::doDelete() { } - populateView(); + populateView(); } @@ -247,3 +247,3 @@ void AdvancedFm::filePerms() { } - populateView(); + populateView(); } @@ -280,3 +280,3 @@ void AdvancedFm::upDir() { - populateView(); + populateView(); update(); @@ -341,4 +341,4 @@ void AdvancedFm::copy() { } - rePopulate(); - setOtherTabCurrent(); + setOtherTabCurrent(); + rePopulate(); } @@ -391,4 +391,4 @@ void AdvancedFm::copyAs() { } - rePopulate(); - setOtherTabCurrent(); + rePopulate(); + setOtherTabCurrent(); } @@ -440,3 +440,3 @@ void AdvancedFm::copySameDir() { } - populateView(); + rePopulate(); } @@ -463,3 +463,3 @@ void AdvancedFm::move() { if(curFile.right(1).find("/",0,TRUE) == -1) - curFile +="/"; + curFile +="/"; curFile+= item; @@ -467,24 +467,72 @@ void AdvancedFm::move() { - QFile f( curFile); + if(QFileInfo(curFile).isDir()) { + moveDirectory( curFile, destFile ); + rePopulate(); + return; + } + + QFile f( curFile); if( f.exists()) { - if( !copyFile( curFile, destFile) ) { - QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); - return; + if( !copyFile( curFile, destFile) ) { + QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); + return; } else - QFile::remove(curFile); + QFile::remove(curFile); } - } + } } - rePopulate(); - setOtherTabCurrent(); + rePopulate(); + setOtherTabCurrent(); +} + +bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { + int err = 0; + if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; + err = system((const char*)cmd); + } else + err = -1; + + if(err!=0) { + QMessageBox::message(tr("Note"),tr("Could not move\n") + src); + return false; + } + return true; } +bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { + + QString cmd = "/bin/cp -fpR " + src + " " + dest; + qWarning(cmd); + int err = system( (const char *) cmd ); + if ( err != 0 ) { + QMessageBox::message("AdvancedFm", + tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); + return false; + } + + return true; +} + + bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { - bool success = true; - struct stat status; - QFile srcFile(src); - QFile destFile(dest); - int err=0; - int read_fd=0; + + + if(QFileInfo(src).isDir()) { + if( copyDirectory( src, dest )) { + setOtherTabCurrent(); + populateView(); + return true; + } + else + return false; + } + + + bool success = true; + struct stat status; + QFile srcFile(src); + QFile destFile(dest); + int err=0; + int read_fd=0; int write_fd=0; @@ -635,5 +683,5 @@ void AdvancedFm::mkSym() { } - rePopulate(); - setOtherTabCurrent(); - } + rePopulate(); + setOtherTabCurrent(); + } } @@ -689,3 +737,3 @@ void AdvancedFm::startProcess(const QString & cmd) { void AdvancedFm::processEnded(OProcess *) { - populateView(); + rePopulate(); } @@ -777,3 +825,3 @@ void AdvancedFm::renameIt() { doRename( thisView ); - populateView(); + rePopulate(); } @@ -796,3 +844,3 @@ void AdvancedFm::okRename() { delete view->currentItem(); - populateView(); + rePopulate(); } |