author | llornkcor <llornkcor> | 2002-04-19 23:56:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-19 23:56:15 (UTC) |
commit | 221f2cbeaec8f28d39a5f95655f109a4b0fd33fc (patch) (unidiff) | |
tree | 937feadc08d0b1d2e8af9214b974355177916d6f | |
parent | d2c2dd7d80cfd5359db07952385bca575f1eeeae (diff) | |
download | opie-221f2cbeaec8f28d39a5f95655f109a4b0fd33fc.zip opie-221f2cbeaec8f28d39a5f95655f109a4b0fd33fc.tar.gz opie-221f2cbeaec8f28d39a5f95655f109a4b0fd33fc.tar.bz2 |
fixed label, and forgot last log - added ability to save output to file
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 8a1eeec..2126745 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1088,183 +1088,183 @@ void AdvancedFm::copyAs() | |||
1088 | f.remove(); | 1088 | f.remove(); |
1089 | if(!copyFile(destFile, curFile) ) | 1089 | if(!copyFile(destFile, curFile) ) |
1090 | qWarning("nothin doing"); | 1090 | qWarning("nothin doing"); |
1091 | } | 1091 | } |
1092 | populateLocalView(); | 1092 | populateLocalView(); |
1093 | TabWidget->setCurrentPage(0); | 1093 | TabWidget->setCurrentPage(0); |
1094 | } | 1094 | } |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | void AdvancedFm::move() { | 1097 | void AdvancedFm::move() { |
1098 | QString curFile = getPath(); | 1098 | QString curFile = getPath(); |
1099 | // qDebug(curFile); | 1099 | // qDebug(curFile); |
1100 | QString destFile; | 1100 | QString destFile; |
1101 | if (TabWidget->currentPageIndex() == 0) { | 1101 | if (TabWidget->currentPageIndex() == 0) { |
1102 | QString destFile = currentRemoteDir.canonicalPath() + "/" + Local_View->currentItem()->text(0); | 1102 | QString destFile = currentRemoteDir.canonicalPath() + "/" + Local_View->currentItem()->text(0); |
1103 | qDebug("Destination file is "+destFile); | 1103 | qDebug("Destination file is "+destFile); |
1104 | 1104 | ||
1105 | QFile f(destFile); | 1105 | QFile f(destFile); |
1106 | if( f.exists()) | 1106 | if( f.exists()) |
1107 | f.remove(); | 1107 | f.remove(); |
1108 | if(!copyFile( destFile, curFile) ) { | 1108 | if(!copyFile( destFile, curFile) ) { |
1109 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); | 1109 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); |
1110 | return; | 1110 | return; |
1111 | } | 1111 | } |
1112 | QFile::remove(curFile); | 1112 | QFile::remove(curFile); |
1113 | TabWidget->setCurrentPage(1); | 1113 | TabWidget->setCurrentPage(1); |
1114 | } else { | 1114 | } else { |
1115 | QString destFile = currentDir.canonicalPath() + "/" + Remote_View->currentItem()->text(0); | 1115 | QString destFile = currentDir.canonicalPath() + "/" + Remote_View->currentItem()->text(0); |
1116 | qDebug("Destination file is "+destFile); | 1116 | qDebug("Destination file is "+destFile); |
1117 | 1117 | ||
1118 | QFile f(destFile); | 1118 | QFile f(destFile); |
1119 | if( f.exists()) | 1119 | if( f.exists()) |
1120 | f.remove(); | 1120 | f.remove(); |
1121 | if(!copyFile(destFile, curFile) ) { | 1121 | if(!copyFile(destFile, curFile) ) { |
1122 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); | 1122 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); |
1123 | return; | 1123 | return; |
1124 | } | 1124 | } |
1125 | QFile::remove(curFile); | 1125 | QFile::remove(curFile); |
1126 | TabWidget->setCurrentPage(0); | 1126 | TabWidget->setCurrentPage(0); |
1127 | } | 1127 | } |
1128 | populateRemoteView(); | 1128 | populateRemoteView(); |
1129 | populateLocalView(); | 1129 | populateLocalView(); |
1130 | } | 1130 | } |
1131 | 1131 | ||
1132 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) | 1132 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) |
1133 | { | 1133 | { |
1134 | char bf[ 50000 ]; | 1134 | char bf[ 50000 ]; |
1135 | int bytesRead; | 1135 | int bytesRead; |
1136 | bool success = TRUE; | 1136 | bool success = TRUE; |
1137 | struct stat status; | 1137 | struct stat status; |
1138 | 1138 | ||
1139 | QFile s( src ); | 1139 | QFile s( src ); |
1140 | QFile d( dest ); | 1140 | QFile d( dest ); |
1141 | 1141 | ||
1142 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 1142 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
1143 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 1143 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
1144 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 1144 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
1145 | success = FALSE; | 1145 | success = FALSE; |
1146 | break; | 1146 | break; |
1147 | } | 1147 | } |
1148 | } | 1148 | } |
1149 | if( success && (bytesRead > 0) ){ | 1149 | if( success && (bytesRead > 0) ){ |
1150 | d.writeBlock( bf, bytesRead ); | 1150 | d.writeBlock( bf, bytesRead ); |
1151 | } | 1151 | } |
1152 | } else { | 1152 | } else { |
1153 | success = FALSE; | 1153 | success = FALSE; |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | // Set file permissions | 1156 | // Set file permissions |
1157 | if( stat( (const char *) src, &status ) == 0 ){ | 1157 | if( stat( (const char *) src, &status ) == 0 ){ |
1158 | chmod( (const char *) dest, status.st_mode ); | 1158 | chmod( (const char *) dest, status.st_mode ); |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | return success; | 1161 | return success; |
1162 | } | 1162 | } |
1163 | 1163 | ||
1164 | void AdvancedFm::runCommand() { | 1164 | void AdvancedFm::runCommand() { |
1165 | QString curFile; | 1165 | QString curFile; |
1166 | if (TabWidget->currentPageIndex() == 0) { | 1166 | if (TabWidget->currentPageIndex() == 0) { |
1167 | if( Local_View->currentItem()) | 1167 | if( Local_View->currentItem()) |
1168 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); | 1168 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); |
1169 | } else { | 1169 | } else { |
1170 | if(Remote_View->currentItem()) | 1170 | if(Remote_View->currentItem()) |
1171 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); | 1171 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | InputDialog *fileDlg; | 1174 | InputDialog *fileDlg; |
1175 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1175 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1176 | fileDlg->setInputText(curFile); | 1176 | fileDlg->setInputText(curFile); |
1177 | fileDlg->exec(); | 1177 | fileDlg->exec(); |
1178 | QString command; | 1178 | QString command; |
1179 | if( fileDlg->result() == 1 ) { | 1179 | if( fileDlg->result() == 1 ) { |
1180 | command = fileDlg->LineEdit1->text(); | 1180 | command = fileDlg->LineEdit1->text(); |
1181 | 1181 | ||
1182 | int err=0; | 1182 | int err=0; |
1183 | Output *outDlg; | 1183 | Output *outDlg; |
1184 | outDlg = new Output(this, tr("Formatter Output"),FALSE); | 1184 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1185 | outDlg->showMaximized(); | 1185 | outDlg->showMaximized(); |
1186 | outDlg->show(); | 1186 | outDlg->show(); |
1187 | qApp->processEvents(); | 1187 | qApp->processEvents(); |
1188 | FILE *fp; | 1188 | FILE *fp; |
1189 | char line[130]; | 1189 | char line[130]; |
1190 | sleep(1); | 1190 | sleep(1); |
1191 | // if(command.find("2>",0,TRUE) != -1) | 1191 | // if(command.find("2>",0,TRUE) != -1) |
1192 | command +=" 2>&1"; | 1192 | command +=" 2>&1"; |
1193 | fp = popen( (const char *) command, "r"); | 1193 | fp = popen( (const char *) command, "r"); |
1194 | if ( !fp ) { | 1194 | if ( !fp ) { |
1195 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1195 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1196 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); | 1196 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); |
1197 | pclose(fp); | 1197 | pclose(fp); |
1198 | return; | 1198 | return; |
1199 | } else { | 1199 | } else { |
1200 | while ( fgets( line, sizeof line, fp)) { | 1200 | while ( fgets( line, sizeof line, fp)) { |
1201 | QString lineStr = line; | 1201 | QString lineStr = line; |
1202 | lineStr=lineStr.left(lineStr.length()-1); | 1202 | lineStr=lineStr.left(lineStr.length()-1); |
1203 | outDlg->OutputEdit->append(lineStr); | 1203 | outDlg->OutputEdit->append(lineStr); |
1204 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1204 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | } | 1207 | } |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | void AdvancedFm::runCommandStd() { | 1210 | void AdvancedFm::runCommandStd() { |
1211 | QString curFile; | 1211 | QString curFile; |
1212 | if (TabWidget->currentPageIndex() == 0) { | 1212 | if (TabWidget->currentPageIndex() == 0) { |
1213 | if( Local_View->currentItem()) | 1213 | if( Local_View->currentItem()) |
1214 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); | 1214 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); |
1215 | } else { | 1215 | } else { |
1216 | if(Remote_View->currentItem()) | 1216 | if(Remote_View->currentItem()) |
1217 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); | 1217 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | InputDialog *fileDlg; | 1220 | InputDialog *fileDlg; |
1221 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1221 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1222 | fileDlg->setInputText(curFile); | 1222 | fileDlg->setInputText(curFile); |
1223 | fileDlg->exec(); | 1223 | fileDlg->exec(); |
1224 | QString command; | 1224 | QString command; |
1225 | if( fileDlg->result() == 1 ) { | 1225 | if( fileDlg->result() == 1 ) { |
1226 | qApp->processEvents(); | 1226 | qApp->processEvents(); |
1227 | command = fileDlg->LineEdit1->text() + " &"; | 1227 | command = fileDlg->LineEdit1->text() + " &"; |
1228 | system(command.latin1()); | 1228 | system(command.latin1()); |
1229 | } | 1229 | } |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | void AdvancedFm::fileStatus() { | 1232 | void AdvancedFm::fileStatus() { |
1233 | QString curFile; | 1233 | QString curFile; |
1234 | if (TabWidget->currentPageIndex() == 0) { | 1234 | if (TabWidget->currentPageIndex() == 0) { |
1235 | curFile = Local_View->currentItem()->text(0); | 1235 | curFile = Local_View->currentItem()->text(0); |
1236 | } else { | 1236 | } else { |
1237 | curFile = Remote_View->currentItem()->text(0); | 1237 | curFile = Remote_View->currentItem()->text(0); |
1238 | } | 1238 | } |
1239 | QString command = " stat -l "+ curFile +" 2>&1"; | 1239 | QString command = " stat -l "+ curFile +" 2>&1"; |
1240 | int err=0; | 1240 | int err=0; |
1241 | Output *outDlg; | 1241 | Output *outDlg; |
1242 | outDlg = new Output(this, tr("Formatter Output"),FALSE); | 1242 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1243 | outDlg->showMaximized(); | 1243 | outDlg->showMaximized(); |
1244 | outDlg->show(); | 1244 | outDlg->show(); |
1245 | qApp->processEvents(); | 1245 | qApp->processEvents(); |
1246 | FILE *fp; | 1246 | FILE *fp; |
1247 | char line[130]; | 1247 | char line[130]; |
1248 | sleep(1); | 1248 | sleep(1); |
1249 | fp = popen( (const char *) command, "r"); | 1249 | fp = popen( (const char *) command, "r"); |
1250 | if ( !fp ) { | 1250 | if ( !fp ) { |
1251 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1251 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1252 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); | 1252 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); |
1253 | pclose(fp); | 1253 | pclose(fp); |
1254 | return; | 1254 | return; |
1255 | } else { | 1255 | } else { |
1256 | while ( fgets( line, sizeof line, fp)) { | 1256 | while ( fgets( line, sizeof line, fp)) { |
1257 | outDlg->OutputEdit->append(line); | 1257 | outDlg->OutputEdit->append(line); |
1258 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1258 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1259 | 1259 | ||
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | } | 1262 | } |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | void AdvancedFm::doAbout() { | 1265 | void AdvancedFm::doAbout() { |
1266 | QMessageBox::message("AdvancedFm","Advanced FileManager\n" | 1266 | QMessageBox::message("AdvancedFm","Advanced FileManager\n" |
1267 | "is copyright 2002 by\n" | 1267 | "is copyright 2002 by\n" |
1268 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1268 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1269 | "and is licensed by the GPL"); | 1269 | "and is licensed by the GPL"); |
1270 | } | 1270 | } |