-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 2461e26..81a4318 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -575,264 +575,265 @@ void AdvancedFm::runCommand() { | |||
575 | InputDialog *fileDlg; | 575 | InputDialog *fileDlg; |
576 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 576 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
577 | fileDlg->setInputText(curFile); | 577 | fileDlg->setInputText(curFile); |
578 | fileDlg->exec(); | 578 | fileDlg->exec(); |
579 | //QString command; | 579 | //QString command; |
580 | 580 | ||
581 | if( fileDlg->result() == 1 ) { | 581 | if( fileDlg->result() == 1 ) { |
582 | // qDebug(fileDlg->LineEdit1->text()); | 582 | // qDebug(fileDlg->LineEdit1->text()); |
583 | QStringList command; | 583 | QStringList command; |
584 | 584 | ||
585 | command << "/bin/sh"; | 585 | command << "/bin/sh"; |
586 | command << "-c"; | 586 | command << "-c"; |
587 | command << fileDlg->LineEdit1->text(); | 587 | command << fileDlg->LineEdit1->text(); |
588 | Output *outDlg; | 588 | Output *outDlg; |
589 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 589 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
590 | QPEApplication::execDialog( outDlg ); | 590 | QPEApplication::execDialog( outDlg ); |
591 | qApp->processEvents(); | 591 | qApp->processEvents(); |
592 | 592 | ||
593 | } | 593 | } |
594 | } | 594 | } |
595 | 595 | ||
596 | void AdvancedFm::runCommandStd() { | 596 | void AdvancedFm::runCommandStd() { |
597 | if( !CurrentView()->currentItem()) return; | 597 | if( !CurrentView()->currentItem()) return; |
598 | QString curFile; | 598 | QString curFile; |
599 | QDir *thisDir = CurrentDir(); | 599 | QDir *thisDir = CurrentDir(); |
600 | QListView *thisView = CurrentView(); | 600 | QListView *thisView = CurrentView(); |
601 | if( thisView->currentItem()) | 601 | if( thisView->currentItem()) |
602 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 602 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
603 | 603 | ||
604 | InputDialog *fileDlg; | 604 | InputDialog *fileDlg; |
605 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 605 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
606 | fileDlg->setInputText(curFile); | 606 | fileDlg->setInputText(curFile); |
607 | fileDlg->exec(); | 607 | fileDlg->exec(); |
608 | 608 | ||
609 | if( fileDlg->result() == 1 ) { | 609 | if( fileDlg->result() == 1 ) { |
610 | qApp->processEvents(); | 610 | qApp->processEvents(); |
611 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 611 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
612 | } | 612 | } |
613 | } | 613 | } |
614 | 614 | ||
615 | void AdvancedFm::fileStatus() { | 615 | void AdvancedFm::fileStatus() { |
616 | if( !CurrentView()->currentItem()) return; | 616 | if( !CurrentView()->currentItem()) return; |
617 | QString curFile; | 617 | QString curFile; |
618 | curFile = CurrentView()->currentItem()->text(0); | 618 | curFile = CurrentView()->currentItem()->text(0); |
619 | 619 | ||
620 | QStringList command; | 620 | QStringList command; |
621 | command << "/bin/sh"; | 621 | command << "/bin/sh"; |
622 | command << "-c"; | 622 | command << "-c"; |
623 | command << "stat -l "+ curFile; | 623 | command << "stat -l "+ curFile; |
624 | 624 | ||
625 | Output *outDlg; | 625 | Output *outDlg; |
626 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 626 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
627 | QPEApplication::execDialog( outDlg ); | 627 | QPEApplication::execDialog( outDlg ); |
628 | qApp->processEvents(); | 628 | qApp->processEvents(); |
629 | } | 629 | } |
630 | 630 | ||
631 | 631 | ||
632 | void AdvancedFm::mkDir() { | 632 | void AdvancedFm::mkDir() { |
633 | makeDir(); | 633 | makeDir(); |
634 | } | 634 | } |
635 | 635 | ||
636 | void AdvancedFm::rn() { | 636 | void AdvancedFm::rn() { |
637 | renameIt(); | 637 | renameIt(); |
638 | } | 638 | } |
639 | 639 | ||
640 | void AdvancedFm::del() { | 640 | void AdvancedFm::del() { |
641 | doDelete(); | 641 | doDelete(); |
642 | } | 642 | } |
643 | 643 | ||
644 | void AdvancedFm::mkSym() { | 644 | void AdvancedFm::mkSym() { |
645 | QString cmd; | 645 | QString cmd; |
646 | QStringList curFileList = getPath(); | 646 | QStringList curFileList = getPath(); |
647 | if( curFileList.count() > 0) { | 647 | if( curFileList.count() > 0) { |
648 | QDir *thisDir = CurrentDir(); | 648 | QDir *thisDir = CurrentDir(); |
649 | QDir * thatDir = OtherDir(); | 649 | QDir * thatDir = OtherDir(); |
650 | 650 | ||
651 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 651 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
652 | 652 | ||
653 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 653 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
654 | if(destName.right(1) == "/") { | 654 | if(destName.right(1) == "/") { |
655 | destName = destName.left( destName.length() -1); | 655 | destName = destName.left( destName.length() -1); |
656 | } | 656 | } |
657 | 657 | ||
658 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 658 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
659 | 659 | ||
660 | if( curFile.right(1) == "/") { | 660 | if( curFile.right(1) == "/") { |
661 | curFile = curFile.left( curFile.length() -1); | 661 | curFile = curFile.left( curFile.length() -1); |
662 | } | 662 | } |
663 | 663 | ||
664 | cmd = "ln -s "+curFile+" "+destName; | 664 | cmd = "ln -s "+curFile+" "+destName; |
665 | // qDebug(cmd); | 665 | // qDebug(cmd); |
666 | startProcess( (const QString)cmd ); | 666 | startProcess( (const QString)cmd ); |
667 | } | 667 | } |
668 | rePopulate(); | 668 | rePopulate(); |
669 | setOtherTabCurrent(); | 669 | setOtherTabCurrent(); |
670 | } | 670 | } |
671 | } | 671 | } |
672 | 672 | ||
673 | void AdvancedFm::doBeam() { | 673 | void AdvancedFm::doBeam() { |
674 | Ir ir; | 674 | Ir ir; |
675 | if(!ir.supported()) { | 675 | if(!ir.supported()) { |
676 | } else { | 676 | } else { |
677 | QStringList curFileList = getPath(); | 677 | QStringList curFileList = getPath(); |
678 | if( curFileList.count() > 0) { | 678 | if( curFileList.count() > 0) { |
679 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 679 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
680 | QString curFile = (*it); | 680 | QString curFile = (*it); |
681 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 681 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
682 | if( curFilePath.right(1) == "/") { | 682 | if( curFilePath.right(1) == "/") { |
683 | curFilePath = curFilePath.left( curFilePath.length() -1); | 683 | curFilePath = curFilePath.left( curFilePath.length() -1); |
684 | } | 684 | } |
685 | Ir *file = new Ir(this, "IR"); | 685 | Ir *file = new Ir(this, "IR"); |
686 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); | 686 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
687 | file->send( curFilePath, curFile ); | 687 | file->send( curFilePath, curFile ); |
688 | } | 688 | } |
689 | } | 689 | } |
690 | } | 690 | } |
691 | } | 691 | } |
692 | 692 | ||
693 | void AdvancedFm::fileBeamFinished( Ir *) { | 693 | void AdvancedFm::fileBeamFinished( Ir *) { |
694 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 694 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
695 | } | 695 | } |
696 | 696 | ||
697 | void AdvancedFm::selectAll() { | 697 | void AdvancedFm::selectAll() { |
698 | QListView *thisView = CurrentView(); | 698 | QListView *thisView = CurrentView(); |
699 | thisView->selectAll(true); | 699 | thisView->selectAll(true); |
700 | thisView->setSelected( thisView->firstChild(),false); | 700 | thisView->setSelected( thisView->firstChild(),false); |
701 | } | 701 | } |
702 | 702 | ||
703 | void AdvancedFm::startProcess(const QString & cmd) { | 703 | void AdvancedFm::startProcess(const QString & cmd) { |
704 | QStringList command; | 704 | QStringList command; |
705 | OProcess *process; | 705 | OProcess *process; |
706 | process = new OProcess(); | 706 | process = new OProcess(); |
707 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | 707 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), |
708 | this, SLOT( processEnded(Opie::Core::OProcess*))); | 708 | this, SLOT( processEnded(Opie::Core::OProcess*))); |
709 | 709 | ||
710 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | 710 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), |
711 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); | 711 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
712 | 712 | ||
713 | command << "/bin/sh"; | 713 | command << "/bin/sh"; |
714 | command << "-c"; | 714 | command << "-c"; |
715 | command << cmd.latin1(); | 715 | command << cmd.latin1(); |
716 | *process << command; | 716 | *process << command; |
717 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 717 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
718 | qDebug("could not start process"); | 718 | qDebug("could not start process"); |
719 | } | 719 | } |
720 | 720 | ||
721 | void AdvancedFm::processEnded(OProcess *) { | 721 | void AdvancedFm::processEnded(OProcess *) { |
722 | rePopulate(); | 722 | rePopulate(); |
723 | } | 723 | } |
724 | 724 | ||
725 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 725 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
726 | // qWarning("received stderrt %d bytes", buflen); | 726 | // qWarning("received stderrt %d bytes", buflen); |
727 | 727 | ||
728 | QString lineStr = buffer; | 728 | QString lineStr = buffer; |
729 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 729 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
730 | } | 730 | } |
731 | 731 | ||
732 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 732 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
733 | if ( o->inherits( "QLineEdit" ) ) { | 733 | if ( o->inherits( "QLineEdit" ) ) { |
734 | if ( e->type() == QEvent::KeyPress ) { | 734 | if ( e->type() == QEvent::KeyPress ) { |
735 | QKeyEvent *ke = (QKeyEvent*)e; | 735 | QKeyEvent *ke = (QKeyEvent*)e; |
736 | if ( ke->key() == Key_Return || | 736 | if ( ke->key() == Key_Return || |
737 | ke->key() == Key_Enter ) { | 737 | ke->key() == Key_Enter ) { |
738 | okRename(); | 738 | okRename(); |
739 | return true; | 739 | return true; |
740 | } | 740 | } |
741 | else if ( ke->key() == Key_Escape ) { | 741 | else if ( ke->key() == Key_Escape ) { |
742 | cancelRename(); | 742 | cancelRename(); |
743 | return true; | 743 | return true; |
744 | } | 744 | } |
745 | } | 745 | } |
746 | else if ( e->type() == QEvent::FocusOut ) { | 746 | else if ( e->type() == QEvent::FocusOut ) { |
747 | cancelRename(); | 747 | cancelRename(); |
748 | return true; | 748 | return true; |
749 | } | 749 | } |
750 | } | 750 | } |
751 | if ( o->inherits( "QListView" ) ) { | 751 | if ( o->inherits( "QListView" ) ) { |
752 | if ( e->type() == QEvent::FocusIn ) { | 752 | if ( e->type() == QEvent::FocusIn ) { |
753 | if( o == Local_View) { //keep track of which view | 753 | if( o == Local_View) { //keep track of which view |
754 | whichTab=1; | 754 | whichTab=1; |
755 | } | 755 | } |
756 | else { | 756 | else { |
757 | whichTab=2; | 757 | whichTab=2; |
758 | } | 758 | } |
759 | } | 759 | } |
760 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 760 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
761 | } | 761 | } |
762 | 762 | ||
763 | return QWidget::eventFilter( o, e ); | 763 | return QWidget::eventFilter( o, e ); |
764 | } | 764 | } |
765 | 765 | ||
766 | 766 | ||
767 | void AdvancedFm::cancelRename() { | 767 | void AdvancedFm::cancelRename() { |
768 | // qDebug("cancel rename"); | 768 | // qDebug("cancel rename"); |
769 | QListView * view; | 769 | QListView * view; |
770 | view = CurrentView(); | 770 | view = CurrentView(); |
771 | 771 | ||
772 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 772 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
773 | delete renameBox; | 773 | delete renameBox; |
774 | renameBox = 0; | 774 | renameBox = 0; |
775 | if ( resetFocus ) { | 775 | if ( resetFocus ) { |
776 | view->viewport()->setFocusProxy( view); | 776 | view->viewport()->setFocusProxy( view); |
777 | view->setFocus(); | 777 | view->setFocus(); |
778 | } | 778 | } |
779 | } | 779 | } |
780 | 780 | ||
781 | void AdvancedFm::doRename(QListView * view) { | 781 | void AdvancedFm::doRename(QListView * view) { |
782 | if( !CurrentView()->currentItem()) return; | 782 | if( !CurrentView()->currentItem()) return; |
783 | 783 | ||
784 | QRect r = view->itemRect( view->currentItem( )); | 784 | QRect r = view->itemRect( view->currentItem( )); |
785 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 785 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
786 | r.setX( view->contentsX() ); | 786 | r.setX( view->contentsX() ); |
787 | 787 | ||
788 | if ( r.width() > view->visibleWidth() ) | 788 | if ( r.width() > view->visibleWidth() ) |
789 | r.setWidth( view->visibleWidth() ); | 789 | r.setWidth( view->visibleWidth() ); |
790 | 790 | ||
791 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 791 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
792 | renameBox->setFrame(true); | 792 | renameBox->setFrame(true); |
793 | 793 | ||
794 | renameBox->setText( view->currentItem()->text(0) ); | 794 | renameBox->setText( view->currentItem()->text(0) ); |
795 | 795 | ||
796 | renameBox->selectAll(); | 796 | renameBox->selectAll(); |
797 | renameBox->installEventFilter( this ); | 797 | renameBox->installEventFilter( this ); |
798 | 798 | ||
799 | view->addChild( renameBox, r.x(), r.y() ); | 799 | view->addChild( renameBox, r.x(), r.y() ); |
800 | 800 | ||
801 | renameBox->resize( r.size() ); | 801 | renameBox->resize( r.size() ); |
802 | 802 | ||
803 | view->viewport()->setFocusProxy( renameBox ); | 803 | view->viewport()->setFocusProxy( renameBox ); |
804 | 804 | ||
805 | renameBox->setFocus(); | 805 | renameBox->setFocus(); |
806 | renameBox->show(); | 806 | renameBox->show(); |
807 | } | 807 | } |
808 | 808 | ||
809 | 809 | ||
810 | void AdvancedFm::renameIt() { | 810 | void AdvancedFm::renameIt() { |
811 | if( !CurrentView()->currentItem()) return; | 811 | if( !CurrentView()->currentItem()) return; |
812 | 812 | ||
813 | QListView *thisView = CurrentView(); | 813 | QListView *thisView = CurrentView(); |
814 | oldName = thisView->currentItem()->text(0); | 814 | oldName = thisView->currentItem()->text(0); |
815 | doRename( thisView ); | 815 | doRename( thisView ); |
816 | } | 816 | } |
817 | 817 | ||
818 | void AdvancedFm::okRename() { | 818 | void AdvancedFm::okRename() { |
819 | if( !renameBox) return; | 819 | if( !renameBox) return; |
820 | 820 | ||
821 | QString newName = renameBox->text(); | 821 | QString newName = renameBox->text(); |
822 | cancelRename(); | 822 | cancelRename(); |
823 | QListView * view = CurrentView(); | 823 | QListView * view = CurrentView(); |
824 | QString path = CurrentDir()->canonicalPath() + "/"; | 824 | QString path = CurrentDir()->canonicalPath() + "/"; |
825 | oldName = path + oldName; | 825 | oldName = path + oldName; |
826 | newName = path + newName; | 826 | newName = path + newName; |
827 | if( rename( oldName.latin1(), newName.latin1())== -1) | 827 | if( rename( oldName.latin1(), newName.latin1())== -1) |
828 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 828 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
829 | else | 829 | else |
830 | oldName = ""; | 830 | oldName = ""; |
831 | view->takeItem( view->currentItem() ); | 831 | QListViewItem *item = view->currentItem(); |
832 | delete view->currentItem(); | 832 | view->takeItem( item ); |
833 | delete item; | ||
833 | rePopulate(); | 834 | rePopulate(); |
834 | } | 835 | } |
835 | 836 | ||
836 | void AdvancedFm::openSearch() { | 837 | void AdvancedFm::openSearch() { |
837 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 838 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
838 | } | 839 | } |