-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 @@ -253,71 +253,71 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) { 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); } } } @@ -352,67 +352,71 @@ void AdvancedFm::changeTo(const QString dir) { 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) @@ -726,65 +730,65 @@ QDir *AdvancedFm::OtherDir() { 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()); } } } 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 @@ -99,73 +99,73 @@ void AdvancedFm::init() { 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")); 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 @@ -16,65 +16,65 @@ /* 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); } @@ -711,133 +711,135 @@ void AdvancedFm::selectAll() { 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")); } |