summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-28 21:59:34 (UTC)
committer llornkcor <llornkcor>2002-04-28 21:59:34 (UTC)
commit726d985ddb6a5c7eb25a48efdadb189eb38b9a2a (patch) (unidiff)
treee92814b56ee706ccb1d95a0c2e86294aa79ab2c2
parentd9a38221ea876cae8ef8b015968e14af75e202bb (diff)
downloadopie-726d985ddb6a5c7eb25a48efdadb189eb38b9a2a.zip
opie-726d985ddb6a5c7eb25a48efdadb189eb38b9a2a.tar.gz
opie-726d985ddb6a5c7eb25a48efdadb189eb38b9a2a.tar.bz2
fixed multi symlink handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp149
1 files changed, 76 insertions, 73 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index bd513c0..b5fcccf 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -290,69 +290,69 @@ void AdvancedFm::populateLocalView()
290 290
291 bool isDir=FALSE; 291 bool isDir=FALSE;
292 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 292 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
293 QFileInfoListIterator it(*list); 293 QFileInfoListIterator it(*list);
294 QFileInfo *fi; 294 QFileInfo *fi;
295 while ( (fi=it.current()) ) { 295 while ( (fi=it.current()) ) {
296 if (fi->isSymLink() ) { 296 if (fi->isSymLink() ) {
297 QString symLink=fi->readLink(); 297 QString symLink=fi->readLink();
298// qDebug("Symlink detected "+symLink); 298// qDebug("Symlink detected "+symLink);
299 QFileInfo sym( symLink); 299 QFileInfo sym( symLink);
300 fileS.sprintf( "%10li", sym.size() ); 300 fileS.sprintf( "%10li", sym.size() );
301 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 301 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
302 fileDate = sym.lastModified().toString(); 302 fileDate = sym.lastModified().toString();
303 } else { 303 } else {
304 fileS.sprintf( "%10li", fi->size() ); 304 fileS.sprintf( "%10li", fi->size() );
305 fileL.sprintf( "%s",fi->fileName().data() ); 305 fileL.sprintf( "%s",fi->fileName().data() );
306 fileDate= fi->lastModified().toString(); 306 fileDate= fi->lastModified().toString();
307 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 307 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
308 fileL+="/"; 308 fileL+="/";
309 isDir=TRUE; 309 isDir=TRUE;
310// qDebug( fileL); 310// qDebug( fileL);
311 } 311 }
312 } 312 }
313 if(fileL !="./" && fi->exists()) { 313 if(fileL !="./" && fi->exists()) {
314 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 314 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
315 if(isDir || fileL.find("/",0,TRUE) != -1) { 315 if(isDir || fileL.find("/",0,TRUE) != -1) {
316 if( !QDir( fi->filePath() ).isReadable()) 316 if( !QDir( fi->filePath() ).isReadable())
317 pm = Resource::loadPixmap( "lockedfolder" ); 317 pm = Resource::loadPixmap( "lockedfolder" );
318 else 318 else
319 pm= Resource::loadPixmap( "folder" ); 319 pm= Resource::loadPixmap( "folder" );
320 item->setPixmap( 0,pm ); 320 item->setPixmap( 0,pm );
321 } else { 321 } else {
322 if(fi->isExecutable()) { 322// if(fi->isExecutable()) {
323 pm = Resource::loadPixmap( "exec"); 323// pm = Resource::loadPixmap( "exec");
324 item->setPixmap( 0,pm); 324// item->setPixmap( 0,pm);
325 } 325// }
326 else if( !fi->isReadable() ) { 326 if( !fi->isReadable() ) {
327 pm = Resource::loadPixmap( "locked" ); 327 pm = Resource::loadPixmap( "locked" );
328 item->setPixmap( 0,pm); 328 item->setPixmap( 0,pm);
329 329
330 } 330 }
331 else { 331 else {
332 MimeType mt(fi->filePath()); 332 MimeType mt(fi->filePath());
333 pm=mt.pixmap(); //sets the correct pixmap for mimetype 333 pm=mt.pixmap(); //sets the correct pixmap for mimetype
334 if(pm.isNull()) 334 if(pm.isNull())
335 pm = Resource::loadPixmap( "UnknownDocument-14" ); 335 pm = Resource::loadPixmap( "UnknownDocument-14" );
336 item->setPixmap( 0,pm); 336 item->setPixmap( 0,pm);
337 } 337 }
338 } 338 }
339 if( fileL.find("->",0,TRUE) != -1) { 339 if( fileL.find("->",0,TRUE) != -1) {
340 // overlay link image 340 // overlay link image
341 pm= Resource::loadPixmap( "folder" ); 341 pm= Resource::loadPixmap( "folder" );
342 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 342 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
343 QPainter painter( &pm ); 343 QPainter painter( &pm );
344 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 344 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
345 pm.setMask( pm.createHeuristicMask( FALSE ) ); 345 pm.setMask( pm.createHeuristicMask( FALSE ) );
346 item->setPixmap( 0, pm); 346 item->setPixmap( 0, pm);
347 } 347 }
348 } isDir=FALSE; 348 } isDir=FALSE;
349 ++it; 349 ++it;
350 } 350 }
351 351
352 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 352 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
353 struct stat buf; 353 struct stat buf;
354 struct stat st; 354 struct stat st;
355 dev_t devT; 355 dev_t devT;
356 mode_t mode; 356 mode_t mode;
357 DIR *dir; 357 DIR *dir;
358 int fd = 0; 358 int fd = 0;
@@ -406,69 +406,69 @@ void AdvancedFm::populateRemoteView()
406 QFileInfoListIterator it(*list); 406 QFileInfoListIterator it(*list);
407 QFileInfo *fi; 407 QFileInfo *fi;
408 while ( (fi=it.current()) ) { 408 while ( (fi=it.current()) ) {
409 if (fi->isSymLink() ){ 409 if (fi->isSymLink() ){
410 QString symLink=fi->readLink(); 410 QString symLink=fi->readLink();
411// qDebug("Symlink detected "+symLink); 411// qDebug("Symlink detected "+symLink);
412 QFileInfo sym( symLink); 412 QFileInfo sym( symLink);
413 fileS.sprintf( "%10li", sym.size() ); 413 fileS.sprintf( "%10li", sym.size() );
414 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 414 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
415 fileDate = sym.lastModified().toString(); 415 fileDate = sym.lastModified().toString();
416 } else { 416 } else {
417// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 417// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
418 fileS.sprintf( "%10li", fi->size() ); 418 fileS.sprintf( "%10li", fi->size() );
419 fileL.sprintf( "%s",fi->fileName().data() ); 419 fileL.sprintf( "%s",fi->fileName().data() );
420 fileDate= fi->lastModified().toString(); 420 fileDate= fi->lastModified().toString();
421 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 421 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
422 fileL+="/"; 422 fileL+="/";
423 isDir=TRUE; 423 isDir=TRUE;
424// qDebug( fileL); 424// qDebug( fileL);
425 } 425 }
426 } 426 }
427 if(fileL !="./" && fi->exists()) { 427 if(fileL !="./" && fi->exists()) {
428 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 428 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
429 QPixmap pm; 429 QPixmap pm;
430 430
431 if(isDir || fileL.find("/",0,TRUE) != -1) { 431 if(isDir || fileL.find("/",0,TRUE) != -1) {
432 if( !QDir( fi->filePath() ).isReadable()) 432 if( !QDir( fi->filePath() ).isReadable())
433 pm = Resource::loadPixmap( "lockedfolder" ); 433 pm = Resource::loadPixmap( "lockedfolder" );
434 else 434 else
435 pm= Resource::loadPixmap( "folder" ); 435 pm= Resource::loadPixmap( "folder" );
436 item->setPixmap( 0,pm ); 436 item->setPixmap( 0,pm );
437 } else { 437 } else {
438 if(fi->isExecutable()) { 438// if(fi->isExecutable()) {
439 pm = Resource::loadPixmap( "exec"); 439// pm = Resource::loadPixmap( "exec");
440 item->setPixmap( 0,pm); 440// item->setPixmap( 0,pm);
441 } 441// }
442 else if( !fi->isReadable() ) { 442 if( !fi->isReadable() ) {
443 pm = Resource::loadPixmap( "locked" ); 443 pm = Resource::loadPixmap( "locked" );
444 item->setPixmap( 0,pm); 444 item->setPixmap( 0,pm);
445 } else { 445 } else {
446 MimeType mt(fi->filePath()); 446 MimeType mt(fi->filePath());
447 pm=mt.pixmap(); //sets the correct pixmap for mimetype 447 pm=mt.pixmap(); //sets the correct pixmap for mimetype
448 if(pm.isNull()) 448 if(pm.isNull())
449 pm = Resource::loadPixmap( "UnknownDocument-14" ); 449 pm = Resource::loadPixmap( "UnknownDocument-14" );
450 item->setPixmap( 0,pm); 450 item->setPixmap( 0,pm);
451 } 451 }
452 } 452 }
453 if( fileL.find("->",0,TRUE) != -1) { 453 if( fileL.find("->",0,TRUE) != -1) {
454 // overlay link image 454 // overlay link image
455 pm= Resource::loadPixmap( "folder" ); 455 pm= Resource::loadPixmap( "folder" );
456 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 456 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
457 QPainter painter( &pm ); 457 QPainter painter( &pm );
458 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 458 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
459 pm.setMask( pm.createHeuristicMask( FALSE ) ); 459 pm.setMask( pm.createHeuristicMask( FALSE ) );
460 item->setPixmap( 0, pm); 460 item->setPixmap( 0, pm);
461 } 461 }
462 } isDir=FALSE; 462 } isDir=FALSE;
463 ++it; 463 ++it;
464 } 464 }
465 465
466 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 466 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
467 struct stat buf; 467 struct stat buf;
468 struct stat st; 468 struct stat st;
469 mode_t mode; 469 mode_t mode;
470 DIR *dir; 470 DIR *dir;
471 int fd = 0; 471 int fd = 0;
472 struct dirent *mydirent; 472 struct dirent *mydirent;
473 int i = 1; 473 int i = 1;
474 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 474 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
@@ -687,94 +687,94 @@ void AdvancedFm::showRemoteMenu(QListViewItem * item)
687 else 687 else
688 m.insertItem( tr( "Open" ), this, SLOT( runThis() )); 688 m.insertItem( tr( "Open" ), this, SLOT( runThis() ));
689 m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); 689 m.insertItem( tr( "Open as Text" ), this, SLOT( runText() ));
690 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 690 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
691 m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 691 m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
692 m.insertSeparator(); 692 m.insertSeparator();
693 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 693 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
694 m.insertItem( tr( "Copy" ), this, SLOT( copy() )); 694 m.insertItem( tr( "Copy" ), this, SLOT( copy() ));
695 m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 695 m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
696 m.insertItem( tr( "Move" ), this, SLOT( move() )); 696 m.insertItem( tr( "Move" ), this, SLOT( move() ));
697 m.insertSeparator(); 697 m.insertSeparator();
698 m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 698 m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
699 m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 699 m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
700 m.insertSeparator(); 700 m.insertSeparator();
701 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 701 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
702 m.insertSeparator(); 702 m.insertSeparator();
703 m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 703 m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
704 m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 704 m.insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
705 m.setCheckable(TRUE); 705 m.setCheckable(TRUE);
706 if (!b) 706 if (!b)
707 m.setItemChecked(m.idAt(0),TRUE); 707 m.setItemChecked(m.idAt(0),TRUE);
708 else 708 else
709 m.setItemChecked(m.idAt(0),FALSE); 709 m.setItemChecked(m.idAt(0),FALSE);
710 m.exec( QCursor::pos() ); 710 m.exec( QCursor::pos() );
711 } 711 }
712} 712}
713 713
714void AdvancedFm::runThis() { 714void AdvancedFm::runThis() {
715// QFileInfo *fi; 715// QFileInfo *fi;
716 if (TabWidget->currentPageIndex() == 0) { 716 if (TabWidget->currentPageIndex() == 0) {
717 QString curFile = Local_View->currentItem()->text(0); 717 QString curFile = Local_View->currentItem()->text(0);
718 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); 718 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
719 if(fileInfo.isExecutable()) { 719// if(fileInfo.isExecutable()) {
720 QCopEnvelope e("QPE/System", "execute(QString)" ); 720// QCopEnvelope e("QPE/System", "execute(QString)" );
721 e << curFile; 721// e << curFile;
722 } else { 722// } else {
723 curFile = currentDir.canonicalPath()+"/"+curFile; 723 curFile = currentDir.canonicalPath()+"/"+curFile;
724 DocLnk nf(curFile); 724 DocLnk nf(curFile);
725 QString execStr = nf.exec(); 725 QString execStr = nf.exec();
726 qDebug( execStr); 726 qDebug( execStr);
727 if( execStr.isEmpty() ) { 727 if( execStr.isEmpty() ) {
728 } else { 728 } else {
729 nf.execute(); 729 nf.execute();
730 } 730 }
731 } 731// }
732// MimeType mt( curFile); 732// MimeType mt( curFile);
733 } else { 733 } else {
734 QString curFile = Remote_View->currentItem()->text(0); 734 QString curFile = Remote_View->currentItem()->text(0);
735 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); 735 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
736 if(fileInfo.isExecutable()) { 736// if(fileInfo.isExecutable()) {
737 QCopEnvelope e("QPE/System", "execute(QString)" ); 737// QCopEnvelope e("QPE/System", "execute(QString)" );
738 e << curFile; 738// e << curFile;
739 } else { 739// } else {
740 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 740 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
741 DocLnk nf(curFile); 741 DocLnk nf(curFile);
742 QString execStr = nf.exec(); 742 QString execStr = nf.exec();
743 qDebug(execStr); 743 qDebug(execStr);
744 if( execStr.isEmpty() ) { 744 if( execStr.isEmpty() ) {
745 } else { 745 } else {
746 nf.execute(); 746 nf.execute();
747 } 747 }
748 } 748// }
749// MimeType mt( curFile); 749// MimeType mt( curFile);
750 } 750 }
751} 751}
752 752
753void AdvancedFm::runText() { 753void AdvancedFm::runText() {
754 if (TabWidget->currentPageIndex() == 0) { 754 if (TabWidget->currentPageIndex() == 0) {
755 QString curFile = Local_View->currentItem()->text(0); 755 QString curFile = Local_View->currentItem()->text(0);
756 curFile = currentDir.canonicalPath()+"/"+curFile; 756 curFile = currentDir.canonicalPath()+"/"+curFile;
757 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 757 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
758 e << curFile; 758 e << curFile;
759 } else { 759 } else {
760 QString curFile = Remote_View->currentItem()->text(0); 760 QString curFile = Remote_View->currentItem()->text(0);
761 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 761 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
762 DocLnk nf(curFile); 762 DocLnk nf(curFile);
763 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 763 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
764 e << curFile; 764 e << curFile;
765 } 765 }
766} 766}
767 767
768void AdvancedFm::localMakDir() 768void AdvancedFm::localMakDir()
769{ 769{
770 InputDialog *fileDlg; 770 InputDialog *fileDlg;
771 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 771 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
772 fileDlg->exec(); 772 fileDlg->exec();
773 if( fileDlg->result() == 1 ) { 773 if( fileDlg->result() == 1 ) {
774 QString filename = fileDlg->LineEdit1->text(); 774 QString filename = fileDlg->LineEdit1->text();
775 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 775 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
776 } 776 }
777 populateLocalView(); 777 populateLocalView();
778} 778}
779 779
780void AdvancedFm::remoteMakDir() 780void AdvancedFm::remoteMakDir()
@@ -1017,65 +1017,65 @@ void AdvancedFm::doProperties() {
1017 QStringList curFileList = getPath(); 1017 QStringList curFileList = getPath();
1018 QString filePath; 1018 QString filePath;
1019 if (TabWidget->currentPageIndex() == 0) { 1019 if (TabWidget->currentPageIndex() == 0) {
1020 filePath = currentDir.canonicalPath()+"/"; 1020 filePath = currentDir.canonicalPath()+"/";
1021 } else { 1021 } else {
1022 filePath= currentRemoteDir.canonicalPath()+"/"; 1022 filePath= currentRemoteDir.canonicalPath()+"/";
1023 } 1023 }
1024 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1024 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1025 DocLnk lnk( (filePath+*it)); 1025 DocLnk lnk( (filePath+*it));
1026 LnkProperties prop( &lnk ); 1026 LnkProperties prop( &lnk );
1027// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 1027// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
1028 prop.showMaximized(); 1028 prop.showMaximized();
1029 prop.exec(); 1029 prop.exec();
1030 } 1030 }
1031} 1031}
1032 1032
1033QStringList AdvancedFm::getPath() { 1033QStringList AdvancedFm::getPath() {
1034 QStringList strList; 1034 QStringList strList;
1035 if (TabWidget->currentPageIndex() == 0) { 1035 if (TabWidget->currentPageIndex() == 0) {
1036 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 1036 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
1037 QListViewItemIterator it( Local_View ); 1037 QListViewItemIterator it( Local_View );
1038 for ( ; it.current(); ++it ) { 1038 for ( ; it.current(); ++it ) {
1039 if ( it.current()->isSelected() ) { 1039 if ( it.current()->isSelected() ) {
1040 strList << it.current()->text(0); 1040 strList << it.current()->text(0);
1041 } 1041 }
1042 } 1042 }
1043 return strList; 1043 return strList;
1044 } else { 1044 } else {
1045 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 1045 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
1046 QListViewItemIterator it( Remote_View ); 1046 QListViewItemIterator it( Remote_View );
1047 for ( ; it.current(); ++it ) { 1047 for ( ; it.current(); ++it ) {
1048 if ( it.current()->isSelected() ) { 1048 if ( it.current()->isSelected() ) {
1049 strList << currentDir.canonicalPath()+"/"+ it.current()->text(0); 1049 strList << it.current()->text(0);
1050 } 1050 }
1051 } 1051 }
1052 return strList; 1052 return strList;
1053 } 1053 }
1054 return ""; 1054 return "";
1055} 1055}
1056 1056
1057void AdvancedFm::homeButtonPushed() { 1057void AdvancedFm::homeButtonPushed() {
1058 QString current = QDir::homeDirPath(); 1058 QString current = QDir::homeDirPath();
1059 chdir( current.latin1() ); 1059 chdir( current.latin1() );
1060 if (TabWidget->currentPageIndex() == 0) { 1060 if (TabWidget->currentPageIndex() == 0) {
1061 currentDir.cd( current, TRUE); 1061 currentDir.cd( current, TRUE);
1062 populateLocalView(); 1062 populateLocalView();
1063 } else { 1063 } else {
1064 currentRemoteDir.cd( current, TRUE); 1064 currentRemoteDir.cd( current, TRUE);
1065 populateRemoteView(); 1065 populateRemoteView();
1066 } 1066 }
1067 update(); 1067 update();
1068} 1068}
1069 1069
1070void AdvancedFm::docButtonPushed() { 1070void AdvancedFm::docButtonPushed() {
1071 QString current = QPEApplication::documentDir(); 1071 QString current = QPEApplication::documentDir();
1072 chdir( current.latin1() ); 1072 chdir( current.latin1() );
1073 if (TabWidget->currentPageIndex() == 0) { 1073 if (TabWidget->currentPageIndex() == 0) {
1074 currentDir.cd( current, TRUE); 1074 currentDir.cd( current, TRUE);
1075 populateLocalView(); 1075 populateLocalView();
1076 } else { 1076 } else {
1077 currentRemoteDir.cd( current, TRUE); 1077 currentRemoteDir.cd( current, TRUE);
1078 populateRemoteView(); 1078 populateRemoteView();
1079 } 1079 }
1080 update(); 1080 update();
1081} 1081}
@@ -1110,161 +1110,155 @@ void AdvancedFm::CFButtonPushed() {
1110 1110
1111 1111
1112void AdvancedFm::upDir() 1112void AdvancedFm::upDir()
1113{ 1113{
1114 if (TabWidget->currentPageIndex() == 0) { 1114 if (TabWidget->currentPageIndex() == 0) {
1115 QString current = currentDir.canonicalPath(); 1115 QString current = currentDir.canonicalPath();
1116 QDir dir(current); 1116 QDir dir(current);
1117 dir.cdUp(); 1117 dir.cdUp();
1118 current = dir.canonicalPath(); 1118 current = dir.canonicalPath();
1119 chdir( current.latin1() ); 1119 chdir( current.latin1() );
1120 currentDir.cd( current, TRUE); 1120 currentDir.cd( current, TRUE);
1121 populateLocalView(); 1121 populateLocalView();
1122 update(); 1122 update();
1123 } else { 1123 } else {
1124 QString current = currentRemoteDir.canonicalPath(); 1124 QString current = currentRemoteDir.canonicalPath();
1125 QDir dir(current); 1125 QDir dir(current);
1126 dir.cdUp(); 1126 dir.cdUp();
1127 current = dir.canonicalPath(); 1127 current = dir.canonicalPath();
1128 chdir( current.latin1() ); 1128 chdir( current.latin1() );
1129 currentRemoteDir.cd( current, TRUE); 1129 currentRemoteDir.cd( current, TRUE);
1130 populateRemoteView(); 1130 populateRemoteView();
1131 update(); 1131 update();
1132 } 1132 }
1133} 1133}
1134 1134
1135void AdvancedFm::copy() 1135void AdvancedFm::copy()
1136{ 1136{
1137 QStringList curFileList = getPath(); 1137 QStringList curFileList = getPath();
1138 QString curFile; 1138 QString curFile;
1139 if (TabWidget->currentPageIndex() == 0) { 1139 if (TabWidget->currentPageIndex() == 0) {
1140 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1140 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1141 1141
1142 QString destFile = currentRemoteDir.canonicalPath(); 1142 QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1143 if(destFile.right(1).find("/",0,TRUE) == -1) 1143// if(destFile.right(1).find("/",0,TRUE) == -1)
1144 destFile+="/"; 1144// destFile+="/";
1145 destFile +=(*it); 1145// destFile +=(*it);
1146 curFile = currentDir.canonicalPath(); 1146
1147 if(curFile.right(1).find("/",0,TRUE) == -1) 1147 curFile = currentDir.canonicalPath()+"/"+(*it);
1148 curFile +="/"; 1148// if(curFile.right(1).find("/",0,TRUE) == -1)
1149 curFile +=(*it); 1149// curFile +="/";
1150// curFile +=(*it);
1151
1150 QFile f(destFile); 1152 QFile f(destFile);
1151 if( f.exists()) 1153 if( f.exists())
1152 f.remove(); 1154 f.remove();
1153 if(!copyFile(destFile, curFile) ) 1155 if(!copyFile(destFile, curFile) ) {
1156 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1154 qWarning("nothin doing"); 1157 qWarning("nothin doing");
1158 }
1155 } 1159 }
1156 populateRemoteView(); 1160 populateRemoteView();
1157 TabWidget->setCurrentPage(1); 1161 TabWidget->setCurrentPage(1);
1158 1162
1159 } else { 1163 } else {
1160 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1164 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1161 1165
1162 QString destFile = currentDir.canonicalPath(); 1166 QString destFile = currentDir.canonicalPath()+"/"+(*it);
1163 if(destFile.right(1).find("/",0,TRUE) == -1) 1167 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1164 destFile+="/"; 1168
1165 destFile +=(*it);
1166 curFile = currentRemoteDir.canonicalPath();
1167 if(curFile.right(1).find("/",0,TRUE) == -1)
1168 curFile +="/";
1169 curFile +=(*it);
1170 QFile f(destFile); 1169 QFile f(destFile);
1171 if( f.exists()) 1170 if( f.exists())
1172 f.remove(); 1171 f.remove();
1173 if(!copyFile(destFile, curFile) ) 1172 if(!copyFile(destFile, curFile) ) {
1174 qWarning("nothin doing"); 1173 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1174
1175 qWarning("nothin doing");
1176 }
1175 } 1177 }
1176 populateLocalView(); 1178 populateLocalView();
1177 TabWidget->setCurrentPage(0); 1179 TabWidget->setCurrentPage(0);
1178 } 1180 }
1179} 1181}
1180 1182
1181void AdvancedFm::copyAs() 1183void AdvancedFm::copyAs()
1182{ 1184{
1183 QStringList curFileList = getPath(); 1185 QStringList curFileList = getPath();
1184 QString curFile; 1186 QString curFile;
1185 InputDialog *fileDlg; 1187 InputDialog *fileDlg;
1186 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1188 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1187 1189
1188 if (TabWidget->currentPageIndex() == 0) { 1190 if (TabWidget->currentPageIndex() == 0) {
1189 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1191 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1190 QString destFile; 1192 QString destFile;
1191 curFile = currentDir.canonicalPath(); 1193 curFile = currentDir.canonicalPath()+"/"+(*it);
1192 if(curFile.right(1).find("/",0,TRUE) == -1)
1193 curFile +="/";
1194 curFile+=(*it);
1195// InputDialog *fileDlg; 1194// InputDialog *fileDlg;
1196// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1195// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1197 fileDlg->setInputText((const QString &) destFile ); 1196 fileDlg->setInputText((const QString &) destFile );
1198 fileDlg->exec(); 1197 fileDlg->exec();
1199 if( fileDlg->result() == 1 ) { 1198 if( fileDlg->result() == 1 ) {
1200 QString filename = fileDlg->LineEdit1->text(); 1199 QString filename = fileDlg->LineEdit1->text();
1201 destFile = currentRemoteDir.canonicalPath(); 1200 destFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1202 if(destFile.right(1).find("/",0,TRUE) == -1)
1203 destFile+="/";
1204 destFile +=(*it);
1205 1201
1206 QFile f(destFile); 1202 QFile f(destFile);
1207 if( f.exists()) 1203 if( f.exists())
1208 f.remove(); 1204 f.remove();
1209 if(!copyFile(destFile, curFile) ) 1205 if(!copyFile(destFile, curFile) ) {
1206 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1210 qWarning("nothin doing"); 1207 qWarning("nothin doing");
1208 }
1211 } 1209 }
1212 } 1210 }
1213 1211
1214 populateRemoteView(); 1212 populateRemoteView();
1215 TabWidget->setCurrentPage(1); 1213 TabWidget->setCurrentPage(1);
1216 } else { 1214 } else {
1217 if (TabWidget->currentPageIndex() == 0) { 1215 if (TabWidget->currentPageIndex() == 0) {
1218 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1216 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1219 1217
1220 curFile = currentDir.canonicalPath(); 1218 curFile = currentDir.canonicalPath()+"/"+(*it);
1221 if(curFile.right(1).find("/",0,TRUE) == -1)
1222 curFile +="/";
1223 curFile+=(*it);
1224 QString destFile; 1219 QString destFile;
1225 fileDlg->setInputText((const QString &) destFile); 1220 fileDlg->setInputText((const QString &) destFile);
1226 fileDlg->exec(); 1221 fileDlg->exec();
1227 if( fileDlg->result() == 1 ) { 1222 if( fileDlg->result() == 1 ) {
1228 QString filename = fileDlg->LineEdit1->text(); 1223 QString filename = fileDlg->LineEdit1->text();
1229 destFile = currentDir.canonicalPath(); 1224 destFile = currentDir.canonicalPath()+"/"+(*it);
1230 if(destFile.right(1).find("/",0,TRUE) == -1)
1231 destFile+="/";
1232 destFile +=(*it);
1233 1225
1234 QFile f(destFile); 1226 QFile f(destFile);
1235 if( f.exists()) 1227 if( f.exists())
1236 f.remove(); 1228 f.remove();
1237 if(!copyFile(destFile, curFile) ) 1229 if(!copyFile(destFile, curFile) ) {
1238 qWarning("nothin doing"); 1230 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1231 qWarning("nothin doing");
1232 }
1239 } 1233 }
1240 } 1234 }
1241 populateLocalView(); 1235 populateLocalView();
1242 TabWidget->setCurrentPage(0); 1236 TabWidget->setCurrentPage(0);
1243 } 1237 }
1244 } 1238 }
1245} 1239}
1246 1240
1247void AdvancedFm::move() { 1241void AdvancedFm::move() {
1248 1242
1249 QStringList curFileList = getPath(); 1243 QStringList curFileList = getPath();
1250 QString curFile; 1244 QString curFile;
1251// qDebug(curFile); 1245// qDebug(curFile);
1252 QString destFile; 1246 QString destFile;
1253 1247
1254 if (TabWidget->currentPageIndex() == 0) { 1248 if (TabWidget->currentPageIndex() == 0) {
1255 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1249 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1256 QString destFile = currentRemoteDir.canonicalPath(); 1250 QString destFile = currentRemoteDir.canonicalPath();
1257 if(destFile.right(1).find("/",0,TRUE) == -1) 1251 if(destFile.right(1).find("/",0,TRUE) == -1)
1258 destFile+="/"; 1252 destFile+="/";
1259 destFile +=(*it); 1253 destFile +=(*it);
1260 curFile = currentDir.canonicalPath(); 1254 curFile = currentDir.canonicalPath();
1261 qDebug("Destination file is "+destFile); 1255 qDebug("Destination file is "+destFile);
1262 if(curFile.right(1).find("/",0,TRUE) == -1) 1256 if(curFile.right(1).find("/",0,TRUE) == -1)
1263 curFile +="/"; 1257 curFile +="/";
1264 curFile+=(*it); 1258 curFile+=(*it);
1265 1259
1266 QFile f(destFile); 1260 QFile f(destFile);
1267 if( f.exists()) 1261 if( f.exists())
1268 f.remove(); 1262 f.remove();
1269 if(!copyFile( destFile, curFile) ) { 1263 if(!copyFile( destFile, curFile) ) {
1270 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); 1264 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile));
@@ -1505,64 +1499,73 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
1505 case Key_2: 1499 case Key_2:
1506 switchToRemoteTab(); 1500 switchToRemoteTab();
1507 break; 1501 break;
1508 case Key_3: 1502 case Key_3:
1509 CFButtonPushed(); 1503 CFButtonPushed();
1510 break; 1504 break;
1511 case Key_4: 1505 case Key_4:
1512 SDButtonPushed(); 1506 SDButtonPushed();
1513 break; 1507 break;
1514 case Key_5: 1508 case Key_5:
1515 homeButtonPushed(); 1509 homeButtonPushed();
1516 break; 1510 break;
1517 case Key_6: 1511 case Key_6:
1518 docButtonPushed(); 1512 docButtonPushed();
1519 break; 1513 break;
1520 case Key_7: 1514 case Key_7:
1521 break; 1515 break;
1522 case Key_8: 1516 case Key_8:
1523 break; 1517 break;
1524 case Key_9: 1518 case Key_9:
1525 break; 1519 break;
1526 case Key_0: 1520 case Key_0:
1527 break; 1521 break;
1528 1522
1529 1523
1530 1524
1531 } 1525 }
1532 1526
1533} 1527}
1534 1528
1535void AdvancedFm::mkSym() { 1529void AdvancedFm::mkSym() {
1536 QString cmd; 1530 QString cmd;
1531 QStringList curFileList = getPath();
1532
1537 if (TabWidget->currentPageIndex() == 0) { 1533 if (TabWidget->currentPageIndex() == 0) {
1538 QString curFile = Local_View->currentItem()->text(0); 1534 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1539 if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1); 1535
1540 QString destName = currentRemoteDir.canonicalPath()+"/"+curFile; 1536 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
1541 curFile = currentDir.canonicalPath()+"/"+curFile; 1537 QString curFile = currentDir.canonicalPath()+"/"+(*it);
1542 cmd = "ln -s "+curFile+" "+destName; 1538 cmd = "ln -s "+curFile+" "+destName;
1543 system(cmd.latin1() ); 1539 qDebug(cmd);
1544 populateRemoteView(); 1540 system(cmd.latin1() );
1541 }
1542 populateRemoteView();
1543 TabWidget->setCurrentPage(1);
1545 } else { 1544 } else {
1546 QString curFile = Remote_View->currentItem()->text(0); 1545 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1547 if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1); 1546
1548 QString destName = currentDir.canonicalPath()+"/"+curFile; 1547 QString destName = currentDir.canonicalPath()+"/"+(*it);
1549 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 1548 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1550 cmd = "ln -s "+curFile+" "+destName; 1549
1551 system(cmd.latin1() ); 1550 cmd = "ln -s "+curFile+" "+destName;
1552 populateLocalView(); 1551 qDebug(cmd);
1552 system(cmd.latin1() );
1553 }
1554 populateLocalView();
1555 TabWidget->setCurrentPage(0);
1553 } 1556 }
1554} 1557}
1555 1558
1556void AdvancedFm::QPEButtonPushed() { 1559void AdvancedFm::QPEButtonPushed() {
1557 QString current = QPEApplication::qpeDir(); 1560 QString current = QPEApplication::qpeDir();
1558 chdir( current.latin1() ); 1561 chdir( current.latin1() );
1559 if (TabWidget->currentPageIndex() == 0) { 1562 if (TabWidget->currentPageIndex() == 0) {
1560 currentDir.cd( current, TRUE); 1563 currentDir.cd( current, TRUE);
1561 populateLocalView(); 1564 populateLocalView();
1562 } else { 1565 } else {
1563 currentRemoteDir.cd( current, TRUE); 1566 currentRemoteDir.cd( current, TRUE);
1564 populateRemoteView(); 1567 populateRemoteView();
1565 } 1568 }
1566 update(); 1569 update();
1567 1570
1568} 1571}