summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-02-24 03:49:20 (UTC)
committer llornkcor <llornkcor>2003-02-24 03:49:20 (UTC)
commit04470810d71cc8aa3ddde193559312fd3ecc7a11 (patch) (side-by-side diff)
treef9d291fed1aa1627927863fc0381d6d15f6b6f7e
parente144592570ddacf26d27f3e2759dbe7f2370d0a0 (diff)
downloadopie-04470810d71cc8aa3ddde193559312fd3ecc7a11.zip
opie-04470810d71cc8aa3ddde193559312fd3ecc7a11.tar.gz
opie-04470810d71cc8aa3ddde193559312fd3ecc7a11.tar.bz2
fix for hidden dirs
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp34
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp18
2 files changed, 26 insertions, 26 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index fc6c3bf..d56e746 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -193,322 +193,319 @@ void AdvancedFm::populateView()
else { //everything else goes by mimetype
MimeType mt(fi->filePath());
pm=mt.pixmap(); //sets the correct pixmap for mimetype
if(pm.isNull())
pm = Resource::loadPixmap( "UnknownDocument-14" );
}
item->setPixmap( 0,pm);
if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
{
// overlay link image
pm= Resource::loadPixmap( "folder" );
QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
QPainter painter( &pm );
painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
pm.setMask( pm.createHeuristicMask( FALSE ) );
item->setPixmap( 0, pm);
}
}
isDir=FALSE;
++it;
}
if( path.find("dev",0,TRUE) != -1)
{
struct stat buf;
dev_t devT;
DIR *dir;
struct dirent *mydirent;
if((dir = opendir( path.latin1())) != NULL)
while ((mydirent = readdir(dir)) != NULL)
{
lstat( mydirent->d_name, &buf);
// qDebug(mydirent->d_name);
fileL.sprintf("%s", mydirent->d_name);
devT = buf.st_dev;
fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
fileDate.sprintf("%s", ctime( &buf.st_mtime));
if( fileL.find(".") == -1 )
{
item= new QListViewItem( thisView, fileL, fileS, fileDate);
pm = Resource::loadPixmap( "UnknownDocument-14" );
item->setPixmap( 0,pm);
}
}
closedir(dir);
}
thisView->setSorting( 3,FALSE);
fillCombo( (const QString &) path );
}
void AdvancedFm::ListClicked(QListViewItem *selectedItem)
{
if(selectedItem)
{
QString strItem=selectedItem->text(0);
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 *, const QPoint& , int ) {
switch (mouse) {
case 1:
{
if(renameBox != 0 )
{
cancelRename();
}
-
}
break;
case 2:
menuTimer.start( 500, TRUE );
break;
};
}
void AdvancedFm::switchToLocalTab()
{
TabWidget->setCurrentTab(0);
Local_View->setFocus();
}
void AdvancedFm::switchToRemoteTab()
{
TabWidget->setCurrentTab(1);
Remote_View->setFocus();
}
void AdvancedFm::readConfig()
{
Config cfg("AdvancedFm");
}
void AdvancedFm::writeConfig()
{
Config cfg("AdvancedFm");
}
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 &currentPath)
{
// qDebug("%d",TabWidget->getCurrentTab());
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);
+ QList<QListViewItem> * getSelectedItems( QListView * thisView );
+ QListViewItemIterator it( thisView );
+ for ( ; it.current(); ++it )
+ {
+ if ( it.current()->isSelected() )
+ {
+ strList << it.current()->text(0);
// qDebug(it.current()->text(0));
- }
- }
- return strList;
+ }
+ }
+ return strList;
}
void AdvancedFm::homeButtonPushed()
{
QString current = QDir::homeDirPath();
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
void AdvancedFm::docButtonPushed()
{
QString current = QPEApplication::documentDir();
chdir( current.latin1() );
-
- CurrentDir()->cd( current, TRUE);
- populateView();
+ CurrentDir()->cd( current, TRUE);
+ populateView();
update();
}
void AdvancedFm::SDButtonPushed()
{
QString current = "/mnt/card";// this can change so fix
chdir( current.latin1() );
- CurrentDir()->cd( current, TRUE);
- populateView();
+ CurrentDir()->cd( current, TRUE);
+ populateView();
update();
}
void AdvancedFm::CFButtonPushed()
{
QString current;
if(zaurusDevice)
current= "/mnt/cf"; //zaurus
else
current = "/mnt/hda"; //ipaq
-
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
void AdvancedFm::doAbout()
{
QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
"is copyright 2002-2003 by\n"
"L.J.Potter<llornkcor@handhelds.org>\n"
"and is licensed by the GPL"));
}
void AdvancedFm::keyPressEvent( QKeyEvent *e)
{
// e->accept();
if( CurrentView()->hasFocus() )
{
switch ( e->key() ) {
case Key_Delete:
del();
break;
case Key_A:
copyAs();
break;
case Key_C:
copy();
break;
case Key_E:
runThis();
break;
case Key_G:
{
currentPathCombo->lineEdit()->setFocus();
}
break;
case Key_H:
showHidden();
break;
case Key_I:
fileStatus();
break;
case Key_M:
move();
break;
case Key_N:
mkDir();
break;
case Key_P:
filePerms();
break;
case Key_R:
rn();
break;
case Key_U:
upDir();
break;
case Key_1:
switchToLocalTab();
break;
case Key_2:
switchToRemoteTab();
break;
case Key_3:
CFButtonPushed();
break;
case Key_4:
SDButtonPushed();
break;
case Key_5:
homeButtonPushed();
break;
case Key_6:
docButtonPushed();
break;
case Key_7:
break;
case Key_8:
break;
case Key_9:
break;
case Key_0:
break;
};
e->accept();
}
}
void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
{
if( CurrentView()->hasFocus() )
e->ignore();
}
@@ -694,193 +691,194 @@ void AdvancedFm::addToDocs()
QString curFile;
for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it )
{
curFile = thisDir->canonicalPath()+"/"+(*it);
// qDebug(curFile);
DocLnk f;
// curFile.replace(QRegExp("\\..*"),"");
f.setName((*it));
f.setFile( curFile);
f.writeLink();
}
}
}
void AdvancedFm::customDirsToMenu()
{
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QStringList list = cfg.readListEntry( "CustomDir", ',');
menuButton->insertItems(list );
// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
// {
// customDirMenu->insertItem(*it );
// }
}
void AdvancedFm::dirMenuSelected(int item)
{
qDebug("menu item %d", item);
switch(item)
{
case -21:
case 0:
addCustomDir();
break;
case -22:
case 1:
removeCustomDir();
break;
default:
{
// gotoCustomDir( menuButton->text(item));
// gotoCustomDir( customDirMenu->text(item));
}
break;
};
}
void AdvancedFm::addCustomDir()
{
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QString dir;
QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
dir = CurrentDir()->canonicalPath();
bool addIt=true;
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
{
if( dir == (*it))
{
addIt=false;
}
}
if(addIt)
{
menuButton->insertItem(dir);
// customDirMenu->insertItem(dir);
list << dir;
}
cfg.writeEntry("CustomDir", list, ',');
cfg.write();
}
void AdvancedFm::removeCustomDir()
{
// qDebug("remove custom dir");
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QString dir;
QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
QStringList list2;
dir = CurrentDir()->canonicalPath();
int ramble=2;
// int ramble=-24;
//first remove list
if(list.grep(dir,true).isEmpty())
{
- QMessageBox::message("AdvancedFm",tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!"));
+ QMessageBox::message("AdvancedFm",
+ tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!"));
}
else
{
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
{
if((*it) != dir)//current item is not our current dir, so add it to temp list
{
list2 <<(*it);
}
else
{
// customDirMenu->removeItem( ramble);
menuButton->remove( ramble);
}
ramble++;
// ramble--;
}
cfg.writeEntry("CustomDir", list2, ',');
cfg.write();
}
// customDirsToMenu();
}
void AdvancedFm::gotoCustomDir(const QString &dir)
{
// qDebug("gotoCustomDir(const QString &dir) " +dir );
QString curDir = dir;
QDir *thisDir = CurrentDir();
// if( curDir.isEmpty()) {
// }
if( curDir == s_addBookmark)
{
addCustomDir();
}
if( curDir == s_removeBookmark)
{
removeCustomDir( );
}
else
{
if(QDir( curDir).exists() )
{
thisDir->setPath( curDir );
chdir( curDir.latin1() );
thisDir->cd( curDir, TRUE);
populateView();
}
}
}
QDir *AdvancedFm::CurrentDir()
{
if ( whichTab == 1)
{
return &currentDir;
}
else
{
return &currentRemoteDir;
}
}
QDir *AdvancedFm::OtherDir()
{
if ( whichTab == 1)
{
return &currentRemoteDir;
}
else
{
return &currentDir;
}
}
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;
}
void AdvancedFm::setOtherTabCurrent()
{
if ( whichTab == 1)
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index c553017..062a013 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,184 +1,186 @@
/***************************************************************************
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"
#include <opie/otabwidget.h>
#include <opie/oprocess.h>
#include <qpe/lnkproperties.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/applnk.h>
#include <qpe/ir.h>
#include <qmessagebox.h>
#include <qmultilineedit.h>
#include <qstring.h>
#include <qlayout.h>
#include <qpixmap.h>
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qtabwidget.h>
#include <qtoolbutton.h>
#include <qtabwidget.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
void AdvancedFm::doDirChange()
{
ListClicked( CurrentView()->currentItem());
}
void AdvancedFm::showMenuHidden()
{
if (b)
{
- currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
- currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
- fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
+ 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);
// b=FALSE;
- }
+ }
else
{
- currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
- currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
- fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
+ 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=TRUE;
- }
+ }
populateView();
// populateRemoteView();
// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
if(b) b = false; else b = true;
}
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);
// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
// b=FALSE;
}
else
{
CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
+s OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
// b=TRUE;
}
populateView();
}
QString AdvancedFm::dealWithSymName(const QString &fileName)
{
QString strItem = fileName;
return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
}
void AdvancedFm::runThis()
{
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);
qDebug( fileInfo.owner());
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();
qDebug( execStr);
if( execStr.isEmpty() )
{
}
else
{
nf.execute();
}
}
}
}
void AdvancedFm::runText()
{
QString curFile = CurrentView()->currentItem()->text(0);
if(curFile != "../")
{
if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
curFile = dealWithSymName((const QString&)curFile);
curFile = CurrentDir()->canonicalPath()+"/"+curFile;
QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
e << curFile;
}
}
void AdvancedFm::makeDir()
{
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 )
{
QDir *thisDir = CurrentDir();
QString filename = fileDlg->LineEdit1->text();
thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
}
populateView();
}
void AdvancedFm::doDelete()
{
QStringList curFileList = getPath();
bool doMsg=true;
int count = curFileList.count();
if( count > 0)
{
if(count > 1 )
{
QString msg;
msg=tr("Really delete\n%1 files?").arg(count);
switch ( QMessageBox::warning(this,tr("Delete"),msg
,tr("Yes"),tr("No"),0,0,1) )