summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-01 02:24:51 (UTC)
committer llornkcor <llornkcor>2002-05-01 02:24:51 (UTC)
commit7e5615473c1d103db66f42ae60bf9ed57d52566c (patch) (side-by-side diff)
tree6074a903b03bb844c8d66edaa8d17ae068384288
parent1f6f336326e74534f65f88fe0045946b3d9f6d94 (diff)
downloadopie-7e5615473c1d103db66f42ae60bf9ed57d52566c.zip
opie-7e5615473c1d103db66f42ae60bf9ed57d52566c.tar.gz
opie-7e5615473c1d103db66f42ae60bf9ed57d52566c.tar.bz2
fixed a workaround for QFileInfo::isExecutable() stupid silly bug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index ee3f736..a9ba3c2 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -225,310 +225,320 @@ AdvancedFm::AdvancedFm( )
layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7);
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
this, SLOT( currentPathComboActivated( const QString & ) ) );
connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
this,SLOT(currentPathComboChanged()));
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 7);
filterStr="*";
b=FALSE;
populateLocalView();
populateRemoteView();
}
AdvancedFm::~AdvancedFm()
{
}
void AdvancedFm::cleanUp()
{
QString sfile=QDir::homeDirPath();
if(sfile.right(1) != "/")
sfile+="/._temp";
else
sfile+="._temp";
QFile file( sfile);
if(file.exists())
file.remove();
}
void AdvancedFm::tabChanged(QWidget *w)
{
if (TabWidget->currentPageIndex() == 0) {
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
}
if (TabWidget->currentPageIndex() == 1) {
currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
}
}
void AdvancedFm::populateLocalView()
{
QPixmap pm;
Local_View->clear();
currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentDir.setMatchAllDirs(TRUE);
currentDir.setNameFilter(filterStr);
QString fileL, fileS, fileDate;
// qDebug(currentDir.canonicalPath());
// struct stat buf;
// mode_t mode;
QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
setCaption("AdvancedFm :: "+fs);
bool isDir=FALSE;
const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
while ( (fi=it.current()) ) {
if (fi->isSymLink() ) {
QString symLink=fi->readLink();
// qDebug("Symlink detected "+symLink);
QFileInfo sym( symLink);
fileS.sprintf( "%10li", sym.size() );
fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
fileDate = sym.lastModified().toString();
} else {
fileS.sprintf( "%10li", fi->size() );
fileL.sprintf( "%s",fi->fileName().data() );
fileDate= fi->lastModified().toString();
if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
isDir=TRUE;
// qDebug( fileL);
}
}
QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
if(fileL !="./" && fi->exists()) {
item= new QListViewItem( Local_View, fileL, fileS , fileDate);
if(isDir || fileL.find("/",0,TRUE) != -1) {
if( !QDir( fi->filePath() ).isReadable()) //is directory
pm = Resource::loadPixmap( "lockedfolder" );
else
pm= Resource::loadPixmap( "folder" );
// item->setPixmap( 0,pm );
- } else if( fileInfo.isExecutable() || fs == "vfat" && fi->filePath().contains("/bin") ) { //is exec
- pm = Resource::loadPixmap( "exec");
-// item->setPixmap( 0,pm);
+ } else if( (fileInfo.permission( QFileInfo::ExeUser)
+ | fileInfo.permission( QFileInfo::ExeGroup)
+ | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) {
+ pm = Resource::loadPixmap( "exec");
+// else { //is exec
+// pm = Resource::loadPixmap( "exec");
+// }
+// // item->setPixmap( 0,pm);
} else if( !fi->isReadable() ) {
pm = Resource::loadPixmap( "locked" );
// item->setPixmap( 0,pm);
} 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);
}
item->setPixmap( 0,pm);
- if( fi->isSymLink() &&fileL.find("->",0,TRUE) != -1) {
+ 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(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
struct stat buf;
// struct stat st;
dev_t devT;
// mode_t mode;
DIR *dir;
// int fd = 0;
struct dirent *mydirent;
// int i = 1;
if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
while ((mydirent = readdir(dir)) != NULL) {
lstat( mydirent->d_name, &buf);
qDebug(mydirent->d_name);
// mode = buf.st_mode;
fileL.sprintf("%s", mydirent->d_name);
// fileS.sprintf("%d, %d", ); //this isn't correct
devT = buf.st_dev;
fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
// fileS.sprintf("%d,%d", devT, devT);
fileDate.sprintf("%s", ctime( &buf.st_mtime));
if( fileL.find(".") == -1 ){
item= new QListViewItem( Local_View, fileL, fileS, fileDate);
pm = Resource::loadPixmap( "UnknownDocument-14" );
item->setPixmap( 0,pm);
}
}
closedir(dir);
}
Local_View->setSorting( 3,FALSE);
fillCombo( (const QString &) currentDir.canonicalPath());
}
void AdvancedFm::populateRemoteView()
{
// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
// QListViewItemIterator it( Remote_View );
// for ( ; it.current(); ++it ) {
// if ( it.current()->isSelected() ) {
// QString strItem = it.current()->text(0);
// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem;
// QFileInfo fi(localFile);
// }
// }
QPixmap pm;
Remote_View->clear();
currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentRemoteDir.setMatchAllDirs(TRUE);
currentRemoteDir.setNameFilter(filterStr);
QString fileL, fileS, fileDate;
QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
setCaption("AdvancedFm :: "+fs);
bool isDir=FALSE;
const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
while ( (fi=it.current()) ) {
if (fi->isSymLink() ){
QString symLink=fi->readLink();
// qDebug("Symlink detected "+symLink);
QFileInfo sym( symLink);
fileS.sprintf( "%10li", sym.size() );
fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
fileDate = sym.lastModified().toString();
} else {
// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
fileS.sprintf( "%10li", fi->size() );
fileL.sprintf( "%s",fi->fileName().data() );
fileDate= fi->lastModified().toString();
if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
isDir=TRUE;
// qDebug( fileL);
}
}
+ QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
if(fileL !="./" && fi->exists()) {
item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
QPixmap pm;
if(isDir || fileL.find("/",0,TRUE) != -1) {
if( !QDir( fi->filePath() ).isReadable())
pm = Resource::loadPixmap( "lockedfolder" );
else
pm= Resource::loadPixmap( "folder" );
// item->setPixmap( 0,pm );
- } else if( fi->isExecutable() || fs == "vfat" && fi->filePath().contains("/bin") ) {
- pm = Resource::loadPixmap( "exec");
+ } else if( (fileInfo.permission( QFileInfo::ExeUser)
+ | fileInfo.permission( QFileInfo::ExeGroup)
+ | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) {
+ pm = Resource::loadPixmap( "exec");
+///// } else if(fileInfo.isExecutable()){ //is exec <<<< BROKEN!!
+ pm = Resource::loadPixmap( "exec");
// item->setPixmap( 0,pm);
} else if( !fi->isReadable() ) {
pm = Resource::loadPixmap( "locked" );
// item->setPixmap( 0,pm);
} else {
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);
}
item->setPixmap( 0, pm);
}
isDir=FALSE;
++it;
}
if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
struct stat buf;
// struct stat st;
// mode_t mode;
DIR *dir;
// int fd = 0;
struct dirent *mydirent;
// int i = 1;
if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
while ((mydirent = readdir(dir)) != NULL) {
lstat( mydirent->d_name, &buf);
qDebug(mydirent->d_name);
// mode = buf.st_mode;
fileL.sprintf("%s", mydirent->d_name);
// fileS.sprintf("%d, %d", ); //this isn't correct
fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
fileDate.sprintf("%s", ctime( &buf.st_mtime));
if( fileL.find(".") == -1 ){
item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
pm = Resource::loadPixmap( "UnknownDocument-14" );
item->setPixmap( 0,pm);
}
}
closedir(dir);
}
Remote_View->setSorting( 3,FALSE);
fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
}
void AdvancedFm::localListClicked(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
// is symlink
QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
if(QDir(strItem2).exists() ) {
currentDir.cd(strItem2, TRUE);
populateLocalView();
}
} 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();
} else {
currentDir.cdUp();
populateLocalView();
}
if(QDir(strItem).exists()){
currentDir.cd(strItem, TRUE);
populateLocalView();
}
} else {
strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
if( QFile::exists(strItem ) ) {
// qDebug("upload "+strItem);
}
} //end not symlink
chdir(strItem.latin1());
}
}
}
void AdvancedFm::remoteListClicked(QListViewItem *selectedItem)