-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index fd81313..979549d 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -209,258 +209,263 @@ void AdvancedFm::rePopulate() { populateView(); } void AdvancedFm::ListClicked(QListViewItem *selectedItem) { 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(tab); Local_View->setFocus(); // whichTab = 1; } void AdvancedFm::switchToRemoteTab() { TabWidget->setCurrentWidget(tab_2); Remote_View->setFocus(); // whichTab = 2; } void AdvancedFm::currentPathComboChanged() { QString pDir = currentPathCombo->lineEdit()->text(); if(QDir(pDir).exists()) { CurrentDir()->setPath(pDir ); populateView(); } else { QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); } } 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); } } } 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() { Opie::Core::OStorageInfo info; + if(StorageInfo::hasSd() ) { changeTo(info.sdPath()); } + else if(StorageInfo::hasMmc()) { + changeTo(info.mmcPath()); + } +} void AdvancedFm::CFButtonPushed() { Opie::Core::OStorageInfo info; changeTo(info.cfPath()); } 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( 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 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; } } } endmntent( mntfp ); } QString AdvancedFm::getFileSystemType(const QString ¤tText) { parsetab("/etc/mtab"); //why did TT forget filesystem type? QString current = currentText;//.right( currentText.length()-1); QString baseFs; for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { QString temp = (*it); QString path = temp.left(temp.find("::",0,TRUE) ); path = path.right( path.length()-1); if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); } } return baseFs; } QString AdvancedFm::getDiskSpace( const QString &path) { struct statfs fss; if ( !statfs( path.latin1(), &fss ) ) { int blkSize = fss.f_bsize; // int totalBlks = fs.f_blocks; int availBlks = fss.f_bavail; long mult = blkSize / 1024; long div = 1024 / blkSize; if ( !mult ) mult = 1; if ( !div ) div = 1; return QString::number(availBlks * mult / div); } return ""; } void AdvancedFm::showFileMenu() { QString curApp; curApp = CurrentView()->currentItem()->text(0); MimeType mt(curApp); const AppLnk* app = mt.application(); QFile fi(curApp); QPopupMenu *m = new QPopupMenu(0); QPopupMenu *n = new QPopupMenu(0); // QPopupMenu *o = new QPopupMenu(0); m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); if ( QFileInfo(fi).isDir()) { m->insertSeparator(); m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); } else { if (app) m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this m->insertItem(tr("Execute"),this,SLOT(runThis())); m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); } m->insertItem(tr("Actions"),n); n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); n->insertSeparator(); |