-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 66 |
3 files changed, 46 insertions, 40 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 3cd2067..8d07f69 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -221,230 +221,234 @@ void AdvancedFm::rePopulate() { // TabWidget->setCurrentWidget( tmpTab - 1); } void AdvancedFm::ListClicked(QListViewItem *selectedItem) { // if ( TabWidget->currentWidget() == tab) // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local"); // else // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote"); if(selectedItem) { QString strItem=selectedItem->text(0); // owarn << strItem << oendl; QString strSize=selectedItem->text(1); strSize=strSize.stripWhiteSpace(); bool isDirectory = false; QString strItem2; if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink strItem2 = dealWithSymName((const QString&)strItem); if(QDir(strItem2).exists() ) strItem = strItem2; } if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { if(QDir(strItem).exists()) isDirectory = true; } if( isDirectory ) { CurrentDir()->cd( strItem, TRUE); populateView(); CurrentView()->ensureItemVisible( CurrentView()->firstChild()); } chdir( strItem.latin1()); } } void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { Q_UNUSED(item); switch (mouse) { case 1: { if(renameBox != 0 ) { cancelRename(); } } break; // case 2: // menuTimer.start( 50, TRUE ); // break; }; } void AdvancedFm::refreshCurrentTab() { populateView(); // if ( TabWidget->currentWidget() == tab) { } void AdvancedFm::switchToLocalTab() { TabWidget->setCurrentWidget(0); - Local_View->setFocus(); +// Local_View->setFocus(); whichTab = 1; } void AdvancedFm::switchToRemoteTab() { TabWidget->setCurrentWidget(1); - Remote_View->setFocus(); +// Remote_View->setFocus(); whichTab = 2; } void AdvancedFm::currentPathComboChanged() { if(QDir( currentPathCombo->lineEdit()->text()).exists()) { CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); populateView(); } else { QMessageBox::message(tr("Note"),tr("That directory does not exist")); } } void AdvancedFm::fillCombo(const QString ¤tPath) { if ( TabWidget->currentWidget() == tab) { // if ( whichTab == 1) { currentPathCombo->lineEdit()->setText( currentPath); if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { currentPathCombo->clear(); localDirPathStringList.prepend( currentPath ); currentPathCombo->insertStringList( localDirPathStringList,-1); } } else { currentPathCombo->lineEdit()->setText( currentPath); if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { currentPathCombo->clear(); remoteDirPathStringList.prepend( currentPath ); currentPathCombo->insertStringList( remoteDirPathStringList,-1); } } } void AdvancedFm::currentPathComboActivated(const QString & currentPath) { chdir( currentPath.latin1() ); CurrentDir()->cd( currentPath, TRUE); populateView(); update(); } QStringList AdvancedFm::getPath() { QStringList strList; QListView *thisView=CurrentView(); QList<QListViewItem> * getSelectedItems( QListView * thisView ); QListViewItemIterator it( thisView ); for ( ; it.current(); ++it ) { if ( it.current()->isSelected() ) { strList << it.current()->text(0); // odebug << it.current()->text(0) << oendl; } } return strList; } void AdvancedFm::changeTo(const QString dir) { chdir( dir.latin1()); CurrentDir()->cd(dir, TRUE); populateView(); update(); } void AdvancedFm::homeButtonPushed() { changeTo(QDir::homeDirPath()); } void AdvancedFm::docButtonPushed() { changeTo(QPEApplication::documentDir()); } void AdvancedFm::SDButtonPushed() { changeTo("/mnt/card");// this can change so fix } void AdvancedFm::CFButtonPushed() { if(zaurusDevice) changeTo("/mnt/cf"); //zaurus else changeTo("/mnt/hda"); //ipaq } void AdvancedFm::QPEButtonPushed() { changeTo(QPEApplication::qpeDir()); } void AdvancedFm::doAbout() { QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); } void AdvancedFm::keyPressEvent( QKeyEvent *e) { Q_UNUSED(e); } void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { - if( CurrentView()->hasFocus() ) - e->ignore(); - if( e->key() == Key_Left ) +// if( CurrentView()->hasFocus() ) +// e->ignore(); + if( currentPathCombo->lineEdit()->hasFocus()) { +// qDebug("shout!"); + } + + else if( e->key() == Key_Left ) upDir(); else if( e->key() == Key_Return || e->key() == Key_Enter) navigateToSelected(); else if( e->key() == Key_Tab) setOtherTabCurrent(); else if( e->key() == Key_Delete ) del(); else if( e->key() == Key_A) copyAs(); else if( e->key() == Key_C) copy(); else if( e->key() == Key_E) runThis(); else if( e->key() == Key_G) currentPathCombo->lineEdit()->setFocus(); else if( e->key() == Key_H ) showHidden(); else if( e->key() == Key_I) fileStatus(); else if( e->key() == Key_M) move(); else if( e->key() == Key_N ) mkDir(); else if( e->key() == Key_P) filePerms(); else if( e->key() == Key_R ) rn(); else if( e->key() == Key_U ) upDir(); else if( e->key() == Key_1) switchToLocalTab(); else if( e->key() == Key_2) switchToRemoteTab(); else if( e->key() == Key_3) CFButtonPushed(); else if( e->key() == Key_4) SDButtonPushed(); else if( e->key() == Key_5 ) homeButtonPushed(); else if( e->key() == Key_6 ) docButtonPushed(); else e->accept(); } void AdvancedFm::parsetab(const QString &fileName) { fileSystemTypeList.clear(); fsList.clear(); struct mntent *me; FILE *mntfp = setmntent( fileName.latin1(), "r" ); if ( mntfp ) { while ( (me = getmntent( mntfp )) != 0 ) { QString deviceName = me->mnt_fsname; QString filesystemType = me->mnt_type; QString mountDir = me->mnt_dir; if(deviceName != "none") { if( fsList.contains(filesystemType) == 0 & filesystemType.find("proc",0,TRUE) == -1 & filesystemType.find("cramfs",0,TRUE) == -1 & filesystemType.find("auto",0,TRUE) == -1) fsList << filesystemType; fileSystemTypeList << mountDir+"::"+filesystemType; @@ -694,107 +698,107 @@ void AdvancedFm::gotoCustomDir(const QString &dir) { // if( curDir.isEmpty()) { // } if( dir == s_addBookmark) { addCustomDir(); } if( dir == s_removeBookmark) { removeCustomDir( ); } else { changeTo( dir); // if(QDir( curDir).exists() ) // { // thisDir->setPath( curDir ); // chdir( curDir.latin1() ); // thisDir->cd( curDir, TRUE); // populateView(); // } } } QDir *AdvancedFm::CurrentDir() { if ( whichTab == 1) { // qDebug("CurrentTab is Local"); return ¤tDir; } else { // qDebug("CurrentTab is Remote"); return ¤tRemoteDir; } } QDir *AdvancedFm::OtherDir() { // if ( TabWidget->currentWidget() == tab) { if ( whichTab == 1) { return ¤tRemoteDir; } else { return ¤tDir; } } QListView * AdvancedFm::CurrentView() { // if ( TabWidget->currentWidget() == tab) { if ( whichTab == 1) { // qDebug("CurrentView: local"); return Local_View; } else { // owarn << "CurrentView Tab 2" << oendl; // qDebug("CurrentView: remote"); return Remote_View; } } QListView * AdvancedFm::OtherView() { if ( whichTab == 1) return Remote_View; else return Local_View; } void AdvancedFm::setOtherTabCurrent() { // qDebug("setOtherTabCurrent() %d",whichTab); if ( whichTab == 1) { TabWidget->setCurrentWidget(1); } else { TabWidget->setCurrentWidget(0); } - OtherView()->setFocus(); +// OtherView()->setFocus(); OtherView()->setSelected( CurrentView()->firstChild(), true); } void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { // odebug << "qcop message "+msg << oendl; QDataStream stream ( data, IO_ReadOnly ); if ( msg == "openDirectory(QString)" ) { // odebug << "received" << oendl; QString file; stream >> file; changeTo( (const QString &) file); } } void AdvancedFm::setDocument(const QString &file) { changeTo( file); } void AdvancedFm::findFile(const QString &fileName) { QFileInfo fi(fileName); QListView *thisView = CurrentView(); QListViewItemIterator it( thisView ); for ( ; it.current(); ++it ) { if(it.current()->text(0) == fi.fileName()) { it.current()->setSelected(true); thisView->ensureItemVisible(it.current()); } } } void AdvancedFm::slotSwitchMenu(int item) { Q_UNUSED(item); // qDebug( "Switch %d",item); // viewMenu->setItemChecked(item, true); } void AdvancedFm::navigateToSelected() { if( !CurrentView()->currentItem()) return; doDirChange(); } diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index d2e1d8e..fe565a0 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp @@ -67,137 +67,137 @@ void AdvancedFm::init() { cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); cfButton->setAutoRaise( true ); menuBar->insertItem( cfButton ); sdButton = new QToolButton( 0, "SDButton"); sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); sdButton->setAutoRaise( true ); menuBar->insertItem( sdButton ); docButton = new QToolButton( 0,"docsButton"); docButton->setPixmap(Resource::loadPixmap("DocsIcon")); docButton->setAutoRaise( true ); menuBar->insertItem( docButton ); homeButton = new QToolButton( 0, "homeButton"); homeButton->setPixmap(Resource::loadPixmap("home")); homeButton->setAutoRaise( true ); menuBar->insertItem( homeButton ); fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); fileMenu->setCheckable(TRUE); viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); viewMenu->insertItem( tr( "Refresh" ), this, SLOT( refreshCurrentTab())); // viewMenu->insertSeparator(); // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); viewMenu->setCheckable(true); viewMenu->setItemChecked( viewMenu->idAt(0), true); viewMenu->setItemChecked( viewMenu->idAt(1), false); s_addBookmark = tr("Bookmark Directory"); s_removeBookmark = tr("Remove Current Directory from Bookmarks"); // menuButton->insertItem(""); // customDirMenu->insertItem(tr("Add This Directory")); // customDirMenu->insertItem(tr("Remove This Directory")); // customDirMenu->insertSeparator(); QHBoxLayout *CBHB = new QHBoxLayout(); // parent layout will be set later CBHB->setMargin( 0 ); CBHB->setSpacing( 1 ); menuButton = new MenuButton( this ); menuButton->setUseLabel(false); menuButton->setMaximumWidth( 20 ); menuButton->insertItem( s_addBookmark); menuButton->insertItem( s_removeBookmark); menuButton->insertSeparator(); - menuButton->setFocusPolicy(NoFocus); +// menuButton->setFocusPolicy(NoFocus); CBHB->addWidget( menuButton ); customDirsToMenu(); currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); currentPathCombo->setEditable(TRUE); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); - currentPathCombo->setFocusPolicy(NoFocus); +// currentPathCombo->setFocusPolicy(NoFocus); CBHB->addWidget( currentPathCombo ); layout->addLayout( CBHB ); TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); // TabWidget = new QTabWidget( this, "TabWidget" ); layout->addWidget( TabWidget, 4 ); tab = new QWidget( TabWidget, "tab" ); tabLayout = new QGridLayout( tab ); tabLayout->setSpacing( 2); tabLayout->setMargin( 2); Local_View = new QListView( tab, "Local_View" ); Local_View->addColumn( tr("File"),130); Local_View->addColumn( tr("Size"),-1); Local_View->setColumnAlignment(1,QListView::AlignRight); Local_View->addColumn( tr("Date"),-1); Local_View->setColumnAlignment(2,QListView::AlignRight); Local_View->setAllColumnsShowFocus(TRUE); Local_View->setMultiSelection( TRUE ); Local_View->setSelectionMode(QListView::Extended); Local_View->setFocusPolicy(StrongFocus); Local_View->installEventFilter( this ); QPEApplication::setStylusOperation( Local_View->viewport() , QPEApplication::RightOnHold); tabLayout->addWidget( Local_View, 0, 0 ); TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); // TabWidget->insertTab( tab, tr("1")); tab_2 = new QWidget( TabWidget, "tab_2" ); tabLayout_2 = new QGridLayout( tab_2 ); tabLayout_2->setSpacing( 2); tabLayout_2->setMargin( 2); Remote_View = new QListView( tab_2, "Remote_View" ); Remote_View->addColumn( tr("File"),130); Remote_View->addColumn( tr("Size"),-1); Remote_View->setColumnAlignment(1,QListView::AlignRight); Remote_View->addColumn( tr("Date"),-1); Remote_View->setColumnAlignment(2,QListView::AlignRight); Remote_View->setAllColumnsShowFocus(TRUE); Remote_View->setMultiSelection( TRUE ); Remote_View->setSelectionMode(QListView::Extended); Remote_View->setFocusPolicy(StrongFocus); Remote_View->installEventFilter( this ); QPEApplication::setStylusOperation( Remote_View->viewport(), QPEApplication::RightOnHold); tabLayout_2->addWidget( Remote_View, 0, 0 ); TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); TabWidget->setSizeChange( 370 ); // TabWidget->insertTab( tab_2, tr( "2")); /* tab_3 = new QWidget( TabWidget, "tab_3" ); tabLayout_3 = new QGridLayout( tab_3 ); tabLayout_3->setSpacing( 2); tabLayout_3->setMargin( 2); // OFileDialog fileDialog; 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 @@ -1,112 +1,112 @@ /*************************************************************************** AdvancedFm.cpp ------------------- ** Created: Sat Mar 9 23:33:09 2002 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "advancedfm.h" #include "output.h" #include "filePermissions.h" /* OPIE */ #include <opie2/odebug.h> #include <qpe/lnkproperties.h> #include <qpe/qpeapplication.h> #include <qpe/applnk.h> using namespace Opie::Core; /* QT*/ #include <qmessagebox.h> #include <qpopupmenu.h> #include <qlistview.h> /* STD */ #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <dirent.h> #include <sys/sendfile.h> #include <fcntl.h> void AdvancedFm::doDirChange() { QString pathItem = CurrentView()->currentItem()->text(0); if( pathItem == "../") { ListClicked( CurrentView()->currentItem()); } else { if( pathItem.find(" -> ",0,TRUE) != -1) pathItem = dealWithSymName((const QString&)pathItem)+"/"; // owarn << pathItem << oendl; - gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); + changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); } } void AdvancedFm::showMenuHidden() { if (b) { CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); } else { CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); } b = !b; populateView(); } void AdvancedFm::showHidden() { if (b) { CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); } else { CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); } populateView(); } QString AdvancedFm::dealWithSymName(const QString &fileName) { QString strItem = fileName; return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); } void AdvancedFm::runThis() { if( !CurrentView()->currentItem()) return; QString fs; QDir *thisDir = CurrentDir(); QString curFile = CurrentView()->currentItem()->text(0); QString path = thisDir->canonicalPath(); if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink curFile = dealWithSymName((const QString&)curFile); if(curFile != "../") { fs = getFileSystemType((const QString &) path); QFileInfo fileInfo( path + "/" + curFile); // odebug << fileInfo.owner() << oendl; if( (fileInfo.permission( QFileInfo::ExeUser) | fileInfo.permission( QFileInfo::ExeGroup) | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { QCopEnvelope e("QPE/System", "execute(QString)" ); e << curFile; } else { curFile = path + "/" + curFile; DocLnk nf(curFile); QString execStr = nf.exec(); // odebug << execStr << oendl; if( execStr.isEmpty() ) { } else { @@ -679,165 +679,167 @@ void AdvancedFm::mkSym() { } 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(Opie::Core::OProcess*)), this, SLOT( processEnded(Opie::Core::OProcess*))); connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); command << "/bin/sh"; command << "-c"; command << cmd.latin1(); *process << command; if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) odebug << "could not start process" << oendl; } void AdvancedFm::processEnded(OProcess *) { rePopulate(); } void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { // owarn << "received stderrt " << buflen << " bytes" << oendl; 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; + if ( o->inherits( "QLineEdit" ) ) { + qDebug("QLineEdit event"); + 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 ) { + else if ( ke->key() == Key_Escape ) { cancelRename(); return true; - } + } } - else if ( e->type() == QEvent::FocusOut ) { + else if ( e->type() == QEvent::FocusOut ) { cancelRename(); return true; - } + } } - if ( o->inherits( "QListView" ) ) { +/* if ( o->inherits( "QListView" ) ) { if ( e->type() == QEvent::FocusIn ) { // if( o == Local_View) { //keep track of which view // qDebug("local view"); // whichTab = 1; // } else { // whichTab = 2; // qDebug("remote view"); // } } OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection } - +*/ return QWidget::eventFilter( o, e ); } void AdvancedFm::cancelRename() { // odebug << "cancel rename" << oendl; 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() ) 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->show(); } void AdvancedFm::renameIt() { - if( !CurrentView()->currentItem()) return; + if( !CurrentView()->currentItem()) return; - QListView *thisView = CurrentView(); + QListView *thisView = CurrentView(); oldName = thisView->currentItem()->text(0); doRename( thisView ); } void AdvancedFm::okRename() { - if( !renameBox) return; - - QString newName = renameBox->text(); - 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 = ""; - QListViewItem *item = view->currentItem(); - view->takeItem( item ); - delete item; - rePopulate(); + qDebug("okrename"); + if( !renameBox) return; + + QString newName = renameBox->text(); + 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 = ""; + QListViewItem *item = view->currentItem(); + view->takeItem( item ); + delete item; + rePopulate(); } void AdvancedFm::openSearch() { QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); } |