summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp7
-rw-r--r--noncore/apps/advancedfm/advancedfm.h4
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp62
3 files changed, 63 insertions, 10 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 2fc4b49..ecf471d 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -93,29 +93,32 @@ void AdvancedFm::tabChanged(QWidget *) {
93 viewMenu->setItemChecked(viewMenu->idAt(1), true); 93 viewMenu->setItemChecked(viewMenu->idAt(1), true);
94 } 94 }
95 95
96 QString fs= getFileSystemType( (const QString &) path); 96 QString fs= getFileSystemType( (const QString &) path);
97 97
98 setCaption(tr("AdvancedFm :: ")+fs+" :: " 98 setCaption(tr("AdvancedFm :: ")+fs+" :: "
99 +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); 99 +checkDiskSpace( (const QString &) path )+ tr(" kB free") );
100 chdir( path.latin1()); 100 chdir( path.latin1());
101} 101}
102 102
103 103
104void AdvancedFm::populateView() { 104void AdvancedFm::populateView() {
105
106qWarning("PopulateView");
105 QPixmap pm; 107 QPixmap pm;
106 QListView *thisView = CurrentView(); 108 QListView *thisView = CurrentView();
107 QDir *thisDir = CurrentDir(); 109 QDir *thisDir = CurrentDir();
108 QString path = thisDir->canonicalPath(); 110 QString path = thisDir->canonicalPath();
109// qWarning("path is "+path); 111
112qWarning("path is "+path);
110 thisView->clear(); 113 thisView->clear();
111 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 114 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
112 thisDir->setMatchAllDirs(TRUE); 115 thisDir->setMatchAllDirs(TRUE);
113 thisDir->setNameFilter(filterStr); 116 thisDir->setNameFilter(filterStr);
114 QString fileL, fileS, fileDate; 117 QString fileL, fileS, fileDate;
115 QString fs= getFileSystemType((const QString &) path); 118 QString fs= getFileSystemType((const QString &) path);
116 setCaption(tr("AdvancedFm :: ")+fs+" :: " 119 setCaption(tr("AdvancedFm :: ")+fs+" :: "
117 +checkDiskSpace((const QString &) path)+ tr(" kB free") ); 120 +checkDiskSpace((const QString &) path)+ tr(" kB free") );
118 bool isDir=FALSE; 121 bool isDir=FALSE;
119 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 122 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
120 QFileInfoListIterator it(*list); 123 QFileInfoListIterator it(*list);
121 QFileInfo *fi; 124 QFileInfo *fi;
@@ -800,25 +803,25 @@ QListView * AdvancedFm::CurrentView() {
800 return Remote_View; 803 return Remote_View;
801 } 804 }
802} 805}
803 806
804QListView * AdvancedFm::OtherView() { 807QListView * AdvancedFm::OtherView() {
805 if ( whichTab == 1) 808 if ( whichTab == 1)
806 return Remote_View; 809 return Remote_View;
807 else 810 else
808 return Local_View; 811 return Local_View;
809} 812}
810 813
811void AdvancedFm::setOtherTabCurrent() { 814void AdvancedFm::setOtherTabCurrent() {
812// qWarning("setOtherTabCurrent()"); 815 qWarning("setOtherTabCurrent() %d", whichTab);
813 if ( whichTab == 1) { 816 if ( whichTab == 1) {
814 TabWidget->setCurrentWidget(1); 817 TabWidget->setCurrentWidget(1);
815 } else { 818 } else {
816 TabWidget->setCurrentWidget(0); 819 TabWidget->setCurrentWidget(0);
817 } 820 }
818 OtherView()->setFocus(); 821 OtherView()->setFocus();
819 OtherView()->setSelected( CurrentView()->firstChild(), true); 822 OtherView()->setSelected( CurrentView()->firstChild(), true);
820} 823}
821 824
822void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 825void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
823// qDebug("qcop message "+msg ); 826// qDebug("qcop message "+msg );
824 QDataStream stream ( data, IO_ReadOnly ); 827 QDataStream stream ( data, IO_ReadOnly );
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 5f6eabb..be574c4 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -145,25 +145,27 @@ protected slots:
145 void currentPathComboChanged(); 145 void currentPathComboChanged();
146 void copy(); 146 void copy();
147 void copyAs(); 147 void copyAs();
148 void copySameDir(); 148 void copySameDir();
149 void currentPathComboActivated(const QString &); 149 void currentPathComboActivated(const QString &);
150 void fillCombo(const QString &); 150 void fillCombo(const QString &);
151 bool copyFile( const QString & , const QString & ); 151 bool copyFile( const QString & , const QString & );
152 void move(); 152 void move();
153 void fileStatus(); 153 void fileStatus();
154 void doAbout(); 154 void doAbout();
155 void doBeam(); 155 void doBeam();
156 void fileBeamFinished( Ir *); 156 void fileBeamFinished( Ir *);
157 157 bool copyDirectory( const QString & , const QString & );
158// void navigateToSelected();
159 bool moveDirectory( const QString & , const QString & );
158// void slotSwitchtoLocal(int); 160// void slotSwitchtoLocal(int);
159 161
160private: 162private:
161 MenuButton *menuButton; 163 MenuButton *menuButton;
162 QString oldName; 164 QString oldName;
163 QTimer menuTimer; 165 QTimer menuTimer;
164 void startProcess(const QString &); 166 void startProcess(const QString &);
165 bool eventFilter( QObject * , QEvent * ); 167 bool eventFilter( QObject * , QEvent * );
166 void cancelRename(); 168 void cancelRename();
167 void doRename(QListView *); 169 void doRename(QListView *);
168 void okRename(); 170 void okRename();
169 void customDirsToMenu(); 171 void customDirsToMenu();
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
@@ -59,37 +59,37 @@ void AdvancedFm::doDirChange() {
59} 59}
60 60
61void AdvancedFm::showMenuHidden() { 61void AdvancedFm::showMenuHidden() {
62 if (b) { 62 if (b) {
63 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 63 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
64 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 64 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
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
75void AdvancedFm::showHidden() { 75void 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
86QString AdvancedFm::dealWithSymName(const QString &fileName) { 86QString 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}
90 90
91void AdvancedFm::runThis() { 91void AdvancedFm::runThis() {
92 if( !CurrentView()->currentItem()) return; 92 if( !CurrentView()->currentItem()) return;
93 QString fs; 93 QString fs;
94 QDir *thisDir = CurrentDir(); 94 QDir *thisDir = CurrentDir();
95 95
@@ -330,26 +330,26 @@ void AdvancedFm::copy() {
330 break; 330 break;
331 }; 331 };
332 } 332 }
333 f.remove(); 333 f.remove();
334 } 334 }
335 335
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();
343 setOtherTabCurrent(); 342 setOtherTabCurrent();
343 rePopulate();
344 } 344 }
345} 345}
346 346
347void AdvancedFm::copyAs() { 347void AdvancedFm::copyAs() {
348 qApp->processEvents(); 348 qApp->processEvents();
349 349
350 QStringList curFileList = getPath(); 350 QStringList curFileList = getPath();
351 QString curFile, item; 351 QString curFile, item;
352 InputDialog *fileDlg; 352 InputDialog *fileDlg;
353 353
354 QDir *thisDir = CurrentDir(); 354 QDir *thisDir = CurrentDir();
355 QDir *thatDir = OtherDir(); 355 QDir *thatDir = OtherDir();
@@ -429,25 +429,25 @@ void AdvancedFm::copySameDir() {
429 }; 429 };
430 } 430 }
431 if(!copyFile( curFile,destFile) ) { 431 if(!copyFile( curFile,destFile) ) {
432 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 432 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
433 +curFile +tr("to\n")+destFile); 433 +curFile +tr("to\n")+destFile);
434 return; 434 return;
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
444void AdvancedFm::move() { 444void AdvancedFm::move() {
445 qApp->processEvents(); 445 qApp->processEvents();
446 446
447 QStringList curFileList = getPath(); 447 QStringList curFileList = getPath();
448 if( curFileList.count() > 0) { 448 if( curFileList.count() > 0) {
449 QString curFile, destFile, item; 449 QString curFile, destFile, item;
450 450
451 QDir *thisDir = CurrentDir(); 451 QDir *thisDir = CurrentDir();
452 QDir *thatDir = OtherDir(); 452 QDir *thatDir = OtherDir();
453 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 453 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
@@ -456,40 +456,88 @@ void AdvancedFm::move() {
456 456
457 if(destFile.right(1).find("/",0,TRUE) == -1) 457 if(destFile.right(1).find("/",0,TRUE) == -1)
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 if(QFileInfo(curFile).isDir()) {
469 moveDirectory( curFile, destFile );
470 rePopulate();
471 return;
472 }
473
468 QFile f( curFile); 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();
481} 487}
482 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;
501}
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 ) {
519
520
521 if(QFileInfo(src).isDir()) {
522 if( copyDirectory( src, dest )) {
523 setOtherTabCurrent();
524 populateView();
525 return true;
526 }
527 else
528 return false;
529 }
530
531
484 bool success = true; 532 bool success = true;
485 struct stat status; 533 struct stat status;
486 QFile srcFile(src); 534 QFile srcFile(src);
487 QFile destFile(dest); 535 QFile destFile(dest);
488 int err=0; 536 int err=0;
489 int read_fd=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;
@@ -678,25 +726,25 @@ void AdvancedFm::startProcess(const QString & cmd) {
678 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), 726 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)),
679 this, SLOT( oprocessStderr(OProcess *, char *, int))); 727 this, SLOT( oprocessStderr(OProcess *, char *, int)));
680 728
681 command << "/bin/sh"; 729 command << "/bin/sh";
682 command << "-c"; 730 command << "-c";
683 command << cmd.latin1(); 731 command << cmd.latin1();
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
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 ) {
694// qWarning("received stderrt %d bytes", buflen); 742// qWarning("received stderrt %d bytes", buflen);
695 743
696 QString lineStr = buffer; 744 QString lineStr = buffer;
697 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); 745 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
698} 746}
699 747
700bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 748bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
701 if ( o->inherits( "QLineEdit" ) ) { 749 if ( o->inherits( "QLineEdit" ) ) {
702 if ( e->type() == QEvent::KeyPress ) { 750 if ( e->type() == QEvent::KeyPress ) {
@@ -766,37 +814,37 @@ void AdvancedFm::doRename(QListView * view) {
766 renameBox->resize( r.size() ); 814 renameBox->resize( r.size() );
767 view->viewport()->setFocusProxy( renameBox ); 815 view->viewport()->setFocusProxy( renameBox );
768 renameBox->setFocus(); 816 renameBox->setFocus();
769 renameBox->show(); 817 renameBox->show();
770} 818}
771 819
772 820
773void AdvancedFm::renameIt() { 821void 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
781void AdvancedFm::okRename() { 829void 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();
785 QListView * view = CurrentView(); 833 QListView * view = CurrentView();
786 QString path = CurrentDir()->canonicalPath() + "/"; 834 QString path = CurrentDir()->canonicalPath() + "/";
787 oldName = path + oldName; 835 oldName = path + oldName;
788 newName = path + newName; 836 newName = path + newName;
789 837
790 if( rename( oldName.latin1(), newName.latin1())== -1) 838 if( rename( oldName.latin1(), newName.latin1())== -1)
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
800void AdvancedFm::openSearch() { 848void AdvancedFm::openSearch() {
801 QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); 849 QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
802} 850}