summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index ecf471d..ac16540 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -484,257 +484,258 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
484 484
485 485
486void AdvancedFm::QPEButtonPushed() { 486void AdvancedFm::QPEButtonPushed() {
487 QString current = QPEApplication::qpeDir(); 487 QString current = QPEApplication::qpeDir();
488 chdir( current.latin1() ); 488 chdir( current.latin1() );
489 CurrentDir()->cd( current, TRUE); 489 CurrentDir()->cd( current, TRUE);
490 populateView(); 490 populateView();
491 update(); 491 update();
492} 492}
493 493
494void AdvancedFm::parsetab(const QString &fileName) { 494void AdvancedFm::parsetab(const QString &fileName) {
495 495
496 fileSystemTypeList.clear(); 496 fileSystemTypeList.clear();
497 fsList.clear(); 497 fsList.clear();
498 struct mntent *me; 498 struct mntent *me;
499 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 499 FILE *mntfp = setmntent( fileName.latin1(), "r" );
500 if ( mntfp ) { 500 if ( mntfp ) {
501 while ( (me = getmntent( mntfp )) != 0 ) { 501 while ( (me = getmntent( mntfp )) != 0 ) {
502 QString deviceName = me->mnt_fsname; 502 QString deviceName = me->mnt_fsname;
503 QString filesystemType = me->mnt_type; 503 QString filesystemType = me->mnt_type;
504 QString mountDir = me->mnt_dir; 504 QString mountDir = me->mnt_dir;
505 if(deviceName != "none") { 505 if(deviceName != "none") {
506 if( fsList.contains(filesystemType) == 0 506 if( fsList.contains(filesystemType) == 0
507 & filesystemType.find("proc",0,TRUE) == -1 507 & filesystemType.find("proc",0,TRUE) == -1
508 & filesystemType.find("cramfs",0,TRUE) == -1 508 & filesystemType.find("cramfs",0,TRUE) == -1
509 & filesystemType.find("auto",0,TRUE) == -1) 509 & filesystemType.find("auto",0,TRUE) == -1)
510 fsList << filesystemType; 510 fsList << filesystemType;
511 fileSystemTypeList << mountDir+"::"+filesystemType; 511 fileSystemTypeList << mountDir+"::"+filesystemType;
512 } 512 }
513 } 513 }
514 } 514 }
515 endmntent( mntfp ); 515 endmntent( mntfp );
516} 516}
517 517
518QString AdvancedFm::getFileSystemType(const QString &currentText) { 518QString AdvancedFm::getFileSystemType(const QString &currentText) {
519 parsetab("/etc/mtab"); //why did TT forget filesystem type? 519 parsetab("/etc/mtab"); //why did TT forget filesystem type?
520 QString current = currentText;//.right( currentText.length()-1); 520 QString current = currentText;//.right( currentText.length()-1);
521 QString baseFs; 521 QString baseFs;
522 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 522 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
523 QString temp = (*it); 523 QString temp = (*it);
524 QString path = temp.left(temp.find("::",0,TRUE) ); 524 QString path = temp.left(temp.find("::",0,TRUE) );
525 path = path.right( path.length()-1); 525 path = path.right( path.length()-1);
526 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 526 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
527 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 527 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
528 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 528 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
529 } 529 }
530 } 530 }
531 return baseFs; 531 return baseFs;
532} 532}
533 533
534QString AdvancedFm::getDiskSpace( const QString &path) { 534QString AdvancedFm::getDiskSpace( const QString &path) {
535 struct statfs fss; 535 struct statfs fss;
536 if ( !statfs( path.latin1(), &fss ) ) { 536 if ( !statfs( path.latin1(), &fss ) ) {
537 int blkSize = fss.f_bsize; 537 int blkSize = fss.f_bsize;
538 // int totalBlks = fs.f_blocks; 538 // int totalBlks = fs.f_blocks;
539 int availBlks = fss.f_bavail; 539 int availBlks = fss.f_bavail;
540 540
541 long mult = blkSize / 1024; 541 long mult = blkSize / 1024;
542 long div = 1024 / blkSize; 542 long div = 1024 / blkSize;
543 if ( !mult ) mult = 1; 543 if ( !mult ) mult = 1;
544 if ( !div ) div = 1; 544 if ( !div ) div = 1;
545 545
546 return QString::number(availBlks * mult / div); 546 return QString::number(availBlks * mult / div);
547 } 547 }
548 return ""; 548 return "";
549} 549}
550 550
551 551
552void AdvancedFm::showFileMenu() { 552void AdvancedFm::showFileMenu() {
553 QString curApp; 553 QString curApp;
554 curApp = CurrentView()->currentItem()->text(0); 554 curApp = CurrentView()->currentItem()->text(0);
555 555
556 MimeType mt( curApp ); 556 MimeType mt( curApp );
557 const AppLnk* app = mt.application(); 557 const AppLnk* app = mt.application();
558 QFile fi(curApp); 558 QFile fi(curApp);
559 QPopupMenu *m = new QPopupMenu(0); 559 QPopupMenu *m = new QPopupMenu(0);
560 QPopupMenu *n = new QPopupMenu(0); 560 QPopupMenu *n = new QPopupMenu(0);
561 // QPopupMenu *o = new QPopupMenu(0); 561 // QPopupMenu *o = new QPopupMenu(0);
562 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 562 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
563 563
564 if ( QFileInfo(fi).isDir() ) { 564 if ( QFileInfo(fi).isDir() ) {
565 m->insertSeparator(); 565 m->insertSeparator();
566 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); 566 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
567 } else { 567 } else {
568 568
569 if ( app ) 569 if ( app )
570 m->insertItem( app->pixmap(), tr( "Open in " 570 m->insertItem( app->pixmap(), tr( "Open in "
571 + app->name() ), this, SLOT( runThis() ) ); 571 + app->name() ), this, SLOT( runThis() ) );
572 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 572 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
573 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 573 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
574 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 574 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
575 } 575 }
576 576
577 m->insertItem(tr("Actions"),n); 577 m->insertItem(tr("Actions"),n);
578 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); 578 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
579 579
580 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 580 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
581 581
582 n->insertSeparator(); 582 n->insertSeparator();
583 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); 583 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
584 584
585 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 585 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
586 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 586 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
587 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 587 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
588 n->insertItem( tr( "Move" ), this, SLOT( move() )); 588 n->insertItem( tr( "Move" ), this, SLOT( move() ));
589 589
590 n->insertSeparator(); 590 n->insertSeparator();
591 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); 591 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
592 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 592 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
593 593
594 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 594 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
595 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 595 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
596 596
597 m->insertSeparator(); 597 m->insertSeparator();
598 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 598 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
599 599
600#if defined(QT_QWS_OPIE) 600#if defined(QT_QWS_OPIE)
601 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 601 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
602#endif 602#endif
603 m->setCheckable(TRUE); 603 m->setCheckable(TRUE);
604 if (!b) 604 if (!b)
605 m->setItemChecked(m->idAt(0),TRUE); 605 m->setItemChecked(m->idAt(0),TRUE);
606 else 606 else
607 m->setItemChecked(m->idAt(0),FALSE); 607 m->setItemChecked(m->idAt(0),FALSE);
608 608
609 if(Ir::supported()) 609 if(Ir::supported())
610 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 610 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
611 m->setFocus(); 611 m->setFocus();
612 m->exec( QPoint( 4,QCursor::pos().y()) ); 612
613 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
613 614
614 if(m) delete m; 615 if(m) delete m;
615} 616}
616 617
617 618
618void AdvancedFm::cancelMenuTimer() { 619void AdvancedFm::cancelMenuTimer() {
619 620
620 if( menuTimer.isActive() ) 621 if( menuTimer.isActive() )
621 menuTimer.stop(); 622 menuTimer.stop();
622} 623}
623 624
624QString AdvancedFm::checkDiskSpace(const QString &path) { 625QString AdvancedFm::checkDiskSpace(const QString &path) {
625 struct statfs fss; 626 struct statfs fss;
626 if ( !statfs( path.latin1(), &fss ) ) { 627 if ( !statfs( path.latin1(), &fss ) ) {
627 int blkSize = fss.f_bsize; 628 int blkSize = fss.f_bsize;
628// int totalBlks = fs.f_blocks; 629// int totalBlks = fs.f_blocks;
629 int availBlks = fss.f_bavail; 630 int availBlks = fss.f_bavail;
630 631
631 long mult = blkSize / 1024; 632 long mult = blkSize / 1024;
632 long div = 1024 / blkSize; 633 long div = 1024 / blkSize;
633 if ( !mult ) mult = 1; 634 if ( !mult ) mult = 1;
634 if ( !div ) div = 1; 635 if ( !div ) div = 1;
635 636
636 637
637 return QString::number(availBlks * mult / div); 638 return QString::number(availBlks * mult / div);
638 } 639 }
639 return ""; 640 return "";
640} 641}
641 642
642void AdvancedFm::addToDocs() { 643void AdvancedFm::addToDocs() {
643 QStringList strListPaths = getPath(); 644 QStringList strListPaths = getPath();
644 QDir *thisDir = CurrentDir(); 645 QDir *thisDir = CurrentDir();
645 646
646 if( strListPaths.count() > 0) { 647 if( strListPaths.count() > 0) {
647 QString curFile; 648 QString curFile;
648 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 649 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
649 curFile = thisDir->canonicalPath()+"/"+(*it); 650 curFile = thisDir->canonicalPath()+"/"+(*it);
650// qDebug(curFile); 651// qDebug(curFile);
651 QFileInfo fi(curFile); 652 QFileInfo fi(curFile);
652 DocLnk f; 653 DocLnk f;
653// curFile.replace(QRegExp("\\..*"),""); 654// curFile.replace(QRegExp("\\..*"),"");
654 f.setName(fi.baseName() ); 655 f.setName(fi.baseName() );
655 f.setFile( curFile); 656 f.setFile( curFile);
656 f.writeLink(); 657 f.writeLink();
657 } 658 }
658 } 659 }
659} 660}
660 661
661 662
662void AdvancedFm::customDirsToMenu() { 663void AdvancedFm::customDirsToMenu() {
663 664
664 Config cfg("AdvancedFm"); 665 Config cfg("AdvancedFm");
665 cfg.setGroup("Menu"); 666 cfg.setGroup("Menu");
666 667
667 QStringList list = cfg.readListEntry( "CustomDir", ','); 668 QStringList list = cfg.readListEntry( "CustomDir", ',');
668 menuButton->insertItems(list ); 669 menuButton->insertItems(list );
669 670
670// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 671// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
671// { 672// {
672// customDirMenu->insertItem(*it ); 673// customDirMenu->insertItem(*it );
673// } 674// }
674} 675}
675 676
676void AdvancedFm::dirMenuSelected(int item) { 677void AdvancedFm::dirMenuSelected(int item) {
677 switch(item) 678 switch(item)
678 { 679 {
679 680
680 case -21: 681 case -21:
681 case 0: 682 case 0:
682 addCustomDir(); 683 addCustomDir();
683 break; 684 break;
684 case -22: 685 case -22:
685 case 1: 686 case 1:
686 removeCustomDir(); 687 removeCustomDir();
687 break; 688 break;
688 default: 689 default:
689 { 690 {
690// gotoCustomDir( menuButton->text(item)); 691// gotoCustomDir( menuButton->text(item));
691// gotoCustomDir( customDirMenu->text(item)); 692// gotoCustomDir( customDirMenu->text(item));
692 } 693 }
693 break; 694 break;
694 695
695 }; 696 };
696} 697}
697 698
698void AdvancedFm::addCustomDir() { 699void AdvancedFm::addCustomDir() {
699 Config cfg("AdvancedFm"); 700 Config cfg("AdvancedFm");
700 cfg.setGroup("Menu"); 701 cfg.setGroup("Menu");
701 QString dir; 702 QString dir;
702 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 703 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
703 704
704 dir = CurrentDir()->canonicalPath(); 705 dir = CurrentDir()->canonicalPath();
705 706
706 bool addIt=true; 707 bool addIt=true;
707 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 708 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
708 if( dir == (*it)) { 709 if( dir == (*it)) {
709 addIt=false; 710 addIt=false;
710 } 711 }
711 } 712 }
712 if(addIt) { 713 if(addIt) {
713 menuButton->insertItem(dir); 714 menuButton->insertItem(dir);
714// customDirMenu->insertItem(dir); 715// customDirMenu->insertItem(dir);
715 list << dir; 716 list << dir;
716 } 717 }
717 718
718 cfg.writeEntry("CustomDir", list, ','); 719 cfg.writeEntry("CustomDir", list, ',');
719 cfg.write(); 720 cfg.write();
720} 721}
721 722
722void AdvancedFm::removeCustomDir() { 723void AdvancedFm::removeCustomDir() {
723// qDebug("remove custom dir"); 724// qDebug("remove custom dir");
724 Config cfg("AdvancedFm"); 725 Config cfg("AdvancedFm");
725 cfg.setGroup("Menu"); 726 cfg.setGroup("Menu");
726 QString dir; 727 QString dir;
727 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 728 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
728 QStringList list2; 729 QStringList list2;
729 dir = CurrentDir()->canonicalPath(); 730 dir = CurrentDir()->canonicalPath();
730 int ramble=2; 731 int ramble=2;
731// int ramble=-24; 732// int ramble=-24;
732//first remove list 733//first remove list
733 if(list.grep(dir,true).isEmpty()) { 734 if(list.grep(dir,true).isEmpty()) {
734 QMessageBox::message(tr( "AdvancedFm" ), 735 QMessageBox::message(tr( "AdvancedFm" ),
735 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); 736 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!"));
736 } else { 737 } else {
737 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 738 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
738 if((*it) != dir) { 739 if((*it) != dir) {
739//current item is not our current dir, so add it to temp list 740//current item is not our current dir, so add it to temp list
740 list2 <<(*it); 741 list2 <<(*it);