-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 2e6b0da..b5a05d3 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -360,486 +360,485 @@ void AdvancedFm::copyAs() { | |||
360 | if( fileDlg->result() == 1 ) { | 360 | if( fileDlg->result() == 1 ) { |
361 | QString filename = fileDlg->LineEdit1->text(); | 361 | QString filename = fileDlg->LineEdit1->text(); |
362 | destFile = thatDir->canonicalPath()+"/"+filename; | 362 | destFile = thatDir->canonicalPath()+"/"+filename; |
363 | 363 | ||
364 | QFile f( destFile); | 364 | QFile f( destFile); |
365 | if( f.exists()) { | 365 | if( f.exists()) { |
366 | switch (QMessageBox::warning(this,tr("File Exists!"), | 366 | switch (QMessageBox::warning(this,tr("File Exists!"), |
367 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), | 367 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), |
368 | tr("Yes"),tr("No"),0,0,1) ) { | 368 | tr("Yes"),tr("No"),0,0,1) ) { |
369 | case 0: | 369 | case 0: |
370 | f.remove(); | 370 | f.remove(); |
371 | break; | 371 | break; |
372 | case 1: | 372 | case 1: |
373 | return; | 373 | return; |
374 | break; | 374 | break; |
375 | }; | 375 | }; |
376 | } | 376 | } |
377 | if( !copyFile( curFile, destFile) ) { | 377 | if( !copyFile( curFile, destFile) ) { |
378 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 378 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | } | 381 | } |
382 | delete fileDlg; | 382 | delete fileDlg; |
383 | 383 | ||
384 | } | 384 | } |
385 | rePopulate(); | 385 | rePopulate(); |
386 | // setOtherTabCurrent(); | 386 | // setOtherTabCurrent(); |
387 | qApp->processEvents(); | 387 | qApp->processEvents(); |
388 | 388 | ||
389 | } | 389 | } |
390 | 390 | ||
391 | void AdvancedFm::copySameDirTimer() { | 391 | void AdvancedFm::copySameDirTimer() { |
392 | QTimer::singleShot(125,this,SLOT(copySameDir())); | 392 | QTimer::singleShot(125,this,SLOT(copySameDir())); |
393 | } | 393 | } |
394 | 394 | ||
395 | void AdvancedFm::copySameDir() { | 395 | void AdvancedFm::copySameDir() { |
396 | qApp->processEvents(); | 396 | qApp->processEvents(); |
397 | QStringList curFileList = getPath(); | 397 | QStringList curFileList = getPath(); |
398 | QString curFile, item, destFile; | 398 | QString curFile, item, destFile; |
399 | InputDialog *fileDlg; | 399 | InputDialog *fileDlg; |
400 | 400 | ||
401 | QDir *thisDir = CurrentDir(); | 401 | QDir *thisDir = CurrentDir(); |
402 | 402 | ||
403 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 403 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
404 | item=(*it); | 404 | item=(*it); |
405 | curFile = thisDir->canonicalPath()+"/"+ item; | 405 | curFile = thisDir->canonicalPath()+"/"+ item; |
406 | 406 | ||
407 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 407 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
408 | fileDlg->setInputText((const QString &) destFile ); | 408 | fileDlg->setInputText((const QString &) destFile ); |
409 | fileDlg->exec(); | 409 | fileDlg->exec(); |
410 | 410 | ||
411 | if( fileDlg->result() == 1 ) { | 411 | if( fileDlg->result() == 1 ) { |
412 | 412 | ||
413 | QString filename = fileDlg->LineEdit1->text(); | 413 | QString filename = fileDlg->LineEdit1->text(); |
414 | destFile = thisDir->canonicalPath()+"/"+filename; | 414 | destFile = thisDir->canonicalPath()+"/"+filename; |
415 | 415 | ||
416 | QFile f(destFile); | 416 | QFile f(destFile); |
417 | if( f.exists()) { | 417 | if( f.exists()) { |
418 | switch (QMessageBox::warning(this,tr("Delete"), | 418 | switch (QMessageBox::warning(this,tr("Delete"), |
419 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), | 419 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), |
420 | tr("Yes"),tr("No"),0,0,1) ) { | 420 | tr("Yes"),tr("No"),0,0,1) ) { |
421 | case 0: | 421 | case 0: |
422 | 422 | ||
423 | f.remove(); | 423 | f.remove(); |
424 | break; | 424 | break; |
425 | case 1: | 425 | case 1: |
426 | return; | 426 | return; |
427 | break; | 427 | break; |
428 | }; | 428 | }; |
429 | } | 429 | } |
430 | if(!copyFile( curFile,destFile) ) { | 430 | if(!copyFile( curFile,destFile) ) { |
431 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 431 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
432 | return; | 432 | return; |
433 | } | 433 | } |
434 | 434 | ||
435 | // odebug << "copy "+curFile+" as "+destFile << oendl; | 435 | // odebug << "copy "+curFile+" as "+destFile << oendl; |
436 | } | 436 | } |
437 | delete fileDlg; | 437 | delete fileDlg; |
438 | } | 438 | } |
439 | rePopulate(); | 439 | rePopulate(); |
440 | } | 440 | } |
441 | 441 | ||
442 | void AdvancedFm::moveTimer() { | 442 | void AdvancedFm::moveTimer() { |
443 | QTimer::singleShot(125,this,SLOT(move())); | 443 | QTimer::singleShot(125,this,SLOT(move())); |
444 | } | 444 | } |
445 | 445 | ||
446 | void AdvancedFm::move() { | 446 | void AdvancedFm::move() { |
447 | 447 | ||
448 | QStringList curFileList = getPath(); | 448 | QStringList curFileList = getPath(); |
449 | if( curFileList.count() > 0) { | 449 | if( curFileList.count() > 0) { |
450 | QString curFile, destFile, item; | 450 | QString curFile, destFile, item; |
451 | 451 | ||
452 | QDir *thisDir = CurrentDir(); | 452 | QDir *thisDir = CurrentDir(); |
453 | QDir *thatDir = OtherDir(); | 453 | QDir *thatDir = OtherDir(); |
454 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 454 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
455 | item=(*it); | 455 | item=(*it); |
456 | QString destFile = thatDir->canonicalPath(); | 456 | QString destFile = thatDir->canonicalPath(); |
457 | 457 | ||
458 | if(destFile.right(1).find("/",0,TRUE) == -1) | 458 | if(destFile.right(1).find("/",0,TRUE) == -1) |
459 | destFile+="/"; | 459 | destFile+="/"; |
460 | destFile += item; | 460 | destFile += item; |
461 | // odebug << "Destination file is "+destFile << oendl; | 461 | // odebug << "Destination file is "+destFile << oendl; |
462 | 462 | ||
463 | curFile = thisDir->canonicalPath(); | 463 | curFile = thisDir->canonicalPath(); |
464 | if(curFile.right(1).find("/",0,TRUE) == -1) | 464 | if(curFile.right(1).find("/",0,TRUE) == -1) |
465 | curFile +="/"; | 465 | curFile +="/"; |
466 | curFile+= item; | 466 | curFile+= item; |
467 | // odebug << "CurrentFile file is " + curFile << oendl; | 467 | // odebug << "CurrentFile file is " + curFile << oendl; |
468 | 468 | ||
469 | if(QFileInfo(curFile).isDir()) { | 469 | if(QFileInfo(curFile).isDir()) { |
470 | moveDirectory( curFile, destFile ); | 470 | moveDirectory( curFile, destFile ); |
471 | rePopulate(); | 471 | rePopulate(); |
472 | return; | 472 | return; |
473 | } | 473 | } |
474 | QFile f( curFile); | 474 | QFile f( curFile); |
475 | if( f.exists()) { | 475 | if( f.exists()) { |
476 | if( !copyFile( curFile, destFile) ) { | 476 | if( !copyFile( curFile, destFile) ) { |
477 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 477 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
478 | return; | 478 | return; |
479 | } else | 479 | } else |
480 | QFile::remove(curFile); | 480 | QFile::remove(curFile); |
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
484 | } | 484 | } |
485 | rePopulate(); | 485 | rePopulate(); |
486 | //setOtherTabCurrent(); | 486 | //setOtherTabCurrent(); |
487 | } | 487 | } |
488 | 488 | ||
489 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 489 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
490 | int err = 0; | 490 | int err = 0; |
491 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; | 491 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; |
492 | err = system((const char*)cmd); | 492 | err = system((const char*)cmd); |
493 | } else | 493 | } else |
494 | err = -1; | 494 | err = -1; |
495 | 495 | ||
496 | if(err!=0) { | 496 | if(err!=0) { |
497 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); | 497 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); |
498 | return false; | 498 | return false; |
499 | } | 499 | } |
500 | return true; | 500 | return true; |
501 | } | 501 | } |
502 | 502 | ||
503 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 503 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
504 | 504 | ||
505 | QString cmd = "/bin/cp -fpR " + src + " " + dest; | 505 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
506 | owarn << cmd << oendl; | 506 | owarn << cmd << oendl; |
507 | int err = system( (const char *) cmd ); | 507 | int err = system( (const char *) cmd ); |
508 | if ( err != 0 ) { | 508 | if ( err != 0 ) { |
509 | QMessageBox::message("AdvancedFm", | 509 | QMessageBox::message("AdvancedFm", |
510 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); | 510 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); |
511 | return false; | 511 | return false; |
512 | } | 512 | } |
513 | 513 | ||
514 | return true; | 514 | return true; |
515 | } | 515 | } |
516 | 516 | ||
517 | 517 | ||
518 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 518 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
519 | if(QFileInfo(src).isDir()) { | 519 | if(QFileInfo(src).isDir()) { |
520 | if( copyDirectory( src, dest )) { | 520 | if( copyDirectory( src, dest )) { |
521 | // setOtherTabCurrent(); | 521 | // setOtherTabCurrent(); |
522 | rePopulate(); | 522 | rePopulate(); |
523 | return true; | 523 | return true; |
524 | } | 524 | } |
525 | else | 525 | else |
526 | return false; | 526 | return false; |
527 | } | 527 | } |
528 | 528 | ||
529 | 529 | ||
530 | bool success = true; | 530 | bool success = true; |
531 | struct stat status; | 531 | struct stat status; |
532 | QFile srcFile(src); | 532 | QFile srcFile(src); |
533 | QFile destFile(dest); | 533 | QFile destFile(dest); |
534 | int err=0; | 534 | int err=0; |
535 | int read_fd=0; | 535 | int read_fd=0; |
536 | int write_fd=0; | 536 | int write_fd=0; |
537 | struct stat stat_buf; | 537 | struct stat stat_buf; |
538 | off_t offset = 0; | 538 | off_t offset = 0; |
539 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 539 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
540 | // owarn << "open failed" << oendl; | 540 | // owarn << "open failed" << oendl; |
541 | return success = false; | 541 | return success = false; |
542 | } | 542 | } |
543 | read_fd = srcFile.handle(); | 543 | read_fd = srcFile.handle(); |
544 | if(read_fd != -1) { | 544 | if(read_fd != -1) { |
545 | fstat (read_fd, &stat_buf); | 545 | fstat (read_fd, &stat_buf); |
546 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 546 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
547 | // owarn << "destfile open failed" << oendl; | 547 | // owarn << "destfile open failed" << oendl; |
548 | return success = false; | 548 | return success = false; |
549 | } | 549 | } |
550 | write_fd = destFile.handle(); | 550 | write_fd = destFile.handle(); |
551 | if(write_fd != -1) { | 551 | if(write_fd != -1) { |
552 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 552 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
553 | if( err == -1) { | 553 | if( err == -1) { |
554 | QString msg; | 554 | QString msg; |
555 | switch(err) { | 555 | switch(err) { |
556 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 556 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
557 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 557 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
558 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 558 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
559 | case EIO: msg = "Unspecified error while reading from in_fd."; | 559 | case EIO: msg = "Unspecified error while reading from in_fd."; |
560 | }; | 560 | }; |
561 | success = false; | 561 | success = false; |
562 | // owarn << msg << oendl; | 562 | // owarn << msg << oendl; |
563 | } | 563 | } |
564 | } else { | 564 | } else { |
565 | success = false; | 565 | success = false; |
566 | } | 566 | } |
567 | } else { | 567 | } else { |
568 | success = false; | 568 | success = false; |
569 | } | 569 | } |
570 | srcFile.close(); | 570 | srcFile.close(); |
571 | destFile.close(); | 571 | destFile.close(); |
572 | // Set file permissions | 572 | // Set file permissions |
573 | if( stat( QFile::encodeName(src), &status ) == 0 ) { | 573 | if( stat( QFile::encodeName(src), &status ) == 0 ) { |
574 | chmod( QFile::encodeName(dest), status.st_mode ); | 574 | chmod( QFile::encodeName(dest), status.st_mode ); |
575 | } | 575 | } |
576 | 576 | ||
577 | return success; | 577 | return success; |
578 | } | 578 | } |
579 | 579 | ||
580 | void AdvancedFm::runCommand() { | 580 | void AdvancedFm::runCommand() { |
581 | if( !CurrentView()->currentItem()) return; | 581 | if( !CurrentView()->currentItem()) return; |
582 | QDir *thisDir = CurrentDir(); | 582 | QDir *thisDir = CurrentDir(); |
583 | 583 | ||
584 | QString curFile; | 584 | QString curFile; |
585 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 585 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
586 | 586 | ||
587 | InputDialog *fileDlg; | 587 | InputDialog *fileDlg; |
588 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 588 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
589 | fileDlg->setInputText(curFile); | 589 | fileDlg->setInputText(curFile); |
590 | fileDlg->exec(); | 590 | fileDlg->exec(); |
591 | //QString command; | 591 | //QString command; |
592 | 592 | ||
593 | if( fileDlg->result() == 1 ) { | 593 | if( fileDlg->result() == 1 ) { |
594 | // odebug << fileDlg->LineEdit1->text() << oendl; | 594 | // odebug << fileDlg->LineEdit1->text() << oendl; |
595 | QStringList command; | 595 | QStringList command; |
596 | 596 | ||
597 | command << "/bin/sh"; | 597 | command << "/bin/sh"; |
598 | command << "-c"; | 598 | command << "-c"; |
599 | command << fileDlg->LineEdit1->text(); | 599 | command << fileDlg->LineEdit1->text(); |
600 | Output *outDlg; | 600 | Output *outDlg; |
601 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 601 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
602 | QPEApplication::execDialog( outDlg ); | 602 | QPEApplication::execDialog( outDlg ); |
603 | qApp->processEvents(); | 603 | qApp->processEvents(); |
604 | 604 | ||
605 | } | 605 | } |
606 | } | 606 | } |
607 | 607 | ||
608 | void AdvancedFm::runCommandStd() { | 608 | void AdvancedFm::runCommandStd() { |
609 | if( !CurrentView()->currentItem()) return; | 609 | if( !CurrentView()->currentItem()) return; |
610 | QString curFile; | 610 | QString curFile; |
611 | QDir *thisDir = CurrentDir(); | 611 | QDir *thisDir = CurrentDir(); |
612 | QListView *thisView = CurrentView(); | 612 | QListView *thisView = CurrentView(); |
613 | if( thisView->currentItem()) | 613 | if( thisView->currentItem()) |
614 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 614 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
615 | 615 | ||
616 | InputDialog *fileDlg; | 616 | InputDialog *fileDlg; |
617 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 617 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
618 | fileDlg->setInputText(curFile); | 618 | fileDlg->setInputText(curFile); |
619 | fileDlg->exec(); | 619 | fileDlg->exec(); |
620 | 620 | ||
621 | if( fileDlg->result() == 1 ) { | 621 | if( fileDlg->result() == 1 ) { |
622 | qApp->processEvents(); | 622 | qApp->processEvents(); |
623 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 623 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | void AdvancedFm::fileStatus() { | 627 | void AdvancedFm::fileStatus() { |
628 | if( !CurrentView()->currentItem()) return; | 628 | if( !CurrentView()->currentItem()) return; |
629 | QString curFile; | 629 | QString curFile; |
630 | curFile = CurrentView()->currentItem()->text(0); | 630 | curFile = CurrentView()->currentItem()->text(0); |
631 | 631 | ||
632 | QStringList command; | 632 | QStringList command; |
633 | command << "/bin/sh"; | 633 | command << "/bin/sh"; |
634 | command << "-c"; | 634 | command << "-c"; |
635 | command << "stat -l "+ curFile; | 635 | command << "stat -l "+ curFile; |
636 | 636 | ||
637 | Output *outDlg; | 637 | Output *outDlg; |
638 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 638 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
639 | QPEApplication::execDialog( outDlg ); | 639 | QPEApplication::execDialog( outDlg ); |
640 | qApp->processEvents(); | 640 | qApp->processEvents(); |
641 | } | 641 | } |
642 | 642 | ||
643 | 643 | ||
644 | void AdvancedFm::mkDir() { | 644 | void AdvancedFm::mkDir() { |
645 | makeDir(); | 645 | makeDir(); |
646 | } | 646 | } |
647 | 647 | ||
648 | void AdvancedFm::rn() { | 648 | void AdvancedFm::rn() { |
649 | renameIt(); | 649 | renameIt(); |
650 | } | 650 | } |
651 | 651 | ||
652 | void AdvancedFm::del() { | 652 | void AdvancedFm::del() { |
653 | doDelete(); | 653 | doDelete(); |
654 | } | 654 | } |
655 | 655 | ||
656 | void AdvancedFm::mkSym() { | 656 | void AdvancedFm::mkSym() { |
657 | QString cmd; | 657 | QString cmd; |
658 | QStringList curFileList = getPath(); | 658 | QStringList curFileList = getPath(); |
659 | if( curFileList.count() > 0) { | 659 | if( curFileList.count() > 0) { |
660 | QDir *thisDir = CurrentDir(); | 660 | QDir *thisDir = CurrentDir(); |
661 | QDir * thatDir = OtherDir(); | 661 | QDir * thatDir = OtherDir(); |
662 | 662 | ||
663 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 663 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
664 | 664 | ||
665 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 665 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
666 | if(destName.right(1) == "/") { | 666 | if(destName.right(1) == "/") { |
667 | destName = destName.left( destName.length() -1); | 667 | destName = destName.left( destName.length() -1); |
668 | } | 668 | } |
669 | 669 | ||
670 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 670 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
671 | 671 | ||
672 | if( curFile.right(1) == "/") { | 672 | if( curFile.right(1) == "/") { |
673 | curFile = curFile.left( curFile.length() -1); | 673 | curFile = curFile.left( curFile.length() -1); |
674 | } | 674 | } |
675 | 675 | ||
676 | cmd = "ln -s "+curFile+" "+destName; | 676 | cmd = "ln -s "+curFile+" "+destName; |
677 | // odebug << cmd << oendl; | 677 | // odebug << cmd << oendl; |
678 | startProcess( (const QString)cmd ); | 678 | startProcess( (const QString)cmd ); |
679 | } | 679 | } |
680 | rePopulate(); | 680 | rePopulate(); |
681 | setOtherTabCurrent(); | 681 | setOtherTabCurrent(); |
682 | } | 682 | } |
683 | } | 683 | } |
684 | 684 | ||
685 | void AdvancedFm::doBeam() { | 685 | void AdvancedFm::doBeam() { |
686 | Ir ir; | 686 | Ir ir; |
687 | if(!ir.supported()) { | 687 | if(!ir.supported()) { |
688 | } else { | 688 | } else { |
689 | QStringList curFileList = getPath(); | 689 | QStringList curFileList = getPath(); |
690 | if( curFileList.count() > 0) { | 690 | if( curFileList.count() > 0) { |
691 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 691 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
692 | QString curFile = (*it); | 692 | QString curFile = (*it); |
693 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 693 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
694 | if( curFilePath.right(1) == "/") { | 694 | if( curFilePath.right(1) == "/") { |
695 | curFilePath = curFilePath.left( curFilePath.length() -1); | 695 | curFilePath = curFilePath.left( curFilePath.length() -1); |
696 | } | 696 | } |
697 | Ir *file = new Ir(this, "IR"); | 697 | Ir *file = new Ir(this, "IR"); |
698 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); | 698 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
699 | file->send( curFilePath, curFile ); | 699 | file->send( curFilePath, curFile ); |
700 | } | 700 | } |
701 | } | 701 | } |
702 | } | 702 | } |
703 | } | 703 | } |
704 | 704 | ||
705 | void AdvancedFm::fileBeamFinished( Ir *) { | 705 | void AdvancedFm::fileBeamFinished( Ir *) { |
706 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 706 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
707 | } | 707 | } |
708 | 708 | ||
709 | void AdvancedFm::selectAll() { | 709 | void AdvancedFm::selectAll() { |
710 | QListView *thisView = CurrentView(); | 710 | QListView *thisView = CurrentView(); |
711 | thisView->selectAll(true); | 711 | thisView->selectAll(true); |
712 | thisView->setSelected( thisView->firstChild(),false); | 712 | thisView->setSelected( thisView->firstChild(),false); |
713 | } | 713 | } |
714 | 714 | ||
715 | void AdvancedFm::startProcess(const QString & cmd) { | 715 | void AdvancedFm::startProcess(const QString & cmd) { |
716 | QStringList command; | 716 | QStringList command; |
717 | OProcess *process; | 717 | OProcess *process; |
718 | process = new OProcess(); | 718 | process = new OProcess(); |
719 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processEnded(Opie::Core::OProcess*))); | 719 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processEnded(Opie::Core::OProcess*))); |
720 | 720 | ||
721 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); | 721 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
722 | 722 | ||
723 | command << "/bin/sh"; | 723 | command << "/bin/sh"; |
724 | command << "-c"; | 724 | command << "-c"; |
725 | command << cmd.latin1(); | 725 | command << cmd.latin1(); |
726 | *process << command; | 726 | *process << command; |
727 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 727 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
728 | odebug << "could not start process" << oendl; | 728 | odebug << "could not start process" << oendl; |
729 | } | 729 | } |
730 | 730 | ||
731 | void AdvancedFm::processEnded(OProcess *) { | 731 | void AdvancedFm::processEnded(OProcess *) { |
732 | rePopulate(); | 732 | rePopulate(); |
733 | } | 733 | } |
734 | 734 | ||
735 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 735 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
736 | // owarn << "received stderrt " << buflen << " bytes" << oendl; | 736 | // owarn << "received stderrt " << buflen << " bytes" << oendl; |
737 | 737 | ||
738 | QString lineStr = buffer; | 738 | QString lineStr = buffer; |
739 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 739 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
740 | } | 740 | } |
741 | 741 | ||
742 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 742 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
743 | if ( o->inherits( "QLineEdit" ) ) { | 743 | if ( o->inherits( "QLineEdit" ) ) { |
744 | qDebug("QLineEdit event"); | ||
745 | if ( e->type() == QEvent::KeyPress ) { | 744 | if ( e->type() == QEvent::KeyPress ) { |
746 | QKeyEvent *ke = (QKeyEvent*)e; | 745 | QKeyEvent *ke = (QKeyEvent*)e; |
747 | if ( ke->key() == Key_Return || | 746 | if ( ke->key() == Key_Return || |
748 | ke->key() == Key_Enter ) { | 747 | ke->key() == Key_Enter ) { |
749 | okRename(); | 748 | okRename(); |
750 | return true; | 749 | return true; |
751 | } | 750 | } |
752 | else if ( ke->key() == Key_Escape ) { | 751 | else if ( ke->key() == Key_Escape ) { |
753 | cancelRename(); | 752 | cancelRename(); |
754 | return true; | 753 | return true; |
755 | } | 754 | } |
756 | } | 755 | } |
757 | else if ( e->type() == QEvent::FocusOut ) { | 756 | else if ( e->type() == QEvent::FocusOut ) { |
758 | cancelRename(); | 757 | cancelRename(); |
759 | return true; | 758 | return true; |
760 | } | 759 | } |
761 | } | 760 | } |
762 | /* if ( o->inherits( "QListView" ) ) { | 761 | /* if ( o->inherits( "QListView" ) ) { |
763 | if ( e->type() == QEvent::FocusIn ) { | 762 | if ( e->type() == QEvent::FocusIn ) { |
764 | // if( o == Local_View) { //keep track of which view | 763 | // if( o == Local_View) { //keep track of which view |
765 | // qDebug("local view"); | 764 | // qDebug("local view"); |
766 | // whichTab = 1; | 765 | // whichTab = 1; |
767 | // } else { | 766 | // } else { |
768 | // whichTab = 2; | 767 | // whichTab = 2; |
769 | // qDebug("remote view"); | 768 | // qDebug("remote view"); |
770 | // } | 769 | // } |
771 | } | 770 | } |
772 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 771 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
773 | } | 772 | } |
774 | */ | 773 | */ |
775 | return QWidget::eventFilter( o, e ); | 774 | return QWidget::eventFilter( o, e ); |
776 | } | 775 | } |
777 | 776 | ||
778 | 777 | ||
779 | void AdvancedFm::cancelRename() { | 778 | void AdvancedFm::cancelRename() { |
780 | // odebug << "cancel rename" << oendl; | 779 | // odebug << "cancel rename" << oendl; |
781 | QListView * view; | 780 | QListView * view; |
782 | view = CurrentView(); | 781 | view = CurrentView(); |
783 | 782 | ||
784 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 783 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
785 | delete renameBox; | 784 | delete renameBox; |
786 | renameBox = 0; | 785 | renameBox = 0; |
787 | if ( resetFocus ) { | 786 | if ( resetFocus ) { |
788 | view->viewport()->setFocusProxy( view); | 787 | view->viewport()->setFocusProxy( view); |
789 | view->setFocus(); | 788 | view->setFocus(); |
790 | } | 789 | } |
791 | } | 790 | } |
792 | 791 | ||
793 | void AdvancedFm::doRename(QListView * view) { | 792 | void AdvancedFm::doRename(QListView * view) { |
794 | if( !CurrentView()->currentItem()) return; | 793 | if( !CurrentView()->currentItem()) return; |
795 | 794 | ||
796 | QRect r = view->itemRect( view->currentItem( )); | 795 | QRect r = view->itemRect( view->currentItem( )); |
797 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 796 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
798 | r.setX( view->contentsX() ); | 797 | r.setX( view->contentsX() ); |
799 | if ( r.width() > view->visibleWidth() ) | 798 | if ( r.width() > view->visibleWidth() ) |
800 | r.setWidth( view->visibleWidth() ); | 799 | r.setWidth( view->visibleWidth() ); |
801 | 800 | ||
802 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 801 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
803 | renameBox->setFrame(true); | 802 | renameBox->setFrame(true); |
804 | renameBox->setText( view->currentItem()->text(0) ); | 803 | renameBox->setText( view->currentItem()->text(0) ); |
805 | renameBox->selectAll(); | 804 | renameBox->selectAll(); |
806 | renameBox->installEventFilter( this ); | 805 | renameBox->installEventFilter( this ); |
807 | view->addChild( renameBox, r.x(), r.y() ); | 806 | view->addChild( renameBox, r.x(), r.y() ); |
808 | renameBox->resize( r.size() ); | 807 | renameBox->resize( r.size() ); |
809 | view->viewport()->setFocusProxy( renameBox ); | 808 | view->viewport()->setFocusProxy( renameBox ); |
810 | renameBox->setFocus(); | 809 | renameBox->setFocus(); |
811 | renameBox->show(); | 810 | renameBox->show(); |
812 | } | 811 | } |
813 | 812 | ||
814 | 813 | ||
815 | void AdvancedFm::renameIt() { | 814 | void AdvancedFm::renameIt() { |
816 | if( !CurrentView()->currentItem()) return; | 815 | if( !CurrentView()->currentItem()) return; |
817 | 816 | ||
818 | QListView *thisView = CurrentView(); | 817 | QListView *thisView = CurrentView(); |
819 | oldName = thisView->currentItem()->text(0); | 818 | oldName = thisView->currentItem()->text(0); |
820 | doRename( thisView ); | 819 | doRename( thisView ); |
821 | } | 820 | } |
822 | 821 | ||
823 | void AdvancedFm::okRename() { | 822 | void AdvancedFm::okRename() { |
824 | qDebug("okrename"); | 823 | qDebug("okrename"); |
825 | if( !renameBox) return; | 824 | if( !renameBox) return; |
826 | 825 | ||
827 | QString newName = renameBox->text(); | 826 | QString newName = renameBox->text(); |
828 | cancelRename(); | 827 | cancelRename(); |
829 | QListView * view = CurrentView(); | 828 | QListView * view = CurrentView(); |
830 | QString path = CurrentDir()->canonicalPath() + "/"; | 829 | QString path = CurrentDir()->canonicalPath() + "/"; |
831 | oldName = path + oldName; | 830 | oldName = path + oldName; |
832 | newName = path + newName; | 831 | newName = path + newName; |
833 | if( rename( oldName.latin1(), newName.latin1())== -1) | 832 | if( rename( oldName.latin1(), newName.latin1())== -1) |
834 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 833 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
835 | else | 834 | else |
836 | oldName = ""; | 835 | oldName = ""; |
837 | QListViewItem *item = view->currentItem(); | 836 | QListViewItem *item = view->currentItem(); |
838 | view->takeItem( item ); | 837 | view->takeItem( item ); |
839 | delete item; | 838 | delete item; |
840 | rePopulate(); | 839 | rePopulate(); |
841 | } | 840 | } |
842 | 841 | ||
843 | void AdvancedFm::openSearch() { | 842 | void AdvancedFm::openSearch() { |
844 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 843 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
845 | } | 844 | } |