author | llornkcor <llornkcor> | 2003-02-23 03:47:07 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-23 03:47:07 (UTC) |
commit | 2678456bf180bcf0ab7cfa112f3c723cf1d87c84 (patch) (unidiff) | |
tree | eb7edd83adc3204088f2f3e0ed3c0ff9e48f5040 | |
parent | d51ca116a8c4d234db93021ccad36506980c317f (diff) | |
download | opie-2678456bf180bcf0ab7cfa112f3c723cf1d87c84.zip opie-2678456bf180bcf0ab7cfa112f3c723cf1d87c84.tar.gz opie-2678456bf180bcf0ab7cfa112f3c723cf1d87c84.tar.bz2 |
fix rename
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 2ddcabc..e7c0b6a 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -330,808 +330,808 @@ void AdvancedFm::remoteDelete() { | |||
330 | }; | 330 | }; |
331 | } | 331 | } |
332 | QString cmd="rm "+f; | 332 | QString cmd="rm "+f; |
333 | QFile file(f); | 333 | QFile file(f); |
334 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 334 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
335 | file.remove(); | 335 | file.remove(); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | populateRemoteView(); | 339 | populateRemoteView(); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | void AdvancedFm::filePerms() { | 343 | void AdvancedFm::filePerms() { |
344 | 344 | ||
345 | QStringList curFileList = getPath(); | 345 | QStringList curFileList = getPath(); |
346 | QString filePath; | 346 | QString filePath; |
347 | 347 | ||
348 | if (TabWidget->getCurrentTab() == 0) { | 348 | if (TabWidget->getCurrentTab() == 0) { |
349 | filePath = currentDir.canonicalPath()+"/"; | 349 | filePath = currentDir.canonicalPath()+"/"; |
350 | } else { | 350 | } else { |
351 | filePath= currentRemoteDir.canonicalPath()+"/"; | 351 | filePath= currentRemoteDir.canonicalPath()+"/"; |
352 | } | 352 | } |
353 | 353 | ||
354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
355 | filePermissions *filePerm; | 355 | filePermissions *filePerm; |
356 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 356 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
357 | filePerm->showMaximized(); | 357 | filePerm->showMaximized(); |
358 | filePerm->exec(); | 358 | filePerm->exec(); |
359 | if( filePerm) | 359 | if( filePerm) |
360 | delete filePerm; | 360 | delete filePerm; |
361 | } | 361 | } |
362 | if (TabWidget->getCurrentTab() == 0) { | 362 | if (TabWidget->getCurrentTab() == 0) { |
363 | populateLocalView(); | 363 | populateLocalView(); |
364 | } else { | 364 | } else { |
365 | populateRemoteView(); | 365 | populateRemoteView(); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | void AdvancedFm::doProperties() { | 369 | void AdvancedFm::doProperties() { |
370 | #if defined(QT_QWS_OPIE) | 370 | #if defined(QT_QWS_OPIE) |
371 | 371 | ||
372 | QStringList curFileList = getPath(); | 372 | QStringList curFileList = getPath(); |
373 | 373 | ||
374 | QString filePath; | 374 | QString filePath; |
375 | if (TabWidget->getCurrentTab() == 0) { | 375 | if (TabWidget->getCurrentTab() == 0) { |
376 | filePath = currentDir.canonicalPath()+"/"; | 376 | filePath = currentDir.canonicalPath()+"/"; |
377 | } else { | 377 | } else { |
378 | filePath= currentRemoteDir.canonicalPath()+"/"; | 378 | filePath= currentRemoteDir.canonicalPath()+"/"; |
379 | } | 379 | } |
380 | qDebug("%d",curFileList.count()); | 380 | qDebug("%d",curFileList.count()); |
381 | 381 | ||
382 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 382 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
383 | qDebug((filePath+*it)); | 383 | qDebug((filePath+*it)); |
384 | DocLnk lnk( (filePath+*it)); | 384 | DocLnk lnk( (filePath+*it)); |
385 | LnkProperties prop( &lnk ); | 385 | LnkProperties prop( &lnk ); |
386 | prop.showMaximized(); | 386 | prop.showMaximized(); |
387 | prop.exec(); | 387 | prop.exec(); |
388 | } | 388 | } |
389 | #endif | 389 | #endif |
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | void AdvancedFm::upDir() { | 393 | void AdvancedFm::upDir() { |
394 | if (TabWidget->getCurrentTab() == 0) { | 394 | if (TabWidget->getCurrentTab() == 0) { |
395 | QString current = currentDir.canonicalPath(); | 395 | QString current = currentDir.canonicalPath(); |
396 | QDir dir(current); | 396 | QDir dir(current); |
397 | dir.cdUp(); | 397 | dir.cdUp(); |
398 | current = dir.canonicalPath(); | 398 | current = dir.canonicalPath(); |
399 | chdir( current.latin1() ); | 399 | chdir( current.latin1() ); |
400 | currentDir.cd( current, TRUE); | 400 | currentDir.cd( current, TRUE); |
401 | populateLocalView(); | 401 | populateLocalView(); |
402 | update(); | 402 | update(); |
403 | } else { | 403 | } else { |
404 | QString current = currentRemoteDir.canonicalPath(); | 404 | QString current = currentRemoteDir.canonicalPath(); |
405 | QDir dir(current); | 405 | QDir dir(current); |
406 | dir.cdUp(); | 406 | dir.cdUp(); |
407 | current = dir.canonicalPath(); | 407 | current = dir.canonicalPath(); |
408 | chdir( current.latin1() ); | 408 | chdir( current.latin1() ); |
409 | currentRemoteDir.cd( current, TRUE); | 409 | currentRemoteDir.cd( current, TRUE); |
410 | populateRemoteView(); | 410 | populateRemoteView(); |
411 | update(); | 411 | update(); |
412 | } | 412 | } |
413 | } | 413 | } |
414 | 414 | ||
415 | void AdvancedFm::copy() { | 415 | void AdvancedFm::copy() { |
416 | qApp->processEvents(); | 416 | qApp->processEvents(); |
417 | QStringList curFileList = getPath(); | 417 | QStringList curFileList = getPath(); |
418 | bool doMsg=true; | 418 | bool doMsg=true; |
419 | int count=curFileList.count(); | 419 | int count=curFileList.count(); |
420 | if( count > 0) { | 420 | if( count > 0) { |
421 | if(count > 1 ){ | 421 | if(count > 1 ){ |
422 | QString msg; | 422 | QString msg; |
423 | msg=tr("Really copy\n%1 files?").arg(count); | 423 | msg=tr("Really copy\n%1 files?").arg(count); |
424 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 424 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
425 | ,tr("Yes"),tr("No"),0,0,1) ) { | 425 | ,tr("Yes"),tr("No"),0,0,1) ) { |
426 | case 0: | 426 | case 0: |
427 | doMsg=false; | 427 | doMsg=false; |
428 | break; | 428 | break; |
429 | case 1: | 429 | case 1: |
430 | return; | 430 | return; |
431 | break; | 431 | break; |
432 | }; | 432 | }; |
433 | } | 433 | } |
434 | 434 | ||
435 | QString curFile, item, destFile; | 435 | QString curFile, item, destFile; |
436 | if (TabWidget->getCurrentTab() == 0) { | 436 | if (TabWidget->getCurrentTab() == 0) { |
437 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 437 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
438 | item=(*it); | 438 | item=(*it); |
439 | if(item.find("->",0,TRUE)) //symlink | 439 | if(item.find("->",0,TRUE)) //symlink |
440 | item = item.left(item.find("->",0,TRUE)); | 440 | item = item.left(item.find("->",0,TRUE)); |
441 | 441 | ||
442 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; | 442 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; |
443 | qDebug("Destination file is "+destFile); | 443 | qDebug("Destination file is "+destFile); |
444 | 444 | ||
445 | curFile = currentDir.canonicalPath()+"/"+ item; | 445 | curFile = currentDir.canonicalPath()+"/"+ item; |
446 | qDebug("CurrentFile file is " + curFile); | 446 | qDebug("CurrentFile file is " + curFile); |
447 | 447 | ||
448 | QFile f(destFile); | 448 | QFile f(destFile); |
449 | if( f.exists()) { | 449 | if( f.exists()) { |
450 | if(doMsg) { | 450 | if(doMsg) { |
451 | switch ( QMessageBox::warning(this,tr("File Exists!"), tr("%1 exists. Ok to overwrite?").arg( item ), tr("Yes"),tr("No"),0,0,1) ) { | 451 | switch ( QMessageBox::warning(this,tr("File Exists!"), tr("%1 exists. Ok to overwrite?").arg( item ), tr("Yes"),tr("No"),0,0,1) ) { |
452 | case 1: | 452 | case 1: |
453 | return; | 453 | return; |
454 | break; | 454 | break; |
455 | }; | 455 | }; |
456 | } | 456 | } |
457 | f.remove(); | 457 | f.remove(); |
458 | } | 458 | } |
459 | if(!copyFile( curFile, destFile) ) { | 459 | if(!copyFile( curFile, destFile) ) { |
460 | QMessageBox::message("AdvancedFm",tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 460 | QMessageBox::message("AdvancedFm",tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
461 | return; | 461 | return; |
462 | } | 462 | } |
463 | } | 463 | } |
464 | populateRemoteView(); | 464 | populateRemoteView(); |
465 | TabWidget->setCurrentTab(1); | 465 | TabWidget->setCurrentTab(1); |
466 | 466 | ||
467 | } else { | 467 | } else { |
468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
469 | item= (*it); | 469 | item= (*it); |
470 | if(item.find("->",0,TRUE)) //symlink | 470 | if(item.find("->",0,TRUE)) //symlink |
471 | item = item.left(item.find("->",0,TRUE)); | 471 | item = item.left(item.find("->",0,TRUE)); |
472 | 472 | ||
473 | destFile = currentDir.canonicalPath()+"/"+ item; | 473 | destFile = currentDir.canonicalPath()+"/"+ item; |
474 | qDebug("Destination file is "+destFile); | 474 | qDebug("Destination file is "+destFile); |
475 | 475 | ||
476 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; | 476 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; |
477 | qDebug("CurrentFile file is " + curFile); | 477 | qDebug("CurrentFile file is " + curFile); |
478 | 478 | ||
479 | QFile f(destFile); | 479 | QFile f(destFile); |
480 | if( f.exists()) { | 480 | if( f.exists()) { |
481 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 481 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
482 | item+tr("\nexists. Ok to overwrite?"), | 482 | item+tr("\nexists. Ok to overwrite?"), |
483 | tr("Yes"),tr("No"),0,0,1) ) { | 483 | tr("Yes"),tr("No"),0,0,1) ) { |
484 | case 1: | 484 | case 1: |
485 | return; | 485 | return; |
486 | break; | 486 | break; |
487 | }; | 487 | }; |
488 | f.remove(); | 488 | f.remove(); |
489 | } | 489 | } |
490 | if(!copyFile( curFile, destFile) ) { | 490 | if(!copyFile( curFile, destFile) ) { |
491 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 491 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
492 | +curFile +tr("to\n")+destFile); | 492 | +curFile +tr("to\n")+destFile); |
493 | return; | 493 | return; |
494 | 494 | ||
495 | } | 495 | } |
496 | } | 496 | } |
497 | populateLocalView(); | 497 | populateLocalView(); |
498 | TabWidget->setCurrentTab(0); | 498 | TabWidget->setCurrentTab(0); |
499 | } | 499 | } |
500 | 500 | ||
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | void AdvancedFm::copyAs() { | 504 | void AdvancedFm::copyAs() { |
505 | qApp->processEvents(); | 505 | qApp->processEvents(); |
506 | 506 | ||
507 | QStringList curFileList = getPath(); | 507 | QStringList curFileList = getPath(); |
508 | QString curFile, item; | 508 | QString curFile, item; |
509 | InputDialog *fileDlg; | 509 | InputDialog *fileDlg; |
510 | if (TabWidget->getCurrentTab() == 0) { | 510 | if (TabWidget->getCurrentTab() == 0) { |
511 | qDebug("tab 1"); | 511 | qDebug("tab 1"); |
512 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 512 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
513 | QString destFile; | 513 | QString destFile; |
514 | item=(*it); | 514 | item=(*it); |
515 | curFile = currentDir.canonicalPath()+"/"+(*it); | 515 | curFile = currentDir.canonicalPath()+"/"+(*it); |
516 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 516 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
517 | 517 | ||
518 | fileDlg->setInputText((const QString &) destFile ); | 518 | fileDlg->setInputText((const QString &) destFile ); |
519 | fileDlg->exec(); | 519 | fileDlg->exec(); |
520 | 520 | ||
521 | if( fileDlg->result() == 1 ) { | 521 | if( fileDlg->result() == 1 ) { |
522 | QString filename = fileDlg->LineEdit1->text(); | 522 | QString filename = fileDlg->LineEdit1->text(); |
523 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 523 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
524 | 524 | ||
525 | QFile f(destFile); | 525 | QFile f(destFile); |
526 | if( f.exists()) { | 526 | if( f.exists()) { |
527 | switch (QMessageBox::warning(this,tr("File Exists!"), | 527 | switch (QMessageBox::warning(this,tr("File Exists!"), |
528 | item+tr("\nexists. Ok to overwrite?"), | 528 | item+tr("\nexists. Ok to overwrite?"), |
529 | tr("Yes"),tr("No"),0,0,1) ) { | 529 | tr("Yes"),tr("No"),0,0,1) ) { |
530 | case 0: | 530 | case 0: |
531 | f.remove(); | 531 | f.remove(); |
532 | break; | 532 | break; |
533 | case 1: | 533 | case 1: |
534 | return; | 534 | return; |
535 | break; | 535 | break; |
536 | }; | 536 | }; |
537 | } | 537 | } |
538 | if(!copyFile( curFile,destFile) ) { | 538 | if(!copyFile( curFile,destFile) ) { |
539 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 539 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
540 | +curFile +tr("to\n")+destFile); | 540 | +curFile +tr("to\n")+destFile); |
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | } | 543 | } |
544 | delete fileDlg; | 544 | delete fileDlg; |
545 | 545 | ||
546 | } | 546 | } |
547 | populateRemoteView(); | 547 | populateRemoteView(); |
548 | TabWidget->setCurrentTab(1); | 548 | TabWidget->setCurrentTab(1); |
549 | 549 | ||
550 | } else { | 550 | } else { |
551 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 551 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
552 | 552 | ||
553 | item=(*it); | 553 | item=(*it); |
554 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 554 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
555 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 555 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
556 | 556 | ||
557 | QString destFile; | 557 | QString destFile; |
558 | fileDlg->setInputText((const QString &) destFile); | 558 | fileDlg->setInputText((const QString &) destFile); |
559 | fileDlg->exec(); | 559 | fileDlg->exec(); |
560 | 560 | ||
561 | if( fileDlg->result() == 1 ) { | 561 | if( fileDlg->result() == 1 ) { |
562 | QString filename = fileDlg->LineEdit1->text(); | 562 | QString filename = fileDlg->LineEdit1->text(); |
563 | destFile = currentDir.canonicalPath()+"/"+filename; | 563 | destFile = currentDir.canonicalPath()+"/"+filename; |
564 | 564 | ||
565 | QFile f( destFile); | 565 | QFile f( destFile); |
566 | if( f.exists()) { | 566 | if( f.exists()) { |
567 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 567 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
568 | item+tr("\nexists. Ok to overwrite?"), | 568 | item+tr("\nexists. Ok to overwrite?"), |
569 | tr("Yes"),tr("No"),0,0,1) ) { | 569 | tr("Yes"),tr("No"),0,0,1) ) { |
570 | case 0: | 570 | case 0: |
571 | f.remove(); | 571 | f.remove(); |
572 | break; | 572 | break; |
573 | case 1: | 573 | case 1: |
574 | return; | 574 | return; |
575 | break; | 575 | break; |
576 | }; | 576 | }; |
577 | } | 577 | } |
578 | if(!copyFile( curFile,destFile) ) { | 578 | if(!copyFile( curFile,destFile) ) { |
579 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 579 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
580 | +curFile +tr("to\n")+destFile); | 580 | +curFile +tr("to\n")+destFile); |
581 | return; | 581 | return; |
582 | } | 582 | } |
583 | 583 | ||
584 | } | 584 | } |
585 | delete fileDlg; | 585 | delete fileDlg; |
586 | 586 | ||
587 | } | 587 | } |
588 | populateLocalView(); | 588 | populateLocalView(); |
589 | TabWidget->setCurrentTab(0); | 589 | TabWidget->setCurrentTab(0); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
593 | void AdvancedFm::copySameDir() { | 593 | void AdvancedFm::copySameDir() { |
594 | qApp->processEvents(); | 594 | qApp->processEvents(); |
595 | QStringList curFileList = getPath(); | 595 | QStringList curFileList = getPath(); |
596 | QString curFile, item, destFile; | 596 | QString curFile, item, destFile; |
597 | InputDialog *fileDlg; | 597 | InputDialog *fileDlg; |
598 | 598 | ||
599 | if (TabWidget->getCurrentTab() == 0) { | 599 | if (TabWidget->getCurrentTab() == 0) { |
600 | 600 | ||
601 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 601 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
602 | item=(*it); | 602 | item=(*it); |
603 | curFile = currentDir.canonicalPath()+"/"+ item; | 603 | curFile = currentDir.canonicalPath()+"/"+ item; |
604 | 604 | ||
605 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 605 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
606 | fileDlg->setInputText((const QString &) destFile ); | 606 | fileDlg->setInputText((const QString &) destFile ); |
607 | fileDlg->exec(); | 607 | fileDlg->exec(); |
608 | 608 | ||
609 | if( fileDlg->result() == 1 ) { | 609 | if( fileDlg->result() == 1 ) { |
610 | 610 | ||
611 | QString filename = fileDlg->LineEdit1->text(); | 611 | QString filename = fileDlg->LineEdit1->text(); |
612 | destFile = currentDir.canonicalPath()+"/"+filename; | 612 | destFile = currentDir.canonicalPath()+"/"+filename; |
613 | 613 | ||
614 | QFile f(destFile); | 614 | QFile f(destFile); |
615 | if( f.exists()) { | 615 | if( f.exists()) { |
616 | switch (QMessageBox::warning(this,tr("Delete"), | 616 | switch (QMessageBox::warning(this,tr("Delete"), |
617 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 617 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
618 | tr("Yes"),tr("No"),0,0,1) ) { | 618 | tr("Yes"),tr("No"),0,0,1) ) { |
619 | case 0: | 619 | case 0: |
620 | 620 | ||
621 | f.remove(); | 621 | f.remove(); |
622 | break; | 622 | break; |
623 | case 1: | 623 | case 1: |
624 | return; | 624 | return; |
625 | break; | 625 | break; |
626 | }; | 626 | }; |
627 | } | 627 | } |
628 | if(!copyFile( curFile,destFile) ) { | 628 | if(!copyFile( curFile,destFile) ) { |
629 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 629 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
630 | +curFile +tr("to\n")+destFile); | 630 | +curFile +tr("to\n")+destFile); |
631 | return; | 631 | return; |
632 | } | 632 | } |
633 | 633 | ||
634 | qDebug("copy "+curFile+" as "+destFile); | 634 | qDebug("copy "+curFile+" as "+destFile); |
635 | } | 635 | } |
636 | delete fileDlg; | 636 | delete fileDlg; |
637 | } | 637 | } |
638 | populateLocalView(); | 638 | populateLocalView(); |
639 | 639 | ||
640 | } else { | 640 | } else { |
641 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 641 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
642 | item=(*it); | 642 | item=(*it); |
643 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; | 643 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; |
644 | 644 | ||
645 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 645 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
646 | fileDlg->setInputText((const QString &) destFile); | 646 | fileDlg->setInputText((const QString &) destFile); |
647 | fileDlg->exec(); | 647 | fileDlg->exec(); |
648 | if( fileDlg->result() == 1 ) { | 648 | if( fileDlg->result() == 1 ) { |
649 | QString filename = fileDlg->LineEdit1->text(); | 649 | QString filename = fileDlg->LineEdit1->text(); |
650 | 650 | ||
651 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 651 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
652 | 652 | ||
653 | QFile f(destFile); | 653 | QFile f(destFile); |
654 | if( f.exists()) { | 654 | if( f.exists()) { |
655 | switch ( QMessageBox::warning(this,tr("Delete"), | 655 | switch ( QMessageBox::warning(this,tr("Delete"), |
656 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 656 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
657 | tr("Yes"),tr("No"),0,0,1) ) { | 657 | tr("Yes"),tr("No"),0,0,1) ) { |
658 | case 0: | 658 | case 0: |
659 | f.remove(); | 659 | f.remove(); |
660 | break; | 660 | break; |
661 | case 1: | 661 | case 1: |
662 | return; | 662 | return; |
663 | break; | 663 | break; |
664 | }; | 664 | }; |
665 | } | 665 | } |
666 | if(!copyFile( curFile,destFile) ) { | 666 | if(!copyFile( curFile,destFile) ) { |
667 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 667 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
668 | +curFile +tr("to\n")+destFile); | 668 | +curFile +tr("to\n")+destFile); |
669 | return; | 669 | return; |
670 | } | 670 | } |
671 | qDebug("copy "+curFile+" as "+destFile); | 671 | qDebug("copy "+curFile+" as "+destFile); |
672 | } | 672 | } |
673 | delete fileDlg; | 673 | delete fileDlg; |
674 | } | 674 | } |
675 | populateRemoteView(); | 675 | populateRemoteView(); |
676 | } | 676 | } |
677 | } | 677 | } |
678 | 678 | ||
679 | void AdvancedFm::move() { | 679 | void AdvancedFm::move() { |
680 | qApp->processEvents(); | 680 | qApp->processEvents(); |
681 | 681 | ||
682 | QStringList curFileList = getPath(); | 682 | QStringList curFileList = getPath(); |
683 | if( curFileList.count() > 0) { | 683 | if( curFileList.count() > 0) { |
684 | QString curFile, destFile, item; | 684 | QString curFile, destFile, item; |
685 | 685 | ||
686 | if (TabWidget->getCurrentTab() == 0) { | 686 | if (TabWidget->getCurrentTab() == 0) { |
687 | 687 | ||
688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
689 | item=(*it); | 689 | item=(*it); |
690 | QString destFile = currentRemoteDir.canonicalPath(); | 690 | QString destFile = currentRemoteDir.canonicalPath(); |
691 | 691 | ||
692 | if(destFile.right(1).find("/",0,TRUE) == -1) | 692 | if(destFile.right(1).find("/",0,TRUE) == -1) |
693 | destFile+="/"; | 693 | destFile+="/"; |
694 | destFile += item; | 694 | destFile += item; |
695 | curFile = currentDir.canonicalPath(); | 695 | curFile = currentDir.canonicalPath(); |
696 | 696 | ||
697 | qDebug("Destination file is "+destFile); | 697 | qDebug("Destination file is "+destFile); |
698 | 698 | ||
699 | if(curFile.right(1).find("/",0,TRUE) == -1) | 699 | if(curFile.right(1).find("/",0,TRUE) == -1) |
700 | curFile +="/"; | 700 | curFile +="/"; |
701 | 701 | ||
702 | curFile+= item; | 702 | curFile+= item; |
703 | qDebug("CurrentFile file is " + curFile); | 703 | qDebug("CurrentFile file is " + curFile); |
704 | 704 | ||
705 | QFile f( curFile); | 705 | QFile f( curFile); |
706 | if( f.exists()) { | 706 | if( f.exists()) { |
707 | if(!copyFile( curFile,destFile) ) { | 707 | if(!copyFile( curFile,destFile) ) { |
708 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 708 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
709 | return; | 709 | return; |
710 | } else | 710 | } else |
711 | QFile::remove(curFile); | 711 | QFile::remove(curFile); |
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | TabWidget->setCurrentTab(1); | 715 | TabWidget->setCurrentTab(1); |
716 | 716 | ||
717 | } else { //view 2 | 717 | } else { //view 2 |
718 | 718 | ||
719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
720 | item = (*it); | 720 | item = (*it); |
721 | QString destFile = currentDir.canonicalPath(); | 721 | QString destFile = currentDir.canonicalPath(); |
722 | 722 | ||
723 | if(destFile.right(1).find("/",0,TRUE) == -1) | 723 | if(destFile.right(1).find("/",0,TRUE) == -1) |
724 | destFile+="/"; | 724 | destFile+="/"; |
725 | 725 | ||
726 | destFile += item; | 726 | destFile += item; |
727 | 727 | ||
728 | qDebug("Destination file is "+destFile); | 728 | qDebug("Destination file is "+destFile); |
729 | 729 | ||
730 | curFile = currentRemoteDir.canonicalPath(); | 730 | curFile = currentRemoteDir.canonicalPath(); |
731 | 731 | ||
732 | if(curFile.right(1).find("/",0,TRUE) == -1) | 732 | if(curFile.right(1).find("/",0,TRUE) == -1) |
733 | curFile +="/"; | 733 | curFile +="/"; |
734 | curFile+= item; | 734 | curFile+= item; |
735 | qDebug("CurrentFile file is " + curFile); | 735 | qDebug("CurrentFile file is " + curFile); |
736 | 736 | ||
737 | QFile f( curFile); | 737 | QFile f( curFile); |
738 | if( f.exists()) { | 738 | if( f.exists()) { |
739 | if(!copyFile( curFile, destFile) ) { | 739 | if(!copyFile( curFile, destFile) ) { |
740 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | 740 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); |
741 | return; | 741 | return; |
742 | } else | 742 | } else |
743 | QFile::remove( curFile); | 743 | QFile::remove( curFile); |
744 | } | 744 | } |
745 | TabWidget->setCurrentTab(0); | 745 | TabWidget->setCurrentTab(0); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | populateRemoteView(); | 748 | populateRemoteView(); |
749 | populateLocalView(); | 749 | populateLocalView(); |
750 | } | 750 | } |
751 | } | 751 | } |
752 | 752 | ||
753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
754 | char bf[ 50000 ]; | 754 | char bf[ 50000 ]; |
755 | int bytesRead; | 755 | int bytesRead; |
756 | bool success = TRUE; | 756 | bool success = TRUE; |
757 | struct stat status; | 757 | struct stat status; |
758 | 758 | ||
759 | QFile s( src ); | 759 | QFile s( src ); |
760 | QFile d( dest ); | 760 | QFile d( dest ); |
761 | 761 | ||
762 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 762 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
763 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 763 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
765 | success = FALSE; | 765 | success = FALSE; |
766 | break; | 766 | break; |
767 | } | 767 | } |
768 | } | 768 | } |
769 | if( success && (bytesRead > 0) ){ | 769 | if( success && (bytesRead > 0) ){ |
770 | d.writeBlock( bf, bytesRead ); | 770 | d.writeBlock( bf, bytesRead ); |
771 | } | 771 | } |
772 | } else { | 772 | } else { |
773 | success = FALSE; | 773 | success = FALSE; |
774 | } | 774 | } |
775 | 775 | ||
776 | // Set file permissions | 776 | // Set file permissions |
777 | if( stat( (const char *) src, &status ) == 0 ){ | 777 | if( stat( (const char *) src, &status ) == 0 ){ |
778 | chmod( (const char *) dest, status.st_mode ); | 778 | chmod( (const char *) dest, status.st_mode ); |
779 | } | 779 | } |
780 | 780 | ||
781 | return success; | 781 | return success; |
782 | } | 782 | } |
783 | 783 | ||
784 | void AdvancedFm::runCommand() { | 784 | void AdvancedFm::runCommand() { |
785 | QString curFile; | 785 | QString curFile; |
786 | if (TabWidget->getCurrentTab() == 0) { | 786 | if (TabWidget->getCurrentTab() == 0) { |
787 | if( Local_View->currentItem()) | 787 | if( Local_View->currentItem()) |
788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
789 | } else { | 789 | } else { |
790 | if(Remote_View->currentItem()) | 790 | if(Remote_View->currentItem()) |
791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
792 | } | 792 | } |
793 | 793 | ||
794 | InputDialog *fileDlg; | 794 | InputDialog *fileDlg; |
795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
796 | fileDlg->setInputText(curFile); | 796 | fileDlg->setInputText(curFile); |
797 | fileDlg->exec(); | 797 | fileDlg->exec(); |
798 | //QString command; | 798 | //QString command; |
799 | 799 | ||
800 | if( fileDlg->result() == 1 ) { | 800 | if( fileDlg->result() == 1 ) { |
801 | qDebug(fileDlg->LineEdit1->text()); | 801 | qDebug(fileDlg->LineEdit1->text()); |
802 | QStringList command; | 802 | QStringList command; |
803 | 803 | ||
804 | command << "/bin/sh"; | 804 | command << "/bin/sh"; |
805 | command << "-c"; | 805 | command << "-c"; |
806 | command << fileDlg->LineEdit1->text(); | 806 | command << fileDlg->LineEdit1->text(); |
807 | Output *outDlg; | 807 | Output *outDlg; |
808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
809 | outDlg->showMaximized(); | 809 | outDlg->showMaximized(); |
810 | outDlg->exec(); | 810 | outDlg->exec(); |
811 | qApp->processEvents(); | 811 | qApp->processEvents(); |
812 | 812 | ||
813 | } | 813 | } |
814 | } | 814 | } |
815 | 815 | ||
816 | void AdvancedFm::runCommandStd() { | 816 | void AdvancedFm::runCommandStd() { |
817 | QString curFile; | 817 | QString curFile; |
818 | if (TabWidget->getCurrentTab() == 0) { | 818 | if (TabWidget->getCurrentTab() == 0) { |
819 | if( Local_View->currentItem()) | 819 | if( Local_View->currentItem()) |
820 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 820 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
821 | } else { | 821 | } else { |
822 | if(Remote_View->currentItem()) | 822 | if(Remote_View->currentItem()) |
823 | curFile = currentRemoteDir.canonicalPath() +"/" | 823 | curFile = currentRemoteDir.canonicalPath() +"/" |
824 | + Remote_View->currentItem()->text(0); | 824 | + Remote_View->currentItem()->text(0); |
825 | } | 825 | } |
826 | 826 | ||
827 | InputDialog *fileDlg; | 827 | InputDialog *fileDlg; |
828 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 828 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
829 | fileDlg->setInputText(curFile); | 829 | fileDlg->setInputText(curFile); |
830 | fileDlg->exec(); | 830 | fileDlg->exec(); |
831 | 831 | ||
832 | if( fileDlg->result() == 1 ) { | 832 | if( fileDlg->result() == 1 ) { |
833 | qApp->processEvents(); | 833 | qApp->processEvents(); |
834 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 834 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | void AdvancedFm::fileStatus() { | 838 | void AdvancedFm::fileStatus() { |
839 | QString curFile; | 839 | QString curFile; |
840 | if (TabWidget->getCurrentTab() == 0) { | 840 | if (TabWidget->getCurrentTab() == 0) { |
841 | curFile = Local_View->currentItem()->text(0); | 841 | curFile = Local_View->currentItem()->text(0); |
842 | } else { | 842 | } else { |
843 | curFile = Remote_View->currentItem()->text(0); | 843 | curFile = Remote_View->currentItem()->text(0); |
844 | } | 844 | } |
845 | 845 | ||
846 | QStringList command; | 846 | QStringList command; |
847 | command << "/bin/sh"; | 847 | command << "/bin/sh"; |
848 | command << "-c"; | 848 | command << "-c"; |
849 | command << "stat -l "+ curFile; | 849 | command << "stat -l "+ curFile; |
850 | 850 | ||
851 | Output *outDlg; | 851 | Output *outDlg; |
852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
853 | outDlg->showMaximized(); | 853 | outDlg->showMaximized(); |
854 | outDlg->exec(); | 854 | outDlg->exec(); |
855 | qApp->processEvents(); | 855 | qApp->processEvents(); |
856 | 856 | ||
857 | 857 | ||
858 | // Output *outDlg; | 858 | // Output *outDlg; |
859 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 859 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
860 | // outDlg->showMaximized(); | 860 | // outDlg->showMaximized(); |
861 | // outDlg->show(); | 861 | // outDlg->show(); |
862 | // qApp->processEvents(); | 862 | // qApp->processEvents(); |
863 | 863 | ||
864 | // FILE *fp; | 864 | // FILE *fp; |
865 | // char line[130]; | 865 | // char line[130]; |
866 | // sleep(1); | 866 | // sleep(1); |
867 | // fp = popen( (const char *) command, "r"); | 867 | // fp = popen( (const char *) command, "r"); |
868 | // if ( !fp ) { | 868 | // if ( !fp ) { |
869 | // qDebug("Could not execute '" + command + "'! err=%d", fp); | 869 | // qDebug("Could not execute '" + command + "'! err=%d", fp); |
870 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 870 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
871 | // pclose(fp); | 871 | // pclose(fp); |
872 | // return; | 872 | // return; |
873 | // } else { | 873 | // } else { |
874 | // while ( fgets( line, sizeof line, fp)) { | 874 | // while ( fgets( line, sizeof line, fp)) { |
875 | // outDlg->OutputEdit->append(line); | 875 | // outDlg->OutputEdit->append(line); |
876 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 876 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
877 | 877 | ||
878 | // } | 878 | // } |
879 | 879 | ||
880 | // } | 880 | // } |
881 | // pclose(fp); | 881 | // pclose(fp); |
882 | } | 882 | } |
883 | 883 | ||
884 | 884 | ||
885 | void AdvancedFm::mkDir() { | 885 | void AdvancedFm::mkDir() { |
886 | if (TabWidget->getCurrentTab() == 0) | 886 | if (TabWidget->getCurrentTab() == 0) |
887 | localMakDir(); | 887 | localMakDir(); |
888 | else | 888 | else |
889 | remoteMakDir(); | 889 | remoteMakDir(); |
890 | 890 | ||
891 | } | 891 | } |
892 | 892 | ||
893 | void AdvancedFm::rn() { | 893 | void AdvancedFm::rn() { |
894 | if (TabWidget->getCurrentTab() == 0) | 894 | if (TabWidget->getCurrentTab() == 0) |
895 | localRename(); | 895 | localRename(); |
896 | else | 896 | else |
897 | remoteRename(); | 897 | remoteRename(); |
898 | 898 | ||
899 | } | 899 | } |
900 | 900 | ||
901 | void AdvancedFm::del() { | 901 | void AdvancedFm::del() { |
902 | if (TabWidget->getCurrentTab() == 0) | 902 | if (TabWidget->getCurrentTab() == 0) |
903 | localDelete(); | 903 | localDelete(); |
904 | else | 904 | else |
905 | remoteDelete(); | 905 | remoteDelete(); |
906 | } | 906 | } |
907 | 907 | ||
908 | void AdvancedFm::mkSym() { | 908 | void AdvancedFm::mkSym() { |
909 | QString cmd; | 909 | QString cmd; |
910 | QStringList curFileList = getPath(); | 910 | QStringList curFileList = getPath(); |
911 | if( curFileList.count() > 0) { | 911 | if( curFileList.count() > 0) { |
912 | 912 | ||
913 | if (TabWidget->getCurrentTab() == 0) { | 913 | if (TabWidget->getCurrentTab() == 0) { |
914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
915 | 915 | ||
916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
920 | cmd = "ln -s "+curFile+" "+destName; | 920 | cmd = "ln -s "+curFile+" "+destName; |
921 | qDebug(cmd); | 921 | qDebug(cmd); |
922 | startProcess( (const QString)cmd ); | 922 | startProcess( (const QString)cmd ); |
923 | } | 923 | } |
924 | populateRemoteView(); | 924 | populateRemoteView(); |
925 | TabWidget->setCurrentTab(1); | 925 | TabWidget->setCurrentTab(1); |
926 | } else { | 926 | } else { |
927 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 927 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
928 | 928 | ||
929 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 929 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
933 | 933 | ||
934 | cmd = "ln -s "+curFile+" "+destName; | 934 | cmd = "ln -s "+curFile+" "+destName; |
935 | qDebug(cmd); | 935 | qDebug(cmd); |
936 | startProcess( (const QString)cmd ); | 936 | startProcess( (const QString)cmd ); |
937 | } | 937 | } |
938 | populateLocalView(); | 938 | populateLocalView(); |
939 | TabWidget->setCurrentTab(0); | 939 | TabWidget->setCurrentTab(0); |
940 | } | 940 | } |
941 | } | 941 | } |
942 | } | 942 | } |
943 | 943 | ||
944 | void AdvancedFm::doBeam() { | 944 | void AdvancedFm::doBeam() { |
945 | Ir ir; | 945 | Ir ir; |
946 | if(!ir.supported()){ | 946 | if(!ir.supported()){ |
947 | } else { | 947 | } else { |
948 | 948 | ||
949 | QStringList curFileList = getPath(); | 949 | QStringList curFileList = getPath(); |
950 | if( curFileList.count() > 0) { | 950 | if( curFileList.count() > 0) { |
951 | 951 | ||
952 | if (TabWidget->getCurrentTab() == 0) { | 952 | if (TabWidget->getCurrentTab() == 0) { |
953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
954 | 954 | ||
955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
957 | Ir *file = new Ir(this, "IR"); | 957 | Ir *file = new Ir(this, "IR"); |
958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
959 | file->send( curFile, curFile ); | 959 | file->send( curFile, curFile ); |
960 | } | 960 | } |
961 | 961 | ||
962 | } else { | 962 | } else { |
963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
964 | 964 | ||
965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
967 | Ir *file = new Ir(this, "IR"); | 967 | Ir *file = new Ir(this, "IR"); |
968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
969 | file->send( curFile, curFile ); | 969 | file->send( curFile, curFile ); |
970 | 970 | ||
971 | } | 971 | } |
972 | } | 972 | } |
973 | } | 973 | } |
974 | } | 974 | } |
975 | 975 | ||
976 | } | 976 | } |
977 | 977 | ||
978 | void AdvancedFm::fileBeamFinished( Ir *) { | 978 | void AdvancedFm::fileBeamFinished( Ir *) { |
979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
980 | 980 | ||
981 | } | 981 | } |
982 | 982 | ||
983 | void AdvancedFm::selectAll() { | 983 | void AdvancedFm::selectAll() { |
984 | if (TabWidget->getCurrentTab() == 0) { | 984 | if (TabWidget->getCurrentTab() == 0) { |
985 | Local_View->selectAll(true); | 985 | Local_View->selectAll(true); |
986 | Local_View->setSelected( Local_View->firstChild(),false); | 986 | Local_View->setSelected( Local_View->firstChild(),false); |
987 | } else { | 987 | } else { |
988 | Remote_View->selectAll(true); | 988 | Remote_View->selectAll(true); |
989 | Remote_View->setSelected( Remote_View->firstChild(),false); | 989 | Remote_View->setSelected( Remote_View->firstChild(),false); |
990 | } | 990 | } |
991 | } | 991 | } |
992 | 992 | ||
993 | void AdvancedFm::startProcess(const QString & cmd) { | 993 | void AdvancedFm::startProcess(const QString & cmd) { |
994 | QStringList command; | 994 | QStringList command; |
995 | OProcess *process; | 995 | OProcess *process; |
996 | process = new OProcess(); | 996 | process = new OProcess(); |
997 | connect(process, SIGNAL(processExited(OProcess *)), | 997 | connect(process, SIGNAL(processExited(OProcess *)), |
998 | this, SLOT( processEnded())); | 998 | this, SLOT( processEnded())); |
999 | 999 | ||
1000 | command << "/bin/sh"; | 1000 | command << "/bin/sh"; |
1001 | command << "-c"; | 1001 | command << "-c"; |
1002 | command << cmd.latin1(); | 1002 | command << cmd.latin1(); |
1003 | *process << command; | 1003 | *process << command; |
1004 | if(!process->start(OProcess::NotifyOnExit) ) | 1004 | if(!process->start(OProcess::NotifyOnExit) ) |
1005 | qDebug("could not start process"); | 1005 | qDebug("could not start process"); |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void AdvancedFm::processEnded() { | 1008 | void AdvancedFm::processEnded() { |
1009 | populateLocalView(); | 1009 | populateLocalView(); |
1010 | populateRemoteView(); | 1010 | populateRemoteView(); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 1013 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
1014 | if ( o->inherits( "QLineEdit" ) ) { | 1014 | if ( o->inherits( "QLineEdit" ) ) { |
1015 | if ( e->type() == QEvent::KeyPress ) { | 1015 | if ( e->type() == QEvent::KeyPress ) { |
1016 | QKeyEvent *ke = (QKeyEvent*)e; | 1016 | QKeyEvent *ke = (QKeyEvent*)e; |
1017 | if ( ke->key() == Key_Return || | 1017 | if ( ke->key() == Key_Return || |
1018 | ke->key() == Key_Enter ) { | 1018 | ke->key() == Key_Enter ) { |
1019 | okRename(); | 1019 | okRename(); |
1020 | return true; | 1020 | return true; |
1021 | } else if ( ke->key() == Key_Escape ) { | 1021 | } else if ( ke->key() == Key_Escape ) { |
1022 | cancelRename(); | 1022 | cancelRename(); |
1023 | return true; | 1023 | return true; |
1024 | } | 1024 | } |
1025 | } else if ( e->type() == QEvent::FocusOut ) { | 1025 | } else if ( e->type() == QEvent::FocusOut ) { |
1026 | cancelRename(); | 1026 | cancelRename(); |
1027 | return true; | 1027 | return true; |
1028 | } | 1028 | } |
1029 | } | 1029 | } |
1030 | if ( o->inherits( "QListView" ) ) { | 1030 | if ( o->inherits( "QListView" ) ) { |
1031 | if ( e->type() == QEvent::FocusOut ) { | 1031 | if ( e->type() == QEvent::FocusOut ) { |
1032 | printf("focusIn\n"); | 1032 | printf("focusIn\n"); |
1033 | 1033 | ||
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | return QWidget::eventFilter( o, e ); | 1037 | return QWidget::eventFilter( o, e ); |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | 1040 | ||
1041 | void AdvancedFm::cancelRename() | 1041 | void AdvancedFm::cancelRename() |
1042 | { | 1042 | { |
1043 | qDebug("cancel rename"); | 1043 | qDebug("cancel rename"); |
1044 | QListView * view; | 1044 | QListView * view; |
1045 | if (TabWidget->getCurrentTab() == 0) | 1045 | if (TabWidget->getCurrentTab() == 0) |
1046 | { | 1046 | { |
1047 | view = Local_View; | 1047 | view = Local_View; |
1048 | } | 1048 | } |
1049 | else | 1049 | else |
1050 | { | 1050 | { |
1051 | view = Remote_View; | 1051 | view = Remote_View; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 1054 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
1055 | delete renameBox; | 1055 | delete renameBox; |
1056 | renameBox = 0; | 1056 | renameBox = 0; |
1057 | if ( resetFocus ) { | 1057 | if ( resetFocus ) { |
1058 | view->viewport()->setFocusProxy( view); | 1058 | view->viewport()->setFocusProxy( view); |
1059 | view->setFocus(); | 1059 | view->setFocus(); |
1060 | } | 1060 | } |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | void AdvancedFm::doRename(QListView * view) | 1063 | void AdvancedFm::doRename(QListView * view) |
1064 | { | 1064 | { |
1065 | 1065 | ||
1066 | QRect r = view->itemRect( view->currentItem( )); | 1066 | QRect r = view->itemRect( view->currentItem( )); |
1067 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 1067 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
1068 | r.setX( view->contentsX() ); | 1068 | r.setX( view->contentsX() ); |
1069 | if ( r.width() > view->visibleWidth() ) | 1069 | if ( r.width() > view->visibleWidth() ) |
1070 | r.setWidth( view->visibleWidth() ); | 1070 | r.setWidth( view->visibleWidth() ); |
1071 | 1071 | ||
1072 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 1072 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
1073 | renameBox->setFrame(true); | 1073 | renameBox->setFrame(true); |
1074 | 1074 | ||
1075 | renameBox->setText( view->currentItem()->text(0) ); | 1075 | renameBox->setText( view->currentItem()->text(0) ); |
1076 | 1076 | ||
1077 | renameBox->selectAll(); | 1077 | renameBox->selectAll(); |
1078 | renameBox->installEventFilter( this ); | 1078 | renameBox->installEventFilter( this ); |
1079 | view->addChild( renameBox, r.x(), r.y() ); | 1079 | view->addChild( renameBox, r.x(), r.y() ); |
1080 | renameBox->resize( r.size() ); | 1080 | renameBox->resize( r.size() ); |
1081 | view->viewport()->setFocusProxy( renameBox ); | 1081 | view->viewport()->setFocusProxy( renameBox ); |
1082 | renameBox->setFocus(); | 1082 | renameBox->setFocus(); |
1083 | renameBox->show(); | 1083 | renameBox->show(); |
1084 | 1084 | ||
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | 1087 | ||
1088 | void AdvancedFm::localRename() | 1088 | void AdvancedFm::localRename() |
1089 | { | 1089 | { |
1090 | oldName = Local_View->currentItem()->text(0); | 1090 | oldName = Local_View->currentItem()->text(0); |
1091 | doRename(Local_View ); | 1091 | doRename(Local_View ); |
1092 | populateLocalView(); | 1092 | populateLocalView(); |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | void AdvancedFm::remoteRename() | 1095 | void AdvancedFm::remoteRename() |
1096 | { | 1096 | { |
1097 | oldName = Remote_View->currentItem()->text(0); | 1097 | oldName = Remote_View->currentItem()->text(0); |
1098 | doRename(Local_View ); | 1098 | doRename(Remote_View ); |
1099 | populateRemoteView(); | 1099 | populateRemoteView(); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void AdvancedFm::okRename() | 1102 | void AdvancedFm::okRename() |
1103 | { | 1103 | { |
1104 | QString newName = renameBox->text(); | 1104 | QString newName = renameBox->text(); |
1105 | cancelRename(); | 1105 | cancelRename(); |
1106 | int tabs=0; | 1106 | int tabs=0; |
1107 | QListView * view; | 1107 | QListView * view; |
1108 | tabs = TabWidget->getCurrentTab(); | 1108 | tabs = TabWidget->getCurrentTab(); |
1109 | if ( tabs == 0) | 1109 | if ( tabs == 0) |
1110 | { | 1110 | { |
1111 | view = Local_View; | 1111 | view = Local_View; |
1112 | QString path = currentDir.canonicalPath() + "/"; | 1112 | QString path = currentDir.canonicalPath() + "/"; |
1113 | oldName = path + oldName; | 1113 | oldName = path + oldName; |
1114 | newName = path + newName; | 1114 | newName = path + newName; |
1115 | } | 1115 | } |
1116 | else | 1116 | else |
1117 | { | 1117 | { |
1118 | view = Remote_View; | 1118 | view = Remote_View; |
1119 | QString path = currentRemoteDir.canonicalPath() + "/"; | 1119 | QString path = currentRemoteDir.canonicalPath() + "/"; |
1120 | oldName = path + oldName; | 1120 | oldName = path + oldName; |
1121 | newName = path + newName; | 1121 | newName = path + newName; |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | if( view->currentItem() == NULL) | 1124 | if( view->currentItem() == NULL) |
1125 | return; | 1125 | return; |
1126 | if( rename(oldName.latin1(), newName.latin1())== -1) | 1126 | if( rename(oldName.latin1(), newName.latin1())== -1) |
1127 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1127 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1128 | else | 1128 | else |
1129 | oldName = ""; | 1129 | oldName = ""; |
1130 | 1130 | ||
1131 | view->takeItem( view->currentItem() ); | 1131 | view->takeItem( view->currentItem() ); |
1132 | delete view->currentItem(); | 1132 | delete view->currentItem(); |
1133 | if ( tabs == 0) | 1133 | if ( tabs == 0) |
1134 | populateLocalView(); | 1134 | populateLocalView(); |
1135 | else | 1135 | else |
1136 | populateRemoteView(); | 1136 | populateRemoteView(); |
1137 | } | 1137 | } |