-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 2ddcabc..e7c0b6a 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -714,424 +714,424 @@ void AdvancedFm::move() { | |||
714 | 714 | ||
715 | TabWidget->setCurrentTab(1); | 715 | TabWidget->setCurrentTab(1); |
716 | 716 | ||
717 | } else { //view 2 | 717 | } else { //view 2 |
718 | 718 | ||
719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
720 | item = (*it); | 720 | item = (*it); |
721 | QString destFile = currentDir.canonicalPath(); | 721 | QString destFile = currentDir.canonicalPath(); |
722 | 722 | ||
723 | if(destFile.right(1).find("/",0,TRUE) == -1) | 723 | if(destFile.right(1).find("/",0,TRUE) == -1) |
724 | destFile+="/"; | 724 | destFile+="/"; |
725 | 725 | ||
726 | destFile += item; | 726 | destFile += item; |
727 | 727 | ||
728 | qDebug("Destination file is "+destFile); | 728 | qDebug("Destination file is "+destFile); |
729 | 729 | ||
730 | curFile = currentRemoteDir.canonicalPath(); | 730 | curFile = currentRemoteDir.canonicalPath(); |
731 | 731 | ||
732 | if(curFile.right(1).find("/",0,TRUE) == -1) | 732 | if(curFile.right(1).find("/",0,TRUE) == -1) |
733 | curFile +="/"; | 733 | curFile +="/"; |
734 | curFile+= item; | 734 | curFile+= item; |
735 | qDebug("CurrentFile file is " + curFile); | 735 | qDebug("CurrentFile file is " + curFile); |
736 | 736 | ||
737 | QFile f( curFile); | 737 | QFile f( curFile); |
738 | if( f.exists()) { | 738 | if( f.exists()) { |
739 | if(!copyFile( curFile, destFile) ) { | 739 | if(!copyFile( curFile, destFile) ) { |
740 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | 740 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); |
741 | return; | 741 | return; |
742 | } else | 742 | } else |
743 | QFile::remove( curFile); | 743 | QFile::remove( curFile); |
744 | } | 744 | } |
745 | TabWidget->setCurrentTab(0); | 745 | TabWidget->setCurrentTab(0); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | populateRemoteView(); | 748 | populateRemoteView(); |
749 | populateLocalView(); | 749 | populateLocalView(); |
750 | } | 750 | } |
751 | } | 751 | } |
752 | 752 | ||
753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
754 | char bf[ 50000 ]; | 754 | char bf[ 50000 ]; |
755 | int bytesRead; | 755 | int bytesRead; |
756 | bool success = TRUE; | 756 | bool success = TRUE; |
757 | struct stat status; | 757 | struct stat status; |
758 | 758 | ||
759 | QFile s( src ); | 759 | QFile s( src ); |
760 | QFile d( dest ); | 760 | QFile d( dest ); |
761 | 761 | ||
762 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 762 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
763 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 763 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
765 | success = FALSE; | 765 | success = FALSE; |
766 | break; | 766 | break; |
767 | } | 767 | } |
768 | } | 768 | } |
769 | if( success && (bytesRead > 0) ){ | 769 | if( success && (bytesRead > 0) ){ |
770 | d.writeBlock( bf, bytesRead ); | 770 | d.writeBlock( bf, bytesRead ); |
771 | } | 771 | } |
772 | } else { | 772 | } else { |
773 | success = FALSE; | 773 | success = FALSE; |
774 | } | 774 | } |
775 | 775 | ||
776 | // Set file permissions | 776 | // Set file permissions |
777 | if( stat( (const char *) src, &status ) == 0 ){ | 777 | if( stat( (const char *) src, &status ) == 0 ){ |
778 | chmod( (const char *) dest, status.st_mode ); | 778 | chmod( (const char *) dest, status.st_mode ); |
779 | } | 779 | } |
780 | 780 | ||
781 | return success; | 781 | return success; |
782 | } | 782 | } |
783 | 783 | ||
784 | void AdvancedFm::runCommand() { | 784 | void AdvancedFm::runCommand() { |
785 | QString curFile; | 785 | QString curFile; |
786 | if (TabWidget->getCurrentTab() == 0) { | 786 | if (TabWidget->getCurrentTab() == 0) { |
787 | if( Local_View->currentItem()) | 787 | if( Local_View->currentItem()) |
788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
789 | } else { | 789 | } else { |
790 | if(Remote_View->currentItem()) | 790 | if(Remote_View->currentItem()) |
791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
792 | } | 792 | } |
793 | 793 | ||
794 | InputDialog *fileDlg; | 794 | InputDialog *fileDlg; |
795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
796 | fileDlg->setInputText(curFile); | 796 | fileDlg->setInputText(curFile); |
797 | fileDlg->exec(); | 797 | fileDlg->exec(); |
798 | //QString command; | 798 | //QString command; |
799 | 799 | ||
800 | if( fileDlg->result() == 1 ) { | 800 | if( fileDlg->result() == 1 ) { |
801 | qDebug(fileDlg->LineEdit1->text()); | 801 | qDebug(fileDlg->LineEdit1->text()); |
802 | QStringList command; | 802 | QStringList command; |
803 | 803 | ||
804 | command << "/bin/sh"; | 804 | command << "/bin/sh"; |
805 | command << "-c"; | 805 | command << "-c"; |
806 | command << fileDlg->LineEdit1->text(); | 806 | command << fileDlg->LineEdit1->text(); |
807 | Output *outDlg; | 807 | Output *outDlg; |
808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
809 | outDlg->showMaximized(); | 809 | outDlg->showMaximized(); |
810 | outDlg->exec(); | 810 | outDlg->exec(); |
811 | qApp->processEvents(); | 811 | qApp->processEvents(); |
812 | 812 | ||
813 | } | 813 | } |
814 | } | 814 | } |
815 | 815 | ||
816 | void AdvancedFm::runCommandStd() { | 816 | void AdvancedFm::runCommandStd() { |
817 | QString curFile; | 817 | QString curFile; |
818 | if (TabWidget->getCurrentTab() == 0) { | 818 | if (TabWidget->getCurrentTab() == 0) { |
819 | if( Local_View->currentItem()) | 819 | if( Local_View->currentItem()) |
820 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 820 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
821 | } else { | 821 | } else { |
822 | if(Remote_View->currentItem()) | 822 | if(Remote_View->currentItem()) |
823 | curFile = currentRemoteDir.canonicalPath() +"/" | 823 | curFile = currentRemoteDir.canonicalPath() +"/" |
824 | + Remote_View->currentItem()->text(0); | 824 | + Remote_View->currentItem()->text(0); |
825 | } | 825 | } |
826 | 826 | ||
827 | InputDialog *fileDlg; | 827 | InputDialog *fileDlg; |
828 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 828 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
829 | fileDlg->setInputText(curFile); | 829 | fileDlg->setInputText(curFile); |
830 | fileDlg->exec(); | 830 | fileDlg->exec(); |
831 | 831 | ||
832 | if( fileDlg->result() == 1 ) { | 832 | if( fileDlg->result() == 1 ) { |
833 | qApp->processEvents(); | 833 | qApp->processEvents(); |
834 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 834 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | void AdvancedFm::fileStatus() { | 838 | void AdvancedFm::fileStatus() { |
839 | QString curFile; | 839 | QString curFile; |
840 | if (TabWidget->getCurrentTab() == 0) { | 840 | if (TabWidget->getCurrentTab() == 0) { |
841 | curFile = Local_View->currentItem()->text(0); | 841 | curFile = Local_View->currentItem()->text(0); |
842 | } else { | 842 | } else { |
843 | curFile = Remote_View->currentItem()->text(0); | 843 | curFile = Remote_View->currentItem()->text(0); |
844 | } | 844 | } |
845 | 845 | ||
846 | QStringList command; | 846 | QStringList command; |
847 | command << "/bin/sh"; | 847 | command << "/bin/sh"; |
848 | command << "-c"; | 848 | command << "-c"; |
849 | command << "stat -l "+ curFile; | 849 | command << "stat -l "+ curFile; |
850 | 850 | ||
851 | Output *outDlg; | 851 | Output *outDlg; |
852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
853 | outDlg->showMaximized(); | 853 | outDlg->showMaximized(); |
854 | outDlg->exec(); | 854 | outDlg->exec(); |
855 | qApp->processEvents(); | 855 | qApp->processEvents(); |
856 | 856 | ||
857 | 857 | ||
858 | // Output *outDlg; | 858 | // Output *outDlg; |
859 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 859 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
860 | // outDlg->showMaximized(); | 860 | // outDlg->showMaximized(); |
861 | // outDlg->show(); | 861 | // outDlg->show(); |
862 | // qApp->processEvents(); | 862 | // qApp->processEvents(); |
863 | 863 | ||
864 | // FILE *fp; | 864 | // FILE *fp; |
865 | // char line[130]; | 865 | // char line[130]; |
866 | // sleep(1); | 866 | // sleep(1); |
867 | // fp = popen( (const char *) command, "r"); | 867 | // fp = popen( (const char *) command, "r"); |
868 | // if ( !fp ) { | 868 | // if ( !fp ) { |
869 | // qDebug("Could not execute '" + command + "'! err=%d", fp); | 869 | // qDebug("Could not execute '" + command + "'! err=%d", fp); |
870 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 870 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
871 | // pclose(fp); | 871 | // pclose(fp); |
872 | // return; | 872 | // return; |
873 | // } else { | 873 | // } else { |
874 | // while ( fgets( line, sizeof line, fp)) { | 874 | // while ( fgets( line, sizeof line, fp)) { |
875 | // outDlg->OutputEdit->append(line); | 875 | // outDlg->OutputEdit->append(line); |
876 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 876 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
877 | 877 | ||
878 | // } | 878 | // } |
879 | 879 | ||
880 | // } | 880 | // } |
881 | // pclose(fp); | 881 | // pclose(fp); |
882 | } | 882 | } |
883 | 883 | ||
884 | 884 | ||
885 | void AdvancedFm::mkDir() { | 885 | void AdvancedFm::mkDir() { |
886 | if (TabWidget->getCurrentTab() == 0) | 886 | if (TabWidget->getCurrentTab() == 0) |
887 | localMakDir(); | 887 | localMakDir(); |
888 | else | 888 | else |
889 | remoteMakDir(); | 889 | remoteMakDir(); |
890 | 890 | ||
891 | } | 891 | } |
892 | 892 | ||
893 | void AdvancedFm::rn() { | 893 | void AdvancedFm::rn() { |
894 | if (TabWidget->getCurrentTab() == 0) | 894 | if (TabWidget->getCurrentTab() == 0) |
895 | localRename(); | 895 | localRename(); |
896 | else | 896 | else |
897 | remoteRename(); | 897 | remoteRename(); |
898 | 898 | ||
899 | } | 899 | } |
900 | 900 | ||
901 | void AdvancedFm::del() { | 901 | void AdvancedFm::del() { |
902 | if (TabWidget->getCurrentTab() == 0) | 902 | if (TabWidget->getCurrentTab() == 0) |
903 | localDelete(); | 903 | localDelete(); |
904 | else | 904 | else |
905 | remoteDelete(); | 905 | remoteDelete(); |
906 | } | 906 | } |
907 | 907 | ||
908 | void AdvancedFm::mkSym() { | 908 | void AdvancedFm::mkSym() { |
909 | QString cmd; | 909 | QString cmd; |
910 | QStringList curFileList = getPath(); | 910 | QStringList curFileList = getPath(); |
911 | if( curFileList.count() > 0) { | 911 | if( curFileList.count() > 0) { |
912 | 912 | ||
913 | if (TabWidget->getCurrentTab() == 0) { | 913 | if (TabWidget->getCurrentTab() == 0) { |
914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
915 | 915 | ||
916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
920 | cmd = "ln -s "+curFile+" "+destName; | 920 | cmd = "ln -s "+curFile+" "+destName; |
921 | qDebug(cmd); | 921 | qDebug(cmd); |
922 | startProcess( (const QString)cmd ); | 922 | startProcess( (const QString)cmd ); |
923 | } | 923 | } |
924 | populateRemoteView(); | 924 | populateRemoteView(); |
925 | TabWidget->setCurrentTab(1); | 925 | TabWidget->setCurrentTab(1); |
926 | } else { | 926 | } else { |
927 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 927 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
928 | 928 | ||
929 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 929 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
933 | 933 | ||
934 | cmd = "ln -s "+curFile+" "+destName; | 934 | cmd = "ln -s "+curFile+" "+destName; |
935 | qDebug(cmd); | 935 | qDebug(cmd); |
936 | startProcess( (const QString)cmd ); | 936 | startProcess( (const QString)cmd ); |
937 | } | 937 | } |
938 | populateLocalView(); | 938 | populateLocalView(); |
939 | TabWidget->setCurrentTab(0); | 939 | TabWidget->setCurrentTab(0); |
940 | } | 940 | } |
941 | } | 941 | } |
942 | } | 942 | } |
943 | 943 | ||
944 | void AdvancedFm::doBeam() { | 944 | void AdvancedFm::doBeam() { |
945 | Ir ir; | 945 | Ir ir; |
946 | if(!ir.supported()){ | 946 | if(!ir.supported()){ |
947 | } else { | 947 | } else { |
948 | 948 | ||
949 | QStringList curFileList = getPath(); | 949 | QStringList curFileList = getPath(); |
950 | if( curFileList.count() > 0) { | 950 | if( curFileList.count() > 0) { |
951 | 951 | ||
952 | if (TabWidget->getCurrentTab() == 0) { | 952 | if (TabWidget->getCurrentTab() == 0) { |
953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
954 | 954 | ||
955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
957 | Ir *file = new Ir(this, "IR"); | 957 | Ir *file = new Ir(this, "IR"); |
958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
959 | file->send( curFile, curFile ); | 959 | file->send( curFile, curFile ); |
960 | } | 960 | } |
961 | 961 | ||
962 | } else { | 962 | } else { |
963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
964 | 964 | ||
965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
967 | Ir *file = new Ir(this, "IR"); | 967 | Ir *file = new Ir(this, "IR"); |
968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
969 | file->send( curFile, curFile ); | 969 | file->send( curFile, curFile ); |
970 | 970 | ||
971 | } | 971 | } |
972 | } | 972 | } |
973 | } | 973 | } |
974 | } | 974 | } |
975 | 975 | ||
976 | } | 976 | } |
977 | 977 | ||
978 | void AdvancedFm::fileBeamFinished( Ir *) { | 978 | void AdvancedFm::fileBeamFinished( Ir *) { |
979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
980 | 980 | ||
981 | } | 981 | } |
982 | 982 | ||
983 | void AdvancedFm::selectAll() { | 983 | void AdvancedFm::selectAll() { |
984 | if (TabWidget->getCurrentTab() == 0) { | 984 | if (TabWidget->getCurrentTab() == 0) { |
985 | Local_View->selectAll(true); | 985 | Local_View->selectAll(true); |
986 | Local_View->setSelected( Local_View->firstChild(),false); | 986 | Local_View->setSelected( Local_View->firstChild(),false); |
987 | } else { | 987 | } else { |
988 | Remote_View->selectAll(true); | 988 | Remote_View->selectAll(true); |
989 | Remote_View->setSelected( Remote_View->firstChild(),false); | 989 | Remote_View->setSelected( Remote_View->firstChild(),false); |
990 | } | 990 | } |
991 | } | 991 | } |
992 | 992 | ||
993 | void AdvancedFm::startProcess(const QString & cmd) { | 993 | void AdvancedFm::startProcess(const QString & cmd) { |
994 | QStringList command; | 994 | QStringList command; |
995 | OProcess *process; | 995 | OProcess *process; |
996 | process = new OProcess(); | 996 | process = new OProcess(); |
997 | connect(process, SIGNAL(processExited(OProcess *)), | 997 | connect(process, SIGNAL(processExited(OProcess *)), |
998 | this, SLOT( processEnded())); | 998 | this, SLOT( processEnded())); |
999 | 999 | ||
1000 | command << "/bin/sh"; | 1000 | command << "/bin/sh"; |
1001 | command << "-c"; | 1001 | command << "-c"; |
1002 | command << cmd.latin1(); | 1002 | command << cmd.latin1(); |
1003 | *process << command; | 1003 | *process << command; |
1004 | if(!process->start(OProcess::NotifyOnExit) ) | 1004 | if(!process->start(OProcess::NotifyOnExit) ) |
1005 | qDebug("could not start process"); | 1005 | qDebug("could not start process"); |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void AdvancedFm::processEnded() { | 1008 | void AdvancedFm::processEnded() { |
1009 | populateLocalView(); | 1009 | populateLocalView(); |
1010 | populateRemoteView(); | 1010 | populateRemoteView(); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 1013 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
1014 | if ( o->inherits( "QLineEdit" ) ) { | 1014 | if ( o->inherits( "QLineEdit" ) ) { |
1015 | if ( e->type() == QEvent::KeyPress ) { | 1015 | if ( e->type() == QEvent::KeyPress ) { |
1016 | QKeyEvent *ke = (QKeyEvent*)e; | 1016 | QKeyEvent *ke = (QKeyEvent*)e; |
1017 | if ( ke->key() == Key_Return || | 1017 | if ( ke->key() == Key_Return || |
1018 | ke->key() == Key_Enter ) { | 1018 | ke->key() == Key_Enter ) { |
1019 | okRename(); | 1019 | okRename(); |
1020 | return true; | 1020 | return true; |
1021 | } else if ( ke->key() == Key_Escape ) { | 1021 | } else if ( ke->key() == Key_Escape ) { |
1022 | cancelRename(); | 1022 | cancelRename(); |
1023 | return true; | 1023 | return true; |
1024 | } | 1024 | } |
1025 | } else if ( e->type() == QEvent::FocusOut ) { | 1025 | } else if ( e->type() == QEvent::FocusOut ) { |
1026 | cancelRename(); | 1026 | cancelRename(); |
1027 | return true; | 1027 | return true; |
1028 | } | 1028 | } |
1029 | } | 1029 | } |
1030 | if ( o->inherits( "QListView" ) ) { | 1030 | if ( o->inherits( "QListView" ) ) { |
1031 | if ( e->type() == QEvent::FocusOut ) { | 1031 | if ( e->type() == QEvent::FocusOut ) { |
1032 | printf("focusIn\n"); | 1032 | printf("focusIn\n"); |
1033 | 1033 | ||
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | return QWidget::eventFilter( o, e ); | 1037 | return QWidget::eventFilter( o, e ); |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | 1040 | ||
1041 | void AdvancedFm::cancelRename() | 1041 | void AdvancedFm::cancelRename() |
1042 | { | 1042 | { |
1043 | qDebug("cancel rename"); | 1043 | qDebug("cancel rename"); |
1044 | QListView * view; | 1044 | QListView * view; |
1045 | if (TabWidget->getCurrentTab() == 0) | 1045 | if (TabWidget->getCurrentTab() == 0) |
1046 | { | 1046 | { |
1047 | view = Local_View; | 1047 | view = Local_View; |
1048 | } | 1048 | } |
1049 | else | 1049 | else |
1050 | { | 1050 | { |
1051 | view = Remote_View; | 1051 | view = Remote_View; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 1054 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
1055 | delete renameBox; | 1055 | delete renameBox; |
1056 | renameBox = 0; | 1056 | renameBox = 0; |
1057 | if ( resetFocus ) { | 1057 | if ( resetFocus ) { |
1058 | view->viewport()->setFocusProxy( view); | 1058 | view->viewport()->setFocusProxy( view); |
1059 | view->setFocus(); | 1059 | view->setFocus(); |
1060 | } | 1060 | } |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | void AdvancedFm::doRename(QListView * view) | 1063 | void AdvancedFm::doRename(QListView * view) |
1064 | { | 1064 | { |
1065 | 1065 | ||
1066 | QRect r = view->itemRect( view->currentItem( )); | 1066 | QRect r = view->itemRect( view->currentItem( )); |
1067 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 1067 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
1068 | r.setX( view->contentsX() ); | 1068 | r.setX( view->contentsX() ); |
1069 | if ( r.width() > view->visibleWidth() ) | 1069 | if ( r.width() > view->visibleWidth() ) |
1070 | r.setWidth( view->visibleWidth() ); | 1070 | r.setWidth( view->visibleWidth() ); |
1071 | 1071 | ||
1072 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 1072 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
1073 | renameBox->setFrame(true); | 1073 | renameBox->setFrame(true); |
1074 | 1074 | ||
1075 | renameBox->setText( view->currentItem()->text(0) ); | 1075 | renameBox->setText( view->currentItem()->text(0) ); |
1076 | 1076 | ||
1077 | renameBox->selectAll(); | 1077 | renameBox->selectAll(); |
1078 | renameBox->installEventFilter( this ); | 1078 | renameBox->installEventFilter( this ); |
1079 | view->addChild( renameBox, r.x(), r.y() ); | 1079 | view->addChild( renameBox, r.x(), r.y() ); |
1080 | renameBox->resize( r.size() ); | 1080 | renameBox->resize( r.size() ); |
1081 | view->viewport()->setFocusProxy( renameBox ); | 1081 | view->viewport()->setFocusProxy( renameBox ); |
1082 | renameBox->setFocus(); | 1082 | renameBox->setFocus(); |
1083 | renameBox->show(); | 1083 | renameBox->show(); |
1084 | 1084 | ||
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | 1087 | ||
1088 | void AdvancedFm::localRename() | 1088 | void AdvancedFm::localRename() |
1089 | { | 1089 | { |
1090 | oldName = Local_View->currentItem()->text(0); | 1090 | oldName = Local_View->currentItem()->text(0); |
1091 | doRename(Local_View ); | 1091 | doRename(Local_View ); |
1092 | populateLocalView(); | 1092 | populateLocalView(); |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | void AdvancedFm::remoteRename() | 1095 | void AdvancedFm::remoteRename() |
1096 | { | 1096 | { |
1097 | oldName = Remote_View->currentItem()->text(0); | 1097 | oldName = Remote_View->currentItem()->text(0); |
1098 | doRename(Local_View ); | 1098 | doRename(Remote_View ); |
1099 | populateRemoteView(); | 1099 | populateRemoteView(); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void AdvancedFm::okRename() | 1102 | void AdvancedFm::okRename() |
1103 | { | 1103 | { |
1104 | QString newName = renameBox->text(); | 1104 | QString newName = renameBox->text(); |
1105 | cancelRename(); | 1105 | cancelRename(); |
1106 | int tabs=0; | 1106 | int tabs=0; |
1107 | QListView * view; | 1107 | QListView * view; |
1108 | tabs = TabWidget->getCurrentTab(); | 1108 | tabs = TabWidget->getCurrentTab(); |
1109 | if ( tabs == 0) | 1109 | if ( tabs == 0) |
1110 | { | 1110 | { |
1111 | view = Local_View; | 1111 | view = Local_View; |
1112 | QString path = currentDir.canonicalPath() + "/"; | 1112 | QString path = currentDir.canonicalPath() + "/"; |
1113 | oldName = path + oldName; | 1113 | oldName = path + oldName; |
1114 | newName = path + newName; | 1114 | newName = path + newName; |
1115 | } | 1115 | } |
1116 | else | 1116 | else |
1117 | { | 1117 | { |
1118 | view = Remote_View; | 1118 | view = Remote_View; |
1119 | QString path = currentRemoteDir.canonicalPath() + "/"; | 1119 | QString path = currentRemoteDir.canonicalPath() + "/"; |
1120 | oldName = path + oldName; | 1120 | oldName = path + oldName; |
1121 | newName = path + newName; | 1121 | newName = path + newName; |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | if( view->currentItem() == NULL) | 1124 | if( view->currentItem() == NULL) |
1125 | return; | 1125 | return; |
1126 | if( rename(oldName.latin1(), newName.latin1())== -1) | 1126 | if( rename(oldName.latin1(), newName.latin1())== -1) |
1127 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1127 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1128 | else | 1128 | else |
1129 | oldName = ""; | 1129 | oldName = ""; |
1130 | 1130 | ||
1131 | view->takeItem( view->currentItem() ); | 1131 | view->takeItem( view->currentItem() ); |
1132 | delete view->currentItem(); | 1132 | delete view->currentItem(); |
1133 | if ( tabs == 0) | 1133 | if ( tabs == 0) |
1134 | populateLocalView(); | 1134 | populateLocalView(); |
1135 | else | 1135 | else |
1136 | populateRemoteView(); | 1136 | populateRemoteView(); |
1137 | } | 1137 | } |