Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 680 |
1 files changed, 299 insertions, 381 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index d8bdff7..74654fc 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -84,3 +84,5 @@ AdvancedFm::~AdvancedFm() { -void AdvancedFm::cleanUp() { + +void AdvancedFm::cleanUp() +{ QString sfile=QDir::homeDirPath(); @@ -95,27 +97,22 @@ void AdvancedFm::cleanUp() { -void AdvancedFm::tabChanged(QWidget *w) { -// qDebug("tab changed %d",TabWidget->getCurrentTab()); +void AdvancedFm::tabChanged(QWidget *w) +{ + if( w == tab) + whichTab = 1; + else + whichTab = 2; + +// qDebug("tab changed %d", whichTab ); + + QString path = CurrentDir()->canonicalPath(); + currentPathCombo->lineEdit()->setText( path ); - if ( w == tab) { -// if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); - QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); - setCaption("AdvancedFm :: "+fs+" :: " - +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); - } - if ( w == tab_2) { -// if (TabWidget->getCurrentTab() == 1) { + QString fs= getFileSystemType( (const QString &) path); -// if (TabWidget->currentPageIndex() == 1) { - currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); - viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); - viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); - QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); setCaption("AdvancedFm :: "+fs+" :: " - +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); - } + +checkDiskSpace( (const QString &) path )+ " kB free" ); + chdir( path.latin1()); } @@ -123,3 +120,4 @@ void AdvancedFm::tabChanged(QWidget *w) { -void AdvancedFm::populateLocalView() { +void AdvancedFm::populateLocalView() +{ QPixmap pm; @@ -137,4 +135,6 @@ void AdvancedFm::populateLocalView() { QFileInfo *fi; - while ( (fi=it.current()) ) { - if (fi->isSymLink() ) { + while ( (fi=it.current()) ) + { + if (fi->isSymLink() ) + { QString symLink=fi->readLink(); @@ -144,3 +144,5 @@ void AdvancedFm::populateLocalView() { fileDate = sym.lastModified().toString(); - } else { + } + else + { fileS.sprintf( "%10i", fi->size() ); @@ -148,3 +150,4 @@ void AdvancedFm::populateLocalView() { fileDate= fi->lastModified().toString(); - if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { + if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) + { fileL+="/"; @@ -154,6 +157,8 @@ void AdvancedFm::populateLocalView() { QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); - if(fileL !="./" && fi->exists()) { + if(fileL !="./" && fi->exists()) + { item= new QListViewItem( Local_View, fileL, fileS , fileDate); - if(isDir || fileL.find("/",0,TRUE) != -1) { + if(isDir || fileL.find("/",0,TRUE) != -1) + { @@ -163,11 +168,18 @@ void AdvancedFm::populateLocalView() { pm= Resource::loadPixmap( "folder" ); - } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { + } + else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) + { pm = Resource::loadPixmap( "exec"); - } else if( (fileInfo.permission( QFileInfo::ExeUser) + } + else if( (fileInfo.permission( QFileInfo::ExeUser) | fileInfo.permission( QFileInfo::ExeGroup) - | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { + | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) + { pm = Resource::loadPixmap( "exec"); - } else if( !fi->isReadable() ) { + } + else if( !fi->isReadable() ) + { pm = Resource::loadPixmap( "locked" ); - } else { //everything else goes by mimetype + } + else { //everything else goes by mimetype MimeType mt(fi->filePath()); @@ -178,3 +190,4 @@ void AdvancedFm::populateLocalView() { item->setPixmap( 0,pm); - if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { + if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) + { // overlay link image @@ -192,3 +205,4 @@ void AdvancedFm::populateLocalView() { - if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { + if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) + { struct stat buf; @@ -197,4 +211,6 @@ void AdvancedFm::populateLocalView() { struct dirent *mydirent; + if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) - while ((mydirent = readdir(dir)) != NULL) { + while ((mydirent = readdir(dir)) != NULL) + { lstat( mydirent->d_name, &buf); @@ -205,3 +221,4 @@ void AdvancedFm::populateLocalView() { fileDate.sprintf("%s", ctime( &buf.st_mtime)); - if( fileL.find(".") == -1 ){ + if( fileL.find(".") == -1 ) + { item= new QListViewItem( Local_View, fileL, fileS, fileDate); @@ -220,3 +237,4 @@ void AdvancedFm::populateLocalView() { -void AdvancedFm::populateRemoteView() { +void AdvancedFm::populateRemoteView() +{ QPixmap pm; @@ -235,4 +253,6 @@ void AdvancedFm::populateRemoteView() { QFileInfo *fi; - while ( (fi=it.current()) ) { - if (fi->isSymLink() ){ + while ( (fi=it.current()) ) + { + if (fi->isSymLink() ) + { QString symLink=fi->readLink(); @@ -243,3 +263,5 @@ void AdvancedFm::populateRemoteView() { fileDate = sym.lastModified().toString(); - } else { + } + else + { // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); @@ -248,3 +270,5 @@ void AdvancedFm::populateRemoteView() { fileDate= fi->lastModified().toString(); - if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { + + if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) + { fileL+="/"; @@ -254,4 +278,6 @@ void AdvancedFm::populateRemoteView() { } + QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); - if(fileL !="./" && fi->exists()) { + if(fileL !="./" && fi->exists()) + { item= new QListViewItem( Remote_View, fileL, fileS, fileDate); @@ -259,3 +285,4 @@ void AdvancedFm::populateRemoteView() { - if(isDir || fileL.find("/",0,TRUE) != -1) { + if(isDir || fileL.find("/",0,TRUE) != -1) + { if( !QDir( fi->filePath() ).isReadable()) @@ -264,11 +291,19 @@ void AdvancedFm::populateRemoteView() { pm= Resource::loadPixmap( "folder" ); - } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { + } + else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) + { pm = Resource::loadPixmap( "exec"); - } else if( (fileInfo.permission( QFileInfo::ExeUser) + } + else if( (fileInfo.permission( QFileInfo::ExeUser) | fileInfo.permission( QFileInfo::ExeGroup) - | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { + | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) + { pm = Resource::loadPixmap( "exec"); - } else if( !fi->isReadable() ) { + } + else if( !fi->isReadable() ) + { pm = Resource::loadPixmap( "locked" ); - } else { + } + else + { MimeType mt(fi->filePath()); @@ -278,3 +313,4 @@ void AdvancedFm::populateRemoteView() { } - if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { + if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) + { // overlay link image @@ -292,3 +328,4 @@ void AdvancedFm::populateRemoteView() { - if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { + if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) + { struct stat buf; @@ -297,3 +334,5 @@ void AdvancedFm::populateRemoteView() { if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) - while ((mydirent = readdir(dir)) != NULL) { + + while ((mydirent = readdir(dir)) != NULL) + { lstat( mydirent->d_name, &buf); @@ -303,3 +342,5 @@ void AdvancedFm::populateRemoteView() { fileDate.sprintf("%s", ctime( &buf.st_mtime)); - if( fileL.find(".") == -1 ){ + + if( fileL.find(".") == -1 ) + { item= new QListViewItem( Remote_View, fileL, fileS, fileDate); @@ -317,4 +358,6 @@ void AdvancedFm::populateRemoteView() { -void AdvancedFm::localListClicked(QListViewItem *selectedItem) { - if(selectedItem) { +void AdvancedFm::ListClicked(QListViewItem *selectedItem) +{ + if(selectedItem) + { QString strItem=selectedItem->text(0); @@ -322,80 +365,25 @@ void AdvancedFm::localListClicked(QListViewItem *selectedItem) { strSize=strSize.stripWhiteSpace(); - if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink - QString strItem2 = dealWithSymName((const QString&)strItem); -// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); - if(QDir(strItem2).exists() ) { - currentDir.cd(strItem2, TRUE); - populateLocalView(); + 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; } - } else { // not a symlink - if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { - if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { - strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); - currentDir.cd(strItem,FALSE); - populateLocalView(); - Local_View->ensureItemVisible(Local_View->firstChild()); - } else { - currentDir.cdUp(); - populateLocalView(); - Local_View->ensureItemVisible(Local_View->firstChild()); - } - if(QDir(strItem).exists()){ - currentDir.cd(strItem, TRUE); - Local_View->ensureItemVisible(Local_View->firstChild()); - populateLocalView(); - } - } else { - strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); - if( QFile::exists(strItem ) ) { - // qDebug("clicked item "+strItem); - // DocLnk doc( strItem, FALSE ); - // doc.execute(); - // Local_View->clearSelection(); - } - } //end not symlink - chdir(strItem.latin1()); - } + if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) + { + if(QDir(strItem).exists()) + isDirectory = true; } -} - -void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { - if(selectedItem) { - QString strItem=selectedItem->text(0); - QString strSize=selectedItem->text(1); - strSize=strSize.stripWhiteSpace(); - if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink - QString strItem2 = dealWithSymName((const QString&)strItem); -// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); - currentRemoteDir.cd(strItem2, TRUE); - populateRemoteView(); - } else { // not a symlink - if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { - if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { - strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); - currentRemoteDir.cd(strItem,FALSE); - populateRemoteView(); - Remote_View->ensureItemVisible(Remote_View->firstChild()); - } else { - currentRemoteDir.cdUp(); - populateRemoteView(); - Remote_View->ensureItemVisible(Remote_View->firstChild()); - } - if(QDir(strItem).exists()){ - currentRemoteDir.cd(strItem, TRUE); - populateRemoteView(); - Remote_View->ensureItemVisible(Remote_View->firstChild()); - } - } else { - strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); - if( QFile::exists(strItem ) ) { - // qDebug("clicked item "+strItem); - // DocLnk doc( strItem, FALSE ); - // doc.execute(); - // Remote_View->clearSelection(); + if( isDirectory ) + { + CurrentDir()->cd( strItem, TRUE); + PopulateView(); + CurrentView()->ensureItemVisible( CurrentView()->firstChild()); } - } //end not symlink chdir(strItem.latin1()); @@ -403,7 +391,4 @@ void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { } -} - -void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { -// qDebug("list pressed"); +void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { switch (mouse) { @@ -413,3 +398,2 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , i { -// qDebug("cancel rename"); cancelRename(); @@ -421,3 +405,2 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , i menuTimer.start( 500, TRUE ); -// qDebug("Start menu timer\n"); break; @@ -426,23 +409,4 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , i -void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { - - switch (mouse) { - case 1: - { - if(renameBox != 0 ) +void AdvancedFm::switchToLocalTab() { -// qDebug("cancel rename"); - cancelRename(); - } - } - break; - case 2: - menuTimer.start( 500, TRUE ); -// qDebug("Start menu timer"); - break; - }; -} - - -void AdvancedFm::switchToLocalTab() { TabWidget->setCurrentTab(0); @@ -451,3 +415,4 @@ void AdvancedFm::switchToLocalTab() { -void AdvancedFm::switchToRemoteTab() { +void AdvancedFm::switchToRemoteTab() +{ TabWidget->setCurrentTab(1); @@ -456,3 +421,4 @@ void AdvancedFm::switchToRemoteTab() { -void AdvancedFm::readConfig() { +void AdvancedFm::readConfig() +{ Config cfg("AdvancedFm"); @@ -460,3 +426,4 @@ void AdvancedFm::readConfig() { -void AdvancedFm::writeConfig() { +void AdvancedFm::writeConfig() +{ Config cfg("AdvancedFm"); @@ -464,18 +431,11 @@ void AdvancedFm::writeConfig() { -void AdvancedFm::currentPathComboChanged() { - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - if(QDir( currentPathCombo->lineEdit()->text()).exists()) { - currentDir.setPath( currentPathCombo->lineEdit()->text() ); - populateLocalView(); - } else { - QMessageBox::message(tr("Note"),tr("That directory does not exist")); - } +void AdvancedFm::currentPathComboChanged() +{ + if(QDir( currentPathCombo->lineEdit()->text()).exists()) + { + CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); + PopulateView(); } - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - if(QDir( currentPathCombo->lineEdit()->text()).exists()) { - currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); - populateRemoteView(); - } else { + else + { QMessageBox::message(tr("Note"),tr("That directory does not exist")); @@ -483,10 +443,11 @@ void AdvancedFm::currentPathComboChanged() { } -} -void AdvancedFm::fillCombo(const QString ¤tPath) { +void AdvancedFm::fillCombo(const QString ¤tPath) +{ // qDebug("%d",TabWidget->getCurrentTab()); - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { + if ( whichTab == 1) + { currentPathCombo->lineEdit()->setText( currentPath); - if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { + if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) + { currentPathCombo->clear(); @@ -495,5 +456,8 @@ void AdvancedFm::fillCombo(const QString ¤tPath) { } - } else { + } + else + { currentPathCombo->lineEdit()->setText( currentPath); - if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { + if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) + { currentPathCombo->clear(); @@ -505,35 +469,20 @@ void AdvancedFm::fillCombo(const QString ¤tPath) { -void AdvancedFm::currentPathComboActivated(const QString & currentPath) { - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - chdir( currentPath.latin1() ); - currentDir.cd( currentPath, TRUE); - populateLocalView(); - update(); - } else { +void AdvancedFm::currentPathComboActivated(const QString & currentPath) +{ chdir( currentPath.latin1() ); - currentRemoteDir.cd( currentPath, TRUE); - populateRemoteView(); + CurrentDir()->cd( currentPath, TRUE); + PopulateView(); update(); } -} -QStringList AdvancedFm::getPath() { +QStringList AdvancedFm::getPath() +{ QStringList strList; - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - QList<QListViewItem> * getSelectedItems( QListView * Local_View ); - QListViewItemIterator it( Local_View ); - for ( ; it.current(); ++it ) { - if ( it.current()->isSelected() ) { - strList << it.current()->text(0); -// qDebug(it.current()->text(0)); - } - } - return strList; - } else { - QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); - QListViewItemIterator it( Remote_View ); - for ( ; it.current(); ++it ) { - if ( it.current()->isSelected() ) { + QListView *thisView=CurrentView(); + QList<QListViewItem> * getSelectedItems( QListView * thisView ); + QListViewItemIterator it( thisView ); + for ( ; it.current(); ++it ) + { + if ( it.current()->isSelected() ) + { strList << it.current()->text(0); @@ -544,16 +493,9 @@ QStringList AdvancedFm::getPath() { } - return ""; -} -void AdvancedFm::homeButtonPushed() { +void AdvancedFm::homeButtonPushed() +{ QString current = QDir::homeDirPath(); chdir( current.latin1() ); - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - currentDir.cd( current, TRUE); - populateLocalView(); - } else { - currentRemoteDir.cd( current, TRUE); - populateRemoteView(); - } + CurrentDir()->cd( current, TRUE); + PopulateView(); update(); @@ -561,3 +503,4 @@ void AdvancedFm::homeButtonPushed() { -void AdvancedFm::docButtonPushed() { +void AdvancedFm::docButtonPushed() +{ QString current = QPEApplication::documentDir(); @@ -565,10 +508,4 @@ void AdvancedFm::docButtonPushed() { - if (TabWidget->getCurrentTab() == 0) { -//if (TabWidget->currentPageIndex() == 0) { - currentDir.cd( current, TRUE); - populateLocalView(); - } else { - currentRemoteDir.cd( current, TRUE); - populateRemoteView(); - } + CurrentDir()->cd( current, TRUE); + PopulateView(); update(); @@ -576,18 +513,13 @@ void AdvancedFm::docButtonPushed() { -void AdvancedFm::SDButtonPushed() { +void AdvancedFm::SDButtonPushed() +{ QString current = "/mnt/card";// this can change so fix chdir( current.latin1() ); - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - currentDir.cd( current, TRUE); - populateLocalView(); - } else { - currentRemoteDir.cd( current, TRUE); - populateRemoteView(); - } + CurrentDir()->cd( current, TRUE); + PopulateView(); update(); - } -void AdvancedFm::CFButtonPushed() { +void AdvancedFm::CFButtonPushed() +{ QString current; @@ -599,10 +531,4 @@ void AdvancedFm::CFButtonPushed() { chdir( current.latin1() ); - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - currentDir.cd( current, TRUE); - populateLocalView(); - } else { - currentRemoteDir.cd( current, TRUE); - populateRemoteView(); - } + CurrentDir()->cd( current, TRUE); + PopulateView(); update(); @@ -611,6 +537,6 @@ void AdvancedFm::CFButtonPushed() { - -void AdvancedFm::doAbout() { +void AdvancedFm::doAbout() +{ QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" - "is copyright 2002 by\n" + "is copyright 2002-2003 by\n" "L.J.Potter<llornkcor@handhelds.org>\n" @@ -619,4 +545,7 @@ void AdvancedFm::doAbout() { -void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { - if( TabWidget->hasFocus()) +void AdvancedFm::keyPressEvent( QKeyEvent *e) +{ +// e->accept(); + if( CurrentView()->hasFocus() ) + { switch ( e->key() ) { @@ -625,7 +554,4 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { break; - case Key_H: - showHidden(); - break; - case Key_E: - runThis(); + case Key_A: + copyAs(); break; @@ -634,10 +560,13 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { break; - case Key_A: - copyAs(); + case Key_E: + runThis(); break; - case Key_M: - move(); + case Key_G: + { + currentPathCombo->lineEdit()->setFocus(); + } break; - case Key_R: - rn(); + + case Key_H: + showHidden(); break; @@ -646,4 +575,7 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { break; - case Key_U: - upDir(); + case Key_M: + move(); + break; + case Key_N: + mkDir(); break; @@ -652,4 +584,7 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { break; - case Key_N: - mkDir(); + case Key_R: + rn(); + break; + case Key_U: + upDir(); break; @@ -681,2 +616,4 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { break; + }; + e->accept(); } @@ -684,14 +621,15 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { +void AdvancedFm::keyReleaseEvent( QKeyEvent *e) +{ + if( CurrentView()->hasFocus() ) + e->ignore(); +} + -void AdvancedFm::QPEButtonPushed() { +void AdvancedFm::QPEButtonPushed() +{ QString current = QPEApplication::qpeDir(); chdir( current.latin1() ); - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - currentDir.cd( current, TRUE); - populateLocalView(); - } else { - currentRemoteDir.cd( current, TRUE); - populateRemoteView(); - } + CurrentDir()->cd( current, TRUE); + PopulateView(); update(); @@ -699,3 +637,4 @@ void AdvancedFm::QPEButtonPushed() { -void AdvancedFm::parsetab(const QString &fileName) { +void AdvancedFm::parsetab(const QString &fileName) +{ @@ -705,4 +644,6 @@ void AdvancedFm::parsetab(const QString &fileName) { FILE *mntfp = setmntent( fileName.latin1(), "r" ); - if ( mntfp ) { - while ( (me = getmntent( mntfp )) != 0 ) { + if ( mntfp ) + { + while ( (me = getmntent( mntfp )) != 0 ) + { QString deviceName = me->mnt_fsname; @@ -710,3 +651,4 @@ void AdvancedFm::parsetab(const QString &fileName) { QString mountDir = me->mnt_dir; - if(deviceName != "none") { + if(deviceName != "none") + { if( fsList.contains(filesystemType) == 0 @@ -723,3 +665,4 @@ void AdvancedFm::parsetab(const QString &fileName) { -QString AdvancedFm::getFileSystemType(const QString ¤tText) { +QString AdvancedFm::getFileSystemType(const QString ¤tText) +{ parsetab("/etc/mtab"); //why did TT forget filesystem type? @@ -739,3 +682,4 @@ QString AdvancedFm::getFileSystemType(const QString ¤tText) { -QString AdvancedFm::getDiskSpace( const QString &path) { +QString AdvancedFm::getDiskSpace( const QString &path) +{ struct statfs fss; @@ -757,13 +701,6 @@ QString AdvancedFm::getDiskSpace( const QString &path) { -void AdvancedFm::showFileMenu() { - +void AdvancedFm::showFileMenu() +{ QString curApp; - bool isLocalView = false; - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - isLocalView = TRUE; - curApp = Local_View->currentItem()->text(0); - } else { - curApp = Remote_View->currentItem()->text(0); - } + curApp = CurrentView()->currentItem()->text(0); @@ -775,11 +712,11 @@ void AdvancedFm::showFileMenu() { // QPopupMenu *o = new QPopupMenu(0); - if (TabWidget->getCurrentTab() == 0) m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); - else - m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); - if ( QFileInfo(fi).isDir() ) { + if ( QFileInfo(fi).isDir() ) + { m->insertSeparator(); - m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); - } else { + m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); + } + else + { @@ -794,6 +731,3 @@ void AdvancedFm::showFileMenu() { m->insertItem(tr("Actions"),n); - if(isLocalView) - n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); - else - n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); + n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); @@ -802,8 +736,3 @@ void AdvancedFm::showFileMenu() { n->insertSeparator(); - - - if(isLocalView) - n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); - else - n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); + n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); @@ -815,9 +744,3 @@ void AdvancedFm::showFileMenu() { n->insertSeparator(); - - if(isLocalView) - n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); - else - n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); - - + n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); @@ -848,4 +771,4 @@ void AdvancedFm::showFileMenu() { -void AdvancedFm::cancelMenuTimer() { - +void AdvancedFm::cancelMenuTimer() +{ // qDebug("selectionChanged: cancel menu timer"); @@ -855,5 +778,7 @@ void AdvancedFm::cancelMenuTimer() { -QString AdvancedFm::checkDiskSpace(const QString &path) { +QString AdvancedFm::checkDiskSpace(const QString &path) +{ struct statfs fss; - if ( !statfs( path.latin1(), &fss ) ) { + if ( !statfs( path.latin1(), &fss ) ) + { int blkSize = fss.f_bsize; @@ -873,22 +798,14 @@ QString AdvancedFm::checkDiskSpace(const QString &path) { -void AdvancedFm::addToDocs() { +void AdvancedFm::addToDocs() +{ QStringList strListPaths = getPath(); - if( strListPaths.count() > 0) { + QDir *thisDir = CurrentDir(); + + if( strListPaths.count() > 0) + { QString curFile; - if (TabWidget->getCurrentTab() == 0) { -// if (TabWidget->currentPageIndex() == 0) { - for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { - curFile = currentDir.canonicalPath()+"/"+(*it); -// qDebug(curFile); - DocLnk f; -// curFile.replace(QRegExp("\\..*"),""); - f.setName((*it)); - f.setFile( curFile); - f.writeLink(); - } - } else { - for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { - curFile = currentRemoteDir.canonicalPath()+"/"+(*it); + for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) + { + curFile = thisDir->canonicalPath()+"/"+(*it); // qDebug(curFile); - DocLnk f; @@ -901,3 +818,2 @@ void AdvancedFm::addToDocs() { } -} @@ -950,10 +866,3 @@ void AdvancedFm::addCustomDir() - if (TabWidget->getCurrentTab() == 0) - { - dir = currentDir.canonicalPath(); - } - else - { - dir = currentRemoteDir.canonicalPath(); - } + dir = CurrentDir()->canonicalPath(); @@ -986,11 +895,3 @@ void AdvancedFm::removeCustomDir() QStringList list2; - - if (TabWidget->getCurrentTab() == 0) - { - dir = currentDir.canonicalPath(); - } - else - { - dir = currentRemoteDir.canonicalPath(); - } + dir = CurrentDir()->canonicalPath(); int ramble=2; @@ -1031,2 +932,3 @@ void AdvancedFm::gotoCustomDir(const QString &dir) QString curDir = dir; + QDir *thisDir = CurrentDir(); // if( curDir.isEmpty()) { @@ -1045,8 +947,15 @@ void AdvancedFm::gotoCustomDir(const QString &dir) { - if (TabWidget->getCurrentTab() == 0) - { - currentDir.setPath( curDir ); + thisDir->setPath( curDir ); chdir( curDir.latin1() ); - currentDir.cd( curDir, TRUE); - populateLocalView(); + thisDir->cd( curDir, TRUE); + PopulateView(); + } + } +} + +QDir *AdvancedFm::CurrentDir() +{ + if ( whichTab == 1) + { + return ¤tDir; } @@ -1054,31 +963,40 @@ void AdvancedFm::gotoCustomDir(const QString &dir) { - currentRemoteDir.setPath( curDir ); - chdir( curDir.latin1() ); - currentRemoteDir.cd( curDir, TRUE); - populateRemoteView(); + return ¤tRemoteDir; } } + +QDir *AdvancedFm::OtherDir() +{ + if ( whichTab == 1) + { + return ¤tRemoteDir; } -// menuButton -// qDebug("gotoCustomDir(const QString &dir) " +dir ); -// QString curDir = dir; -// if(QDir( curDir).exists() ) -// { -// if (TabWidget->getCurrentTab() == 0) -// { -// currentDir.setPath( curDir ); -// chdir( curDir.latin1() ); -// currentDir.cd( curDir, TRUE); -// populateLocalView(); -// } -// else -// { -// currentRemoteDir.setPath( curDir ); -// chdir( curDir.latin1() ); -// currentRemoteDir.cd( curDir, TRUE); -// populateRemoteView(); -// } -// } -// menuButton->setLabel(" "); -// menuButton + else + { + return ¤tDir; + } +} + +void AdvancedFm::PopulateView() +{ + if ( whichTab == 1) + populateLocalView(); + else + populateRemoteView(); +} + +QListView * AdvancedFm::CurrentView() +{ + if ( whichTab == 1) + return Local_View; + else + return Remote_View; +} + +QListView * AdvancedFm::OtherView() +{ + if ( whichTab == 1) + return Remote_View; + else + return Local_View; } |