summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfmMenu.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp76
1 files changed, 28 insertions, 48 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 13dad33..c553017 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -59,46 +59,46 @@ void AdvancedFm::showMenuHidden()
59 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 59 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
60 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 60 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
61// b=FALSE; 61// b=FALSE;
62 62
63 } 63 }
64 else 64 else
65 { 65 {
66 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 66 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
67 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 67 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
68 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 68 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
69// b=TRUE; 69// b=TRUE;
70 } 70 }
71 populateLocalView(); 71 populateView();
72 populateRemoteView(); 72// populateRemoteView();
73// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); 73// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
74 if(b) b = false; else b = true; 74 if(b) b = false; else b = true;
75} 75}
76 76
77void AdvancedFm::showHidden() 77void AdvancedFm::showHidden()
78{ 78{
79 if (b) 79 if (b)
80 { 80 {
81 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 81 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
82// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 82// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
83// b=FALSE; 83// b=FALSE;
84 84
85 } 85 }
86 else 86 else
87 { 87 {
88 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 88 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
89// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 89// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
90// b=TRUE; 90// b=TRUE;
91 } 91 }
92 PopulateView(); 92 populateView();
93} 93}
94 94
95QString AdvancedFm::dealWithSymName(const QString &fileName) 95QString AdvancedFm::dealWithSymName(const QString &fileName)
96{ 96{
97 QString strItem = fileName; 97 QString strItem = fileName;
98 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 98 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
99} 99}
100 100
101void AdvancedFm::runThis() 101void AdvancedFm::runThis()
102{ 102{
103 QString fs; 103 QString fs;
104 QDir *thisDir = CurrentDir(); 104 QDir *thisDir = CurrentDir();
@@ -156,25 +156,25 @@ void AdvancedFm::runText()
156 156
157void AdvancedFm::makeDir() 157void AdvancedFm::makeDir()
158{ 158{
159 InputDialog *fileDlg; 159 InputDialog *fileDlg;
160 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 160 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
161 fileDlg->exec(); 161 fileDlg->exec();
162 if( fileDlg->result() == 1 ) 162 if( fileDlg->result() == 1 )
163 { 163 {
164 QDir *thisDir = CurrentDir(); 164 QDir *thisDir = CurrentDir();
165 QString filename = fileDlg->LineEdit1->text(); 165 QString filename = fileDlg->LineEdit1->text();
166 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 166 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
167 } 167 }
168 PopulateView(); 168 populateView();
169} 169}
170 170
171void AdvancedFm::doDelete() 171void AdvancedFm::doDelete()
172{ 172{
173 173
174 QStringList curFileList = getPath(); 174 QStringList curFileList = getPath();
175 bool doMsg=true; 175 bool doMsg=true;
176 int count = curFileList.count(); 176 int count = curFileList.count();
177 if( count > 0) 177 if( count > 0)
178 { 178 {
179 if(count > 1 ) 179 if(count > 1 )
180 { 180 {
@@ -205,68 +205,68 @@ void AdvancedFm::doDelete()
205 f += myFile; 205 f += myFile;
206 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) 206 if(QDir(f).exists() && !QFileInfo(f).isSymLink() )
207 { 207 {
208 switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + 208 switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f +
209 "\nand all it's contents ?" 209 "\nand all it's contents ?"
210 ,tr("Yes"),tr("No"),0,0,1) ) 210 ,tr("Yes"),tr("No"),0,0,1) )
211 { 211 {
212 case 0: 212 case 0:
213 { 213 {
214 f=f.left(f.length()-1); 214 f=f.left(f.length()-1);
215 QString cmd="rm -rf "+f; 215 QString cmd="rm -rf "+f;
216 startProcess( (const QString)cmd.latin1() ); 216 startProcess( (const QString)cmd.latin1() );
217 PopulateView(); 217 populateView();
218 } 218 }
219 break; 219 break;
220 case 1: 220 case 1:
221 // exit 221 // exit
222 break; 222 break;
223 }; 223 };
224 224
225 } else { 225 } else {
226 if(doMsg) { 226 if(doMsg) {
227 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f 227 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
228 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 228 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
229 case 1: 229 case 1:
230 return; 230 return;
231 break; 231 break;
232 }; 232 };
233 } 233 }
234 QString cmd="rm "+f; 234 QString cmd="rm "+f;
235 QFile file(f); 235 QFile file(f);
236 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 236 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
237 file.remove(); 237 file.remove();
238 } 238 }
239 } 239 }
240 } 240 }
241 PopulateView(); 241 populateView();
242} 242}
243 243
244void AdvancedFm::filePerms() 244void AdvancedFm::filePerms()
245{ 245{
246 QStringList curFileList = getPath(); 246 QStringList curFileList = getPath();
247 QString filePath; 247 QString filePath;
248 248
249 filePath = CurrentDir()->canonicalPath()+"/"; 249 filePath = CurrentDir()->canonicalPath()+"/";
250 250
251 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 251 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
252 { 252 {
253 filePermissions *filePerm; 253 filePermissions *filePerm;
254 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 254 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
255 filePerm->showMaximized(); 255 filePerm->showMaximized();
256 filePerm->exec(); 256 filePerm->exec();
257 if( filePerm) 257 if( filePerm)
258 delete filePerm; 258 delete filePerm;
259 } 259 }
260 PopulateView(); 260 populateView();
261} 261}
262 262
263void AdvancedFm::doProperties() 263void AdvancedFm::doProperties()
264{ 264{
265#if defined(QT_QWS_OPIE) 265#if defined(QT_QWS_OPIE)
266 266
267 QStringList curFileList = getPath(); 267 QStringList curFileList = getPath();
268 268
269 QString filePath; 269 QString filePath;
270 filePath = CurrentDir()->canonicalPath()+"/"; 270 filePath = CurrentDir()->canonicalPath()+"/";
271 271
272 qDebug("%d",curFileList.count()); 272 qDebug("%d",curFileList.count());
@@ -284,25 +284,25 @@ void AdvancedFm::doProperties()
284} 284}
285 285
286void AdvancedFm::upDir() 286void AdvancedFm::upDir()
287{ 287{
288 QDir *thisDir = CurrentDir(); 288 QDir *thisDir = CurrentDir();
289 QString current = thisDir->canonicalPath(); 289 QString current = thisDir->canonicalPath();
290 QDir dir(current); 290 QDir dir(current);
291 dir.cdUp(); 291 dir.cdUp();
292 current = dir.canonicalPath(); 292 current = dir.canonicalPath();
293 chdir( current.latin1() ); 293 chdir( current.latin1() );
294 thisDir->cd( current, TRUE); 294 thisDir->cd( current, TRUE);
295 295
296 PopulateView(); 296 populateView();
297 update(); 297 update();
298} 298}
299 299
300void AdvancedFm::copy() 300void AdvancedFm::copy()
301{ 301{
302 qApp->processEvents(); 302 qApp->processEvents();
303 QStringList curFileList = getPath(); 303 QStringList curFileList = getPath();
304 304
305 QDir *thisDir = CurrentDir(); 305 QDir *thisDir = CurrentDir();
306 QDir *thatDir = OtherDir(); 306 QDir *thatDir = OtherDir();
307 307
308 bool doMsg=true; 308 bool doMsg=true;
@@ -351,27 +351,26 @@ void AdvancedFm::copy()
351 }; 351 };
352 } 352 }
353 f.remove(); 353 f.remove();
354 } 354 }
355 355
356 if( !copyFile( curFile, destFile) ) 356 if( !copyFile( curFile, destFile) )
357 { 357 {
358 QMessageBox::message("AdvancedFm", 358 QMessageBox::message("AdvancedFm",
359 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); 359 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
360 return; 360 return;
361 } 361 }
362 } 362 }
363 363 setOtherTabCurrent();
364 PopulateView(); 364 populateView();
365 // TabWidget->setCurrentTab(1);
366 } 365 }
367} 366}
368 367
369void AdvancedFm::copyAs() 368void AdvancedFm::copyAs()
370{ 369{
371 qApp->processEvents(); 370 qApp->processEvents();
372 371
373 QStringList curFileList = getPath(); 372 QStringList curFileList = getPath();
374 QString curFile, item; 373 QString curFile, item;
375 InputDialog *fileDlg; 374 InputDialog *fileDlg;
376 375
377 QDir *thisDir = CurrentDir(); 376 QDir *thisDir = CurrentDir();
@@ -408,25 +407,26 @@ void AdvancedFm::copyAs()
408 }; 407 };
409 } 408 }
410 if( !copyFile( curFile, destFile) ) 409 if( !copyFile( curFile, destFile) )
411 { 410 {
412 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 411 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
413 +curFile +tr("to\n")+destFile); 412 +curFile +tr("to\n")+destFile);
414 return; 413 return;
415 } 414 }
416 } 415 }
417 delete fileDlg; 416 delete fileDlg;
418 417
419 } 418 }
420 PopulateView(); 419 setOtherTabCurrent();
420 populateView();
421} 421}
422 422
423void AdvancedFm::copySameDir() 423void AdvancedFm::copySameDir()
424{ 424{
425 qApp->processEvents(); 425 qApp->processEvents();
426 QStringList curFileList = getPath(); 426 QStringList curFileList = getPath();
427 QString curFile, item, destFile; 427 QString curFile, item, destFile;
428 InputDialog *fileDlg; 428 InputDialog *fileDlg;
429 429
430 QDir *thisDir = CurrentDir(); 430 QDir *thisDir = CurrentDir();
431 431
432 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 432 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
@@ -461,25 +461,25 @@ void AdvancedFm::copySameDir()
461 } 461 }
462 if(!copyFile( curFile,destFile) ) 462 if(!copyFile( curFile,destFile) )
463 { 463 {
464 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 464 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
465 +curFile +tr("to\n")+destFile); 465 +curFile +tr("to\n")+destFile);
466 return; 466 return;
467 } 467 }
468 468
469 qDebug("copy "+curFile+" as "+destFile); 469 qDebug("copy "+curFile+" as "+destFile);
470 } 470 }
471 delete fileDlg; 471 delete fileDlg;
472 } 472 }
473 PopulateView(); 473 populateView();
474} 474}
475 475
476void AdvancedFm::move() 476void AdvancedFm::move()
477{ 477{
478 qApp->processEvents(); 478 qApp->processEvents();
479 479
480 QStringList curFileList = getPath(); 480 QStringList curFileList = getPath();
481 if( curFileList.count() > 0) 481 if( curFileList.count() > 0)
482 { 482 {
483 QString curFile, destFile, item; 483 QString curFile, destFile, item;
484 484
485 QDir *thisDir = CurrentDir(); 485 QDir *thisDir = CurrentDir();
@@ -503,26 +503,27 @@ void AdvancedFm::move()
503 QFile f( curFile); 503 QFile f( curFile);
504 if( f.exists()) { 504 if( f.exists()) {
505 if( !copyFile( curFile, destFile) ) 505 if( !copyFile( curFile, destFile) )
506 { 506 {
507 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 507 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
508 return; 508 return;
509 } else 509 } else
510 QFile::remove(curFile); 510 QFile::remove(curFile);
511 } 511 }
512 } 512 }
513 513
514 } 514 }
515 populateRemoteView(); 515 setOtherTabCurrent();
516 populateLocalView(); 516 populateView();
517 // populateLocalView();
517} 518}
518 519
519bool AdvancedFm::copyFile( const QString & src, const QString & dest ) 520bool AdvancedFm::copyFile( const QString & src, const QString & dest )
520{ 521{
521 char bf[ 50000 ]; 522 char bf[ 50000 ];
522 int bytesRead; 523 int bytesRead;
523 bool success = TRUE; 524 bool success = TRUE;
524 struct stat status; 525 struct stat status;
525 526
526 QFile s( src ); 527 QFile s( src );
527 QFile d( dest ); 528 QFile d( dest );
528 529
@@ -634,81 +635,60 @@ void AdvancedFm::rn()
634 635
635void AdvancedFm::del() 636void AdvancedFm::del()
636{ 637{
637 doDelete(); 638 doDelete();
638} 639}
639 640
640void AdvancedFm::mkSym() 641void AdvancedFm::mkSym()
641{ 642{
642 QString cmd; 643 QString cmd;
643 QStringList curFileList = getPath(); 644 QStringList curFileList = getPath();
644 if( curFileList.count() > 0) 645 if( curFileList.count() > 0)
645 { 646 {
646 if ( whichTab == 1) 647 QDir *thisDir = CurrentDir();
647 { 648 QDir * thatDir = OtherDir();
648 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
649 {
650 649
651 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
652 if(destName.right(1) == "/")
653 {
654 destName = destName.left( destName.length() -1);
655 }
656 QString curFile = currentDir.canonicalPath()+"/"+(*it);
657 if( curFile.right(1) == "/")
658 {
659 curFile = curFile.left( curFile.length() -1);
660 }
661 cmd = "ln -s "+curFile+" "+destName;
662 qDebug(cmd);
663 startProcess( (const QString)cmd );
664 }
665 populateRemoteView();
666 TabWidget->setCurrentTab(1);
667 }
668 else
669 {
670 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 650 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
671 { 651 {
672 652
673 QString destName = currentDir.canonicalPath()+"/"+(*it); 653 QString destName = thatDir->canonicalPath()+"/"+(*it);
674 if(destName.right(1) == "/") 654 if(destName.right(1) == "/")
675 { 655 {
676 destName = destName.left( destName.length() -1); 656 destName = destName.left( destName.length() -1);
677 } 657 }
678 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 658
659 QString curFile = thisDir->canonicalPath()+"/"+(*it);
660
679 if( curFile.right(1) == "/") 661 if( curFile.right(1) == "/")
680 { 662 {
681 curFile = curFile.left( curFile.length() -1); 663 curFile = curFile.left( curFile.length() -1);
682 } 664 }
683 665
684 cmd = "ln -s "+curFile+" "+destName; 666 cmd = "ln -s "+curFile+" "+destName;
685 qDebug(cmd); 667 qDebug(cmd);
686 startProcess( (const QString)cmd ); 668 startProcess( (const QString)cmd );
687 } 669 }
688 populateLocalView(); 670 setOtherTabCurrent();
689 TabWidget->setCurrentTab(0); 671 populateView();
690 }
691 } 672 }
692} 673}
693 674
694void AdvancedFm::doBeam() 675void AdvancedFm::doBeam()
695{ 676{
696 Ir ir; 677 Ir ir;
697 if(!ir.supported()) 678 if(!ir.supported())
698 { 679 {
699 } 680 }
700 else 681 else
701 { 682 {
702
703 QStringList curFileList = getPath(); 683 QStringList curFileList = getPath();
704 if( curFileList.count() > 0) 684 if( curFileList.count() > 0)
705 { 685 {
706 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 686 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
707 { 687 {
708 688
709 QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); 689 QString curFile = CurrentDir()->canonicalPath()+"/"+(*it);
710 if( curFile.right(1) == "/") 690 if( curFile.right(1) == "/")
711 { 691 {
712 curFile = curFile.left( curFile.length() -1); 692 curFile = curFile.left( curFile.length() -1);
713 } 693 }
714 Ir *file = new Ir(this, "IR"); 694 Ir *file = new Ir(this, "IR");
@@ -746,26 +726,26 @@ void AdvancedFm::startProcess(const QString & cmd)
746 this, SLOT( processEnded())); 726 this, SLOT( processEnded()));
747 727
748 command << "/bin/sh"; 728 command << "/bin/sh";
749 command << "-c"; 729 command << "-c";
750 command << cmd.latin1(); 730 command << cmd.latin1();
751 *process << command; 731 *process << command;
752 if(!process->start(OProcess::NotifyOnExit) ) 732 if(!process->start(OProcess::NotifyOnExit) )
753 qDebug("could not start process"); 733 qDebug("could not start process");
754} 734}
755 735
756void AdvancedFm::processEnded() 736void AdvancedFm::processEnded()
757{ 737{
758 populateLocalView(); 738// populateLocalView();
759 populateRemoteView(); 739 populateView();
760} 740}
761 741
762bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) 742bool AdvancedFm::eventFilter( QObject * o, QEvent * e )
763{ 743{
764 if ( o->inherits( "QLineEdit" ) ) 744 if ( o->inherits( "QLineEdit" ) )
765 { 745 {
766 if ( e->type() == QEvent::KeyPress ) 746 if ( e->type() == QEvent::KeyPress )
767 { 747 {
768 QKeyEvent *ke = (QKeyEvent*)e; 748 QKeyEvent *ke = (QKeyEvent*)e;
769 if ( ke->key() == Key_Return || 749 if ( ke->key() == Key_Return ||
770 ke->key() == Key_Enter ) 750 ke->key() == Key_Enter )
771 { 751 {
@@ -834,36 +814,36 @@ void AdvancedFm::doRename(QListView * view)
834 view->viewport()->setFocusProxy( renameBox ); 814 view->viewport()->setFocusProxy( renameBox );
835 renameBox->setFocus(); 815 renameBox->setFocus();
836 renameBox->show(); 816 renameBox->show();
837 817
838} 818}
839 819
840 820
841void AdvancedFm::renameIt() 821void AdvancedFm::renameIt()
842{ 822{
843 QListView *thisView = CurrentView(); 823 QListView *thisView = CurrentView();
844 oldName = thisView->currentItem()->text(0); 824 oldName = thisView->currentItem()->text(0);
845 doRename( thisView ); 825 doRename( thisView );
846 PopulateView(); 826 populateView();
847} 827}
848 828
849void AdvancedFm::okRename() 829void AdvancedFm::okRename()
850{ 830{
851 QString newName = renameBox->text(); 831 QString newName = renameBox->text();
852 cancelRename(); 832 cancelRename();
853 //int tabs=0; 833 //int tabs=0;
854 QListView * view = CurrentView(); 834 QListView * view = CurrentView();
855 QString path = CurrentDir()->canonicalPath() + "/"; 835 QString path = CurrentDir()->canonicalPath() + "/";
856 oldName = path + oldName; 836 oldName = path + oldName;
857 newName = path + newName; 837 newName = path + newName;
858 838
859 if( view->currentItem() == NULL) 839 if( view->currentItem() == NULL)
860 return; 840 return;
861 if( rename( oldName.latin1(), newName.latin1())== -1) 841 if( rename( oldName.latin1(), newName.latin1())== -1)
862 QMessageBox::message(tr("Note"),tr("Could not rename")); 842 QMessageBox::message(tr("Note"),tr("Could not rename"));
863 else 843 else
864 oldName = ""; 844 oldName = "";
865 845
866 view->takeItem( view->currentItem() ); 846 view->takeItem( view->currentItem() );
867 delete view->currentItem(); 847 delete view->currentItem();
868 PopulateView(); 848 populateView();
869} 849}