-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 @@ -675,176 +675,180 @@ void AdvancedFm::mkSym() { if( curFile.right(1) == "/") { curFile = curFile.left( curFile.length() -1); } cmd = "ln -s "+curFile+" "+destName; // qDebug(cmd); startProcess( (const QString)cmd ); } rePopulate(); setOtherTabCurrent(); } } void AdvancedFm::doBeam() { Ir ir; if(!ir.supported()) { } else { QStringList curFileList = getPath(); if( curFileList.count() > 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString curFile = (*it); QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; if( curFilePath.right(1) == "/") { curFilePath = curFilePath.left( curFilePath.length() -1); } Ir *file = new Ir(this, "IR"); connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); file->send( curFilePath, curFile ); } } } } void AdvancedFm::fileBeamFinished( Ir *) { QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); } void AdvancedFm::selectAll() { QListView *thisView = CurrentView(); thisView->selectAll(true); thisView->setSelected( thisView->firstChild(),false); } void AdvancedFm::startProcess(const QString & cmd) { QStringList command; OProcess *process; process = new OProcess(); connect(process, SIGNAL(processExited(OProcess *)), this, SLOT( processEnded(OProcess *))); connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), this, SLOT( oprocessStderr(OProcess *, char *, int))); command << "/bin/sh"; command << "-c"; command << cmd.latin1(); *process << command; if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) qDebug("could not start process"); } void AdvancedFm::processEnded(OProcess *) { rePopulate(); } void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { // qWarning("received stderrt %d bytes", buflen); QString lineStr = buffer; QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); } bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { if ( o->inherits( "QLineEdit" ) ) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent*)e; if ( ke->key() == Key_Return || ke->key() == Key_Enter ) { okRename(); return true; } else if ( ke->key() == Key_Escape ) { cancelRename(); return true; } } else if ( e->type() == QEvent::FocusOut ) { cancelRename(); return true; } } if ( o->inherits( "QListView" ) ) { if ( e->type() == QEvent::FocusIn ) { if( o == Local_View) { //keep track of which view whichTab=1; } else { whichTab=2; } } OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection } return QWidget::eventFilter( o, e ); } void AdvancedFm::cancelRename() { // qDebug("cancel rename"); QListView * view; view = CurrentView(); bool resetFocus = view->viewport()->focusProxy() == renameBox; delete renameBox; renameBox = 0; if ( resetFocus ) { view->viewport()->setFocusProxy( view); view->setFocus(); } } void AdvancedFm::doRename(QListView * view) { if( !CurrentView()->currentItem()) return; QRect r = view->itemRect( view->currentItem( )); r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); r.setX( view->contentsX() ); - if ( r.width() > view->visibleWidth() ) + + if ( r.width() > view->visibleWidth() ) r.setWidth( view->visibleWidth() ); renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); renameBox->setFrame(true); renameBox->setText( view->currentItem()->text(0) ); renameBox->selectAll(); renameBox->installEventFilter( this ); + view->addChild( renameBox, r.x(), r.y() ); - renameBox->resize( r.size() ); - view->viewport()->setFocusProxy( renameBox ); - renameBox->setFocus(); + + renameBox->resize( r.size() ); + + view->viewport()->setFocusProxy( renameBox ); + + renameBox->setFocus(); renameBox->show(); } void AdvancedFm::renameIt() { - if( !CurrentView()->currentItem()) return; - QListView *thisView = CurrentView(); + if( !CurrentView()->currentItem()) return; + + QListView *thisView = CurrentView(); oldName = thisView->currentItem()->text(0); doRename( thisView ); - rePopulate(); } void AdvancedFm::okRename() { if( !CurrentView()->currentItem()) return; + QString newName = renameBox->text(); - cancelRename(); - QListView * view = CurrentView(); + cancelRename(); + QListView * view = CurrentView(); QString path = CurrentDir()->canonicalPath() + "/"; oldName = path + oldName; newName = path + newName; - if( rename( oldName.latin1(), newName.latin1())== -1) QMessageBox::message(tr("Note"),tr("Could not rename")); else oldName = ""; - view->takeItem( view->currentItem() ); delete view->currentItem(); - rePopulate(); + rePopulate(); } void AdvancedFm::openSearch() { QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); } |