summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index ab31c91..faa03dc 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -673,306 +673,316 @@ void AdvancedFm::showLocalMenu(QListViewItem * item)
673 else 673 else
674 m.setItemChecked(m.idAt(0),FALSE); 674 m.setItemChecked(m.idAt(0),FALSE);
675 m.exec( QCursor::pos() ); 675 m.exec( QCursor::pos() );
676 } 676 }
677} 677}
678 678
679void AdvancedFm::showRemoteMenu(QListViewItem * item) 679void AdvancedFm::showRemoteMenu(QListViewItem * item)
680{ 680{
681 if(item) { 681 if(item) {
682 QPopupMenu m; 682 QPopupMenu m;
683 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); 683 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() ));
684 m.insertSeparator(); 684 m.insertSeparator();
685 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 685 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
686 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 686 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
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()
781{ 781{
782 InputDialog *fileDlg; 782 InputDialog *fileDlg;
783 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 783 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
784 fileDlg->exec(); 784 fileDlg->exec();
785 if( fileDlg->result() == 1 ) { 785 if( fileDlg->result() == 1 ) {
786 QString filename = fileDlg->LineEdit1->text(); 786 QString filename = fileDlg->LineEdit1->text();
787 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); 787 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
788 } 788 }
789 populateRemoteView(); 789 populateRemoteView();
790} 790}
791 791
792void AdvancedFm::localDelete() 792void AdvancedFm::localDelete()
793{ 793{
794 QStringList curFileList = getPath(); 794 QStringList curFileList = getPath();
795 QString myFile; 795 QString myFile;
796 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 796 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
797 myFile = (*it); 797 myFile = (*it);
798 if( myFile.find(" -> ",0,TRUE) != -1) 798 if( myFile.find(" -> ",0,TRUE) != -1)
799 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 799 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
800 800
801 QString f = currentDir.canonicalPath()+"/"+myFile; 801 QString f = currentDir.canonicalPath();
802 if(f.right(1).find("/",0,TRUE) == -1)
803 f+="/";
804 f+=myFile;
802 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 805 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
803 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?" 806 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
807 "\nand all it's contents ?"
804 ,tr("Yes"),tr("No"),0,0,1) ) { 808 ,tr("Yes"),tr("No"),0,0,1) ) {
805 case 0: { 809 case 0: {
806 QString cmd="rmdir -rf "+f; 810 f=f.left(f.length()-1);
811 QString cmd="rm -rf "+f;
807 system( cmd.latin1()); 812 system( cmd.latin1());
808 populateLocalView(); 813 populateLocalView();
809 } 814 }
810 break; 815 break;
811 case 1: 816 case 1:
812 // exit 817 // exit
813 break; 818 break;
814 }; 819 };
815 820
816 } else { 821 } else {
817 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 822 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
818 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 823 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
819 case 0: { 824 case 0: {
820 QString cmd="rm "+f; 825 QString cmd="rm "+f;
821 QFile file(f); 826 QFile file(f);
822 file.remove(); 827 file.remove();
823// system( cmd.latin1()); 828// system( cmd.latin1());
824 populateLocalView(); 829 populateLocalView();
825 } 830 }
826 break; 831 break;
827 case 1: 832 case 1:
828 // exit 833 // exit
829 break; 834 break;
830 }; 835 };
831 } 836 }
832 837
833 } 838 }
834} 839}
835 840
836void AdvancedFm::remoteDelete() 841void AdvancedFm::remoteDelete()
837{ 842{
838 QStringList curFileList = getPath(); 843 QStringList curFileList = getPath();
839 QString myFile; 844 QString myFile;
840 845
841 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 846 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
842 myFile = (*it); 847 myFile = (*it);
843 if(myFile.find(" -> ",0,TRUE) != -1) 848 if(myFile.find(" -> ",0,TRUE) != -1)
844 myFile = myFile.left(myFile.find(" -> ",0,TRUE)); 849 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
845 QString f = currentRemoteDir.canonicalPath()+"/"+myFile; 850 QString f = currentDir.canonicalPath();
851 if(f.right(1).find("/",0,TRUE) == -1)
852 f+="/";
853 f+=myFile;
846 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 854 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
847 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?", 855 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
856 "\nand all it's contents ?",
848 tr("Yes"),tr("No"),0,0,1) ) { 857 tr("Yes"),tr("No"),0,0,1) ) {
849 case 0: { 858 case 0: {
850 QString cmd="rmdir -rf "+f; 859 f=f.left(f.length()-1);
860 QString cmd="rm -rf "+f;
851 system( cmd.latin1()); 861 system( cmd.latin1());
852 populateRemoteView(); 862 populateRemoteView();
853 } 863 }
854 break; 864 break;
855 case 1: 865 case 1:
856 // exit 866 // exit
857 break; 867 break;
858 }; 868 };
859 869
860 } else { 870 } else {
861 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 871 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
862 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 872 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
863 case 0: { 873 case 0: {
864 QString cmd="rm "+f; 874 QString cmd="rm "+f;
865 QFile file(f); 875 QFile file(f);
866 file.remove(); 876 file.remove();
867// system( cmd.latin1()); 877// system( cmd.latin1());
868 populateRemoteView(); 878 populateRemoteView();
869 } 879 }
870 break; 880 break;
871 case 1: 881 case 1:
872 // exit 882 // exit
873 break; 883 break;
874 }; 884 };
875 } 885 }
876 } 886 }
877} 887}
878 888
879void AdvancedFm::localRename() 889void AdvancedFm::localRename()
880{ 890{
881 QString curFile = Local_View->currentItem()->text(0); 891 QString curFile = Local_View->currentItem()->text(0);
882 InputDialog *fileDlg; 892 InputDialog *fileDlg;
883 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 893 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
884 fileDlg->setInputText((const QString &)curFile); 894 fileDlg->setInputText((const QString &)curFile);
885 fileDlg->exec(); 895 fileDlg->exec();
886 if( fileDlg->result() == 1 ) { 896 if( fileDlg->result() == 1 ) {
887 QString oldname = currentDir.canonicalPath() + "/" + curFile; 897 QString oldname = currentDir.canonicalPath() + "/" + curFile;
888 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 898 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
889 if( rename(oldname.latin1(), newName.latin1())== -1) 899 if( rename(oldname.latin1(), newName.latin1())== -1)
890 QMessageBox::message(tr("Note"),tr("Could not rename")); 900 QMessageBox::message(tr("Note"),tr("Could not rename"));
891 } 901 }
892 populateLocalView(); 902 populateLocalView();
893} 903}
894 904
895void AdvancedFm::remoteRename() 905void AdvancedFm::remoteRename()
896{ 906{
897 QString curFile = Local_View->currentItem()->text(0); 907 QString curFile = Local_View->currentItem()->text(0);
898 InputDialog *fileDlg; 908 InputDialog *fileDlg;
899 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 909 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
900 fileDlg->setInputText((const QString &)curFile); 910 fileDlg->setInputText((const QString &)curFile);
901 fileDlg->exec(); 911 fileDlg->exec();
902 if( fileDlg->result() == 1 ) { 912 if( fileDlg->result() == 1 ) {
903 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; 913 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
904 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 914 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
905 if( rename(oldname.latin1(), newName.latin1())== -1) 915 if( rename(oldname.latin1(), newName.latin1())== -1)
906 QMessageBox::message(tr("Note"),tr("Could not rename")); 916 QMessageBox::message(tr("Note"),tr("Could not rename"));
907 } 917 }
908 populateRemoteView(); 918 populateRemoteView();
909} 919}
910 920
911void AdvancedFm::switchToLocalTab() 921void AdvancedFm::switchToLocalTab()
912{ 922{
913 TabWidget->setCurrentPage(0); 923 TabWidget->setCurrentPage(0);
914 Local_View->setFocus(); 924 Local_View->setFocus();
915} 925}
916 926
917void AdvancedFm::switchToRemoteTab() 927void AdvancedFm::switchToRemoteTab()
918{ 928{
919 TabWidget->setCurrentPage(1); 929 TabWidget->setCurrentPage(1);
920 Remote_View->setFocus(); 930 Remote_View->setFocus();
921} 931}
922 932
923void AdvancedFm::readConfig() 933void AdvancedFm::readConfig()
924{ 934{
925 Config cfg("AdvancedFm"); 935 Config cfg("AdvancedFm");
926} 936}
927 937
928void AdvancedFm::writeConfig() 938void AdvancedFm::writeConfig()
929{ 939{
930 Config cfg("AdvancedFm"); 940 Config cfg("AdvancedFm");
931} 941}
932 942
933void AdvancedFm::currentPathComboChanged() 943void AdvancedFm::currentPathComboChanged()
934{ 944{
935 if (TabWidget->currentPageIndex() == 0) { 945 if (TabWidget->currentPageIndex() == 0) {
936 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 946 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
937 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 947 currentDir.setPath( currentPathCombo->lineEdit()->text() );
938 populateLocalView(); 948 populateLocalView();
939 } else { 949 } else {
940 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 950 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
941 } 951 }
942 } 952 }
943 if (TabWidget->currentPageIndex() == 0) { 953 if (TabWidget->currentPageIndex() == 0) {
944 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 954 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
945 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 955 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
946 populateRemoteView(); 956 populateRemoteView();
947 } else { 957 } else {
948 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 958 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
949 } 959 }
950 } 960 }
951} 961}
952 962
953void AdvancedFm::fillCombo(const QString &currentPath) { 963void AdvancedFm::fillCombo(const QString &currentPath) {
954 964
955 if (TabWidget->currentPageIndex() == 0) { 965 if (TabWidget->currentPageIndex() == 0) {
956 currentPathCombo->lineEdit()->setText( currentPath); 966 currentPathCombo->lineEdit()->setText( currentPath);
957 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 967 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
958 currentPathCombo->clear(); 968 currentPathCombo->clear();
959 localDirPathStringList.prepend( currentPath ); 969 localDirPathStringList.prepend( currentPath );
960 currentPathCombo->insertStringList( localDirPathStringList,-1); 970 currentPathCombo->insertStringList( localDirPathStringList,-1);
961 } 971 }
962 } else { 972 } else {
963 currentPathCombo->lineEdit()->setText( currentPath); 973 currentPathCombo->lineEdit()->setText( currentPath);
964 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 974 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
965 currentPathCombo->clear(); 975 currentPathCombo->clear();
966 remoteDirPathStringList.prepend( currentPath ); 976 remoteDirPathStringList.prepend( currentPath );
967 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 977 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
968 } 978 }
969 } 979 }
970} 980}
971 981
972void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 982void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
973 if (TabWidget->currentPageIndex() == 0) { 983 if (TabWidget->currentPageIndex() == 0) {
974 chdir( currentPath.latin1() ); 984 chdir( currentPath.latin1() );
975 currentDir.cd( currentPath, TRUE); 985 currentDir.cd( currentPath, TRUE);
976 populateLocalView(); 986 populateLocalView();
977 update(); 987 update();
978 } else { 988 } else {