summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-16 15:17:00 (UTC)
committer llornkcor <llornkcor>2002-10-16 15:17:00 (UTC)
commit61f2f6ef32685002710f197dc8990fd9e99d83a5 (patch) (unidiff)
tree5fa57efbff0e83a326f6e055c3c59be71d4328bd
parentee8da0d0b70318c24ee2417bbccd9b7cd6e1404e (diff)
downloadopie-61f2f6ef32685002710f197dc8990fd9e99d83a5.zip
opie-61f2f6ef32685002710f197dc8990fd9e99d83a5.tar.gz
opie-61f2f6ef32685002710f197dc8990fd9e99d83a5.tar.bz2
fix for popup menu crash.. didnt like loading executable pixmap
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index d7bad51..b6e7a30 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -599,259 +599,262 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
599 break; 599 break;
600 case Key_R: 600 case Key_R:
601 rn(); 601 rn();
602 break; 602 break;
603 case Key_I: 603 case Key_I:
604 fileStatus(); 604 fileStatus();
605 break; 605 break;
606 case Key_U: 606 case Key_U:
607 upDir(); 607 upDir();
608 break; 608 break;
609 case Key_P: 609 case Key_P:
610 filePerms(); 610 filePerms();
611 break; 611 break;
612 case Key_N: 612 case Key_N:
613 mkDir(); 613 mkDir();
614 break; 614 break;
615 case Key_1: 615 case Key_1:
616 switchToLocalTab(); 616 switchToLocalTab();
617 break; 617 break;
618 case Key_2: 618 case Key_2:
619 switchToRemoteTab(); 619 switchToRemoteTab();
620 break; 620 break;
621 case Key_3: 621 case Key_3:
622 CFButtonPushed(); 622 CFButtonPushed();
623 break; 623 break;
624 case Key_4: 624 case Key_4:
625 SDButtonPushed(); 625 SDButtonPushed();
626 break; 626 break;
627 case Key_5: 627 case Key_5:
628 homeButtonPushed(); 628 homeButtonPushed();
629 break; 629 break;
630 case Key_6: 630 case Key_6:
631 docButtonPushed(); 631 docButtonPushed();
632 break; 632 break;
633 case Key_7: 633 case Key_7:
634 break; 634 break;
635 case Key_8: 635 case Key_8:
636 break; 636 break;
637 case Key_9: 637 case Key_9:
638 break; 638 break;
639 case Key_0: 639 case Key_0:
640 break; 640 break;
641 } 641 }
642} 642}
643 643
644 644
645void AdvancedFm::QPEButtonPushed() { 645void AdvancedFm::QPEButtonPushed() {
646 QString current = QPEApplication::qpeDir(); 646 QString current = QPEApplication::qpeDir();
647 chdir( current.latin1() ); 647 chdir( current.latin1() );
648 if (TabWidget->currentPageIndex() == 0) { 648 if (TabWidget->currentPageIndex() == 0) {
649 currentDir.cd( current, TRUE); 649 currentDir.cd( current, TRUE);
650 populateLocalView(); 650 populateLocalView();
651 } else { 651 } else {
652 currentRemoteDir.cd( current, TRUE); 652 currentRemoteDir.cd( current, TRUE);
653 populateRemoteView(); 653 populateRemoteView();
654 } 654 }
655 update(); 655 update();
656} 656}
657 657
658void AdvancedFm::parsetab(const QString &fileName) { 658void AdvancedFm::parsetab(const QString &fileName) {
659 659
660 fileSystemTypeList.clear(); 660 fileSystemTypeList.clear();
661 fsList.clear(); 661 fsList.clear();
662 struct mntent *me; 662 struct mntent *me;
663 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 663 FILE *mntfp = setmntent( fileName.latin1(), "r" );
664 if ( mntfp ) { 664 if ( mntfp ) {
665 while ( (me = getmntent( mntfp )) != 0 ) { 665 while ( (me = getmntent( mntfp )) != 0 ) {
666 QString deviceName = me->mnt_fsname; 666 QString deviceName = me->mnt_fsname;
667 QString filesystemType = me->mnt_type; 667 QString filesystemType = me->mnt_type;
668 QString mountDir = me->mnt_dir; 668 QString mountDir = me->mnt_dir;
669 if(deviceName != "none") { 669 if(deviceName != "none") {
670 if( fsList.contains(filesystemType) == 0 670 if( fsList.contains(filesystemType) == 0
671 & filesystemType.find("proc",0,TRUE) == -1 671 & filesystemType.find("proc",0,TRUE) == -1
672 & filesystemType.find("cramfs",0,TRUE) == -1 672 & filesystemType.find("cramfs",0,TRUE) == -1
673 & filesystemType.find("auto",0,TRUE) == -1) 673 & filesystemType.find("auto",0,TRUE) == -1)
674 fsList << filesystemType; 674 fsList << filesystemType;
675 fileSystemTypeList << mountDir+"::"+filesystemType; 675 fileSystemTypeList << mountDir+"::"+filesystemType;
676 } 676 }
677 } 677 }
678 } 678 }
679 endmntent( mntfp ); 679 endmntent( mntfp );
680} 680}
681 681
682QString AdvancedFm::getFileSystemType(const QString &currentText) { 682QString AdvancedFm::getFileSystemType(const QString &currentText) {
683 parsetab("/etc/mtab"); //why did TT forget filesystem type? 683 parsetab("/etc/mtab"); //why did TT forget filesystem type?
684 QString current = currentText;//.right( currentText.length()-1); 684 QString current = currentText;//.right( currentText.length()-1);
685 QString baseFs; 685 QString baseFs;
686 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 686 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
687 QString temp = (*it); 687 QString temp = (*it);
688 QString path = temp.left(temp.find("::",0,TRUE) ); 688 QString path = temp.left(temp.find("::",0,TRUE) );
689 path = path.right( path.length()-1); 689 path = path.right( path.length()-1);
690 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 690 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
691 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 691 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
692 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 692 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
693 } 693 }
694 } 694 }
695 return baseFs; 695 return baseFs;
696} 696}
697 697
698QString AdvancedFm::getDiskSpace( const QString &path) { 698QString AdvancedFm::getDiskSpace( const QString &path) {
699 struct statfs fss; 699 struct statfs fss;
700 if ( !statfs( path.latin1(), &fss ) ) { 700 if ( !statfs( path.latin1(), &fss ) ) {
701 int blkSize = fss.f_bsize; 701 int blkSize = fss.f_bsize;
702 // int totalBlks = fs.f_blocks; 702 // int totalBlks = fs.f_blocks;
703 int availBlks = fss.f_bavail; 703 int availBlks = fss.f_bavail;
704 704
705 long mult = blkSize / 1024; 705 long mult = blkSize / 1024;
706 long div = 1024 / blkSize; 706 long div = 1024 / blkSize;
707 if ( !mult ) mult = 1; 707 if ( !mult ) mult = 1;
708 if ( !div ) div = 1; 708 if ( !div ) div = 1;
709 709
710 return QString::number(availBlks * mult / div); 710 return QString::number(availBlks * mult / div);
711 } 711 }
712 return ""; 712 return "";
713} 713}
714 714
715 715
716void AdvancedFm::showFileMenu() { 716void AdvancedFm::showFileMenu() {
717 717
718 QString curApp; 718 QString curApp;
719 bool isLocalView = false; 719 bool isLocalView = false;
720 if (TabWidget->currentPageIndex() == 0) { 720 if (TabWidget->currentPageIndex() == 0) {
721 isLocalView = TRUE; 721 isLocalView = TRUE;
722 curApp = Local_View->currentItem()->text(0); 722 curApp = Local_View->currentItem()->text(0);
723 } else { 723 } else {
724 curApp = Remote_View->currentItem()->text(0); 724 curApp = Remote_View->currentItem()->text(0);
725 } 725 }
726 726
727 MimeType mt( curApp ); 727 MimeType mt( curApp );
728 const AppLnk* app = mt.application();
729 QFile fi(curApp);
730
731 QPopupMenu *m = new QPopupMenu(0);
732 QPopupMenu *n = new QPopupMenu(0);
733// QPopupMenu *o = new QPopupMenu(0);
734
735 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
736 if ( !QFileInfo(fi).isDir() ) {
737// m->insertSeparator();
738// m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
739// } else {
740
741 if ( app )
742 m->insertItem( app->pixmap(), tr( "Open in "
743 + app->name() ), this, SLOT( runThis() ) );
744 else if( QFileInfo(fi).isExecutable() )
745 m->insertItem( Resource::loadPixmap( app->name()), tr( "Execute" ), this, SLOT( runThis() ) );
746
747 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
748 }
749 728
750 m->insertItem(tr("Actions"),n); 729 const AppLnk* app = mt.application();
751 if(isLocalView)
752 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
753 else
754 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
755 730
756 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 731 QFile fi(curApp);
732
733 QPopupMenu *m = new QPopupMenu(0);
734 QPopupMenu *n = new QPopupMenu(0);
735 // QPopupMenu *o = new QPopupMenu(0);
736
737 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
738
739 if ( QFileInfo(fi).isDir() ) {
740 m->insertSeparator();
741 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
742 } else {
743
744 if ( app )
745 m->insertItem( app->pixmap(), tr( "Open in "
746 + app->name() ), this, SLOT( runThis() ) );
747 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
748 m->insertItem( /*Resource::loadPixmap( app->name()),*/ tr( "Execute" ), this, SLOT( runThis() ) );
749
750 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
751 }
752
753 m->insertItem(tr("Actions"),n);
754 if(isLocalView)
755 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
756 else
757 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
758
759 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
757 760
758 n->insertSeparator(); 761 n->insertSeparator();
759 762
760 763
761 if(isLocalView) 764 if(isLocalView)
762 n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 765 n->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
763 else 766 else
764 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 767 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
765 768
766 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 769 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
767 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 770 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
768 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 771 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
769 n->insertItem( tr( "Move" ), this, SLOT( move() )); 772 n->insertItem( tr( "Move" ), this, SLOT( move() ));
770 773
771 n->insertSeparator(); 774 n->insertSeparator();
772 775
773 if(isLocalView) 776 if(isLocalView)
774 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 777 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
775 else 778 else
776 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 779 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
777 780
778 781
779 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 782 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
780 783
781 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 784 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
782 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 785 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
783 786
784 m->insertSeparator(); 787 m->insertSeparator();
785 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 788 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
786 789
787#if defined(QT_QWS_OPIE) 790#if defined(QT_QWS_OPIE)
788 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 791 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
789#endif 792#endif
790 m->setCheckable(TRUE); 793 m->setCheckable(TRUE);
791 if (!b) 794 if (!b)
792 m->setItemChecked(m->idAt(0),TRUE); 795 m->setItemChecked(m->idAt(0),TRUE);
793 else 796 else
794 m->setItemChecked(m->idAt(0),FALSE); 797 m->setItemChecked(m->idAt(0),FALSE);
795 798
796 if(Ir::supported()) 799 if(Ir::supported())
797 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 800 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
798 m->setFocus(); 801 m->setFocus();
799 m->exec( QCursor::pos() ); 802 m->exec( QCursor::pos() );
800 sleep(1); 803 sleep(1);
801 if(m) delete m; 804 if(m) delete m;
802} 805}
803 806
804 807
805void AdvancedFm::cancelMenuTimer() { 808void AdvancedFm::cancelMenuTimer() {
806 809
807// qDebug("selectionChanged: cancel menu timer"); 810// qDebug("selectionChanged: cancel menu timer");
808 if( menuTimer.isActive() ) 811 if( menuTimer.isActive() )
809 menuTimer.stop(); 812 menuTimer.stop();
810} 813}
811 814
812QString AdvancedFm::checkDiskSpace(const QString &path) { 815QString AdvancedFm::checkDiskSpace(const QString &path) {
813 struct statfs fss; 816 struct statfs fss;
814 if ( !statfs( path.latin1(), &fss ) ) { 817 if ( !statfs( path.latin1(), &fss ) ) {
815 int blkSize = fss.f_bsize; 818 int blkSize = fss.f_bsize;
816// int totalBlks = fs.f_blocks; 819// int totalBlks = fs.f_blocks;
817 int availBlks = fss.f_bavail; 820 int availBlks = fss.f_bavail;
818 821
819 long mult = blkSize / 1024; 822 long mult = blkSize / 1024;
820 long div = 1024 / blkSize; 823 long div = 1024 / blkSize;
821 if ( !mult ) mult = 1; 824 if ( !mult ) mult = 1;
822 if ( !div ) div = 1; 825 if ( !div ) div = 1;
823 826
824 827
825 return QString::number(availBlks * mult / div); 828 return QString::number(availBlks * mult / div);
826 } 829 }
827 return ""; 830 return "";
828} 831}
829 832
830void AdvancedFm::addToDocs() { 833void AdvancedFm::addToDocs() {
831 QStringList strListPaths = getPath(); 834 QStringList strListPaths = getPath();
832 if( strListPaths.count() > 0) { 835 if( strListPaths.count() > 0) {
833 QString curFile; 836 QString curFile;
834 if (TabWidget->currentPageIndex() == 0) { 837 if (TabWidget->currentPageIndex() == 0) {
835 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 838 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
836 curFile = currentDir.canonicalPath()+"/"+(*it); 839 curFile = currentDir.canonicalPath()+"/"+(*it);
837 qDebug(curFile); 840 qDebug(curFile);
838 DocLnk f; 841 DocLnk f;
839// curFile.replace(QRegExp("\\..*"),""); 842// curFile.replace(QRegExp("\\..*"),"");
840 f.setName((*it)); 843 f.setName((*it));
841 f.setFile( curFile); 844 f.setFile( curFile);
842 f.writeLink(); 845 f.writeLink();
843 } 846 }
844 } else { 847 } else {
845 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 848 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
846 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 849 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
847 qDebug(curFile); 850 qDebug(curFile);
848 851
849 DocLnk f; 852 DocLnk f;
850// curFile.replace(QRegExp("\\..*"),""); 853// curFile.replace(QRegExp("\\..*"),"");
851 f.setName((*it)); 854 f.setName((*it));
852 f.setFile( curFile); 855 f.setFile( curFile);
853 f.writeLink(); 856 f.writeLink();
854 } 857 }
855 } 858 }
856 } 859 }
857} 860}