-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 34 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 26 |
2 files changed, 45 insertions, 15 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index c653b90..9edf7c1 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -62,16 +62,18 @@ #include <errno.h> #include <sys/vfs.h> #include <mntent.h> #include <sys/utsname.h> AdvancedFm::AdvancedFm( ) : QMainWindow( ) { init(); + renameBox = 0; + initConnections(); populateLocalView(); populateRemoteView(); currentPathCombo->setFocus(); } AdvancedFm::~AdvancedFm() { } @@ -397,34 +399,49 @@ void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { } } void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { // qDebug("list pressed"); switch (mouse) { case 1: + { + if(renameBox != 0 ) + { + qDebug("cancel rename"); + cancelRename(); + } + + } break; case 2: menuTimer.start( 500, TRUE ); qDebug("Start menu timer\n"); break; }; } void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { - switch (mouse) { - case 1: - break; - case 2: - menuTimer.start( 500, TRUE ); - qDebug("Start menu timer"); - break; - }; + switch (mouse) { + case 1: + { + if(renameBox != 0 ) + { + qDebug("cancel rename"); + cancelRename(); + } + } + break; + case 2: + menuTimer.start( 500, TRUE ); + qDebug("Start menu timer"); + break; + }; } void AdvancedFm::switchToLocalTab() { TabWidget->setCurrentTab(0); Local_View->setFocus(); } @@ -874,8 +891,9 @@ void AdvancedFm::addToDocs() { // curFile.replace(QRegExp("\\..*"),""); f.setName((*it)); f.setFile( curFile); f.writeLink(); } } } } + diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index f067013..2ddcabc 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -1022,41 +1022,51 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { cancelRename(); return true; } } else if ( e->type() == QEvent::FocusOut ) { cancelRename(); return true; } } + if ( o->inherits( "QListView" ) ) { + if ( e->type() == QEvent::FocusOut ) { + printf("focusIn\n"); + + } + } + return QWidget::eventFilter( o, e ); } -void AdvancedFm::cancelRename() { +void AdvancedFm::cancelRename() +{ qDebug("cancel rename"); QListView * view; - if (TabWidget->getCurrentTab() == 0) { - view = Local_View; - } + if (TabWidget->getCurrentTab() == 0) + { + view = Local_View; + } else { view = Remote_View; } bool resetFocus = view->viewport()->focusProxy() == renameBox; delete renameBox; renameBox = 0; if ( resetFocus ) { view->viewport()->setFocusProxy( view); view->setFocus(); } } -void AdvancedFm::doRename(QListView * view) { +void AdvancedFm::doRename(QListView * view) +{ QRect r = view->itemRect( view->currentItem( )); r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); r.setX( view->contentsX() ); if ( r.width() > view->visibleWidth() ) r.setWidth( view->visibleWidth() ); renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); @@ -1070,30 +1080,32 @@ void AdvancedFm::doRename(QListView * view) { renameBox->resize( r.size() ); view->viewport()->setFocusProxy( renameBox ); renameBox->setFocus(); renameBox->show(); } -void AdvancedFm::localRename() { +void AdvancedFm::localRename() +{ oldName = Local_View->currentItem()->text(0); doRename(Local_View ); populateLocalView(); } void AdvancedFm::remoteRename() { oldName = Remote_View->currentItem()->text(0); doRename(Local_View ); populateRemoteView(); } -void AdvancedFm::okRename() { +void AdvancedFm::okRename() +{ QString newName = renameBox->text(); cancelRename(); int tabs=0; QListView * view; tabs = TabWidget->getCurrentTab(); if ( tabs == 0) { view = Local_View; |