Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 161 |
1 files changed, 79 insertions, 82 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 78f9da2..18bbd43 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -13,9 +13,6 @@ | |||
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | ||
17 | #include <opie/oprocess.h> | ||
18 | |||
19 | #include <qpe/lnkproperties.h> | 16 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
@@ -69,7 +66,7 @@ void AdvancedFm::showMenuHidden() { | |||
69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 66 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
70 | } | 67 | } |
71 | b = !b; | 68 | b = !b; |
72 | populateView(); | 69 | populateView(); |
73 | } | 70 | } |
74 | 71 | ||
75 | void AdvancedFm::showHidden() { | 72 | void AdvancedFm::showHidden() { |
@@ -80,7 +77,7 @@ void AdvancedFm::showHidden() { | |||
80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 77 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 78 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
82 | } | 79 | } |
83 | populateView(); | 80 | populateView(); |
84 | } | 81 | } |
85 | 82 | ||
86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 83 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
@@ -146,7 +143,7 @@ void AdvancedFm::makeDir() { | |||
146 | QString filename = fileDlg->LineEdit1->text(); | 143 | QString filename = fileDlg->LineEdit1->text(); |
147 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 144 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
148 | } | 145 | } |
149 | populateView(); | 146 | populateView(); |
150 | } | 147 | } |
151 | 148 | ||
152 | void AdvancedFm::doDelete() { | 149 | void AdvancedFm::doDelete() { |
@@ -183,7 +180,7 @@ void AdvancedFm::doDelete() { | |||
183 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 180 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
184 | //if file is a directory | 181 | //if file is a directory |
185 | 182 | ||
186 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 183 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
187 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , | 184 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , |
188 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 185 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
189 | case 0: | 186 | case 0: |
@@ -191,7 +188,7 @@ void AdvancedFm::doDelete() { | |||
191 | f=f.left(f.length()-1); | 188 | f=f.left(f.length()-1); |
192 | QString cmd="rm -rf "+f; | 189 | QString cmd="rm -rf "+f; |
193 | startProcess( (const QString)cmd.latin1() ); | 190 | startProcess( (const QString)cmd.latin1() ); |
194 | populateView(); | 191 | populateView(); |
195 | } | 192 | } |
196 | break; | 193 | break; |
197 | case 1: | 194 | case 1: |
@@ -209,13 +206,13 @@ void AdvancedFm::doDelete() { | |||
209 | break; | 206 | break; |
210 | }; | 207 | }; |
211 | } | 208 | } |
212 | 209 | ||
213 | QString cmd="rm "+f; | 210 | QString cmd="rm "+f; |
214 | QFile file(f); | 211 | QFile file(f); |
215 | QFileInfo fi(myFile); | 212 | QFileInfo fi(myFile); |
216 | if( fi.fileName().find("../",0,TRUE)==-1) { | 213 | if( fi.fileName().find("../",0,TRUE)==-1) { |
217 | // qDebug("remove link files "+myFile); | 214 | // qDebug("remove link files "+myFile); |
218 | 215 | ||
219 | // DocLnk lnk(f); | 216 | // DocLnk lnk(f); |
220 | DocLnk *lnk; | 217 | DocLnk *lnk; |
221 | lnk = new DocLnk(f); | 218 | lnk = new DocLnk(f); |
@@ -228,7 +225,7 @@ void AdvancedFm::doDelete() { | |||
228 | } | 225 | } |
229 | } | 226 | } |
230 | } | 227 | } |
231 | populateView(); | 228 | populateView(); |
232 | } | 229 | } |
233 | 230 | ||
234 | void AdvancedFm::filePerms() { | 231 | void AdvancedFm::filePerms() { |
@@ -244,7 +241,7 @@ void AdvancedFm::filePerms() { | |||
244 | if( filePerm ) | 241 | if( filePerm ) |
245 | delete filePerm; | 242 | delete filePerm; |
246 | } | 243 | } |
247 | populateView(); | 244 | populateView(); |
248 | } | 245 | } |
249 | 246 | ||
250 | void AdvancedFm::doProperties() { | 247 | void AdvancedFm::doProperties() { |
@@ -276,7 +273,7 @@ void AdvancedFm::upDir() { | |||
276 | chdir( current.latin1() ); | 273 | chdir( current.latin1() ); |
277 | thisDir->cd( current, TRUE); | 274 | thisDir->cd( current, TRUE); |
278 | 275 | ||
279 | populateView(); | 276 | populateView(); |
280 | update(); | 277 | update(); |
281 | } | 278 | } |
282 | 279 | ||
@@ -337,8 +334,8 @@ void AdvancedFm::copy() { | |||
337 | return; | 334 | return; |
338 | } | 335 | } |
339 | } | 336 | } |
340 | setOtherTabCurrent(); | 337 | setOtherTabCurrent(); |
341 | rePopulate(); | 338 | rePopulate(); |
342 | } | 339 | } |
343 | } | 340 | } |
344 | 341 | ||
@@ -387,8 +384,8 @@ void AdvancedFm::copyAs() { | |||
387 | delete fileDlg; | 384 | delete fileDlg; |
388 | 385 | ||
389 | } | 386 | } |
390 | rePopulate(); | 387 | rePopulate(); |
391 | setOtherTabCurrent(); | 388 | setOtherTabCurrent(); |
392 | } | 389 | } |
393 | 390 | ||
394 | void AdvancedFm::copySameDir() { | 391 | void AdvancedFm::copySameDir() { |
@@ -436,7 +433,7 @@ void AdvancedFm::copySameDir() { | |||
436 | } | 433 | } |
437 | delete fileDlg; | 434 | delete fileDlg; |
438 | } | 435 | } |
439 | rePopulate(); | 436 | rePopulate(); |
440 | } | 437 | } |
441 | 438 | ||
442 | void AdvancedFm::move() { | 439 | void AdvancedFm::move() { |
@@ -459,80 +456,80 @@ void AdvancedFm::move() { | |||
459 | 456 | ||
460 | curFile = thisDir->canonicalPath(); | 457 | curFile = thisDir->canonicalPath(); |
461 | if(curFile.right(1).find("/",0,TRUE) == -1) | 458 | if(curFile.right(1).find("/",0,TRUE) == -1) |
462 | curFile +="/"; | 459 | curFile +="/"; |
463 | curFile+= item; | 460 | curFile+= item; |
464 | // qDebug("CurrentFile file is " + curFile); | 461 | // qDebug("CurrentFile file is " + curFile); |
465 | 462 | ||
466 | if(QFileInfo(curFile).isDir()) { | 463 | if(QFileInfo(curFile).isDir()) { |
467 | moveDirectory( curFile, destFile ); | 464 | moveDirectory( curFile, destFile ); |
468 | rePopulate(); | 465 | rePopulate(); |
469 | return; | 466 | return; |
470 | } | 467 | } |
471 | 468 | ||
472 | QFile f( curFile); | 469 | QFile f( curFile); |
473 | if( f.exists()) { | 470 | if( f.exists()) { |
474 | if( !copyFile( curFile, destFile) ) { | 471 | if( !copyFile( curFile, destFile) ) { |
475 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 472 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
476 | return; | 473 | return; |
477 | } else | 474 | } else |
478 | QFile::remove(curFile); | 475 | QFile::remove(curFile); |
479 | } | 476 | } |
480 | } | 477 | } |
481 | 478 | ||
482 | } | 479 | } |
483 | rePopulate(); | 480 | rePopulate(); |
484 | setOtherTabCurrent(); | 481 | setOtherTabCurrent(); |
485 | } | 482 | } |
486 | 483 | ||
487 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 484 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
488 | int err = 0; | 485 | int err = 0; |
489 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; | 486 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; |
490 | err = system((const char*)cmd); | 487 | err = system((const char*)cmd); |
491 | } else | 488 | } else |
492 | err = -1; | 489 | err = -1; |
493 | 490 | ||
494 | if(err!=0) { | 491 | if(err!=0) { |
495 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); | 492 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); |
496 | return false; | 493 | return false; |
497 | } | 494 | } |
498 | return true; | 495 | return true; |
499 | } | 496 | } |
500 | 497 | ||
501 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 498 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
502 | 499 | ||
503 | QStringcmd = "/bin/cp -fpR " + src + " " + dest; | 500 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
504 | qWarning(cmd); | 501 | qWarning(cmd); |
505 | interr = system( (const char *) cmd ); | 502 | int err = system( (const char *) cmd ); |
506 | if ( err != 0 ) { | 503 | if ( err != 0 ) { |
507 | QMessageBox::message("AdvancedFm", | 504 | QMessageBox::message("AdvancedFm", |
508 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); | 505 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); |
509 | return false; | 506 | return false; |
510 | } | 507 | } |
511 | 508 | ||
512 | return true; | 509 | return true; |
513 | } | 510 | } |
514 | 511 | ||
515 | 512 | ||
516 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 513 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
517 | 514 | ||
518 | 515 | ||
519 | if(QFileInfo(src).isDir()) { | 516 | if(QFileInfo(src).isDir()) { |
520 | if( copyDirectory( src, dest )) { | 517 | if( copyDirectory( src, dest )) { |
521 | setOtherTabCurrent(); | 518 | setOtherTabCurrent(); |
522 | populateView(); | 519 | populateView(); |
523 | return true; | 520 | return true; |
524 | } | 521 | } |
525 | else | 522 | else |
526 | return false; | 523 | return false; |
527 | } | 524 | } |
528 | 525 | ||
529 | 526 | ||
530 | bool success = true; | 527 | bool success = true; |
531 | struct stat status; | 528 | struct stat status; |
532 | QFile srcFile(src); | 529 | QFile srcFile(src); |
533 | QFile destFile(dest); | 530 | QFile destFile(dest); |
534 | int err=0; | 531 | int err=0; |
535 | int read_fd=0; | 532 | int read_fd=0; |
536 | int write_fd=0; | 533 | int write_fd=0; |
537 | struct stat stat_buf; | 534 | struct stat stat_buf; |
538 | off_t offset = 0; | 535 | off_t offset = 0; |
@@ -547,7 +544,7 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | |||
547 | // qWarning("destfile open failed"); | 544 | // qWarning("destfile open failed"); |
548 | return success = false; | 545 | return success = false; |
549 | } | 546 | } |
550 | write_fd = destFile.handle(); | 547 | write_fd = destFile.handle(); |
551 | if(write_fd != -1) { | 548 | if(write_fd != -1) { |
552 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 549 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
553 | if( err == -1) { | 550 | if( err == -1) { |
@@ -677,9 +674,9 @@ void AdvancedFm::mkSym() { | |||
677 | // qDebug(cmd); | 674 | // qDebug(cmd); |
678 | startProcess( (const QString)cmd ); | 675 | startProcess( (const QString)cmd ); |
679 | } | 676 | } |
680 | rePopulate(); | 677 | rePopulate(); |
681 | setOtherTabCurrent(); | 678 | setOtherTabCurrent(); |
682 | } | 679 | } |
683 | } | 680 | } |
684 | 681 | ||
685 | void AdvancedFm::doBeam() { | 682 | void AdvancedFm::doBeam() { |
@@ -731,7 +728,7 @@ void AdvancedFm::startProcess(const QString & cmd) { | |||
731 | } | 728 | } |
732 | 729 | ||
733 | void AdvancedFm::processEnded(OProcess *) { | 730 | void AdvancedFm::processEnded(OProcess *) { |
734 | rePopulate(); | 731 | rePopulate(); |
735 | } | 732 | } |
736 | 733 | ||
737 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 734 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
@@ -797,7 +794,7 @@ void AdvancedFm::doRename(QListView * view) { | |||
797 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 794 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
798 | r.setX( view->contentsX() ); | 795 | r.setX( view->contentsX() ); |
799 | 796 | ||
800 | if ( r.width() > view->visibleWidth() ) | 797 | if ( r.width() > view->visibleWidth() ) |
801 | r.setWidth( view->visibleWidth() ); | 798 | r.setWidth( view->visibleWidth() ); |
802 | 799 | ||
803 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 800 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
@@ -810,19 +807,19 @@ void AdvancedFm::doRename(QListView * view) { | |||
810 | 807 | ||
811 | view->addChild( renameBox, r.x(), r.y() ); | 808 | view->addChild( renameBox, r.x(), r.y() ); |
812 | 809 | ||
813 | renameBox->resize( r.size() ); | 810 | renameBox->resize( r.size() ); |
814 | 811 | ||
815 | view->viewport()->setFocusProxy( renameBox ); | 812 | view->viewport()->setFocusProxy( renameBox ); |
816 | 813 | ||
817 | renameBox->setFocus(); | 814 | renameBox->setFocus(); |
818 | renameBox->show(); | 815 | renameBox->show(); |
819 | } | 816 | } |
820 | 817 | ||
821 | 818 | ||
822 | void AdvancedFm::renameIt() { | 819 | void AdvancedFm::renameIt() { |
823 | if( !CurrentView()->currentItem()) return; | 820 | if( !CurrentView()->currentItem()) return; |
824 | 821 | ||
825 | QListView *thisView = CurrentView(); | 822 | QListView *thisView = CurrentView(); |
826 | oldName = thisView->currentItem()->text(0); | 823 | oldName = thisView->currentItem()->text(0); |
827 | doRename( thisView ); | 824 | doRename( thisView ); |
828 | } | 825 | } |
@@ -831,8 +828,8 @@ void AdvancedFm::okRename() { | |||
831 | if( !CurrentView()->currentItem()) return; | 828 | if( !CurrentView()->currentItem()) return; |
832 | 829 | ||
833 | QString newName = renameBox->text(); | 830 | QString newName = renameBox->text(); |
834 | cancelRename(); | 831 | cancelRename(); |
835 | QListView * view = CurrentView(); | 832 | QListView * view = CurrentView(); |
836 | QString path = CurrentDir()->canonicalPath() + "/"; | 833 | QString path = CurrentDir()->canonicalPath() + "/"; |
837 | oldName = path + oldName; | 834 | oldName = path + oldName; |
838 | newName = path + newName; | 835 | newName = path + newName; |
@@ -842,7 +839,7 @@ void AdvancedFm::okRename() { | |||
842 | oldName = ""; | 839 | oldName = ""; |
843 | view->takeItem( view->currentItem() ); | 840 | view->takeItem( view->currentItem() ); |
844 | delete view->currentItem(); | 841 | delete view->currentItem(); |
845 | rePopulate(); | 842 | rePopulate(); |
846 | } | 843 | } |
847 | 844 | ||
848 | void AdvancedFm::openSearch() { | 845 | void AdvancedFm::openSearch() { |