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 | |||
@@ -65,25 +65,25 @@ void AdvancedFm::showMenuHidden() { | |||
65 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 65 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
66 | } else { | 66 | } else { |
67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
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 | ||
75 | void AdvancedFm::showHidden() { | 75 | void AdvancedFm::showHidden() { |
76 | if (b) { | 76 | if (b) { |
77 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 77 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
78 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 78 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
79 | } else { | 79 | } else { |
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 | ||
86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
87 | QString strItem = fileName; | 87 | QString strItem = fileName; |
88 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 88 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
89 | } | 89 | } |
@@ -143,13 +143,13 @@ void AdvancedFm::makeDir() { | |||
143 | fileDlg->exec(); | 143 | fileDlg->exec(); |
144 | if( fileDlg->result() == 1 ) { | 144 | if( fileDlg->result() == 1 ) { |
145 | QDir *thisDir = CurrentDir(); | 145 | QDir *thisDir = CurrentDir(); |
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 | ||
152 | void AdvancedFm::doDelete() { | 152 | void AdvancedFm::doDelete() { |
153 | QStringList curFileList = getPath(); | 153 | QStringList curFileList = getPath(); |
154 | bool doMsg=true; | 154 | bool doMsg=true; |
155 | int count = curFileList.count(); | 155 | int count = curFileList.count(); |
@@ -188,13 +188,13 @@ void AdvancedFm::doDelete() { | |||
188 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 188 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
189 | case 0: | 189 | case 0: |
190 | { | 190 | { |
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: |
198 | // exit | 198 | // exit |
199 | break; | 199 | break; |
200 | }; | 200 | }; |
@@ -225,13 +225,13 @@ void AdvancedFm::doDelete() { | |||
225 | // delete lnk; | 225 | // delete lnk; |
226 | file.remove(); | 226 | file.remove(); |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | populateView(); | 231 | populateView(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void AdvancedFm::filePerms() { | 234 | void AdvancedFm::filePerms() { |
235 | QStringList curFileList = getPath(); | 235 | QStringList curFileList = getPath(); |
236 | QString filePath; | 236 | QString filePath; |
237 | 237 | ||
@@ -242,13 +242,13 @@ void AdvancedFm::filePerms() { | |||
242 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 242 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
243 | filePerm->showMaximized(); | 243 | filePerm->showMaximized(); |
244 | filePerm->exec(); | 244 | filePerm->exec(); |
245 | if( filePerm) | 245 | if( filePerm) |
246 | delete filePerm; | 246 | delete filePerm; |
247 | } | 247 | } |
248 | populateView(); | 248 | populateView(); |
249 | } | 249 | } |
250 | 250 | ||
251 | void AdvancedFm::doProperties() { | 251 | void AdvancedFm::doProperties() { |
252 | #if defined(QT_QWS_OPIE) | 252 | #if defined(QT_QWS_OPIE) |
253 | 253 | ||
254 | QStringList curFileList = getPath(); | 254 | QStringList curFileList = getPath(); |
@@ -275,13 +275,13 @@ void AdvancedFm::upDir() { | |||
275 | QDir dir(current); | 275 | QDir dir(current); |
276 | dir.cdUp(); | 276 | dir.cdUp(); |
277 | current = dir.canonicalPath(); | 277 | current = dir.canonicalPath(); |
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 | ||
285 | void AdvancedFm::copy() { | 285 | void AdvancedFm::copy() { |
286 | qApp->processEvents(); | 286 | qApp->processEvents(); |
287 | QStringList curFileList = getPath(); | 287 | QStringList curFileList = getPath(); |
@@ -336,14 +336,14 @@ void AdvancedFm::copy() { | |||
336 | if( !copyFile( curFile, destFile) ) { | 336 | if( !copyFile( curFile, destFile) ) { |
337 | QMessageBox::message("AdvancedFm", | 337 | QMessageBox::message("AdvancedFm", |
338 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 338 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
339 | return; | 339 | return; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | rePopulate(); | 342 | setOtherTabCurrent(); |
343 | setOtherTabCurrent(); | 343 | rePopulate(); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | void AdvancedFm::copyAs() { | 347 | void AdvancedFm::copyAs() { |
348 | qApp->processEvents(); | 348 | qApp->processEvents(); |
349 | 349 | ||
@@ -386,14 +386,14 @@ void AdvancedFm::copyAs() { | |||
386 | return; | 386 | return; |
387 | } | 387 | } |
388 | } | 388 | } |
389 | delete fileDlg; | 389 | delete fileDlg; |
390 | 390 | ||
391 | } | 391 | } |
392 | rePopulate(); | 392 | rePopulate(); |
393 | setOtherTabCurrent(); | 393 | setOtherTabCurrent(); |
394 | } | 394 | } |
395 | 395 | ||
396 | void AdvancedFm::copySameDir() { | 396 | void AdvancedFm::copySameDir() { |
397 | qApp->processEvents(); | 397 | qApp->processEvents(); |
398 | QStringList curFileList = getPath(); | 398 | QStringList curFileList = getPath(); |
399 | QString curFile, item, destFile; | 399 | QString curFile, item, destFile; |
@@ -435,13 +435,13 @@ void AdvancedFm::copySameDir() { | |||
435 | } | 435 | } |
436 | 436 | ||
437 | // qDebug("copy "+curFile+" as "+destFile); | 437 | // qDebug("copy "+curFile+" as "+destFile); |
438 | } | 438 | } |
439 | delete fileDlg; | 439 | delete fileDlg; |
440 | } | 440 | } |
441 | populateView(); | 441 | rePopulate(); |
442 | } | 442 | } |
443 | 443 | ||
444 | void AdvancedFm::move() { | 444 | void AdvancedFm::move() { |
445 | qApp->processEvents(); | 445 | qApp->processEvents(); |
446 | 446 | ||
447 | QStringList curFileList = getPath(); | 447 | QStringList curFileList = getPath(); |
@@ -458,38 +458,86 @@ void AdvancedFm::move() { | |||
458 | destFile+="/"; | 458 | destFile+="/"; |
459 | destFile += item; | 459 | destFile += item; |
460 | // qDebug("Destination file is "+destFile); | 460 | // qDebug("Destination file is "+destFile); |
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 | |||
489 | bool 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 | ||
503 | bool 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 | |||
483 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 518 | bool 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; |
493 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 541 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
494 | // qWarning("open failed"); | 542 | // qWarning("open failed"); |
495 | return success = false; | 543 | return success = false; |
@@ -630,15 +678,15 @@ void AdvancedFm::mkSym() { | |||
630 | } | 678 | } |
631 | 679 | ||
632 | cmd = "ln -s "+curFile+" "+destName; | 680 | cmd = "ln -s "+curFile+" "+destName; |
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 | ||
641 | void AdvancedFm::doBeam() { | 689 | void AdvancedFm::doBeam() { |
642 | Ir ir; | 690 | Ir ir; |
643 | if(!ir.supported()) { | 691 | if(!ir.supported()) { |
644 | } else { | 692 | } else { |
@@ -684,13 +732,13 @@ void AdvancedFm::startProcess(const QString & cmd) { | |||
684 | *process << command; | 732 | *process << command; |
685 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 733 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
686 | qDebug("could not start process"); | 734 | qDebug("could not start process"); |
687 | } | 735 | } |
688 | 736 | ||
689 | void AdvancedFm::processEnded(OProcess *) { | 737 | void AdvancedFm::processEnded(OProcess *) { |
690 | populateView(); | 738 | rePopulate(); |
691 | } | 739 | } |
692 | 740 | ||
693 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 741 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
694 | // qWarning("received stderrt %d bytes", buflen); | 742 | // qWarning("received stderrt %d bytes", buflen); |
695 | 743 | ||
696 | QString lineStr = buffer; | 744 | QString lineStr = buffer; |
@@ -772,13 +820,13 @@ void AdvancedFm::doRename(QListView * view) { | |||
772 | 820 | ||
773 | void AdvancedFm::renameIt() { | 821 | void AdvancedFm::renameIt() { |
774 | if( !CurrentView()->currentItem()) return; | 822 | if( !CurrentView()->currentItem()) return; |
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 | ||
781 | void AdvancedFm::okRename() { | 829 | void AdvancedFm::okRename() { |
782 | if( !CurrentView()->currentItem()) return; | 830 | if( !CurrentView()->currentItem()) return; |
783 | QString newName = renameBox->text(); | 831 | QString newName = renameBox->text(); |
784 | cancelRename(); | 832 | cancelRename(); |
@@ -791,12 +839,12 @@ void AdvancedFm::okRename() { | |||
791 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 839 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
792 | else | 840 | else |
793 | oldName = ""; | 841 | oldName = ""; |
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 | ||
800 | void AdvancedFm::openSearch() { | 848 | void AdvancedFm::openSearch() { |
801 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 849 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
802 | } | 850 | } |