Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 215 |
1 files changed, 116 insertions, 99 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index f89ad30..0a9f921 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -7,17 +7,17 @@ | |||
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "inputDialog.h" | ||
14 | #include "output.h" | 13 | #include "output.h" |
15 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
16 | 15 | ||
17 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | ||
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
@@ -230,13 +230,13 @@ void AdvancedFm::localDelete() { | |||
230 | switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+ | 230 | switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+ |
231 | "\nand all it's contents ?" | 231 | "\nand all it's contents ?" |
232 | ,tr("Yes"),tr("No"),0,0,1) ) { | 232 | ,tr("Yes"),tr("No"),0,0,1) ) { |
233 | case 0: { | 233 | case 0: { |
234 | f=f.left(f.length()-1); | 234 | f=f.left(f.length()-1); |
235 | QString cmd="rm -rf "+f; | 235 | QString cmd="rm -rf "+f; |
236 | system( cmd.latin1()); | 236 | startProcess( (const QString)cmd.latin1() ); |
237 | populateLocalView(); | 237 | populateLocalView(); |
238 | } | 238 | } |
239 | break; | 239 | break; |
240 | case 1: | 240 | case 1: |
241 | // exit | 241 | // exit |
242 | break; | 242 | break; |
@@ -252,13 +252,12 @@ void AdvancedFm::localDelete() { | |||
252 | }; | 252 | }; |
253 | } | 253 | } |
254 | QString cmd="rm "+f; | 254 | QString cmd="rm "+f; |
255 | QFile file(f); | 255 | QFile file(f); |
256 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 256 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
257 | file.remove(); | 257 | file.remove(); |
258 | // system( cmd.latin1()); | ||
259 | } | 258 | } |
260 | } | 259 | } |
261 | } | 260 | } |
262 | populateLocalView(); | 261 | populateLocalView(); |
263 | } | 262 | } |
264 | 263 | ||
@@ -295,13 +294,13 @@ void AdvancedFm::remoteDelete() { | |||
295 | switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ | 294 | switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ |
296 | "\nand all it's contents ?", | 295 | "\nand all it's contents ?", |
297 | tr("Yes"),tr("No"),0,0,1) ) { | 296 | tr("Yes"),tr("No"),0,0,1) ) { |
298 | case 0: { | 297 | case 0: { |
299 | f=f.left(f.length()-1); | 298 | f=f.left(f.length()-1); |
300 | QString cmd="rm -rf "+f; | 299 | QString cmd="rm -rf "+f; |
301 | system( cmd.latin1()); | 300 | startProcess( (const QString)cmd ); |
302 | populateRemoteView(); | 301 | populateRemoteView(); |
303 | } | 302 | } |
304 | break; | 303 | break; |
305 | case 1: | 304 | case 1: |
306 | // exit | 305 | // exit |
307 | break; | 306 | break; |
@@ -317,13 +316,12 @@ void AdvancedFm::remoteDelete() { | |||
317 | }; | 316 | }; |
318 | } | 317 | } |
319 | QString cmd="rm "+f; | 318 | QString cmd="rm "+f; |
320 | QFile file(f); | 319 | QFile file(f); |
321 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 320 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
322 | file.remove(); | 321 | file.remove(); |
323 | // system( cmd.latin1()); | ||
324 | } | 322 | } |
325 | } | 323 | } |
326 | } | 324 | } |
327 | populateRemoteView(); | 325 | populateRemoteView(); |
328 | } | 326 | } |
329 | 327 | ||
@@ -807,55 +805,41 @@ bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { | |||
807 | } | 805 | } |
808 | 806 | ||
809 | return success; | 807 | return success; |
810 | } | 808 | } |
811 | 809 | ||
812 | void AdvancedFm::runCommand() { | 810 | void AdvancedFm::runCommand() { |
813 | QString curFile; | 811 | QString curFile; |
814 | if (TabWidget->getCurrentTab() == 0) { | 812 | if (TabWidget->getCurrentTab() == 0) { |
815 | if( Local_View->currentItem()) | 813 | if( Local_View->currentItem()) |
816 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 814 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
817 | } else { | ||
818 | if(Remote_View->currentItem()) | ||
819 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | ||
820 | } | ||
821 | |||
822 | InputDialog *fileDlg; | ||
823 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | ||
824 | fileDlg->setInputText(curFile); | ||
825 | fileDlg->exec(); | ||
826 | QString command; | ||
827 | if( fileDlg->result() == 1 ) { | ||
828 | command = fileDlg->LineEdit1->text(); | ||
829 | |||
830 | Output *outDlg; | ||
831 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | ||
832 | outDlg->showMaximized(); | ||
833 | outDlg->show(); | ||
834 | qApp->processEvents(); | ||
835 | FILE *fp; | ||
836 | char line[130]; | ||
837 | sleep(1); | ||
838 | command +=" 2>&1"; | ||
839 | fp = popen( (const char *) command, "r"); | ||
840 | if ( !fp ) { | ||
841 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
842 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
843 | pclose(fp); | ||
844 | return; | ||
845 | } else { | 815 | } else { |
846 | while ( fgets( line, sizeof line, fp)) { | 816 | if(Remote_View->currentItem()) |
847 | QString lineStr = line; | 817 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
848 | lineStr=lineStr.left(lineStr.length()-1); | ||
849 | outDlg->OutputEdit->append(lineStr); | ||
850 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
851 | } | ||
852 | } | 818 | } |
853 | pclose(fp); | ||
854 | 819 | ||
855 | } | 820 | InputDialog *fileDlg; |
821 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | ||
822 | fileDlg->setInputText(curFile); | ||
823 | fileDlg->exec(); | ||
824 | //QString command; | ||
825 | |||
826 | if( fileDlg->result() == 1 ) { | ||
827 | qDebug(fileDlg->LineEdit1->text()); | ||
828 | QStringList command; | ||
829 | |||
830 | command << "/bin/sh"; | ||
831 | command << "-c"; | ||
832 | command << fileDlg->LineEdit1->text(); | ||
833 | Output *outDlg; | ||
834 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | ||
835 | outDlg->showMaximized(); | ||
836 | outDlg->exec(); | ||
837 | qApp->processEvents(); | ||
838 | |||
839 | } | ||
856 | } | 840 | } |
857 | 841 | ||
858 | void AdvancedFm::runCommandStd() { | 842 | void AdvancedFm::runCommandStd() { |
859 | QString curFile; | 843 | QString curFile; |
860 | if (TabWidget->getCurrentTab() == 0) { | 844 | if (TabWidget->getCurrentTab() == 0) { |
861 | if( Local_View->currentItem()) | 845 | if( Local_View->currentItem()) |
@@ -867,53 +851,66 @@ void AdvancedFm::runCommandStd() { | |||
867 | } | 851 | } |
868 | 852 | ||
869 | InputDialog *fileDlg; | 853 | InputDialog *fileDlg; |
870 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 854 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
871 | fileDlg->setInputText(curFile); | 855 | fileDlg->setInputText(curFile); |
872 | fileDlg->exec(); | 856 | fileDlg->exec(); |
873 | QString command; | 857 | |
874 | if( fileDlg->result() == 1 ) { | 858 | if( fileDlg->result() == 1 ) { |
875 | qApp->processEvents(); | 859 | qApp->processEvents(); |
876 | command = fileDlg->LineEdit1->text() + " &"; | 860 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
877 | system(command.latin1()); | ||
878 | } | 861 | } |
879 | } | 862 | } |
880 | 863 | ||
881 | void AdvancedFm::fileStatus() { | 864 | void AdvancedFm::fileStatus() { |
882 | QString curFile; | 865 | QString curFile; |
883 | if (TabWidget->getCurrentTab() == 0) { | 866 | if (TabWidget->getCurrentTab() == 0) { |
884 | curFile = Local_View->currentItem()->text(0); | 867 | curFile = Local_View->currentItem()->text(0); |
885 | } else { | 868 | } else { |
886 | curFile = Remote_View->currentItem()->text(0); | 869 | curFile = Remote_View->currentItem()->text(0); |
887 | } | 870 | } |
888 | QString command = " stat -l "+ curFile +" 2>&1"; | ||
889 | Output *outDlg; | ||
890 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | ||
891 | outDlg->showMaximized(); | ||
892 | outDlg->show(); | ||
893 | qApp->processEvents(); | ||
894 | FILE *fp; | ||
895 | char line[130]; | ||
896 | sleep(1); | ||
897 | fp = popen( (const char *) command, "r"); | ||
898 | if ( !fp ) { | ||
899 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
900 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
901 | pclose(fp); | ||
902 | return; | ||
903 | } else { | ||
904 | while ( fgets( line, sizeof line, fp)) { | ||
905 | outDlg->OutputEdit->append(line); | ||
906 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
907 | 871 | ||
908 | } | 872 | QStringList command; |
873 | command << "/bin/sh"; | ||
874 | command << "-c"; | ||
875 | command << "stat -l "+ curFile; | ||
909 | 876 | ||
910 | } | 877 | Output *outDlg; |
911 | pclose(fp); | 878 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
879 | outDlg->showMaximized(); | ||
880 | outDlg->exec(); | ||
881 | qApp->processEvents(); | ||
882 | |||
883 | |||
884 | // Output *outDlg; | ||
885 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | ||
886 | // outDlg->showMaximized(); | ||
887 | // outDlg->show(); | ||
888 | // qApp->processEvents(); | ||
889 | |||
890 | // FILE *fp; | ||
891 | // char line[130]; | ||
892 | // sleep(1); | ||
893 | // fp = popen( (const char *) command, "r"); | ||
894 | // if ( !fp ) { | ||
895 | // qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
896 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
897 | // pclose(fp); | ||
898 | // return; | ||
899 | // } else { | ||
900 | // while ( fgets( line, sizeof line, fp)) { | ||
901 | // outDlg->OutputEdit->append(line); | ||
902 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
903 | |||
904 | // } | ||
905 | |||
906 | // } | ||
907 | // pclose(fp); | ||
912 | } | 908 | } |
913 | 909 | ||
910 | |||
914 | void AdvancedFm::mkDir() { | 911 | void AdvancedFm::mkDir() { |
915 | if (TabWidget->getCurrentTab() == 0) | 912 | if (TabWidget->getCurrentTab() == 0) |
916 | localMakDir(); | 913 | localMakDir(); |
917 | else | 914 | else |
918 | remoteMakDir(); | 915 | remoteMakDir(); |
919 | 916 | ||
@@ -932,45 +929,45 @@ void AdvancedFm::del() { | |||
932 | localDelete(); | 929 | localDelete(); |
933 | else | 930 | else |
934 | remoteDelete(); | 931 | remoteDelete(); |
935 | } | 932 | } |
936 | 933 | ||
937 | void AdvancedFm::mkSym() { | 934 | void AdvancedFm::mkSym() { |
938 | QString cmd; | 935 | QString cmd; |
939 | QStringList curFileList = getPath(); | 936 | QStringList curFileList = getPath(); |
940 | if( curFileList.count() > 0) { | 937 | if( curFileList.count() > 0) { |
941 | 938 | ||
942 | if (TabWidget->getCurrentTab() == 0) { | 939 | if (TabWidget->getCurrentTab() == 0) { |
943 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 940 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
944 | 941 | ||
945 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 942 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
946 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 943 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
947 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 944 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
948 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 945 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
949 | cmd = "ln -s "+curFile+" "+destName; | 946 | cmd = "ln -s "+curFile+" "+destName; |
950 | qDebug(cmd); | 947 | qDebug(cmd); |
951 | system(cmd.latin1() ); | 948 | startProcess( (const QString)cmd ); |
952 | } | 949 | } |
953 | populateRemoteView(); | 950 | populateRemoteView(); |
954 | TabWidget->setCurrentTab(1); | 951 | TabWidget->setCurrentTab(1); |
955 | } else { | 952 | } else { |
956 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
957 | 954 | ||
958 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 955 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
959 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 956 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
960 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 957 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
961 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 958 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
962 | 959 | ||
963 | cmd = "ln -s "+curFile+" "+destName; | 960 | cmd = "ln -s "+curFile+" "+destName; |
964 | qDebug(cmd); | 961 | qDebug(cmd); |
965 | system(cmd.latin1() ); | 962 | startProcess( (const QString)cmd ); |
966 | } | 963 | } |
967 | populateLocalView(); | 964 | populateLocalView(); |
968 | TabWidget->setCurrentTab(0); | 965 | TabWidget->setCurrentTab(0); |
966 | } | ||
969 | } | 967 | } |
970 | } | ||
971 | } | 968 | } |
972 | 969 | ||
973 | void AdvancedFm::doBeam() { | 970 | void AdvancedFm::doBeam() { |
974 | Ir ir; | 971 | Ir ir; |
975 | if(!ir.supported()){ | 972 | if(!ir.supported()){ |
976 | } else { | 973 | } else { |
@@ -1015,6 +1012,26 @@ void AdvancedFm::selectAll() { | |||
1015 | Local_View->setSelected( Local_View->firstChild(),false); | 1012 | Local_View->setSelected( Local_View->firstChild(),false); |
1016 | } else { | 1013 | } else { |
1017 | Remote_View->selectAll(true); | 1014 | Remote_View->selectAll(true); |
1018 | Remote_View->setSelected( Remote_View->firstChild(),false); | 1015 | Remote_View->setSelected( Remote_View->firstChild(),false); |
1019 | } | 1016 | } |
1020 | } | 1017 | } |
1018 | |||
1019 | void AdvancedFm::startProcess(const QString & cmd) { | ||
1020 | QStringList command; | ||
1021 | OProcess *process; | ||
1022 | process = new OProcess(); | ||
1023 | connect(process, SIGNAL(processExited(OProcess *)), | ||
1024 | this, SLOT( processEnded())); | ||
1025 | |||
1026 | command << "/bin/sh"; | ||
1027 | command << "-c"; | ||
1028 | command << cmd.latin1(); | ||
1029 | *process << command; | ||
1030 | if(!process->start(OProcess::NotifyOnExit) ) | ||
1031 | qDebug("could not start process"); | ||
1032 | } | ||
1033 | |||
1034 | void AdvancedFm::processEnded() { | ||
1035 | populateLocalView(); | ||
1036 | populateRemoteView(); | ||
1037 | } | ||