-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 90c887f..26bc36d 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -755,96 +755,100 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | |||
755 | return true; | 755 | return true; |
756 | } | 756 | } |
757 | else if ( ke->key() == Key_Escape ) { | 757 | else if ( ke->key() == Key_Escape ) { |
758 | cancelRename(); | 758 | cancelRename(); |
759 | return true; | 759 | return true; |
760 | } | 760 | } |
761 | } | 761 | } |
762 | else if ( e->type() == QEvent::FocusOut ) { | 762 | else if ( e->type() == QEvent::FocusOut ) { |
763 | cancelRename(); | 763 | cancelRename(); |
764 | return true; | 764 | return true; |
765 | } | 765 | } |
766 | } | 766 | } |
767 | if ( o->inherits( "QListView" ) ) { | 767 | if ( o->inherits( "QListView" ) ) { |
768 | if ( e->type() == QEvent::FocusIn ) { | 768 | if ( e->type() == QEvent::FocusIn ) { |
769 | if( o == Local_View) { //keep track of which view | 769 | if( o == Local_View) { //keep track of which view |
770 | whichTab=1; | 770 | whichTab=1; |
771 | } | 771 | } |
772 | else { | 772 | else { |
773 | whichTab=2; | 773 | whichTab=2; |
774 | } | 774 | } |
775 | } | 775 | } |
776 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 776 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
777 | } | 777 | } |
778 | 778 | ||
779 | return QWidget::eventFilter( o, e ); | 779 | return QWidget::eventFilter( o, e ); |
780 | } | 780 | } |
781 | 781 | ||
782 | 782 | ||
783 | void AdvancedFm::cancelRename() { | 783 | void AdvancedFm::cancelRename() { |
784 | // qDebug("cancel rename"); | 784 | // qDebug("cancel rename"); |
785 | QListView * view; | 785 | QListView * view; |
786 | view = CurrentView(); | 786 | view = CurrentView(); |
787 | 787 | ||
788 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 788 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
789 | delete renameBox; | 789 | delete renameBox; |
790 | renameBox = 0; | 790 | renameBox = 0; |
791 | if ( resetFocus ) { | 791 | if ( resetFocus ) { |
792 | view->viewport()->setFocusProxy( view); | 792 | view->viewport()->setFocusProxy( view); |
793 | view->setFocus(); | 793 | view->setFocus(); |
794 | } | 794 | } |
795 | } | 795 | } |
796 | 796 | ||
797 | void AdvancedFm::doRename(QListView * view) { | 797 | void AdvancedFm::doRename(QListView * view) { |
798 | if( !CurrentView()->currentItem()) return; | 798 | if( !CurrentView()->currentItem()) return; |
799 | 799 | ||
800 | QRect r = view->itemRect( view->currentItem( )); | 800 | QRect r = view->itemRect( view->currentItem( )); |
801 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 801 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
802 | r.setX( view->contentsX() ); | 802 | r.setX( view->contentsX() ); |
803 | if ( r.width() > view->visibleWidth() ) | 803 | |
804 | if ( r.width() > view->visibleWidth() ) | ||
804 | r.setWidth( view->visibleWidth() ); | 805 | r.setWidth( view->visibleWidth() ); |
805 | 806 | ||
806 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 807 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
807 | renameBox->setFrame(true); | 808 | renameBox->setFrame(true); |
808 | 809 | ||
809 | renameBox->setText( view->currentItem()->text(0) ); | 810 | renameBox->setText( view->currentItem()->text(0) ); |
810 | 811 | ||
811 | renameBox->selectAll(); | 812 | renameBox->selectAll(); |
812 | renameBox->installEventFilter( this ); | 813 | renameBox->installEventFilter( this ); |
814 | |||
813 | view->addChild( renameBox, r.x(), r.y() ); | 815 | view->addChild( renameBox, r.x(), r.y() ); |
814 | renameBox->resize( r.size() ); | 816 | |
815 | view->viewport()->setFocusProxy( renameBox ); | 817 | renameBox->resize( r.size() ); |
816 | renameBox->setFocus(); | 818 | |
819 | view->viewport()->setFocusProxy( renameBox ); | ||
820 | |||
821 | renameBox->setFocus(); | ||
817 | renameBox->show(); | 822 | renameBox->show(); |
818 | } | 823 | } |
819 | 824 | ||
820 | 825 | ||
821 | void AdvancedFm::renameIt() { | 826 | void AdvancedFm::renameIt() { |
822 | if( !CurrentView()->currentItem()) return; | 827 | if( !CurrentView()->currentItem()) return; |
823 | QListView *thisView = CurrentView(); | 828 | |
829 | QListView *thisView = CurrentView(); | ||
824 | oldName = thisView->currentItem()->text(0); | 830 | oldName = thisView->currentItem()->text(0); |
825 | doRename( thisView ); | 831 | doRename( thisView ); |
826 | rePopulate(); | ||
827 | } | 832 | } |
828 | 833 | ||
829 | void AdvancedFm::okRename() { | 834 | void AdvancedFm::okRename() { |
830 | if( !CurrentView()->currentItem()) return; | 835 | if( !CurrentView()->currentItem()) return; |
836 | |||
831 | QString newName = renameBox->text(); | 837 | QString newName = renameBox->text(); |
832 | cancelRename(); | 838 | cancelRename(); |
833 | QListView * view = CurrentView(); | 839 | QListView * view = CurrentView(); |
834 | QString path = CurrentDir()->canonicalPath() + "/"; | 840 | QString path = CurrentDir()->canonicalPath() + "/"; |
835 | oldName = path + oldName; | 841 | oldName = path + oldName; |
836 | newName = path + newName; | 842 | newName = path + newName; |
837 | |||
838 | if( rename( oldName.latin1(), newName.latin1())== -1) | 843 | if( rename( oldName.latin1(), newName.latin1())== -1) |
839 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 844 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
840 | else | 845 | else |
841 | oldName = ""; | 846 | oldName = ""; |
842 | |||
843 | view->takeItem( view->currentItem() ); | 847 | view->takeItem( view->currentItem() ); |
844 | delete view->currentItem(); | 848 | delete view->currentItem(); |
845 | rePopulate(); | 849 | rePopulate(); |
846 | } | 850 | } |
847 | 851 | ||
848 | void AdvancedFm::openSearch() { | 852 | void AdvancedFm::openSearch() { |
849 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 853 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
850 | } | 854 | } |