summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfmMenu.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp114
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() {
70 } 70 }
71 rePopulate();
72 b = !b; 71 b = !b;
72 populateView();
73} 73}
@@ -82,3 +82,3 @@ void AdvancedFm::showHidden() {
82 } 82 }
83 rePopulate(); 83 populateView();
84} 84}
@@ -148,3 +148,3 @@ void AdvancedFm::makeDir() {
148 } 148 }
149 populateView(); 149 populateView();
150} 150}
@@ -193,3 +193,3 @@ void AdvancedFm::doDelete() {
193 startProcess( (const QString)cmd.latin1() ); 193 startProcess( (const QString)cmd.latin1() );
194 populateView(); 194 populateView();
195 } 195 }
@@ -230,3 +230,3 @@ void AdvancedFm::doDelete() {
230 } 230 }
231 populateView(); 231 populateView();
232} 232}
@@ -247,3 +247,3 @@ void AdvancedFm::filePerms() {
247 } 247 }
248 populateView(); 248 populateView();
249} 249}
@@ -280,3 +280,3 @@ void AdvancedFm::upDir() {
280 280
281 populateView(); 281 populateView();
282 update(); 282 update();
@@ -341,4 +341,4 @@ void AdvancedFm::copy() {
341 } 341 }
342 rePopulate(); 342 setOtherTabCurrent();
343 setOtherTabCurrent(); 343 rePopulate();
344 } 344 }
@@ -391,4 +391,4 @@ void AdvancedFm::copyAs() {
391 } 391 }
392 rePopulate(); 392 rePopulate();
393 setOtherTabCurrent(); 393 setOtherTabCurrent();
394} 394}
@@ -440,3 +440,3 @@ void AdvancedFm::copySameDir() {
440 } 440 }
441 populateView(); 441 rePopulate();
442} 442}
@@ -463,3 +463,3 @@ void AdvancedFm::move() {
463 if(curFile.right(1).find("/",0,TRUE) == -1) 463 if(curFile.right(1).find("/",0,TRUE) == -1)
464 curFile +="/"; 464 curFile +="/";
465 curFile+= item; 465 curFile+= item;
@@ -467,24 +467,72 @@ void AdvancedFm::move() {
467 467
468 QFile f( curFile); 468 if(QFileInfo(curFile).isDir()) {
469 moveDirectory( curFile, destFile );
470 rePopulate();
471 return;
472 }
473
474 QFile f( curFile);
469 if( f.exists()) { 475 if( f.exists()) {
470 if( !copyFile( curFile, destFile) ) { 476 if( !copyFile( curFile, destFile) ) {
471 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 477 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
472 return; 478 return;
473 } else 479 } else
474 QFile::remove(curFile); 480 QFile::remove(curFile);
475 } 481 }
476 } 482 }
477 483
478 } 484 }
479 rePopulate(); 485 rePopulate();
480 setOtherTabCurrent(); 486 setOtherTabCurrent();
487}
488
489bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
490 int err = 0;
491 if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
492 err = system((const char*)cmd);
493 } else
494 err = -1;
495
496 if(err!=0) {
497 QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
498 return false;
499 }
500 return true;
481} 501}
482 502
503bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
504
505 QStringcmd = "/bin/cp -fpR " + src + " " + dest;
506 qWarning(cmd);
507 interr = system( (const char *) cmd );
508 if ( err != 0 ) {
509 QMessageBox::message("AdvancedFm",
510 tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
511 return false;
512 }
513
514 return true;
515}
516
517
483bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 518bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
484 bool success = true; 519
485 struct stat status; 520
486 QFile srcFile(src); 521 if(QFileInfo(src).isDir()) {
487 QFile destFile(dest); 522 if( copyDirectory( src, dest )) {
488 int err=0; 523 setOtherTabCurrent();
489 int read_fd=0; 524 populateView();
525 return true;
526 }
527 else
528 return false;
529 }
530
531
532 bool success = true;
533 struct stat status;
534 QFile srcFile(src);
535 QFile destFile(dest);
536 int err=0;
537 int read_fd=0;
490 int write_fd=0; 538 int write_fd=0;
@@ -635,5 +683,5 @@ void AdvancedFm::mkSym() {
635 } 683 }
636 rePopulate(); 684 rePopulate();
637 setOtherTabCurrent(); 685 setOtherTabCurrent();
638 } 686 }
639} 687}
@@ -689,3 +737,3 @@ void AdvancedFm::startProcess(const QString & cmd) {
689void AdvancedFm::processEnded(OProcess *) { 737void AdvancedFm::processEnded(OProcess *) {
690 populateView(); 738 rePopulate();
691} 739}
@@ -777,3 +825,3 @@ void AdvancedFm::renameIt() {
777 doRename( thisView ); 825 doRename( thisView );
778 populateView(); 826 rePopulate();
779} 827}
@@ -796,3 +844,3 @@ void AdvancedFm::okRename() {
796 delete view->currentItem(); 844 delete view->currentItem();
797 populateView(); 845 rePopulate();
798} 846}