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
@@ -68,8 +68,8 @@ void AdvancedFm::showMenuHidden() {
68 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 68 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
69 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 69 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
70 } 70 }
71 rePopulate();
72 b = !b; 71 b = !b;
72 populateView();
73} 73}
74 74
75void AdvancedFm::showHidden() { 75void AdvancedFm::showHidden() {
@@ -80,7 +80,7 @@ void AdvancedFm::showHidden() {
80 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 80 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
81 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 81 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
82 } 82 }
83 rePopulate(); 83 populateView();
84} 84}
85 85
86QString AdvancedFm::dealWithSymName(const QString &fileName) { 86QString AdvancedFm::dealWithSymName(const QString &fileName) {
@@ -146,7 +146,7 @@ void AdvancedFm::makeDir() {
146 QString filename = fileDlg->LineEdit1->text(); 146 QString filename = fileDlg->LineEdit1->text();
147 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 147 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
148 } 148 }
149 populateView(); 149 populateView();
150} 150}
151 151
152void AdvancedFm::doDelete() { 152void AdvancedFm::doDelete() {
@@ -191,7 +191,7 @@ void AdvancedFm::doDelete() {
191 f=f.left(f.length()-1); 191 f=f.left(f.length()-1);
192 QString cmd="rm -rf "+f; 192 QString cmd="rm -rf "+f;
193 startProcess( (const QString)cmd.latin1() ); 193 startProcess( (const QString)cmd.latin1() );
194 populateView(); 194 populateView();
195 } 195 }
196 break; 196 break;
197 case 1: 197 case 1:
@@ -228,7 +228,7 @@ void AdvancedFm::doDelete() {
228 } 228 }
229 } 229 }
230 } 230 }
231 populateView(); 231 populateView();
232} 232}
233 233
234void AdvancedFm::filePerms() { 234void AdvancedFm::filePerms() {
@@ -245,7 +245,7 @@ void AdvancedFm::filePerms() {
245 if( filePerm) 245 if( filePerm)
246 delete filePerm; 246 delete filePerm;
247 } 247 }
248 populateView(); 248 populateView();
249} 249}
250 250
251void AdvancedFm::doProperties() { 251void AdvancedFm::doProperties() {
@@ -278,7 +278,7 @@ void AdvancedFm::upDir() {
278 chdir( current.latin1() ); 278 chdir( current.latin1() );
279 thisDir->cd( current, TRUE); 279 thisDir->cd( current, TRUE);
280 280
281 populateView(); 281 populateView();
282 update(); 282 update();
283} 283}
284 284
@@ -339,8 +339,8 @@ void AdvancedFm::copy() {
339 return; 339 return;
340 } 340 }
341 } 341 }
342 rePopulate(); 342 setOtherTabCurrent();
343 setOtherTabCurrent(); 343 rePopulate();
344 } 344 }
345} 345}
346 346
@@ -389,8 +389,8 @@ void AdvancedFm::copyAs() {
389 delete fileDlg; 389 delete fileDlg;
390 390
391 } 391 }
392 rePopulate(); 392 rePopulate();
393 setOtherTabCurrent(); 393 setOtherTabCurrent();
394} 394}
395 395
396void AdvancedFm::copySameDir() { 396void AdvancedFm::copySameDir() {
@@ -438,7 +438,7 @@ void AdvancedFm::copySameDir() {
438 } 438 }
439 delete fileDlg; 439 delete fileDlg;
440 } 440 }
441 populateView(); 441 rePopulate();
442} 442}
443 443
444void AdvancedFm::move() { 444void AdvancedFm::move() {
@@ -461,32 +461,80 @@ void AdvancedFm::move() {
461 461
462 curFile = thisDir->canonicalPath(); 462 curFile = thisDir->canonicalPath();
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;
466// qDebug("CurrentFile file is " + curFile); 466// qDebug("CurrentFile file is " + curFile);
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;
491 struct stat stat_buf; 539 struct stat stat_buf;
492 off_t offset = 0; 540 off_t offset = 0;
@@ -633,9 +681,9 @@ void AdvancedFm::mkSym() {
633// qDebug(cmd); 681// qDebug(cmd);
634 startProcess( (const QString)cmd ); 682 startProcess( (const QString)cmd );
635 } 683 }
636 rePopulate(); 684 rePopulate();
637 setOtherTabCurrent(); 685 setOtherTabCurrent();
638 } 686 }
639} 687}
640 688
641void AdvancedFm::doBeam() { 689void AdvancedFm::doBeam() {
@@ -687,7 +735,7 @@ void AdvancedFm::startProcess(const QString & cmd) {
687} 735}
688 736
689void AdvancedFm::processEnded(OProcess *) { 737void AdvancedFm::processEnded(OProcess *) {
690 populateView(); 738 rePopulate();
691} 739}
692 740
693void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 741void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
@@ -775,7 +823,7 @@ void AdvancedFm::renameIt() {
775 QListView *thisView = CurrentView(); 823 QListView *thisView = CurrentView();
776 oldName = thisView->currentItem()->text(0); 824 oldName = thisView->currentItem()->text(0);
777 doRename( thisView ); 825 doRename( thisView );
778 populateView(); 826 rePopulate();
779} 827}
780 828
781void AdvancedFm::okRename() { 829void AdvancedFm::okRename() {
@@ -794,7 +842,7 @@ void AdvancedFm::okRename() {
794 842
795 view->takeItem( view->currentItem() ); 843 view->takeItem( view->currentItem() );
796 delete view->currentItem(); 844 delete view->currentItem();
797 populateView(); 845 rePopulate();
798} 846}
799 847
800void AdvancedFm::openSearch() { 848void AdvancedFm::openSearch() {