Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 5a46579..2e6b0da 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -24,49 +24,49 @@ using namespace Opie::Core; | |||
24 | /* QT*/ | 24 | /* QT*/ |
25 | 25 | ||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | 31 | ||
32 | #include <errno.h> | 32 | #include <errno.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | #include <sys/stat.h> | 35 | #include <sys/stat.h> |
36 | #include <dirent.h> | 36 | #include <dirent.h> |
37 | #include <sys/sendfile.h> | 37 | #include <sys/sendfile.h> |
38 | #include <fcntl.h> | 38 | #include <fcntl.h> |
39 | 39 | ||
40 | void AdvancedFm::doDirChange() { | 40 | void AdvancedFm::doDirChange() { |
41 | QString pathItem = CurrentView()->currentItem()->text(0); | 41 | QString pathItem = CurrentView()->currentItem()->text(0); |
42 | if( pathItem == "../") { | 42 | if( pathItem == "../") { |
43 | ListClicked( CurrentView()->currentItem()); | 43 | ListClicked( CurrentView()->currentItem()); |
44 | } else { | 44 | } else { |
45 | if( pathItem.find(" -> ",0,TRUE) != -1) | 45 | if( pathItem.find(" -> ",0,TRUE) != -1) |
46 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; | 46 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; |
47 | // owarn << pathItem << oendl; | 47 | // owarn << pathItem << oendl; |
48 | gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | 48 | changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void AdvancedFm::showMenuHidden() { | 52 | void AdvancedFm::showMenuHidden() { |
53 | if (b) { | 53 | if (b) { |
54 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 54 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
55 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 55 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
56 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 56 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
57 | } else { | 57 | } else { |
58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
60 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 60 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
61 | } | 61 | } |
62 | b = !b; | 62 | b = !b; |
63 | populateView(); | 63 | populateView(); |
64 | } | 64 | } |
65 | 65 | ||
66 | void AdvancedFm::showHidden() { | 66 | void AdvancedFm::showHidden() { |
67 | if (b) { | 67 | if (b) { |
68 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 68 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
69 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 69 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
70 | } else { | 70 | } else { |
71 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 71 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
72 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 72 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
@@ -720,78 +720,79 @@ void AdvancedFm::startProcess(const QString & cmd) { | |||
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"); | ||
744 | if ( e->type() == QEvent::KeyPress ) { | 745 | if ( e->type() == QEvent::KeyPress ) { |
745 | QKeyEvent *ke = (QKeyEvent*)e; | 746 | QKeyEvent *ke = (QKeyEvent*)e; |
746 | if ( ke->key() == Key_Return || | 747 | if ( ke->key() == Key_Return || |
747 | ke->key() == Key_Enter ) { | 748 | ke->key() == Key_Enter ) { |
748 | okRename(); | 749 | okRename(); |
749 | return true; | 750 | return true; |
750 | } | 751 | } |
751 | else if ( ke->key() == Key_Escape ) { | 752 | else if ( ke->key() == Key_Escape ) { |
752 | cancelRename(); | 753 | cancelRename(); |
753 | return true; | 754 | return true; |
754 | } | 755 | } |
755 | } | 756 | } |
756 | else if ( e->type() == QEvent::FocusOut ) { | 757 | else if ( e->type() == QEvent::FocusOut ) { |
757 | cancelRename(); | 758 | cancelRename(); |
758 | return true; | 759 | return true; |
759 | } | 760 | } |
760 | } | 761 | } |
761 | if ( o->inherits( "QListView" ) ) { | 762 | /* if ( o->inherits( "QListView" ) ) { |
762 | if ( e->type() == QEvent::FocusIn ) { | 763 | if ( e->type() == QEvent::FocusIn ) { |
763 | // if( o == Local_View) { //keep track of which view | 764 | // if( o == Local_View) { //keep track of which view |
764 | // qDebug("local view"); | 765 | // qDebug("local view"); |
765 | // whichTab = 1; | 766 | // whichTab = 1; |
766 | // } else { | 767 | // } else { |
767 | // whichTab = 2; | 768 | // whichTab = 2; |
768 | // qDebug("remote view"); | 769 | // qDebug("remote view"); |
769 | // } | 770 | // } |
770 | } | 771 | } |
771 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 772 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
772 | } | 773 | } |
773 | 774 | */ | |
774 | return QWidget::eventFilter( o, e ); | 775 | return QWidget::eventFilter( o, e ); |
775 | } | 776 | } |
776 | 777 | ||
777 | 778 | ||
778 | void AdvancedFm::cancelRename() { | 779 | void AdvancedFm::cancelRename() { |
779 | // odebug << "cancel rename" << oendl; | 780 | // odebug << "cancel rename" << oendl; |
780 | QListView * view; | 781 | QListView * view; |
781 | view = CurrentView(); | 782 | view = CurrentView(); |
782 | 783 | ||
783 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 784 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
784 | delete renameBox; | 785 | delete renameBox; |
785 | renameBox = 0; | 786 | renameBox = 0; |
786 | if ( resetFocus ) { | 787 | if ( resetFocus ) { |
787 | view->viewport()->setFocusProxy( view); | 788 | view->viewport()->setFocusProxy( view); |
788 | view->setFocus(); | 789 | view->setFocus(); |
789 | } | 790 | } |
790 | } | 791 | } |
791 | 792 | ||
792 | void AdvancedFm::doRename(QListView * view) { | 793 | void AdvancedFm::doRename(QListView * view) { |
793 | if( !CurrentView()->currentItem()) return; | 794 | if( !CurrentView()->currentItem()) return; |
794 | 795 | ||
795 | QRect r = view->itemRect( view->currentItem( )); | 796 | QRect r = view->itemRect( view->currentItem( )); |
796 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 797 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
797 | r.setX( view->contentsX() ); | 798 | r.setX( view->contentsX() ); |
@@ -799,45 +800,46 @@ void AdvancedFm::doRename(QListView * view) { | |||
799 | r.setWidth( view->visibleWidth() ); | 800 | r.setWidth( view->visibleWidth() ); |
800 | 801 | ||
801 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 802 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
802 | renameBox->setFrame(true); | 803 | renameBox->setFrame(true); |
803 | renameBox->setText( view->currentItem()->text(0) ); | 804 | renameBox->setText( view->currentItem()->text(0) ); |
804 | renameBox->selectAll(); | 805 | renameBox->selectAll(); |
805 | renameBox->installEventFilter( this ); | 806 | renameBox->installEventFilter( this ); |
806 | view->addChild( renameBox, r.x(), r.y() ); | 807 | view->addChild( renameBox, r.x(), r.y() ); |
807 | renameBox->resize( r.size() ); | 808 | renameBox->resize( r.size() ); |
808 | view->viewport()->setFocusProxy( renameBox ); | 809 | view->viewport()->setFocusProxy( renameBox ); |
809 | renameBox->setFocus(); | 810 | renameBox->setFocus(); |
810 | renameBox->show(); | 811 | renameBox->show(); |
811 | } | 812 | } |
812 | 813 | ||
813 | 814 | ||
814 | void AdvancedFm::renameIt() { | 815 | void AdvancedFm::renameIt() { |
815 | if( !CurrentView()->currentItem()) return; | 816 | if( !CurrentView()->currentItem()) return; |
816 | 817 | ||
817 | QListView *thisView = CurrentView(); | 818 | QListView *thisView = CurrentView(); |
818 | oldName = thisView->currentItem()->text(0); | 819 | oldName = thisView->currentItem()->text(0); |
819 | doRename( thisView ); | 820 | doRename( thisView ); |
820 | } | 821 | } |
821 | 822 | ||
822 | void AdvancedFm::okRename() { | 823 | void AdvancedFm::okRename() { |
824 | qDebug("okrename"); | ||
823 | if( !renameBox) return; | 825 | if( !renameBox) return; |
824 | 826 | ||
825 | QString newName = renameBox->text(); | 827 | QString newName = renameBox->text(); |
826 | cancelRename(); | 828 | cancelRename(); |
827 | QListView * view = CurrentView(); | 829 | QListView * view = CurrentView(); |
828 | QString path = CurrentDir()->canonicalPath() + "/"; | 830 | QString path = CurrentDir()->canonicalPath() + "/"; |
829 | oldName = path + oldName; | 831 | oldName = path + oldName; |
830 | newName = path + newName; | 832 | newName = path + newName; |
831 | if( rename( oldName.latin1(), newName.latin1())== -1) | 833 | if( rename( oldName.latin1(), newName.latin1())== -1) |
832 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 834 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
833 | else | 835 | else |
834 | oldName = ""; | 836 | oldName = ""; |
835 | QListViewItem *item = view->currentItem(); | 837 | QListViewItem *item = view->currentItem(); |
836 | view->takeItem( item ); | 838 | view->takeItem( item ); |
837 | delete item; | 839 | delete item; |
838 | rePopulate(); | 840 | rePopulate(); |
839 | } | 841 | } |
840 | 842 | ||
841 | void AdvancedFm::openSearch() { | 843 | void AdvancedFm::openSearch() { |
842 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 844 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
843 | } | 845 | } |