summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp362
1 files changed, 188 insertions, 174 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 818a281..b169a79 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -814,783 +814,797 @@ void AdvancedFm::remoteDelete()
814 populateRemoteView(); 814 populateRemoteView();
815 } 815 }
816 break; 816 break;
817 case 1: 817 case 1:
818 // exit 818 // exit
819 break; 819 break;
820 }; 820 };
821 821
822 } else { 822 } else {
823 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 823 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
824 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 824 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
825 case 0: { 825 case 0: {
826 QString cmd="rm "+f; 826 QString cmd="rm "+f;
827 QFile file(f); 827 QFile file(f);
828 file.remove(); 828 file.remove();
829 // system( cmd.latin1()); 829 // system( cmd.latin1());
830 populateRemoteView(); 830 populateRemoteView();
831 } 831 }
832 break; 832 break;
833 case 1: 833 case 1:
834 // exit 834 // exit
835 break; 835 break;
836 }; 836 };
837 } 837 }
838 } 838 }
839 } 839 }
840} 840}
841 841
842void AdvancedFm::localRename() 842void AdvancedFm::localRename()
843{ 843{
844 QString curFile = Local_View->currentItem()->text(0); 844 QString curFile = Local_View->currentItem()->text(0);
845 qDebug("currentItem "+curFile); 845 qDebug("currentItem "+curFile);
846 if( curFile !="../") { 846 if( curFile !="../") {
847 InputDialog *fileDlg; 847 InputDialog *fileDlg;
848 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 848 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
849 fileDlg->setInputText((const QString &)curFile); 849 fileDlg->setInputText((const QString &)curFile);
850 fileDlg->exec(); 850 fileDlg->exec();
851 if( fileDlg->result() == 1 ) { 851 if( fileDlg->result() == 1 ) {
852 QString oldname = currentDir.canonicalPath() + "/" + curFile; 852 QString oldname = currentDir.canonicalPath() + "/" + curFile;
853 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 853 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
854 if( rename(oldname.latin1(), newName.latin1())== -1) 854 if( rename(oldname.latin1(), newName.latin1())== -1)
855 QMessageBox::message(tr("Note"),tr("Could not rename")); 855 QMessageBox::message(tr("Note"),tr("Could not rename"));
856 } 856 }
857 populateLocalView(); 857 populateLocalView();
858 } 858 }
859} 859}
860 860
861void AdvancedFm::remoteRename() 861void AdvancedFm::remoteRename()
862{ 862{
863 QString curFile = Remote_View->currentItem()->text(0); 863 QString curFile = Remote_View->currentItem()->text(0);
864 if( curFile !="../") { 864 if( curFile !="../") {
865 InputDialog *fileDlg; 865 InputDialog *fileDlg;
866 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 866 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
867 fileDlg->setInputText((const QString &)curFile); 867 fileDlg->setInputText((const QString &)curFile);
868 fileDlg->exec(); 868 fileDlg->exec();
869 if( fileDlg->result() == 1 ) { 869 if( fileDlg->result() == 1 ) {
870 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; 870 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
871 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 871 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
872 if( rename(oldname.latin1(), newName.latin1())== -1) 872 if( rename(oldname.latin1(), newName.latin1())== -1)
873 QMessageBox::message(tr("Note"),tr("Could not rename")); 873 QMessageBox::message(tr("Note"),tr("Could not rename"));
874 } 874 }
875 populateRemoteView(); 875 populateRemoteView();
876 } 876 }
877} 877}
878 878
879void AdvancedFm::switchToLocalTab() 879void AdvancedFm::switchToLocalTab()
880{ 880{
881 TabWidget->setCurrentPage(0); 881 TabWidget->setCurrentPage(0);
882 Local_View->setFocus(); 882 Local_View->setFocus();
883} 883}
884 884
885void AdvancedFm::switchToRemoteTab() 885void AdvancedFm::switchToRemoteTab()
886{ 886{
887 TabWidget->setCurrentPage(1); 887 TabWidget->setCurrentPage(1);
888 Remote_View->setFocus(); 888 Remote_View->setFocus();
889} 889}
890 890
891void AdvancedFm::readConfig() 891void AdvancedFm::readConfig()
892{ 892{
893 Config cfg("AdvancedFm"); 893 Config cfg("AdvancedFm");
894} 894}
895 895
896void AdvancedFm::writeConfig() 896void AdvancedFm::writeConfig()
897{ 897{
898 Config cfg("AdvancedFm"); 898 Config cfg("AdvancedFm");
899} 899}
900 900
901void AdvancedFm::currentPathComboChanged() 901void AdvancedFm::currentPathComboChanged()
902{ 902{
903 if (TabWidget->currentPageIndex() == 0) { 903 if (TabWidget->currentPageIndex() == 0) {
904 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 904 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
905 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 905 currentDir.setPath( currentPathCombo->lineEdit()->text() );
906 populateLocalView(); 906 populateLocalView();
907 } else { 907 } else {
908 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 908 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
909 } 909 }
910 } 910 }
911 if (TabWidget->currentPageIndex() == 0) { 911 if (TabWidget->currentPageIndex() == 0) {
912 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 912 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
913 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 913 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
914 populateRemoteView(); 914 populateRemoteView();
915 } else { 915 } else {
916 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 916 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
917 } 917 }
918 } 918 }
919} 919}
920 920
921void AdvancedFm::fillCombo(const QString &currentPath) { 921void AdvancedFm::fillCombo(const QString &currentPath) {
922 922
923 if (TabWidget->currentPageIndex() == 0) { 923 if (TabWidget->currentPageIndex() == 0) {
924 currentPathCombo->lineEdit()->setText( currentPath); 924 currentPathCombo->lineEdit()->setText( currentPath);
925 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 925 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
926 currentPathCombo->clear(); 926 currentPathCombo->clear();
927 localDirPathStringList.prepend( currentPath ); 927 localDirPathStringList.prepend( currentPath );
928 currentPathCombo->insertStringList( localDirPathStringList,-1); 928 currentPathCombo->insertStringList( localDirPathStringList,-1);
929 } 929 }
930 } else { 930 } else {
931 currentPathCombo->lineEdit()->setText( currentPath); 931 currentPathCombo->lineEdit()->setText( currentPath);
932 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 932 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
933 currentPathCombo->clear(); 933 currentPathCombo->clear();
934 remoteDirPathStringList.prepend( currentPath ); 934 remoteDirPathStringList.prepend( currentPath );
935 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 935 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
936 } 936 }
937 } 937 }
938} 938}
939 939
940void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 940void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
941 if (TabWidget->currentPageIndex() == 0) { 941 if (TabWidget->currentPageIndex() == 0) {
942 chdir( currentPath.latin1() ); 942 chdir( currentPath.latin1() );
943 currentDir.cd( currentPath, TRUE); 943 currentDir.cd( currentPath, TRUE);
944 populateLocalView(); 944 populateLocalView();
945 update(); 945 update();
946 } else { 946 } else {
947 chdir( currentPath.latin1() ); 947 chdir( currentPath.latin1() );
948 currentRemoteDir.cd( currentPath, TRUE); 948 currentRemoteDir.cd( currentPath, TRUE);
949 populateRemoteView(); 949 populateRemoteView();
950 update(); 950 update();
951 } 951 }
952} 952}
953 953
954void AdvancedFm::filePerms() { 954void AdvancedFm::filePerms() {
955 955
956 QStringList curFileList = getPath(); 956 QStringList curFileList = getPath();
957 QString filePath; 957 QString filePath;
958 958
959 if (TabWidget->currentPageIndex() == 0) { 959 if (TabWidget->currentPageIndex() == 0) {
960 filePath = currentDir.canonicalPath()+"/"; 960 filePath = currentDir.canonicalPath()+"/";
961 } else { 961 } else {
962 filePath= currentRemoteDir.canonicalPath()+"/"; 962 filePath= currentRemoteDir.canonicalPath()+"/";
963 } 963 }
964 964
965 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 965 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
966 filePermissions *filePerm; 966 filePermissions *filePerm;
967 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 967 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
968 filePerm->showMaximized(); 968 filePerm->showMaximized();
969 filePerm->exec(); 969 filePerm->exec();
970 if( filePerm) 970 if( filePerm)
971 delete filePerm; 971 delete filePerm;
972 } 972 }
973 if (TabWidget->currentPageIndex() == 0) { 973 if (TabWidget->currentPageIndex() == 0) {
974 populateLocalView(); 974 populateLocalView();
975 } else { 975 } else {
976 populateRemoteView(); 976 populateRemoteView();
977 } 977 }
978} 978}
979 979
980void AdvancedFm::doProperties() { 980void AdvancedFm::doProperties() {
981 QStringList curFileList = getPath(); 981 QStringList curFileList = getPath();
982 QString filePath; 982 QString filePath;
983 if (TabWidget->currentPageIndex() == 0) { 983 if (TabWidget->currentPageIndex() == 0) {
984 filePath = currentDir.canonicalPath()+"/"; 984 filePath = currentDir.canonicalPath()+"/";
985 } else { 985 } else {
986 filePath= currentRemoteDir.canonicalPath()+"/"; 986 filePath= currentRemoteDir.canonicalPath()+"/";
987 } 987 }
988 // qDebug("%d",curFileList.count()); 988 // qDebug("%d",curFileList.count());
989 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 989 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
990 qDebug((filePath+*it)); 990 qDebug((filePath+*it));
991 DocLnk lnk( (filePath+*it)); 991 DocLnk lnk( (filePath+*it));
992 LnkProperties prop( &lnk ); 992 LnkProperties prop( &lnk );
993 prop.showMaximized(); 993 prop.showMaximized();
994 prop.exec(); 994 prop.exec();
995 } 995 }
996} 996}
997 997
998QStringList AdvancedFm::getPath() { 998QStringList AdvancedFm::getPath() {
999 QStringList strList; 999 QStringList strList;
1000 if (TabWidget->currentPageIndex() == 0) { 1000 if (TabWidget->currentPageIndex() == 0) {
1001 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 1001 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
1002 QListViewItemIterator it( Local_View ); 1002 QListViewItemIterator it( Local_View );
1003 for ( ; it.current(); ++it ) { 1003 for ( ; it.current(); ++it ) {
1004 if ( it.current()->isSelected() ) { 1004 if ( it.current()->isSelected() ) {
1005 strList << it.current()->text(0); 1005 strList << it.current()->text(0);
1006 qDebug(it.current()->text(0));
1006 } 1007 }
1007 } 1008 }
1008 return strList; 1009 return strList;
1009 } else { 1010 } else {
1010 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 1011 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
1011 QListViewItemIterator it( Remote_View ); 1012 QListViewItemIterator it( Remote_View );
1012 for ( ; it.current(); ++it ) { 1013 for ( ; it.current(); ++it ) {
1013 if ( it.current()->isSelected() ) { 1014 if ( it.current()->isSelected() ) {
1014 strList << it.current()->text(0); 1015 strList << it.current()->text(0);
1016 qDebug(it.current()->text(0));
1015 } 1017 }
1016 } 1018 }
1017 return strList; 1019 return strList;
1018 } 1020 }
1019 return ""; 1021 return "";
1020} 1022}
1021 1023
1022void AdvancedFm::homeButtonPushed() { 1024void AdvancedFm::homeButtonPushed() {
1023 QString current = QDir::homeDirPath(); 1025 QString current = QDir::homeDirPath();
1024 chdir( current.latin1() ); 1026 chdir( current.latin1() );
1025 if (TabWidget->currentPageIndex() == 0) { 1027 if (TabWidget->currentPageIndex() == 0) {
1026 currentDir.cd( current, TRUE); 1028 currentDir.cd( current, TRUE);
1027 populateLocalView(); 1029 populateLocalView();
1028 } else { 1030 } else {
1029 currentRemoteDir.cd( current, TRUE); 1031 currentRemoteDir.cd( current, TRUE);
1030 populateRemoteView(); 1032 populateRemoteView();
1031 } 1033 }
1032 update(); 1034 update();
1033} 1035}
1034 1036
1035void AdvancedFm::docButtonPushed() { 1037void AdvancedFm::docButtonPushed() {
1036 QString current = QPEApplication::documentDir(); 1038 QString current = QPEApplication::documentDir();
1037 chdir( current.latin1() ); 1039 chdir( current.latin1() );
1038 if (TabWidget->currentPageIndex() == 0) { 1040 if (TabWidget->currentPageIndex() == 0) {
1039 currentDir.cd( current, TRUE); 1041 currentDir.cd( current, TRUE);
1040 populateLocalView(); 1042 populateLocalView();
1041 } else { 1043 } else {
1042 currentRemoteDir.cd( current, TRUE); 1044 currentRemoteDir.cd( current, TRUE);
1043 populateRemoteView(); 1045 populateRemoteView();
1044 } 1046 }
1045 update(); 1047 update();
1046} 1048}
1047 1049
1048void AdvancedFm::SDButtonPushed() { 1050void AdvancedFm::SDButtonPushed() {
1049 QString current = "/mnt/card"; 1051 QString current = "/mnt/card";
1050 chdir( current.latin1() ); 1052 chdir( current.latin1() );
1051 if (TabWidget->currentPageIndex() == 0) { 1053 if (TabWidget->currentPageIndex() == 0) {
1052 currentDir.cd( current, TRUE); 1054 currentDir.cd( current, TRUE);
1053 populateLocalView(); 1055 populateLocalView();
1054 } else { 1056 } else {
1055 currentRemoteDir.cd( current, TRUE); 1057 currentRemoteDir.cd( current, TRUE);
1056 populateRemoteView(); 1058 populateRemoteView();
1057 } 1059 }
1058 update(); 1060 update();
1059 1061
1060} 1062}
1061 1063
1062void AdvancedFm::CFButtonPushed() { 1064void AdvancedFm::CFButtonPushed() {
1063 QString current = "/mnt/cf"; 1065 QString current = "/mnt/cf";
1064 chdir( current.latin1() ); 1066 chdir( current.latin1() );
1065 if (TabWidget->currentPageIndex() == 0) { 1067 if (TabWidget->currentPageIndex() == 0) {
1066 currentDir.cd( current, TRUE); 1068 currentDir.cd( current, TRUE);
1067 populateLocalView(); 1069 populateLocalView();
1068 } else { 1070 } else {
1069 currentRemoteDir.cd( current, TRUE); 1071 currentRemoteDir.cd( current, TRUE);
1070 populateRemoteView(); 1072 populateRemoteView();
1071 } 1073 }
1072 update(); 1074 update();
1073 1075
1074} 1076}
1075 1077
1076 1078
1077void AdvancedFm::upDir() 1079void AdvancedFm::upDir()
1078{ 1080{
1079 if (TabWidget->currentPageIndex() == 0) { 1081 if (TabWidget->currentPageIndex() == 0) {
1080 QString current = currentDir.canonicalPath(); 1082 QString current = currentDir.canonicalPath();
1081 QDir dir(current); 1083 QDir dir(current);
1082 dir.cdUp(); 1084 dir.cdUp();
1083 current = dir.canonicalPath(); 1085 current = dir.canonicalPath();
1084 chdir( current.latin1() ); 1086 chdir( current.latin1() );
1085 currentDir.cd( current, TRUE); 1087 currentDir.cd( current, TRUE);
1086 populateLocalView(); 1088 populateLocalView();
1087 update(); 1089 update();
1088 } else { 1090 } else {
1089 QString current = currentRemoteDir.canonicalPath(); 1091 QString current = currentRemoteDir.canonicalPath();
1090 QDir dir(current); 1092 QDir dir(current);
1091 dir.cdUp(); 1093 dir.cdUp();
1092 current = dir.canonicalPath(); 1094 current = dir.canonicalPath();
1093 chdir( current.latin1() ); 1095 chdir( current.latin1() );
1094 currentRemoteDir.cd( current, TRUE); 1096 currentRemoteDir.cd( current, TRUE);
1095 populateRemoteView(); 1097 populateRemoteView();
1096 update(); 1098 update();
1097 } 1099 }
1098} 1100}
1099 1101
1100void AdvancedFm::copy() 1102void AdvancedFm::copy()
1101{ 1103{
1104 qApp->processEvents();
1102 QStringList curFileList = getPath(); 1105 QStringList curFileList = getPath();
1103 if( curFileList.count() > 0) { 1106 if( curFileList.count() > 0) {
1104 QString curFile; 1107 QString curFile;
1105 if (TabWidget->currentPageIndex() == 0) { 1108 if (TabWidget->currentPageIndex() == 0) {
1106 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1109 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1107 1110
1108 QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1111 QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1112 qDebug("Destination file is "+destFile);
1113
1109 curFile = currentDir.canonicalPath()+"/"+(*it); 1114 curFile = currentDir.canonicalPath()+"/"+(*it);
1115 qDebug("CurrentFile file is " + curFile);
1116
1110 QFile f(destFile); 1117 QFile f(destFile);
1111 if( f.exists()) { 1118 if( f.exists()) {
1112 switch ( QMessageBox::warning(this,tr("Delete"), 1119 switch ( QMessageBox::warning(this,tr("Delete"),
1113 destFile+tr(" already exists\nDo you really want to delete it?"), 1120 destFile+tr(" already exists\nDo you really want to delete it?"),
1114 tr("Yes"),tr("No"),0,0,1) ) { 1121 tr("Yes"),tr("No"),0,0,1) ) {
1115 case 0: 1122 case 0:
1116 f.remove(); 1123 f.remove();
1117 break; 1124 break;
1118 case 1: 1125 case 1:
1119 return; 1126 return;
1120 break; 1127 break;
1121 }; 1128 };
1122 } 1129 }
1123 if(!copyFile(destFile, curFile) ) { 1130 if(!copyFile(destFile, curFile) ) {
1124 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1131 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1125 qWarning("nothin doing"); 1132 qWarning("nothin doing");
1126 } 1133 }
1127 } 1134 }
1128 populateRemoteView(); 1135 populateRemoteView();
1129 TabWidget->setCurrentPage(1); 1136 TabWidget->setCurrentPage(1);
1130 1137
1131 } else { 1138 } else {
1132 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1139 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1133 1140
1134 QString destFile = currentDir.canonicalPath()+"/"+(*it); 1141 QString destFile = currentDir.canonicalPath()+"/"+(*it);
1142 qDebug("Destination file is "+destFile);
1135 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1143 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1144 qDebug("CurrentFile file is " + curFile);
1136 1145
1137 QFile f(destFile); 1146 QFile f(destFile);
1138 if( f.exists()) { 1147 if( f.exists()) {
1139 switch ( QMessageBox::warning(this,tr("Delete"), 1148 switch ( QMessageBox::warning(this,tr("Delete"),
1140 destFile+tr(" already exists\nDo you really want to delete it?"), 1149 destFile+tr(" already exists\nDo you really want to delete it?"),
1141 tr("Yes"),tr("No"),0,0,1) ) { 1150 tr("Yes"),tr("No"),0,0,1) ) {
1142 case 0: 1151 case 0:
1143 f.remove(); 1152 f.remove();
1144 break; 1153 break;
1145 case 1: 1154 case 1:
1146 return; 1155 return;
1147 break; 1156 break;
1148 }; 1157 };
1149 } 1158 }
1150 if(!copyFile(destFile, curFile) ) { 1159 if(!copyFile(destFile, curFile) ) {
1151 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); 1160 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1152 1161
1153 qWarning("nothin doing"); 1162 qWarning("nothin doing");
1154 } 1163 }
1155 } 1164 }
1156 populateLocalView(); 1165 populateLocalView();
1157 TabWidget->setCurrentPage(0); 1166 TabWidget->setCurrentPage(0);
1158 } 1167 }
1168
1159 } 1169 }
1160} 1170}
1161 1171
1162void AdvancedFm::copyAs() 1172void AdvancedFm::copyAs() {
1163{ 1173 qApp->processEvents();
1174
1164 QStringList curFileList = getPath(); 1175 QStringList curFileList = getPath();
1165 if( curFileList.count() > 0) { 1176 QString curFile;
1166 QString curFile; 1177 InputDialog *fileDlg;
1167 InputDialog *fileDlg; 1178 if (TabWidget->currentPageIndex() == 0) {
1168 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1179 qDebug("tab 1");
1180 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1181 QString destFile;
1182 curFile = currentDir.canonicalPath()+"/"+(*it);
1183 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
1169 1184
1170 if (TabWidget->currentPageIndex() == 0) { 1185 fileDlg->setInputText((const QString &) destFile );
1171 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1186 fileDlg->exec();
1172 QString destFile; 1187
1173 curFile = currentDir.canonicalPath()+"/"+(*it); 1188 if( fileDlg->result() == 1 ) {
1174 fileDlg->setInputText((const QString &) destFile ); 1189 QString filename = fileDlg->LineEdit1->text();
1175 fileDlg->exec(); 1190 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
1176 if( fileDlg->result() == 1 ) { 1191
1177 QString filename = fileDlg->LineEdit1->text(); 1192 QFile f(destFile);
1178 destFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1193 if( f.exists()) {
1179 1194 switch (QMessageBox::warning(this,tr("Delete"),
1180 QFile f(destFile); 1195 destFile+tr(" already exists\nDo you really want to delete it?"),
1181 if( f.exists()) { 1196 tr("Yes"),tr("No"),0,0,1) ) {
1182 switch (QMessageBox::warning(this,tr("Delete"), 1197 case 0:
1183 destFile+tr(" already exists\nDo you really want to delete it?"), 1198 f.remove();
1184 tr("Yes"),tr("No"),0,0,1) ) { 1199 break;
1185 case 0: 1200 case 1:
1186 f.remove(); 1201 return;
1187 break; 1202 break;
1188 case 1: 1203 };
1189 return; 1204 }
1190 break; 1205 if(!copyFile(destFile, curFile) ) {
1191 }; 1206 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1192 } 1207 qWarning("nothin doing");
1193 if(!copyFile(destFile, curFile) ) {
1194 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1195 qWarning("nothin doing");
1196 }
1197 } 1208 }
1198 } 1209 }
1199 populateRemoteView(); 1210 delete fileDlg;
1200 TabWidget->setCurrentPage(1);
1201 } else {
1202 if (TabWidget->currentPageIndex() == 0) {
1203 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1204 1211
1205 curFile = currentDir.canonicalPath()+"/"+(*it); 1212 }
1206 QString destFile; 1213 populateRemoteView();
1207 fileDlg->setInputText((const QString &) destFile); 1214 TabWidget->setCurrentPage(1);
1208 fileDlg->exec(); 1215
1209 if( fileDlg->result() == 1 ) { 1216 } else {
1210 QString filename = fileDlg->LineEdit1->text(); 1217 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1211 destFile = currentDir.canonicalPath()+"/"+(*it); 1218
1212 1219 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1213 QFile f(destFile); 1220 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
1214 if( f.exists()) { 1221
1215 switch ( QMessageBox::warning(this,tr("Delete"), 1222 QString destFile;
1216 destFile+tr(" already exists\nDo you really want to delete it?"), 1223 fileDlg->setInputText((const QString &) destFile);
1217 tr("Yes"),tr("No"),0,0,1) ) { 1224 fileDlg->exec();
1218 case 0: 1225
1219 f.remove(); 1226 if( fileDlg->result() == 1 ) {
1220 break; 1227 QString filename = fileDlg->LineEdit1->text();
1221 case 1: 1228 destFile = currentDir.canonicalPath()+"/"+filename;
1222 return; 1229
1223 break; 1230 QFile f( destFile);
1224 }; 1231 if( f.exists()) {
1225 } 1232 switch ( QMessageBox::warning(this,tr("Delete"),
1226 if(!copyFile(destFile, curFile) ) { 1233 destFile+tr(" already exists\nDo you really want to delete it?"),
1227 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); 1234 tr("Yes"),tr("No"),0,0,1) ) {
1228 qWarning("nothin doing"); 1235 case 0:
1229 } 1236 f.remove();
1230 1237 break;
1231 } 1238 case 1:
1239 return;
1240 break;
1241 };
1232 } 1242 }
1233 populateLocalView(); 1243 if(!copyFile(destFile, curFile) ) {
1234 TabWidget->setCurrentPage(0); 1244 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1245 qWarning("nothin doing");
1246 }
1247
1235 } 1248 }
1249 delete fileDlg;
1250
1236 } 1251 }
1252 populateLocalView();
1253 TabWidget->setCurrentPage(0);
1237 } 1254 }
1238
1239} 1255}
1240 1256
1241void AdvancedFm::copySameDir() { 1257void AdvancedFm::copySameDir() {
1258 qApp->processEvents();
1242 QStringList curFileList = getPath(); 1259 QStringList curFileList = getPath();
1243 if( curFileList.count() > 0) { 1260 QString curFile;
1244 QString curFile; 1261 InputDialog *fileDlg;
1245 InputDialog *fileDlg;
1246 1262
1247 if (TabWidget->currentPageIndex() == 0) { 1263 if (TabWidget->currentPageIndex() == 0) {
1248 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1264
1249 QString destFile; 1265 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1250 curFile = currentDir.canonicalPath()+"/"+(*it); 1266
1251 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 1267 QString destFile;
1252 fileDlg->setInputText((const QString &) destFile ); 1268 curFile = currentDir.canonicalPath()+"/"+(*it);
1253 fileDlg->exec(); 1269
1254 if( fileDlg->result() == 1 ) { 1270 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
1255 QString filename = fileDlg->LineEdit1->text(); 1271 fileDlg->setInputText((const QString &) destFile );
1256 destFile = currentDir.canonicalPath()+"/"+filename; 1272 fileDlg->exec();
1257 1273
1258 QFile f(destFile); 1274 if( fileDlg->result() == 1 ) {
1259 if( f.exists()) { 1275
1260 switch (QMessageBox::warning(this,tr("Delete"), 1276 QString filename = fileDlg->LineEdit1->text();
1261 destFile+tr(" already exists\nDo you really want to delete it?"), 1277 destFile = currentDir.canonicalPath()+"/"+filename;
1262 tr("Yes"),tr("No"),0,0,1) ) { 1278
1263 case 0: 1279 QFile f(destFile);
1264 qDebug(""); 1280 if( f.exists()) {
1265 f.remove(); 1281 switch (QMessageBox::warning(this,tr("Delete"),
1266 break; 1282 destFile+tr(" already exists\nDo you really want to delete it?"),
1267 case 1: 1283 tr("Yes"),tr("No"),0,0,1) ) {
1268 return; 1284 case 0:
1269 break; 1285 qDebug("");
1270 }; 1286 f.remove();
1271 } 1287 break;
1272 if(!copyFile(destFile, curFile) ) { 1288 case 1:
1273 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); 1289 return;
1274 qWarning("nothin doing"); 1290 break;
1275 } 1291 };
1276
1277 qDebug("copy "+curFile+" as "+destFile);
1278 } 1292 }
1279 delete fileDlg; 1293 if(!copyFile(destFile, curFile) ) {
1294 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1295 qWarning("nothin doing");
1296 }
1297
1298 qDebug("copy "+curFile+" as "+destFile);
1280 } 1299 }
1281 populateRemoteView(); 1300 delete fileDlg;
1282 TabWidget->setCurrentPage(1); 1301 }
1283 } else { 1302 populateLocalView();
1284 if (TabWidget->currentPageIndex() == 0) {
1285 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1286 1303
1287 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1304 } else {
1288 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 1305 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1289 QString destFile; 1306
1290 fileDlg->setInputText((const QString &) destFile); 1307 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1291 fileDlg->exec(); 1308
1292 if( fileDlg->result() == 1 ) { 1309 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
1293 QString filename = fileDlg->LineEdit1->text(); 1310 QString destFile;
1294 destFile = currentDir.canonicalPath()+"/"+filename; 1311 fileDlg->setInputText((const QString &) destFile);
1295 1312 fileDlg->exec();
1296 QFile f(destFile); 1313 if( fileDlg->result() == 1 ) {
1297 if( f.exists()) { 1314 QString filename = fileDlg->LineEdit1->text();
1298 switch ( QMessageBox::warning(this,tr("Delete"), 1315
1299 destFile+tr(" already exists\nDo you really want to delete it?"), 1316 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
1300 tr("Yes"),tr("No"),0,0,1) ) { 1317
1301 case 0: 1318 QFile f(destFile);
1302 f.remove(); 1319 if( f.exists()) {
1303 break; 1320 switch ( QMessageBox::warning(this,tr("Delete"),
1304 case 1: 1321 destFile+tr(" already exists\nDo you really want to delete it?"),
1305 return; 1322 tr("Yes"),tr("No"),0,0,1) ) {
1306 break; 1323 case 0:
1307 }; 1324 f.remove();
1308 } 1325 break;
1309 if(!copyFile(destFile, curFile) ) { 1326 case 1:
1310 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile); 1327 return;
1311 qWarning("nothin doing"); 1328 break;
1312 } 1329 };
1313 qDebug("copy "+curFile+" as "+destFile);
1314 }
1315 delete fileDlg;
1316 } 1330 }
1317 populateLocalView(); 1331 if(!copyFile(destFile, curFile) ) {
1318 TabWidget->setCurrentPage(0); 1332 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1333 qWarning("nothin doing");
1334 }
1335 qDebug("copy "+curFile+" as "+destFile);
1319 } 1336 }
1337 delete fileDlg;
1320 } 1338 }
1339 populateRemoteView();
1321 } 1340 }
1322
1323} 1341}
1324 1342
1325void AdvancedFm::move() { 1343void AdvancedFm::move() {
1344 qApp->processEvents();
1326 1345
1327 QStringList curFileList = getPath(); 1346 QStringList curFileList = getPath();
1328 if( curFileList.count() > 0) { 1347 if( curFileList.count() > 0) {
1329 QString curFile; 1348 QString curFile;
1330 // qDebug(curFile);
1331 QString destFile; 1349 QString destFile;
1332 1350
1333 if (TabWidget->currentPageIndex() == 0) { 1351 if (TabWidget->currentPageIndex() == 0) {
1352
1334 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1353 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1354
1335 QString destFile = currentRemoteDir.canonicalPath(); 1355 QString destFile = currentRemoteDir.canonicalPath();
1356
1336 if(destFile.right(1).find("/",0,TRUE) == -1) 1357 if(destFile.right(1).find("/",0,TRUE) == -1)
1337 destFile+="/"; 1358 destFile+="/";
1338 destFile +=(*it); 1359 destFile +=(*it);
1339 curFile = currentDir.canonicalPath(); 1360 curFile = currentDir.canonicalPath();
1361
1340 qDebug("Destination file is "+destFile); 1362 qDebug("Destination file is "+destFile);
1363
1341 if(curFile.right(1).find("/",0,TRUE) == -1) 1364 if(curFile.right(1).find("/",0,TRUE) == -1)
1342 curFile +="/"; 1365 curFile +="/";
1366
1343 curFile+=(*it); 1367 curFile+=(*it);
1368 qDebug("CurrentFile file is " + curFile);
1344 1369
1345 QFile f(destFile); 1370 QFile f( curFile);
1346 if( f.exists()) { 1371 if( f.exists()) {
1347 switch (QMessageBox::warning(this,tr("Delete"),
1348 destFile+tr(" already exists\nDo you really want to delete it?"),
1349 tr("Yes"),tr("No"),0,0,1) ) {
1350 case 0:
1351 f.remove();
1352 break;
1353 case 1:
1354 return;
1355 break;
1356 };
1357 if(!copyFile( destFile, curFile) ) { 1372 if(!copyFile( destFile, curFile) ) {
1358 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 1373 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
1359 return; 1374 return;
1360 } 1375 } else
1361 QFile::remove(curFile); 1376 QFile::remove(curFile);
1362 } 1377 }
1363 } 1378 }
1379
1364 TabWidget->setCurrentPage(1); 1380 TabWidget->setCurrentPage(1);
1365 } else { 1381
1382 } else { //view 2
1383
1366 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1384 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1367 QString destFile = currentRemoteDir.canonicalPath(); 1385
1386 QString destFile = currentDir.canonicalPath();
1387
1368 if(destFile.right(1).find("/",0,TRUE) == -1) 1388 if(destFile.right(1).find("/",0,TRUE) == -1)
1369 destFile+="/"; 1389 destFile+="/";
1390
1370 destFile +=(*it); 1391 destFile +=(*it);
1392
1371 qDebug("Destination file is "+destFile); 1393 qDebug("Destination file is "+destFile);
1372 curFile = currentDir.canonicalPath(); 1394
1395 curFile = currentRemoteDir.canonicalPath();
1396
1373 if(curFile.right(1).find("/",0,TRUE) == -1) 1397 if(curFile.right(1).find("/",0,TRUE) == -1)
1374 curFile +="/"; 1398 curFile +="/";
1375 curFile+=(*it); 1399 curFile+=(*it);
1400 qDebug("CurrentFile file is " + curFile);
1376 1401
1377 QFile f(destFile); 1402 QFile f( curFile);
1378 if( f.exists()) { 1403 if( f.exists()) {
1379 switch (QMessageBox::warning(this,tr("Delete"), 1404 if(!copyFile( destFile, curFile) ) {
1380 destFile+tr(" already exists\nDo you really want to delete it?"), 1405 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
1381 tr("Yes"),tr("No"),0,0,1) ) {
1382 case 0:
1383 f.remove();
1384 break;
1385 case 1:
1386 return;
1387 break;
1388 };
1389 if(!copyFile(destFile, curFile) ) {
1390 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
1391 return; 1406 return;
1392 } 1407 } else
1408 QFile::remove( curFile);
1393 } 1409 }
1394 QFile::remove(curFile);
1395 TabWidget->setCurrentPage(0); 1410 TabWidget->setCurrentPage(0);
1396 } 1411 }
1397 } 1412 }
1398 populateRemoteView(); 1413 populateRemoteView();
1399 populateLocalView(); 1414 populateLocalView();
1400 } 1415 }
1401} 1416}
1402 1417
1403bool AdvancedFm::copyFile( const QString & dest, const QString & src ) 1418bool AdvancedFm::copyFile( const QString & dest, const QString & src ) {
1404{
1405 char bf[ 50000 ]; 1419 char bf[ 50000 ];
1406 int bytesRead; 1420 int bytesRead;
1407 bool success = TRUE; 1421 bool success = TRUE;
1408 struct stat status; 1422 struct stat status;
1409 1423
1410 QFile s( src ); 1424 QFile s( src );
1411 QFile d( dest ); 1425 QFile d( dest );
1412 1426
1413 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { 1427 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
1414 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { 1428 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
1415 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 1429 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
1416 success = FALSE; 1430 success = FALSE;
1417 break; 1431 break;
1418 } 1432 }
1419 } 1433 }
1420 if( success && (bytesRead > 0) ){ 1434 if( success && (bytesRead > 0) ){
1421 d.writeBlock( bf, bytesRead ); 1435 d.writeBlock( bf, bytesRead );
1422 } 1436 }
1423 } else { 1437 } else {
1424 success = FALSE; 1438 success = FALSE;
1425 } 1439 }
1426 1440
1427 // Set file permissions 1441 // Set file permissions
1428 if( stat( (const char *) src, &status ) == 0 ){ 1442 if( stat( (const char *) src, &status ) == 0 ){
1429 chmod( (const char *) dest, status.st_mode ); 1443 chmod( (const char *) dest, status.st_mode );
1430 } 1444 }
1431 1445
1432 return success; 1446 return success;
1433} 1447}
1434 1448
1435void AdvancedFm::runCommand() { 1449void AdvancedFm::runCommand() {
1436 QString curFile; 1450 QString curFile;
1437 if (TabWidget->currentPageIndex() == 0) { 1451 if (TabWidget->currentPageIndex() == 0) {
1438 if( Local_View->currentItem()) 1452 if( Local_View->currentItem())
1439 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 1453 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
1440 } else { 1454 } else {
1441 if(Remote_View->currentItem()) 1455 if(Remote_View->currentItem())
1442 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); 1456 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
1443 } 1457 }
1444 1458
1445 InputDialog *fileDlg; 1459 InputDialog *fileDlg;
1446 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 1460 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1447 fileDlg->setInputText(curFile); 1461 fileDlg->setInputText(curFile);
1448 fileDlg->exec(); 1462 fileDlg->exec();
1449 QString command; 1463 QString command;
1450 if( fileDlg->result() == 1 ) { 1464 if( fileDlg->result() == 1 ) {
1451 command = fileDlg->LineEdit1->text(); 1465 command = fileDlg->LineEdit1->text();
1452 1466
1453 Output *outDlg; 1467 Output *outDlg;
1454 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1468 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1455 outDlg->showMaximized(); 1469 outDlg->showMaximized();
1456 outDlg->show(); 1470 outDlg->show();
1457 qApp->processEvents(); 1471 qApp->processEvents();
1458 FILE *fp; 1472 FILE *fp;
1459 char line[130]; 1473 char line[130];
1460 sleep(1); 1474 sleep(1);
1461 command +=" 2>&1"; 1475 command +=" 2>&1";
1462 fp = popen( (const char *) command, "r"); 1476 fp = popen( (const char *) command, "r");
1463 if ( !fp ) { 1477 if ( !fp ) {
1464 qDebug("Could not execute '" + command + "'! err=%d", fp); 1478 qDebug("Could not execute '" + command + "'! err=%d", fp);
1465 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 1479 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
1466 pclose(fp); 1480 pclose(fp);
1467 return; 1481 return;
1468 } else { 1482 } else {
1469 while ( fgets( line, sizeof line, fp)) { 1483 while ( fgets( line, sizeof line, fp)) {
1470 QString lineStr = line; 1484 QString lineStr = line;
1471 lineStr=lineStr.left(lineStr.length()-1); 1485 lineStr=lineStr.left(lineStr.length()-1);
1472 outDlg->OutputEdit->append(lineStr); 1486 outDlg->OutputEdit->append(lineStr);
1473 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1487 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1474 } 1488 }
1475 } 1489 }
1476 pclose(fp); 1490 pclose(fp);
1477 1491
1478 } 1492 }
1479} 1493}
1480 1494
1481void AdvancedFm::runCommandStd() { 1495void AdvancedFm::runCommandStd() {
1482 QString curFile; 1496 QString curFile;
1483 if (TabWidget->currentPageIndex() == 0) { 1497 if (TabWidget->currentPageIndex() == 0) {
1484 if( Local_View->currentItem()) 1498 if( Local_View->currentItem())
1485 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 1499 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
1486 } else { 1500 } else {
1487 if(Remote_View->currentItem()) 1501 if(Remote_View->currentItem())
1488 curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); 1502 curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0);
1489 } 1503 }
1490 1504
1491 InputDialog *fileDlg; 1505 InputDialog *fileDlg;
1492 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 1506 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1493 fileDlg->setInputText(curFile); 1507 fileDlg->setInputText(curFile);
1494 fileDlg->exec(); 1508 fileDlg->exec();
1495 QString command; 1509 QString command;
1496 if( fileDlg->result() == 1 ) { 1510 if( fileDlg->result() == 1 ) {
1497 qApp->processEvents(); 1511 qApp->processEvents();
1498 command = fileDlg->LineEdit1->text() + " &"; 1512 command = fileDlg->LineEdit1->text() + " &";
1499 system(command.latin1()); 1513 system(command.latin1());
1500 } 1514 }
1501} 1515}
1502 1516
1503void AdvancedFm::fileStatus() { 1517void AdvancedFm::fileStatus() {
1504 QString curFile; 1518 QString curFile;
1505 if (TabWidget->currentPageIndex() == 0) { 1519 if (TabWidget->currentPageIndex() == 0) {
1506 curFile = Local_View->currentItem()->text(0); 1520 curFile = Local_View->currentItem()->text(0);
1507 } else { 1521 } else {
1508 curFile = Remote_View->currentItem()->text(0); 1522 curFile = Remote_View->currentItem()->text(0);
1509 } 1523 }
1510 QString command = " stat -l "+ curFile +" 2>&1"; 1524 QString command = " stat -l "+ curFile +" 2>&1";
1511 Output *outDlg; 1525 Output *outDlg;
1512 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1526 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1513 outDlg->showMaximized(); 1527 outDlg->showMaximized();
1514 outDlg->show(); 1528 outDlg->show();
1515 qApp->processEvents(); 1529 qApp->processEvents();
1516 FILE *fp; 1530 FILE *fp;
1517 char line[130]; 1531 char line[130];
1518 sleep(1); 1532 sleep(1);
1519 fp = popen( (const char *) command, "r"); 1533 fp = popen( (const char *) command, "r");
1520 if ( !fp ) { 1534 if ( !fp ) {
1521 qDebug("Could not execute '" + command + "'! err=%d", fp); 1535 qDebug("Could not execute '" + command + "'! err=%d", fp);
1522 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 1536 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
1523 pclose(fp); 1537 pclose(fp);
1524 return; 1538 return;
1525 } else { 1539 } else {
1526 while ( fgets( line, sizeof line, fp)) { 1540 while ( fgets( line, sizeof line, fp)) {
1527 outDlg->OutputEdit->append(line); 1541 outDlg->OutputEdit->append(line);
1528 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1542 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1529 1543
1530 } 1544 }
1531 1545
1532 } 1546 }
1533 pclose(fp); 1547 pclose(fp);
1534} 1548}
1535 1549
1536void AdvancedFm::mkDir() { 1550void AdvancedFm::mkDir() {
1537 if (TabWidget->currentPageIndex() == 0) 1551 if (TabWidget->currentPageIndex() == 0)
1538 localMakDir(); 1552 localMakDir();
1539 else 1553 else
1540 remoteMakDir(); 1554 remoteMakDir();
1541 1555
1542} 1556}
1543 1557
1544void AdvancedFm::rn() { 1558void AdvancedFm::rn() {
1545 if (TabWidget->currentPageIndex() == 0) 1559 if (TabWidget->currentPageIndex() == 0)
1546 localRename(); 1560 localRename();
1547 else 1561 else
1548 remoteRename(); 1562 remoteRename();
1549 1563
1550} 1564}
1551 1565
1552void AdvancedFm::del() { 1566void AdvancedFm::del() {
1553 if (TabWidget->currentPageIndex() == 0) 1567 if (TabWidget->currentPageIndex() == 0)
1554 localDelete(); 1568 localDelete();
1555 else 1569 else
1556 remoteDelete(); 1570 remoteDelete();
1557} 1571}
1558 1572
1559void AdvancedFm::doAbout() { 1573void AdvancedFm::doAbout() {
1560 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 1574 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
1561 "is copyright 2002 by\n" 1575 "is copyright 2002 by\n"
1562 "L.J.Potter<llornkcor@handhelds.org>\n" 1576 "L.J.Potter<llornkcor@handhelds.org>\n"
1563 "and is licensed by the GPL")); 1577 "and is licensed by the GPL"));
1564} 1578}
1565 1579
1566void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 1580void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
1567{ 1581{
1568 if( TabWidget->hasFocus()) 1582 if( TabWidget->hasFocus())
1569 switch ( e->key() ) { 1583 switch ( e->key() ) {
1570 case Key_Delete: 1584 case Key_Delete:
1571 del(); 1585 del();
1572 break; 1586 break;
1573 case Key_H: 1587 case Key_H:
1574 showHidden(); 1588 showHidden();
1575 break; 1589 break;
1576 case Key_E: 1590 case Key_E:
1577 runThis(); 1591 runThis();
1578 break; 1592 break;
1579 case Key_C: 1593 case Key_C:
1580 copy(); 1594 copy();
1581 break; 1595 break;
1582 case Key_A: 1596 case Key_A:
1583 copyAs(); 1597 copyAs();
1584 break; 1598 break;
1585 case Key_M: 1599 case Key_M:
1586 move(); 1600 move();
1587 break; 1601 break;
1588 case Key_R: 1602 case Key_R:
1589 rn(); 1603 rn();
1590 break; 1604 break;
1591 case Key_I: 1605 case Key_I:
1592 fileStatus(); 1606 fileStatus();
1593 break; 1607 break;
1594 case Key_U: 1608 case Key_U:
1595 upDir(); 1609 upDir();
1596 break; 1610 break;