summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp114
1 files changed, 59 insertions, 55 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index f97ae99..d0ccc3f 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1204,292 +1204,292 @@ void AdvancedFm::copy()
1204 } 1204 }
1205 populateRemoteView(); 1205 populateRemoteView();
1206 TabWidget->setCurrentPage(1); 1206 TabWidget->setCurrentPage(1);
1207 1207
1208 } else { 1208 } else {
1209 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1209 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1210 1210
1211 QString destFile = currentDir.canonicalPath()+"/"+(*it); 1211 QString destFile = currentDir.canonicalPath()+"/"+(*it);
1212 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1212 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1213 1213
1214 QFile f(destFile); 1214 QFile f(destFile);
1215 if( f.exists()) { 1215 if( f.exists()) {
1216 switch ( QMessageBox::warning(this,tr("Delete"), 1216 switch ( QMessageBox::warning(this,tr("Delete"),
1217 destFile+tr(" already exists\nDo you really want to delete it?"), 1217 destFile+tr(" already exists\nDo you really want to delete it?"),
1218 tr("Yes"),tr("No"),0,0,1) ) { 1218 tr("Yes"),tr("No"),0,0,1) ) {
1219 case 0: 1219 case 0:
1220 f.remove(); 1220 f.remove();
1221 break; 1221 break;
1222 case 1: 1222 case 1:
1223 return; 1223 return;
1224 break; 1224 break;
1225 }; 1225 };
1226 } 1226 }
1227 if(!copyFile(destFile, curFile) ) { 1227 if(!copyFile(destFile, curFile) ) {
1228 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1228 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1229 1229
1230 qWarning("nothin doing"); 1230 qWarning("nothin doing");
1231 } 1231 }
1232 } 1232 }
1233 populateLocalView(); 1233 populateLocalView();
1234 TabWidget->setCurrentPage(0); 1234 TabWidget->setCurrentPage(0);
1235 } 1235 }
1236 } 1236 }
1237} 1237}
1238 1238
1239void AdvancedFm::copyAs() 1239void AdvancedFm::copyAs()
1240{ 1240{
1241 QStringList curFileList = getPath(); 1241 QStringList curFileList = getPath();
1242 if( curFileList.count() > 0) { 1242 if( curFileList.count() > 0) {
1243 QString curFile; 1243 QString curFile;
1244 InputDialog *fileDlg; 1244 InputDialog *fileDlg;
1245 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1245 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1246 1246
1247 if (TabWidget->currentPageIndex() == 0) { 1247 if (TabWidget->currentPageIndex() == 0) {
1248 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1248 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1249 QString destFile; 1249 QString destFile;
1250 curFile = currentDir.canonicalPath()+"/"+(*it); 1250 curFile = currentDir.canonicalPath()+"/"+(*it);
1251// InputDialog *fileDlg; 1251// InputDialog *fileDlg;
1252// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1252// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1253 fileDlg->setInputText((const QString &) destFile ); 1253 fileDlg->setInputText((const QString &) destFile );
1254 fileDlg->exec(); 1254 fileDlg->exec();
1255 if( fileDlg->result() == 1 ) { 1255 if( fileDlg->result() == 1 ) {
1256 QString filename = fileDlg->LineEdit1->text(); 1256 QString filename = fileDlg->LineEdit1->text();
1257 destFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1257 destFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1258 1258
1259 QFile f(destFile); 1259 QFile f(destFile);
1260 if( f.exists()) { 1260 if( f.exists()) {
1261 switch (QMessageBox::warning(this,tr("Delete"), 1261 switch (QMessageBox::warning(this,tr("Delete"),
1262 destFile+tr(" already exists\nDo you really want to delete it?"), 1262 destFile+tr(" already exists\nDo you really want to delete it?"),
1263 tr("Yes"),tr("No"),0,0,1) ) { 1263 tr("Yes"),tr("No"),0,0,1) ) {
1264 case 0: 1264 case 0:
1265 f.remove(); 1265 f.remove();
1266 break; 1266 break;
1267 case 1: 1267 case 1:
1268 return; 1268 return;
1269 break; 1269 break;
1270 }; 1270 };
1271 } 1271 }
1272 if(!copyFile(destFile, curFile) ) { 1272 if(!copyFile(destFile, curFile) ) {
1273 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1273 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1274 qWarning("nothin doing"); 1274 qWarning("nothin doing");
1275 } 1275 }
1276 } 1276 }
1277 } 1277 }
1278 populateRemoteView(); 1278 populateRemoteView();
1279 TabWidget->setCurrentPage(1); 1279 TabWidget->setCurrentPage(1);
1280 } else { 1280 } else {
1281 if (TabWidget->currentPageIndex() == 0) { 1281 if (TabWidget->currentPageIndex() == 0) {
1282 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1282 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1283 1283
1284 curFile = currentDir.canonicalPath()+"/"+(*it); 1284 curFile = currentDir.canonicalPath()+"/"+(*it);
1285 QString destFile; 1285 QString destFile;
1286 fileDlg->setInputText((const QString &) destFile); 1286 fileDlg->setInputText((const QString &) destFile);
1287 fileDlg->exec(); 1287 fileDlg->exec();
1288 if( fileDlg->result() == 1 ) { 1288 if( fileDlg->result() == 1 ) {
1289 QString filename = fileDlg->LineEdit1->text(); 1289 QString filename = fileDlg->LineEdit1->text();
1290 destFile = currentDir.canonicalPath()+"/"+(*it); 1290 destFile = currentDir.canonicalPath()+"/"+(*it);
1291 1291
1292 QFile f(destFile); 1292 QFile f(destFile);
1293 if( f.exists()) { 1293 if( f.exists()) {
1294 switch ( QMessageBox::warning(this,tr("Delete"), 1294 switch ( QMessageBox::warning(this,tr("Delete"),
1295 destFile+tr(" already exists\nDo you really want to delete it?"), 1295 destFile+tr(" already exists\nDo you really want to delete it?"),
1296 tr("Yes"),tr("No"),0,0,1) ) { 1296 tr("Yes"),tr("No"),0,0,1) ) {
1297 case 0: 1297 case 0:
1298 f.remove(); 1298 f.remove();
1299 break; 1299 break;
1300 case 1: 1300 case 1:
1301 return; 1301 return;
1302 break; 1302 break;
1303 }; 1303 };
1304 } 1304 }
1305 if(!copyFile(destFile, curFile) ) { 1305 if(!copyFile(destFile, curFile) ) {
1306 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1306 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1307 qWarning("nothin doing"); 1307 qWarning("nothin doing");
1308 } 1308 }
1309 1309
1310 } 1310 }
1311 } 1311 }
1312 populateLocalView(); 1312 populateLocalView();
1313 TabWidget->setCurrentPage(0); 1313 TabWidget->setCurrentPage(0);
1314 } 1314 }
1315 } 1315 }
1316 } 1316 }
1317 1317
1318} 1318}
1319 1319
1320void AdvancedFm::copySameDir() { 1320void AdvancedFm::copySameDir() {
1321 QStringList curFileList = getPath(); 1321 QStringList curFileList = getPath();
1322 if( curFileList.count() > 0) { 1322 if( curFileList.count() > 0) {
1323 QString curFile; 1323 QString curFile;
1324 InputDialog *fileDlg; 1324 InputDialog *fileDlg;
1325 1325
1326 if (TabWidget->currentPageIndex() == 0) { 1326 if (TabWidget->currentPageIndex() == 0) {
1327 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1327 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1328 QString destFile; 1328 QString destFile;
1329 curFile = currentDir.canonicalPath()+"/"+(*it); 1329 curFile = currentDir.canonicalPath()+"/"+(*it);
1330 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 1330 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
1331// InputDialog *fileDlg; 1331// InputDialog *fileDlg;
1332// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1332// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1333 fileDlg->setInputText((const QString &) destFile ); 1333 fileDlg->setInputText((const QString &) destFile );
1334 fileDlg->exec(); 1334 fileDlg->exec();
1335 if( fileDlg->result() == 1 ) { 1335 if( fileDlg->result() == 1 ) {
1336 QString filename = fileDlg->LineEdit1->text(); 1336 QString filename = fileDlg->LineEdit1->text();
1337 destFile = currentDir.canonicalPath()+"/"+filename; 1337 destFile = currentDir.canonicalPath()+"/"+filename;
1338 1338
1339 QFile f(destFile); 1339 QFile f(destFile);
1340 if( f.exists()) { 1340 if( f.exists()) {
1341 switch (QMessageBox::warning(this,tr("Delete"), 1341 switch (QMessageBox::warning(this,tr("Delete"),
1342 destFile+tr(" already exists\nDo you really want to delete it?"), 1342 destFile+tr(" already exists\nDo you really want to delete it?"),
1343 tr("Yes"),tr("No"),0,0,1) ) { 1343 tr("Yes"),tr("No"),0,0,1) ) {
1344 case 0: 1344 case 0:
1345 qDebug(""); 1345 qDebug("");
1346 f.remove(); 1346 f.remove();
1347 break; 1347 break;
1348 case 1: 1348 case 1:
1349 return; 1349 return;
1350 break; 1350 break;
1351 }; 1351 };
1352 } 1352 }
1353 if(!copyFile(destFile, curFile) ) { 1353 if(!copyFile(destFile, curFile) ) {
1354 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1354 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1355 qWarning("nothin doing"); 1355 qWarning("nothin doing");
1356 } 1356 }
1357 1357
1358 qDebug("copy "+curFile+" as "+destFile); 1358 qDebug("copy "+curFile+" as "+destFile);
1359 } 1359 }
1360 delete fileDlg; 1360 delete fileDlg;
1361 } 1361 }
1362 populateRemoteView(); 1362 populateRemoteView();
1363 TabWidget->setCurrentPage(1); 1363 TabWidget->setCurrentPage(1);
1364 } else { 1364 } else {
1365 if (TabWidget->currentPageIndex() == 0) { 1365 if (TabWidget->currentPageIndex() == 0) {
1366 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1366 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1367 1367
1368 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1368 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1369 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 1369 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
1370 QString destFile; 1370 QString destFile;
1371 fileDlg->setInputText((const QString &) destFile); 1371 fileDlg->setInputText((const QString &) destFile);
1372 fileDlg->exec(); 1372 fileDlg->exec();
1373 if( fileDlg->result() == 1 ) { 1373 if( fileDlg->result() == 1 ) {
1374 QString filename = fileDlg->LineEdit1->text(); 1374 QString filename = fileDlg->LineEdit1->text();
1375 destFile = currentDir.canonicalPath()+"/"+filename; 1375 destFile = currentDir.canonicalPath()+"/"+filename;
1376 1376
1377 QFile f(destFile); 1377 QFile f(destFile);
1378 if( f.exists()) { 1378 if( f.exists()) {
1379 switch ( QMessageBox::warning(this,tr("Delete"), 1379 switch ( QMessageBox::warning(this,tr("Delete"),
1380 destFile+tr(" already exists\nDo you really want to delete it?"), 1380 destFile+tr(" already exists\nDo you really want to delete it?"),
1381 tr("Yes"),tr("No"),0,0,1) ) { 1381 tr("Yes"),tr("No"),0,0,1) ) {
1382 case 0: 1382 case 0:
1383 f.remove(); 1383 f.remove();
1384 break; 1384 break;
1385 case 1: 1385 case 1:
1386 return; 1386 return;
1387 break; 1387 break;
1388 }; 1388 };
1389 } 1389 }
1390 if(!copyFile(destFile, curFile) ) { 1390 if(!copyFile(destFile, curFile) ) {
1391 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1391 QMessageBox::message("AdvancedFm",tr("Could not copy\n")+curFile +tr("to\n")+destFile);
1392 qWarning("nothin doing"); 1392 qWarning("nothin doing");
1393 } 1393 }
1394 qDebug("copy "+curFile+" as "+destFile); 1394 qDebug("copy "+curFile+" as "+destFile);
1395 } 1395 }
1396 delete fileDlg; 1396 delete fileDlg;
1397 } 1397 }
1398 populateLocalView(); 1398 populateLocalView();
1399 TabWidget->setCurrentPage(0); 1399 TabWidget->setCurrentPage(0);
1400 } 1400 }
1401 } 1401 }
1402 } 1402 }
1403 1403
1404} 1404}
1405 1405
1406void AdvancedFm::move() { 1406void AdvancedFm::move() {
1407 1407
1408 QStringList curFileList = getPath(); 1408 QStringList curFileList = getPath();
1409 if( curFileList.count() > 0) { 1409 if( curFileList.count() > 0) {
1410 QString curFile; 1410 QString curFile;
1411// qDebug(curFile); 1411// qDebug(curFile);
1412 QString destFile; 1412 QString destFile;
1413 1413
1414 if (TabWidget->currentPageIndex() == 0) { 1414 if (TabWidget->currentPageIndex() == 0) {
1415 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1415 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1416 QString destFile = currentRemoteDir.canonicalPath(); 1416 QString destFile = currentRemoteDir.canonicalPath();
1417 if(destFile.right(1).find("/",0,TRUE) == -1) 1417 if(destFile.right(1).find("/",0,TRUE) == -1)
1418 destFile+="/"; 1418 destFile+="/";
1419 destFile +=(*it); 1419 destFile +=(*it);
1420 curFile = currentDir.canonicalPath(); 1420 curFile = currentDir.canonicalPath();
1421 qDebug("Destination file is "+destFile); 1421 qDebug("Destination file is "+destFile);
1422 if(curFile.right(1).find("/",0,TRUE) == -1) 1422 if(curFile.right(1).find("/",0,TRUE) == -1)
1423 curFile +="/"; 1423 curFile +="/";
1424 curFile+=(*it); 1424 curFile+=(*it);
1425 1425
1426 QFile f(destFile); 1426 QFile f(destFile);
1427 if( f.exists()) { 1427 if( f.exists()) {
1428 switch (QMessageBox::warning(this,tr("Delete"), 1428 switch (QMessageBox::warning(this,tr("Delete"),
1429 destFile+tr(" already exists\nDo you really want to delete it?"), 1429 destFile+tr(" already exists\nDo you really want to delete it?"),
1430 tr("Yes"),tr("No"),0,0,1) ) { 1430 tr("Yes"),tr("No"),0,0,1) ) {
1431 case 0: 1431 case 0:
1432 f.remove(); 1432 f.remove();
1433 break; 1433 break;
1434 case 1: 1434 case 1:
1435 return; 1435 return;
1436 break; 1436 break;
1437 }; 1437 };
1438 if(!copyFile( destFile, curFile) ) { 1438 if(!copyFile( destFile, curFile) ) {
1439 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); 1439 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
1440 return; 1440 return;
1441 } 1441 }
1442 QFile::remove(curFile); 1442 QFile::remove(curFile);
1443 } 1443 }
1444 } 1444 }
1445 TabWidget->setCurrentPage(1); 1445 TabWidget->setCurrentPage(1);
1446 } else { 1446 } else {
1447 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1447 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1448 QString destFile = currentRemoteDir.canonicalPath(); 1448 QString destFile = currentRemoteDir.canonicalPath();
1449 if(destFile.right(1).find("/",0,TRUE) == -1) 1449 if(destFile.right(1).find("/",0,TRUE) == -1)
1450 destFile+="/"; 1450 destFile+="/";
1451 destFile +=(*it); 1451 destFile +=(*it);
1452 qDebug("Destination file is "+destFile); 1452 qDebug("Destination file is "+destFile);
1453 curFile = currentDir.canonicalPath(); 1453 curFile = currentDir.canonicalPath();
1454 if(curFile.right(1).find("/",0,TRUE) == -1) 1454 if(curFile.right(1).find("/",0,TRUE) == -1)
1455 curFile +="/"; 1455 curFile +="/";
1456 curFile+=(*it); 1456 curFile+=(*it);
1457 1457
1458 QFile f(destFile); 1458 QFile f(destFile);
1459 if( f.exists()) { 1459 if( f.exists()) {
1460 switch (QMessageBox::warning(this,tr("Delete"), 1460 switch (QMessageBox::warning(this,tr("Delete"),
1461 destFile+tr(" already exists\nDo you really want to delete it?"), 1461 destFile+tr(" already exists\nDo you really want to delete it?"),
1462 tr("Yes"),tr("No"),0,0,1) ) { 1462 tr("Yes"),tr("No"),0,0,1) ) {
1463 case 0: 1463 case 0:
1464 f.remove(); 1464 f.remove();
1465 break; 1465 break;
1466 case 1: 1466 case 1:
1467 return; 1467 return;
1468 break; 1468 break;
1469 }; 1469 };
1470 if(!copyFile(destFile, curFile) ) { 1470 if(!copyFile(destFile, curFile) ) {
1471 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); 1471 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
1472 return; 1472 return;
1473 } 1473 }
1474 } 1474 }
1475 QFile::remove(curFile); 1475 QFile::remove(curFile);
1476 TabWidget->setCurrentPage(0); 1476 TabWidget->setCurrentPage(0);
1477 } 1477 }
1478 } 1478 }
1479 populateRemoteView(); 1479 populateRemoteView();
1480 populateLocalView(); 1480 populateLocalView();
1481 } 1481 }
1482} 1482}
1483 1483
1484 bool AdvancedFm::copyFile( const QString & dest, const QString & src ) 1484 bool AdvancedFm::copyFile( const QString & dest, const QString & src )
1485{ 1485{
1486 char bf[ 50000 ]; 1486 char bf[ 50000 ];
1487 int bytesRead; 1487 int bytesRead;
1488 bool success = TRUE; 1488 bool success = TRUE;
1489 struct stat status; 1489 struct stat status;
1490 1490
1491 QFile s( src ); 1491 QFile s( src );
1492 QFile d( dest ); 1492 QFile d( dest );
1493 1493
1494 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { 1494 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
1495 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { 1495 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
@@ -1524,49 +1524,49 @@ void AdvancedFm::runCommand() {
1524 } 1524 }
1525 1525
1526 InputDialog *fileDlg; 1526 InputDialog *fileDlg;
1527 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 1527 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1528 fileDlg->setInputText(curFile); 1528 fileDlg->setInputText(curFile);
1529 fileDlg->exec(); 1529 fileDlg->exec();
1530 QString command; 1530 QString command;
1531 if( fileDlg->result() == 1 ) { 1531 if( fileDlg->result() == 1 ) {
1532 command = fileDlg->LineEdit1->text(); 1532 command = fileDlg->LineEdit1->text();
1533 1533
1534// int err=0; 1534// int err=0;
1535 Output *outDlg; 1535 Output *outDlg;
1536 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1536 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1537 outDlg->showMaximized(); 1537 outDlg->showMaximized();
1538 outDlg->show(); 1538 outDlg->show();
1539 qApp->processEvents(); 1539 qApp->processEvents();
1540 FILE *fp; 1540 FILE *fp;
1541 char line[130]; 1541 char line[130];
1542 sleep(1); 1542 sleep(1);
1543// if(command.find("2>",0,TRUE) != -1) 1543// if(command.find("2>",0,TRUE) != -1)
1544 command +=" 2>&1"; 1544 command +=" 2>&1";
1545 fp = popen( (const char *) command, "r"); 1545 fp = popen( (const char *) command, "r");
1546 if ( !fp ) { 1546 if ( !fp ) {
1547 qDebug("Could not execute '" + command + "'! err=%d", fp); 1547 qDebug("Could not execute '" + command + "'! err=%d", fp);
1548 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); 1548 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
1549 pclose(fp); 1549 pclose(fp);
1550 return; 1550 return;
1551 } else { 1551 } else {
1552 while ( fgets( line, sizeof line, fp)) { 1552 while ( fgets( line, sizeof line, fp)) {
1553 QString lineStr = line; 1553 QString lineStr = line;
1554 lineStr=lineStr.left(lineStr.length()-1); 1554 lineStr=lineStr.left(lineStr.length()-1);
1555 outDlg->OutputEdit->append(lineStr); 1555 outDlg->OutputEdit->append(lineStr);
1556 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1556 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1557 } 1557 }
1558 } 1558 }
1559 } 1559 }
1560} 1560}
1561 1561
1562void AdvancedFm::runCommandStd() { 1562void AdvancedFm::runCommandStd() {
1563 QString curFile; 1563 QString curFile;
1564 if (TabWidget->currentPageIndex() == 0) { 1564 if (TabWidget->currentPageIndex() == 0) {
1565 if( Local_View->currentItem()) 1565 if( Local_View->currentItem())
1566 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 1566 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
1567 } else { 1567 } else {
1568 if(Remote_View->currentItem()) 1568 if(Remote_View->currentItem())
1569 curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); 1569 curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0);
1570 } 1570 }
1571 1571
1572 InputDialog *fileDlg; 1572 InputDialog *fileDlg;
@@ -1580,89 +1580,89 @@ void AdvancedFm::runCommandStd() {
1580 system(command.latin1()); 1580 system(command.latin1());
1581 } 1581 }
1582} 1582}
1583 1583
1584void AdvancedFm::fileStatus() { 1584void AdvancedFm::fileStatus() {
1585 QString curFile; 1585 QString curFile;
1586 if (TabWidget->currentPageIndex() == 0) { 1586 if (TabWidget->currentPageIndex() == 0) {
1587 curFile = Local_View->currentItem()->text(0); 1587 curFile = Local_View->currentItem()->text(0);
1588 } else { 1588 } else {
1589 curFile = Remote_View->currentItem()->text(0); 1589 curFile = Remote_View->currentItem()->text(0);
1590 } 1590 }
1591 QString command = " stat -l "+ curFile +" 2>&1"; 1591 QString command = " stat -l "+ curFile +" 2>&1";
1592// int err=0; 1592// int err=0;
1593 Output *outDlg; 1593 Output *outDlg;
1594 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1594 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1595 outDlg->showMaximized(); 1595 outDlg->showMaximized();
1596 outDlg->show(); 1596 outDlg->show();
1597 qApp->processEvents(); 1597 qApp->processEvents();
1598 FILE *fp; 1598 FILE *fp;
1599 char line[130]; 1599 char line[130];
1600 sleep(1); 1600 sleep(1);
1601 fp = popen( (const char *) command, "r"); 1601 fp = popen( (const char *) command, "r");
1602 if ( !fp ) { 1602 if ( !fp ) {
1603 qDebug("Could not execute '" + command + "'! err=%d", fp); 1603 qDebug("Could not execute '" + command + "'! err=%d", fp);
1604 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); 1604 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
1605 pclose(fp); 1605 pclose(fp);
1606 return; 1606 return;
1607 } else { 1607 } else {
1608 while ( fgets( line, sizeof line, fp)) { 1608 while ( fgets( line, sizeof line, fp)) {
1609 outDlg->OutputEdit->append(line); 1609 outDlg->OutputEdit->append(line);
1610 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1610 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1611 1611
1612 } 1612 }
1613 1613
1614 } 1614 }
1615} 1615}
1616 1616
1617void AdvancedFm::mkDir() { 1617void AdvancedFm::mkDir() {
1618 if (TabWidget->currentPageIndex() == 0) 1618 if (TabWidget->currentPageIndex() == 0)
1619 localMakDir(); 1619 localMakDir();
1620 else 1620 else
1621 remoteMakDir(); 1621 remoteMakDir();
1622 1622
1623} 1623}
1624 1624
1625void AdvancedFm::rn() { 1625void AdvancedFm::rn() {
1626 if (TabWidget->currentPageIndex() == 0) 1626 if (TabWidget->currentPageIndex() == 0)
1627 localRename(); 1627 localRename();
1628 else 1628 else
1629 remoteRename(); 1629 remoteRename();
1630 1630
1631} 1631}
1632 1632
1633void AdvancedFm::del() { 1633void AdvancedFm::del() {
1634 if (TabWidget->currentPageIndex() == 0) 1634 if (TabWidget->currentPageIndex() == 0)
1635 localDelete(); 1635 localDelete();
1636 else 1636 else
1637 remoteDelete(); 1637 remoteDelete();
1638} 1638}
1639 1639
1640void AdvancedFm::doAbout() { 1640void AdvancedFm::doAbout() {
1641 QMessageBox::message("AdvancedFm","Advanced FileManager\n" 1641 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
1642 "is copyright 2002 by\n" 1642 "is copyright 2002 by\n"
1643 "L.J.Potter<llornkcor@handhelds.org>\n" 1643 "L.J.Potter<llornkcor@handhelds.org>\n"
1644 "and is licensed by the GPL"); 1644 "and is licensed by the GPL"));
1645} 1645}
1646 1646
1647void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 1647void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
1648{ 1648{
1649 if( TabWidget->hasFocus()) 1649 if( TabWidget->hasFocus())
1650 switch ( e->key() ) { 1650 switch ( e->key() ) {
1651 case Key_Delete: 1651 case Key_Delete:
1652 del(); 1652 del();
1653 break; 1653 break;
1654 case Key_H: 1654 case Key_H:
1655 showHidden(); 1655 showHidden();
1656 break; 1656 break;
1657 case Key_E: 1657 case Key_E:
1658 runThis(); 1658 runThis();
1659 break; 1659 break;
1660 case Key_C: 1660 case Key_C:
1661 copy(); 1661 copy();
1662 break; 1662 break;
1663 case Key_A: 1663 case Key_A:
1664 copyAs(); 1664 copyAs();
1665 break; 1665 break;
1666 case Key_M: 1666 case Key_M:
1667 move(); 1667 move();
1668 break; 1668 break;
@@ -1781,48 +1781,51 @@ void AdvancedFm::parsetab(const QString &fileName) {
1781// qDebug(mountDir+"::"+filesystemType); 1781// qDebug(mountDir+"::"+filesystemType);
1782 fileSystemTypeList << mountDir+"::"+filesystemType; 1782 fileSystemTypeList << mountDir+"::"+filesystemType;
1783 } 1783 }
1784 } 1784 }
1785 } 1785 }
1786 endmntent( mntfp ); 1786 endmntent( mntfp );
1787} 1787}
1788 1788
1789QString AdvancedFm::getFileSystemType(const QString &currentText) { 1789QString AdvancedFm::getFileSystemType(const QString &currentText) {
1790 parsetab("/etc/mtab"); //why did TT forget filesystem type? 1790 parsetab("/etc/mtab"); //why did TT forget filesystem type?
1791 QString current = currentText;//.right( currentText.length()-1); 1791 QString current = currentText;//.right( currentText.length()-1);
1792 QString baseFs; 1792 QString baseFs;
1793 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 1793 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
1794 QString temp = (*it); 1794 QString temp = (*it);
1795 QString path = temp.left(temp.find("::",0,TRUE) ); 1795 QString path = temp.left(temp.find("::",0,TRUE) );
1796 path = path.right( path.length()-1); 1796 path = path.right( path.length()-1);
1797 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 1797 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
1798 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 1798 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
1799 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 1799 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
1800 } 1800 }
1801 } 1801 }
1802 return baseFs; 1802 return baseFs;
1803} 1803}
1804 1804
1805QString AdvancedFm::getDiskSpace( const QString &) {
1806
1807}
1805 1808
1806void AdvancedFm::doBeam() { 1809void AdvancedFm::doBeam() {
1807 Ir ir; 1810 Ir ir;
1808 if(!ir.supported()){ 1811 if(!ir.supported()){
1809 } else { 1812 } else {
1810 1813
1811 QStringList curFileList = getPath(); 1814 QStringList curFileList = getPath();
1812 if( curFileList.count() > 0) { 1815 if( curFileList.count() > 0) {
1813 1816
1814 if (TabWidget->currentPageIndex() == 0) { 1817 if (TabWidget->currentPageIndex() == 0) {
1815 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1818 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1816 1819
1817 QString curFile = currentDir.canonicalPath()+"/"+(*it); 1820 QString curFile = currentDir.canonicalPath()+"/"+(*it);
1818 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 1821 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
1819 Ir *file = new Ir(this, "IR"); 1822 Ir *file = new Ir(this, "IR");
1820 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 1823 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
1821 file->send( curFile, curFile ); 1824 file->send( curFile, curFile );
1822 } 1825 }
1823 1826
1824 } else { 1827 } else {
1825 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1828 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1826 1829
1827 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1830 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1828 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 1831 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
@@ -1847,101 +1850,102 @@ void AdvancedFm::fileBeamFinished( Ir *ir) {
1847// QListViewItemIterator it( Local_View ); 1850// QListViewItemIterator it( Local_View );
1848// for ( ; it.current(); ++it ) { 1851// for ( ; it.current(); ++it ) {
1849// if ( it.current()->isSelected() ) { 1852// if ( it.current()->isSelected() ) {
1850// QString strItem = it.current()->text(0); 1853// QString strItem = it.current()->text(0);
1851// QString localFile = currentDir.canonicalPath()+"/"+strItem; 1854// QString localFile = currentDir.canonicalPath()+"/"+strItem;
1852// QFileInfo fi(localFile); 1855// QFileInfo fi(localFile);
1853// } 1856// }
1854// } 1857// }
1855 1858
1856void AdvancedFm::showFileMenu() { 1859void AdvancedFm::showFileMenu() {
1857 1860
1858 QString curApp; 1861 QString curApp;
1859 bool isLocalView = false; 1862 bool isLocalView = false;
1860 if (TabWidget->currentPageIndex() == 0) { 1863 if (TabWidget->currentPageIndex() == 0) {
1861 isLocalView = TRUE; 1864 isLocalView = TRUE;
1862 curApp = Local_View->currentItem()->text(0); 1865 curApp = Local_View->currentItem()->text(0);
1863 } else { 1866 } else {
1864 curApp = Remote_View->currentItem()->text(0); 1867 curApp = Remote_View->currentItem()->text(0);
1865 } 1868 }
1866 1869
1867 MimeType mt( curApp ); 1870 MimeType mt( curApp );
1868 const AppLnk* app = mt.application(); 1871 const AppLnk* app = mt.application();
1869 QFile fi(curApp); 1872 QFile fi(curApp);
1870 1873
1871// QPopupMenu m; 1874 // QPopupMenu m;
1872 QPopupMenu *m = new QPopupMenu(0); 1875 QPopupMenu *m = new QPopupMenu(0);
1873 1876
1874 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 1877 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
1875 m->insertSeparator(); 1878 m->insertSeparator();
1876 if ( QFileInfo(fi).isDir() ) { 1879 if ( QFileInfo(fi).isDir() ) {
1877 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 1880 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
1878 } else { 1881 } else {
1879 1882
1880 if ( app ) 1883 if ( app )
1881 m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); 1884 m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) );
1882 else if( QFileInfo(fi).isExecutable() ) 1885 else if( QFileInfo(fi).isExecutable() )
1883 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 1886 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
1884 1887
1885 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 1888 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
1886 } 1889 }
1887 m->insertSeparator(); 1890 m->insertSeparator();
1888 1891
1889 1892
1890 if(isLocalView) 1893 if(isLocalView)
1891 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 1894 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
1892 else 1895 else
1893 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 1896 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
1894 1897
1895 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 1898 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
1896 m->insertSeparator(); 1899 m->insertSeparator();
1897 1900
1898 if(isLocalView) 1901 if(isLocalView)
1899 m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 1902 m->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
1900 else 1903 else
1901 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 1904 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
1905
1906 m->insertItem( tr( "Copy" ), this, SLOT( copy() ));
1907 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
1908 m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
1909 m->insertItem( tr( "Move" ), this, SLOT( move() ));
1910 m->insertSeparator();
1902 1911
1903 m->insertItem( tr( "Copy" ), this, SLOT( copy() )); 1912 if(isLocalView)
1904 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 1913 m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() ));
1905 m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 1914 else
1906 m->insertItem( tr( "Move" ), this, SLOT( move() )); 1915 m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() ));
1907 m->insertSeparator();
1908 1916
1909 if(isLocalView) 1917 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
1910 m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); 1918 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
1911 else 1919 m->insertSeparator();
1912 m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() ));
1913 1920
1914 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 1921 if(isLocalView)
1915 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 1922 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
1916 m->insertSeparator(); 1923 else
1924 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
1917 1925
1918 if(isLocalView) 1926 m->insertSeparator();
1919 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 1927 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
1920 else 1928
1921 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 1929 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings
1922 1930 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1923 m->insertSeparator(); 1931 m->setCheckable(TRUE);
1924 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 1932 if (!b)
1925 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings 1933 m->setItemChecked(m->idAt(0),TRUE);
1926 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 1934 else
1927 m->setCheckable(TRUE); 1935 m->setItemChecked(m->idAt(0),FALSE);
1928 if (!b) 1936 if(Ir::supported())
1929 m->setItemChecked(m->idAt(0),TRUE); 1937 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
1930 else 1938 m->setFocus();
1931 m->setItemChecked(m->idAt(0),FALSE); 1939 m->exec( QCursor::pos() );
1932 if(Ir::supported()) 1940 sleep(1);
1933 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 1941 if(m) delete m;
1934 m->setFocus();
1935 m->exec( QCursor::pos() );
1936 sleep(1);
1937 if(m) delete m;
1938} 1942}
1939 1943
1940 1944
1941void AdvancedFm::cancelMenuTimer() 1945void AdvancedFm::cancelMenuTimer()
1942{ 1946{
1943 1947
1944 qDebug("selectionChanged: cancel menu timer"); 1948 qDebug("selectionChanged: cancel menu timer");
1945 if( menuTimer.isActive() ) 1949 if( menuTimer.isActive() )
1946 menuTimer.stop(); 1950 menuTimer.stop();
1947} 1951}