summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index a9ba3c2..a378170 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -250,97 +250,97 @@ 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() );
+ fileL.sprintf( "%s -> %s", fi->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.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) {
// 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 ) );
@@ -371,124 +371,123 @@ void AdvancedFm::populateLocalView()
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() );
+ fileL.sprintf( "%s -> %s", fi->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( (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" );
@@ -1302,100 +1301,100 @@ void AdvancedFm::move() {
if(!copyFile(destFile, curFile) ) {
QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile));
return;
}
QFile::remove(curFile);
TabWidget->setCurrentPage(0);
}
}
populateRemoteView();
populateLocalView();
}
bool AdvancedFm::copyFile( const QString & dest, const QString & src )
{
char bf[ 50000 ];
int bytesRead;
bool success = TRUE;
struct stat status;
QFile s( src );
QFile d( dest );
if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
success = FALSE;
break;
}
}
if( success && (bytesRead > 0) ){
d.writeBlock( bf, bytesRead );
}
} else {
success = FALSE;
}
// Set file permissions
if( stat( (const char *) src, &status ) == 0 ){
chmod( (const char *) dest, status.st_mode );
}
return success;
}
void AdvancedFm::runCommand() {
QString curFile;
if (TabWidget->currentPageIndex() == 0) {
if( Local_View->currentItem())
- curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0);
+ curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
} else {
if(Remote_View->currentItem())
- curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0);
+ curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
}
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
fileDlg->setInputText(curFile);
fileDlg->exec();
QString command;
if( fileDlg->result() == 1 ) {
command = fileDlg->LineEdit1->text();
// int err=0;
Output *outDlg;
outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
outDlg->showMaximized();
outDlg->show();
qApp->processEvents();
FILE *fp;
char line[130];
sleep(1);
// if(command.find("2>",0,TRUE) != -1)
command +=" 2>&1";
fp = popen( (const char *) command, "r");
if ( !fp ) {
qDebug("Could not execute '" + command + "'! err=%d", fp);
QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") );
pclose(fp);
return;
} else {
while ( fgets( line, sizeof line, fp)) {
QString lineStr = line;
lineStr=lineStr.left(lineStr.length()-1);
outDlg->OutputEdit->append(lineStr);
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
}
}
}
}
void AdvancedFm::runCommandStd() {
QString curFile;
if (TabWidget->currentPageIndex() == 0) {
if( Local_View->currentItem())
curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0);
} else {
if(Remote_View->currentItem())
curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0);
}