author | llornkcor <llornkcor> | 2002-05-02 02:09:49 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-02 02:09:49 (UTC) |
commit | 6dfc6f34420b8c9222d1c785efc950fc5031a7f0 (patch) (unidiff) | |
tree | a144e5e4c2be3e57d0939090ee5a39982f17804d | |
parent | 45ba3b844e3fb8d9b9e1936ad2abec869d25dd33 (diff) | |
download | opie-6dfc6f34420b8c9222d1c785efc950fc5031a7f0.zip opie-6dfc6f34420b8c9222d1c785efc950fc5031a7f0.tar.gz opie-6dfc6f34420b8c9222d1c785efc950fc5031a7f0.tar.bz2 |
damned QFileInfo::isExecutable bug...
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index e3ab76b..7cd8644 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -637,212 +637,219 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint | |||
637 | }; | 637 | }; |
638 | } | 638 | } |
639 | 639 | ||
640 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 640 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
641 | { | 641 | { |
642 | switch (mouse) { | 642 | switch (mouse) { |
643 | case 1: | 643 | case 1: |
644 | break; | 644 | break; |
645 | case 2: | 645 | case 2: |
646 | showRemoteMenu(item); | 646 | showRemoteMenu(item); |
647 | Remote_View->clearSelection(); | 647 | Remote_View->clearSelection(); |
648 | break; | 648 | break; |
649 | }; | 649 | }; |
650 | } | 650 | } |
651 | 651 | ||
652 | void AdvancedFm::showLocalMenu(QListViewItem * item) | 652 | void AdvancedFm::showLocalMenu(QListViewItem * item) |
653 | { | 653 | { |
654 | if(item) { | 654 | if(item) { |
655 | QPopupMenu m; | 655 | QPopupMenu m; |
656 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 656 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
657 | m.insertSeparator(); | 657 | m.insertSeparator(); |
658 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 658 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
659 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 659 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
660 | else | 660 | else |
661 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); | 661 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); |
662 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 662 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
663 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 663 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
664 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 664 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
665 | m.insertSeparator(); | 665 | m.insertSeparator(); |
666 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 666 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
667 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 667 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
668 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 668 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
669 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 669 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
670 | m.insertSeparator(); | 670 | m.insertSeparator(); |
671 | m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); | 671 | m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); |
672 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 672 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
673 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 673 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
674 | m.insertSeparator(); | 674 | m.insertSeparator(); |
675 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 675 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
676 | m.insertSeparator(); | 676 | m.insertSeparator(); |
677 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 677 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
678 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 678 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
679 | m.setCheckable(TRUE); | 679 | m.setCheckable(TRUE); |
680 | if (!b) | 680 | if (!b) |
681 | m.setItemChecked(m.idAt(0),TRUE); | 681 | m.setItemChecked(m.idAt(0),TRUE); |
682 | else | 682 | else |
683 | m.setItemChecked(m.idAt(0),FALSE); | 683 | m.setItemChecked(m.idAt(0),FALSE); |
684 | m.exec( QCursor::pos() ); | 684 | m.exec( QCursor::pos() ); |
685 | } | 685 | } |
686 | } | 686 | } |
687 | 687 | ||
688 | void AdvancedFm::showRemoteMenu(QListViewItem * item) | 688 | void AdvancedFm::showRemoteMenu(QListViewItem * item) |
689 | { | 689 | { |
690 | if(item) { | 690 | if(item) { |
691 | QPopupMenu m; | 691 | QPopupMenu m; |
692 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); | 692 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); |
693 | m.insertSeparator(); | 693 | m.insertSeparator(); |
694 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 694 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
695 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 695 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
696 | else | 696 | else |
697 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); | 697 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); |
698 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 698 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
699 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 699 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
700 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 700 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
701 | m.insertSeparator(); | 701 | m.insertSeparator(); |
702 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 702 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
703 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 703 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
704 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 704 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
705 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 705 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
706 | m.insertSeparator(); | 706 | m.insertSeparator(); |
707 | m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); | 707 | m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); |
708 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 708 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
709 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 709 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
710 | m.insertSeparator(); | 710 | m.insertSeparator(); |
711 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 711 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
712 | m.insertSeparator(); | 712 | m.insertSeparator(); |
713 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 713 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
714 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 714 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
715 | m.setCheckable(TRUE); | 715 | m.setCheckable(TRUE); |
716 | if (!b) | 716 | if (!b) |
717 | m.setItemChecked(m.idAt(0),TRUE); | 717 | m.setItemChecked(m.idAt(0),TRUE); |
718 | else | 718 | else |
719 | m.setItemChecked(m.idAt(0),FALSE); | 719 | m.setItemChecked(m.idAt(0),FALSE); |
720 | m.exec( QCursor::pos() ); | 720 | m.exec( QCursor::pos() ); |
721 | } | 721 | } |
722 | } | 722 | } |
723 | 723 | ||
724 | void AdvancedFm::runThis() { | 724 | void AdvancedFm::runThis() { |
725 | // QFileInfo *fi; | 725 | // QFileInfo *fi; |
726 | QString fs; | 726 | QString fs; |
727 | if (TabWidget->currentPageIndex() == 0) { | 727 | if (TabWidget->currentPageIndex() == 0) { |
728 | QString curFile = Local_View->currentItem()->text(0); | 728 | QString curFile = Local_View->currentItem()->text(0); |
729 | 729 | ||
730 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 730 | fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
731 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | 731 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); |
732 | qDebug( fileInfo.owner()); | 732 | qDebug( fileInfo.owner()); |
733 | if( fileInfo.isExecutable() || fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 733 | if( (fileInfo.permission( QFileInfo::ExeUser) |
734 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 734 | | fileInfo.permission( QFileInfo::ExeGroup) |
735 | e << curFile; | 735 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
736 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
737 | // if( fileInfo.isExecutable() | | ||
738 | QCopEnvelope e("QPE/System", "execute(QString)" ); | ||
739 | e << curFile; | ||
736 | } else { | 740 | } else { |
737 | curFile = currentDir.canonicalPath()+"/"+curFile; | 741 | curFile = currentDir.canonicalPath()+"/"+curFile; |
738 | DocLnk nf(curFile); | 742 | DocLnk nf(curFile); |
739 | QString execStr = nf.exec(); | 743 | QString execStr = nf.exec(); |
740 | qDebug( execStr); | 744 | qDebug( execStr); |
741 | if( execStr.isEmpty() ) { | 745 | if( execStr.isEmpty() ) { |
742 | } else { | 746 | } else { |
743 | nf.execute(); | 747 | nf.execute(); |
744 | } | 748 | } |
745 | } | 749 | } |
746 | // MimeType mt( curFile); | 750 | // MimeType mt( curFile); |
747 | } else { | 751 | } else { |
748 | QString curFile = Remote_View->currentItem()->text(0); | 752 | QString curFile = Remote_View->currentItem()->text(0); |
749 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 753 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
750 | qDebug("Filesystemtype is "+fs); | 754 | qDebug("Filesystemtype is "+fs); |
751 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | 755 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); |
752 | if(fileInfo.isExecutable() || fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 756 | if( (fileInfo.permission( QFileInfo::ExeUser) |
757 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
758 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | ||
759 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
753 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 760 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
754 | e << curFile; | 761 | e << curFile; |
755 | } else { | 762 | } else { |
756 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 763 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
757 | DocLnk nf(curFile); | 764 | DocLnk nf(curFile); |
758 | QString execStr = nf.exec(); | 765 | QString execStr = nf.exec(); |
759 | qDebug(execStr); | 766 | qDebug(execStr); |
760 | if( execStr.isEmpty() ) { | 767 | if( execStr.isEmpty() ) { |
761 | } else { | 768 | } else { |
762 | nf.execute(); | 769 | nf.execute(); |
763 | } | 770 | } |
764 | } | 771 | } |
765 | // MimeType mt( curFile); | 772 | // MimeType mt( curFile); |
766 | } | 773 | } |
767 | } | 774 | } |
768 | 775 | ||
769 | void AdvancedFm::runText() { | 776 | void AdvancedFm::runText() { |
770 | if (TabWidget->currentPageIndex() == 0) { | 777 | if (TabWidget->currentPageIndex() == 0) { |
771 | QString curFile = Local_View->currentItem()->text(0); | 778 | QString curFile = Local_View->currentItem()->text(0); |
772 | curFile = currentDir.canonicalPath()+"/"+curFile; | 779 | curFile = currentDir.canonicalPath()+"/"+curFile; |
773 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 780 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
774 | e << curFile; | 781 | e << curFile; |
775 | } else { | 782 | } else { |
776 | QString curFile = Remote_View->currentItem()->text(0); | 783 | QString curFile = Remote_View->currentItem()->text(0); |
777 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 784 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
778 | DocLnk nf(curFile); | 785 | DocLnk nf(curFile); |
779 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 786 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
780 | e << curFile; | 787 | e << curFile; |
781 | } | 788 | } |
782 | } | 789 | } |
783 | 790 | ||
784 | void AdvancedFm::localMakDir() | 791 | void AdvancedFm::localMakDir() |
785 | { | 792 | { |
786 | InputDialog *fileDlg; | 793 | InputDialog *fileDlg; |
787 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 794 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
788 | fileDlg->exec(); | 795 | fileDlg->exec(); |
789 | if( fileDlg->result() == 1 ) { | 796 | if( fileDlg->result() == 1 ) { |
790 | QString filename = fileDlg->LineEdit1->text(); | 797 | QString filename = fileDlg->LineEdit1->text(); |
791 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 798 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
792 | } | 799 | } |
793 | populateLocalView(); | 800 | populateLocalView(); |
794 | } | 801 | } |
795 | 802 | ||
796 | void AdvancedFm::remoteMakDir() | 803 | void AdvancedFm::remoteMakDir() |
797 | { | 804 | { |
798 | InputDialog *fileDlg; | 805 | InputDialog *fileDlg; |
799 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 806 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
800 | fileDlg->exec(); | 807 | fileDlg->exec(); |
801 | if( fileDlg->result() == 1 ) { | 808 | if( fileDlg->result() == 1 ) { |
802 | QString filename = fileDlg->LineEdit1->text(); | 809 | QString filename = fileDlg->LineEdit1->text(); |
803 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | 810 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); |
804 | } | 811 | } |
805 | populateRemoteView(); | 812 | populateRemoteView(); |
806 | } | 813 | } |
807 | 814 | ||
808 | void AdvancedFm::localDelete() | 815 | void AdvancedFm::localDelete() |
809 | { | 816 | { |
810 | QStringList curFileList = getPath(); | 817 | QStringList curFileList = getPath(); |
811 | QString myFile; | 818 | QString myFile; |
812 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 819 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
813 | myFile = (*it); | 820 | myFile = (*it); |
814 | if( myFile.find(" -> ",0,TRUE) != -1) | 821 | if( myFile.find(" -> ",0,TRUE) != -1) |
815 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 822 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
816 | 823 | ||
817 | QString f = currentDir.canonicalPath(); | 824 | QString f = currentDir.canonicalPath(); |
818 | if(f.right(1).find("/",0,TRUE) == -1) | 825 | if(f.right(1).find("/",0,TRUE) == -1) |
819 | f+="/"; | 826 | f+="/"; |
820 | f+=myFile; | 827 | f+=myFile; |
821 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 828 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
822 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 829 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
823 | "\nand all it's contents ?" | 830 | "\nand all it's contents ?" |
824 | ,tr("Yes"),tr("No"),0,0,1) ) { | 831 | ,tr("Yes"),tr("No"),0,0,1) ) { |
825 | case 0: { | 832 | case 0: { |
826 | f=f.left(f.length()-1); | 833 | f=f.left(f.length()-1); |
827 | QString cmd="rm -rf "+f; | 834 | QString cmd="rm -rf "+f; |
828 | system( cmd.latin1()); | 835 | system( cmd.latin1()); |
829 | populateLocalView(); | 836 | populateLocalView(); |
830 | } | 837 | } |
831 | break; | 838 | break; |
832 | case 1: | 839 | case 1: |
833 | // exit | 840 | // exit |
834 | break; | 841 | break; |
835 | }; | 842 | }; |
836 | 843 | ||
837 | } else { | 844 | } else { |
838 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 845 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
839 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 846 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
840 | case 0: { | 847 | case 0: { |
841 | QString cmd="rm "+f; | 848 | QString cmd="rm "+f; |
842 | QFile file(f); | 849 | QFile file(f); |
843 | file.remove(); | 850 | file.remove(); |
844 | // system( cmd.latin1()); | 851 | // system( cmd.latin1()); |
845 | populateLocalView(); | 852 | populateLocalView(); |
846 | } | 853 | } |
847 | break; | 854 | break; |
848 | case 1: | 855 | case 1: |