summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-01 02:24:51 (UTC)
committer llornkcor <llornkcor>2002-05-01 02:24:51 (UTC)
commit7e5615473c1d103db66f42ae60bf9ed57d52566c (patch) (unidiff)
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
@@ -257,246 +257,256 @@ void AdvancedFm::cleanUp()
257 file.remove(); 257 file.remove();
258} 258}
259 259
260void AdvancedFm::tabChanged(QWidget *w) 260void AdvancedFm::tabChanged(QWidget *w)
261{ 261{
262 if (TabWidget->currentPageIndex() == 0) { 262 if (TabWidget->currentPageIndex() == 0) {
263 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 263 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
264 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 264 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
265 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 265 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
266 } 266 }
267 if (TabWidget->currentPageIndex() == 1) { 267 if (TabWidget->currentPageIndex() == 1) {
268 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 268 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
269 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 269 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
270 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 270 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
271 } 271 }
272} 272}
273 273
274 274
275void AdvancedFm::populateLocalView() 275void AdvancedFm::populateLocalView()
276{ 276{
277 QPixmap pm; 277 QPixmap pm;
278 Local_View->clear(); 278 Local_View->clear();
279 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 279 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
280 currentDir.setMatchAllDirs(TRUE); 280 currentDir.setMatchAllDirs(TRUE);
281 currentDir.setNameFilter(filterStr); 281 currentDir.setNameFilter(filterStr);
282 QString fileL, fileS, fileDate; 282 QString fileL, fileS, fileDate;
283// qDebug(currentDir.canonicalPath()); 283// qDebug(currentDir.canonicalPath());
284// struct stat buf; 284// struct stat buf;
285// mode_t mode; 285// mode_t mode;
286 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 286 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
287 setCaption("AdvancedFm :: "+fs); 287 setCaption("AdvancedFm :: "+fs);
288 bool isDir=FALSE; 288 bool isDir=FALSE;
289 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 289 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
290 QFileInfoListIterator it(*list); 290 QFileInfoListIterator it(*list);
291 QFileInfo *fi; 291 QFileInfo *fi;
292 while ( (fi=it.current()) ) { 292 while ( (fi=it.current()) ) {
293 if (fi->isSymLink() ) { 293 if (fi->isSymLink() ) {
294 QString symLink=fi->readLink(); 294 QString symLink=fi->readLink();
295// qDebug("Symlink detected "+symLink); 295// qDebug("Symlink detected "+symLink);
296 QFileInfo sym( symLink); 296 QFileInfo sym( symLink);
297 fileS.sprintf( "%10li", sym.size() ); 297 fileS.sprintf( "%10li", sym.size() );
298 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 298 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
299 fileDate = sym.lastModified().toString(); 299 fileDate = sym.lastModified().toString();
300 } else { 300 } else {
301 fileS.sprintf( "%10li", fi->size() ); 301 fileS.sprintf( "%10li", fi->size() );
302 fileL.sprintf( "%s",fi->fileName().data() ); 302 fileL.sprintf( "%s",fi->fileName().data() );
303 fileDate= fi->lastModified().toString(); 303 fileDate= fi->lastModified().toString();
304 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 304 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
305 fileL+="/"; 305 fileL+="/";
306 isDir=TRUE; 306 isDir=TRUE;
307// qDebug( fileL); 307// qDebug( fileL);
308 } 308 }
309 } 309 }
310 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 310 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
311 if(fileL !="./" && fi->exists()) { 311 if(fileL !="./" && fi->exists()) {
312 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 312 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
313 313
314 if(isDir || fileL.find("/",0,TRUE) != -1) { 314 if(isDir || fileL.find("/",0,TRUE) != -1) {
315 315
316 if( !QDir( fi->filePath() ).isReadable()) //is directory 316 if( !QDir( fi->filePath() ).isReadable()) //is directory
317 pm = Resource::loadPixmap( "lockedfolder" ); 317 pm = Resource::loadPixmap( "lockedfolder" );
318 else 318 else
319 pm= Resource::loadPixmap( "folder" ); 319 pm= Resource::loadPixmap( "folder" );
320// item->setPixmap( 0,pm ); 320// item->setPixmap( 0,pm );
321 } else if( fileInfo.isExecutable() || fs == "vfat" && fi->filePath().contains("/bin") ) { //is exec 321 } else if( (fileInfo.permission( QFileInfo::ExeUser)
322 pm = Resource::loadPixmap( "exec"); 322 | fileInfo.permission( QFileInfo::ExeGroup)
323// item->setPixmap( 0,pm); 323 | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) {
324 pm = Resource::loadPixmap( "exec");
325// else { //is exec
326// pm = Resource::loadPixmap( "exec");
327// }
328// // item->setPixmap( 0,pm);
324 } else if( !fi->isReadable() ) { 329 } else if( !fi->isReadable() ) {
325 pm = Resource::loadPixmap( "locked" ); 330 pm = Resource::loadPixmap( "locked" );
326// item->setPixmap( 0,pm); 331// item->setPixmap( 0,pm);
327 } else { //everything else goes by mimetype 332 } else { //everything else goes by mimetype
328 MimeType mt(fi->filePath()); 333 MimeType mt(fi->filePath());
329 pm=mt.pixmap(); //sets the correct pixmap for mimetype 334 pm=mt.pixmap(); //sets the correct pixmap for mimetype
330 if(pm.isNull()) 335 if(pm.isNull())
331 pm = Resource::loadPixmap( "UnknownDocument-14" ); 336 pm = Resource::loadPixmap( "UnknownDocument-14" );
332// item->setPixmap( 0,pm); 337// item->setPixmap( 0,pm);
333 } 338 }
334 item->setPixmap( 0,pm); 339 item->setPixmap( 0,pm);
335 if( fi->isSymLink() &&fileL.find("->",0,TRUE) != -1) { 340 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
336 // overlay link image 341 // overlay link image
337 pm= Resource::loadPixmap( "folder" ); 342 pm= Resource::loadPixmap( "folder" );
338 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 343 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
339 QPainter painter( &pm ); 344 QPainter painter( &pm );
340 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 345 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
341 pm.setMask( pm.createHeuristicMask( FALSE ) ); 346 pm.setMask( pm.createHeuristicMask( FALSE ) );
342 item->setPixmap( 0, pm); 347 item->setPixmap( 0, pm);
343 } 348 }
344 } 349 }
345 isDir=FALSE; 350 isDir=FALSE;
346 ++it; 351 ++it;
347 } 352 }
348 353
349 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 354 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
350 struct stat buf; 355 struct stat buf;
351// struct stat st; 356// struct stat st;
352 dev_t devT; 357 dev_t devT;
353// mode_t mode; 358// mode_t mode;
354 DIR *dir; 359 DIR *dir;
355// int fd = 0; 360// int fd = 0;
356 struct dirent *mydirent; 361 struct dirent *mydirent;
357// int i = 1; 362// int i = 1;
358 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 363 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
359 while ((mydirent = readdir(dir)) != NULL) { 364 while ((mydirent = readdir(dir)) != NULL) {
360 lstat( mydirent->d_name, &buf); 365 lstat( mydirent->d_name, &buf);
361 qDebug(mydirent->d_name); 366 qDebug(mydirent->d_name);
362// mode = buf.st_mode; 367// mode = buf.st_mode;
363 fileL.sprintf("%s", mydirent->d_name); 368 fileL.sprintf("%s", mydirent->d_name);
364// fileS.sprintf("%d, %d", ); //this isn't correct 369// fileS.sprintf("%d, %d", ); //this isn't correct
365 devT = buf.st_dev; 370 devT = buf.st_dev;
366 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 371 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
367// fileS.sprintf("%d,%d", devT, devT); 372// fileS.sprintf("%d,%d", devT, devT);
368 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 373 fileDate.sprintf("%s", ctime( &buf.st_mtime));
369 if( fileL.find(".") == -1 ){ 374 if( fileL.find(".") == -1 ){
370 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 375 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
371 pm = Resource::loadPixmap( "UnknownDocument-14" ); 376 pm = Resource::loadPixmap( "UnknownDocument-14" );
372 item->setPixmap( 0,pm); 377 item->setPixmap( 0,pm);
373 } 378 }
374 } 379 }
375 380
376 closedir(dir); 381 closedir(dir);
377 } 382 }
378 383
379 Local_View->setSorting( 3,FALSE); 384 Local_View->setSorting( 3,FALSE);
380 fillCombo( (const QString &) currentDir.canonicalPath()); 385 fillCombo( (const QString &) currentDir.canonicalPath());
381} 386}
382 387
383 388
384void AdvancedFm::populateRemoteView() 389void AdvancedFm::populateRemoteView()
385{ 390{
386// QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 391// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
387// QListViewItemIterator it( Remote_View ); 392// QListViewItemIterator it( Remote_View );
388// for ( ; it.current(); ++it ) { 393// for ( ; it.current(); ++it ) {
389// if ( it.current()->isSelected() ) { 394// if ( it.current()->isSelected() ) {
390// QString strItem = it.current()->text(0); 395// QString strItem = it.current()->text(0);
391// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; 396// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem;
392// QFileInfo fi(localFile); 397// QFileInfo fi(localFile);
393// } 398// }
394// } 399// }
395 QPixmap pm; 400 QPixmap pm;
396 Remote_View->clear(); 401 Remote_View->clear();
397 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 402 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
398 currentRemoteDir.setMatchAllDirs(TRUE); 403 currentRemoteDir.setMatchAllDirs(TRUE);
399 currentRemoteDir.setNameFilter(filterStr); 404 currentRemoteDir.setNameFilter(filterStr);
400 QString fileL, fileS, fileDate; 405 QString fileL, fileS, fileDate;
401 406
402 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 407 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
403 setCaption("AdvancedFm :: "+fs); 408 setCaption("AdvancedFm :: "+fs);
404 bool isDir=FALSE; 409 bool isDir=FALSE;
405 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 410 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
406 QFileInfoListIterator it(*list); 411 QFileInfoListIterator it(*list);
407 QFileInfo *fi; 412 QFileInfo *fi;
408 while ( (fi=it.current()) ) { 413 while ( (fi=it.current()) ) {
409 if (fi->isSymLink() ){ 414 if (fi->isSymLink() ){
410 QString symLink=fi->readLink(); 415 QString symLink=fi->readLink();
411// qDebug("Symlink detected "+symLink); 416// qDebug("Symlink detected "+symLink);
412 QFileInfo sym( symLink); 417 QFileInfo sym( symLink);
413 fileS.sprintf( "%10li", sym.size() ); 418 fileS.sprintf( "%10li", sym.size() );
414 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 419 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
415 fileDate = sym.lastModified().toString(); 420 fileDate = sym.lastModified().toString();
416 } else { 421 } else {
417// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 422// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
418 fileS.sprintf( "%10li", fi->size() ); 423 fileS.sprintf( "%10li", fi->size() );
419 fileL.sprintf( "%s",fi->fileName().data() ); 424 fileL.sprintf( "%s",fi->fileName().data() );
420 fileDate= fi->lastModified().toString(); 425 fileDate= fi->lastModified().toString();
421 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 426 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
422 fileL+="/"; 427 fileL+="/";
423 isDir=TRUE; 428 isDir=TRUE;
424// qDebug( fileL); 429// qDebug( fileL);
425 } 430 }
426 } 431 }
432 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
427 if(fileL !="./" && fi->exists()) { 433 if(fileL !="./" && fi->exists()) {
428 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 434 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
429 QPixmap pm; 435 QPixmap pm;
430 436
431 if(isDir || fileL.find("/",0,TRUE) != -1) { 437 if(isDir || fileL.find("/",0,TRUE) != -1) {
432 if( !QDir( fi->filePath() ).isReadable()) 438 if( !QDir( fi->filePath() ).isReadable())
433 pm = Resource::loadPixmap( "lockedfolder" ); 439 pm = Resource::loadPixmap( "lockedfolder" );
434 else 440 else
435 pm= Resource::loadPixmap( "folder" ); 441 pm= Resource::loadPixmap( "folder" );
436// item->setPixmap( 0,pm ); 442// item->setPixmap( 0,pm );
437 } else if( fi->isExecutable() || fs == "vfat" && fi->filePath().contains("/bin") ) { 443 } else if( (fileInfo.permission( QFileInfo::ExeUser)
438 pm = Resource::loadPixmap( "exec"); 444 | fileInfo.permission( QFileInfo::ExeGroup)
445 | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) {
446 pm = Resource::loadPixmap( "exec");
447///// } else if(fileInfo.isExecutable()){ //is exec <<<< BROKEN!!
448 pm = Resource::loadPixmap( "exec");
439// item->setPixmap( 0,pm); 449// item->setPixmap( 0,pm);
440 } else if( !fi->isReadable() ) { 450 } else if( !fi->isReadable() ) {
441 pm = Resource::loadPixmap( "locked" ); 451 pm = Resource::loadPixmap( "locked" );
442// item->setPixmap( 0,pm); 452// item->setPixmap( 0,pm);
443 } else { 453 } else {
444 MimeType mt(fi->filePath()); 454 MimeType mt(fi->filePath());
445 pm=mt.pixmap(); //sets the correct pixmap for mimetype 455 pm=mt.pixmap(); //sets the correct pixmap for mimetype
446 if(pm.isNull()) 456 if(pm.isNull())
447 pm = Resource::loadPixmap( "UnknownDocument-14" ); 457 pm = Resource::loadPixmap( "UnknownDocument-14" );
448// item->setPixmap( 0,pm); 458// item->setPixmap( 0,pm);
449 } 459 }
450 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 460 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
451 // overlay link image 461 // overlay link image
452 pm= Resource::loadPixmap( "folder" ); 462 pm= Resource::loadPixmap( "folder" );
453 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 463 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
454 QPainter painter( &pm ); 464 QPainter painter( &pm );
455 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 465 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
456 pm.setMask( pm.createHeuristicMask( FALSE ) ); 466 pm.setMask( pm.createHeuristicMask( FALSE ) );
457// item->setPixmap( 0, pm); 467// item->setPixmap( 0, pm);
458 } 468 }
459 item->setPixmap( 0, pm); 469 item->setPixmap( 0, pm);
460 } 470 }
461 isDir=FALSE; 471 isDir=FALSE;
462 ++it; 472 ++it;
463 } 473 }
464 474
465 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 475 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
466 struct stat buf; 476 struct stat buf;
467// struct stat st; 477// struct stat st;
468// mode_t mode; 478// mode_t mode;
469 DIR *dir; 479 DIR *dir;
470// int fd = 0; 480// int fd = 0;
471 struct dirent *mydirent; 481 struct dirent *mydirent;
472// int i = 1; 482// int i = 1;
473 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 483 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
474 while ((mydirent = readdir(dir)) != NULL) { 484 while ((mydirent = readdir(dir)) != NULL) {
475 lstat( mydirent->d_name, &buf); 485 lstat( mydirent->d_name, &buf);
476 qDebug(mydirent->d_name); 486 qDebug(mydirent->d_name);
477// mode = buf.st_mode; 487// mode = buf.st_mode;
478 fileL.sprintf("%s", mydirent->d_name); 488 fileL.sprintf("%s", mydirent->d_name);
479// fileS.sprintf("%d, %d", ); //this isn't correct 489// fileS.sprintf("%d, %d", ); //this isn't correct
480 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 490 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
481 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 491 fileDate.sprintf("%s", ctime( &buf.st_mtime));
482 if( fileL.find(".") == -1 ){ 492 if( fileL.find(".") == -1 ){
483 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 493 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
484 pm = Resource::loadPixmap( "UnknownDocument-14" ); 494 pm = Resource::loadPixmap( "UnknownDocument-14" );
485 item->setPixmap( 0,pm); 495 item->setPixmap( 0,pm);
486 } 496 }
487 } 497 }
488 498
489 closedir(dir); 499 closedir(dir);
490 } 500 }
491 501
492 Remote_View->setSorting( 3,FALSE); 502 Remote_View->setSorting( 3,FALSE);
493 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 503 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
494} 504}
495 505
496void AdvancedFm::localListClicked(QListViewItem *selectedItem) 506void AdvancedFm::localListClicked(QListViewItem *selectedItem)
497{ 507{
498 if(selectedItem) { 508 if(selectedItem) {
499 QString strItem=selectedItem->text(0); 509 QString strItem=selectedItem->text(0);
500 QString strSize=selectedItem->text(1); 510 QString strSize=selectedItem->text(1);
501 strSize=strSize.stripWhiteSpace(); 511 strSize=strSize.stripWhiteSpace();
502 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 512 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink