summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 828f5a1..cf19ba8 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -403,193 +403,193 @@ QString AdvancedFm::getFileSystemType(const QString &currentText) {
403 parsetab("/etc/mtab"); //why did TT forget filesystem type? 403 parsetab("/etc/mtab"); //why did TT forget filesystem type?
404 QString current = currentText;//.right( currentText.length()-1); 404 QString current = currentText;//.right( currentText.length()-1);
405 QString baseFs; 405 QString baseFs;
406 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 406 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
407 QString temp = (*it); 407 QString temp = (*it);
408 QString path = temp.left(temp.find("::",0,TRUE) ); 408 QString path = temp.left(temp.find("::",0,TRUE) );
409 path = path.right( path.length()-1); 409 path = path.right( path.length()-1);
410 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 410 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
411 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 411 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
412 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 412 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
413 } 413 }
414 } 414 }
415 return baseFs; 415 return baseFs;
416} 416}
417 417
418QString AdvancedFm::getDiskSpace( const QString &path) { 418QString AdvancedFm::getDiskSpace( const QString &path) {
419 struct statfs fss; 419 struct statfs fss;
420 if ( !statfs( path.latin1(), &fss ) ) { 420 if ( !statfs( path.latin1(), &fss ) ) {
421 int blkSize = fss.f_bsize; 421 int blkSize = fss.f_bsize;
422 // int totalBlks = fs.f_blocks; 422 // int totalBlks = fs.f_blocks;
423 int availBlks = fss.f_bavail; 423 int availBlks = fss.f_bavail;
424 424
425 long mult = blkSize / 1024; 425 long mult = blkSize / 1024;
426 long div = 1024 / blkSize; 426 long div = 1024 / blkSize;
427 if ( !mult ) mult = 1; 427 if ( !mult ) mult = 1;
428 if ( !div ) div = 1; 428 if ( !div ) div = 1;
429 429
430 return QString::number(availBlks * mult / div); 430 return QString::number(availBlks * mult / div);
431 } 431 }
432 return ""; 432 return "";
433} 433}
434 434
435 435
436void AdvancedFm::showFileMenu() { 436void AdvancedFm::showFileMenu() {
437 QString curApp; 437 QString curApp;
438 curApp = CurrentView()->currentItem()->text(0); 438 curApp = CurrentView()->currentItem()->text(0);
439 439
440 MimeType mt(curApp); 440 MimeType mt(curApp);
441 const AppLnk* app = mt.application(); 441 const AppLnk* app = mt.application();
442 QFile fi(curApp); 442 QFile fi(curApp);
443 QPopupMenu *m = new QPopupMenu(0); 443 QPopupMenu *m = new QPopupMenu(0);
444 QPopupMenu *n = new QPopupMenu(0); 444 QPopupMenu *n = new QPopupMenu(0);
445 // QPopupMenu *o = new QPopupMenu(0); 445 // QPopupMenu *o = new QPopupMenu(0);
446 m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); 446 m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden()));
447 447
448 if ( QFileInfo(fi).isDir()) { 448 if ( QFileInfo(fi).isDir()) {
449 m->insertSeparator(); 449 m->insertSeparator();
450 m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); 450 m->insertItem(tr("Change Directory"),this,SLOT(doDirChange()));
451 } else { 451 } else {
452 452
453 if (app) 453 if (app)
454 m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); 454 m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis()));
455 else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 455 else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
456 m->insertItem(tr("Execute"),this,SLOT(runThis())); 456 m->insertItem(tr("Execute"),this,SLOT(runThis()));
457 m->insertItem( Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon ), 457 m->insertItem( Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon ),
458 tr("Open as text"),this,SLOT(runText())); 458 tr("Open as text"),this,SLOT(runText()));
459 } 459 }
460 460
461 m->insertItem(tr("Actions"),n); 461 m->insertItem(tr("Actions"),n);
462 n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); 462 n->insertItem(tr("Make Directory"),this,SLOT(makeDir()));
463 463
464 n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); 464 n->insertItem(tr("Make Symlink"),this,SLOT(mkSym()));
465 465
466 n->insertSeparator(); 466 n->insertSeparator();
467 n->insertItem(tr("Rename"),this,SLOT(renameIt())); 467 n->insertItem(tr("Rename"),this,SLOT(renameIt()));
468 468
469 n->insertItem(tr("Copy"),this,SLOT(copyTimer())); 469 n->insertItem(tr("Copy"),this,SLOT(copyTimer()));
470 n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); 470 n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer()));
471 n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); 471 n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer()));
472 n->insertItem(tr("Move"),this,SLOT(moveTimer())); 472 n->insertItem(tr("Move"),this,SLOT(moveTimer()));
473 473
474 n->insertSeparator(); 474 n->insertSeparator();
475 n->insertItem(tr("Delete"),this,SLOT(doDelete())); 475 n->insertItem(tr("Delete"),this,SLOT(doDelete()));
476 m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); 476 m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs()));
477 477
478 m->insertItem(tr("Run Command"),this,SLOT(runCommand())); 478 m->insertItem(tr("Run Command"),this,SLOT(runCommand()));
479 m->insertItem(tr("File Info"),this,SLOT(fileStatus())); 479 m->insertItem(tr("File Info"),this,SLOT(fileStatus()));
480 480
481 m->insertSeparator(); 481 m->insertSeparator();
482 m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); 482 m->insertItem(tr("Set Permissions"),this,SLOT(filePerms()));
483 483
484#if defined(QT_QWS_OPIE) 484#if defined(QT_QWS_OPIE)
485 m->insertItem(tr("Properties"),this,SLOT(doProperties())); 485 m->insertItem(tr("Properties"),this,SLOT(doProperties()));
486#endif 486#endif
487 m->setCheckable(TRUE); 487 m->setCheckable(TRUE);
488 if (!b) 488 if (!b)
489 m->setItemChecked(m->idAt(0),TRUE); 489 m->setItemChecked(m->idAt(0),TRUE);
490 else 490 else
491 m->setItemChecked(m->idAt(0),FALSE); 491 m->setItemChecked(m->idAt(0),FALSE);
492 492
493 if(Ir::supported()) 493 if(Ir::supported())
494 m->insertItem(tr("Beam File"),this,SLOT(doBeam())); 494 m->insertItem(tr("Beam File"),this,SLOT(doBeam()));
495 m->setFocus(); 495 m->setFocus();
496 496
497 m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); 497 m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y()));
498 498
499 if(m) delete m; 499 delete m;
500} 500}
501 501
502 502
503QString AdvancedFm::checkDiskSpace(const QString &path) { 503QString AdvancedFm::checkDiskSpace(const QString &path) {
504 struct statfs fss; 504 struct statfs fss;
505 if ( !statfs( path.latin1(), &fss ) ) { 505 if ( !statfs( path.latin1(), &fss ) ) {
506 int blkSize = fss.f_bsize; 506 int blkSize = fss.f_bsize;
507// int totalBlks = fs.f_blocks; 507// int totalBlks = fs.f_blocks;
508 int availBlks = fss.f_bavail; 508 int availBlks = fss.f_bavail;
509 509
510 long mult = blkSize / 1024; 510 long mult = blkSize / 1024;
511 long div = 1024 / blkSize; 511 long div = 1024 / blkSize;
512 if ( !mult ) mult = 1; 512 if ( !mult ) mult = 1;
513 if ( !div ) div = 1; 513 if ( !div ) div = 1;
514 514
515 515
516 return QString::number(availBlks * mult / div); 516 return QString::number(availBlks * mult / div);
517 } 517 }
518 return ""; 518 return "";
519} 519}
520 520
521void AdvancedFm::addToDocs() { 521void AdvancedFm::addToDocs() {
522 QStringList strListPaths = getPath(); 522 QStringList strListPaths = getPath();
523 QDir *thisDir = CurrentDir(); 523 QDir *thisDir = CurrentDir();
524 524
525 if( strListPaths.count() > 0) { 525 if( strListPaths.count() > 0) {
526 QString curFile; 526 QString curFile;
527 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 527 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
528 curFile = thisDir->canonicalPath()+"/"+(*it); 528 curFile = thisDir->canonicalPath()+"/"+(*it);
529// odebug << curFile << oendl; 529// odebug << curFile << oendl;
530 QFileInfo fi(curFile); 530 QFileInfo fi(curFile);
531 DocLnk f; 531 DocLnk f;
532// curFile.replace(QRegExp("\\..*"),""); 532// curFile.replace(QRegExp("\\..*"),"");
533 f.setName(fi.baseName() ); 533 f.setName(fi.baseName() );
534 f.setFile( curFile); 534 f.setFile( curFile);
535 f.writeLink(); 535 f.writeLink();
536 } 536 }
537 } 537 }
538} 538}
539 539
540 540
541void AdvancedFm::customDirsToMenu() { 541void AdvancedFm::customDirsToMenu() {
542 542
543 Config cfg("AdvancedFm"); 543 Config cfg("AdvancedFm");
544 cfg.setGroup("Menu"); 544 cfg.setGroup("Menu");
545 545
546 QStringList list = cfg.readListEntry( "CustomDir", ','); 546 QStringList list = cfg.readListEntry( "CustomDir", ',');
547 menuButton->insertItems(list ); 547 menuButton->insertItems(list );
548 548
549// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 549// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
550// { 550// {
551// customDirMenu->insertItem(*it ); 551// customDirMenu->insertItem(*it );
552// } 552// }
553} 553}
554 554
555void AdvancedFm::dirMenuSelected(int item) { 555void AdvancedFm::dirMenuSelected(int item) {
556 switch(item) 556 switch(item)
557 { 557 {
558 558
559 case -21: 559 case -21:
560 case 0: 560 case 0:
561 addCustomDir(); 561 addCustomDir();
562 break; 562 break;
563 case -22: 563 case -22:
564 case 1: 564 case 1:
565 removeCustomDir(); 565 removeCustomDir();
566 break; 566 break;
567 default: 567 default:
568 { 568 {
569// gotoCustomDir( menuButton->text(item)); 569// gotoCustomDir( menuButton->text(item));
570// gotoCustomDir( customDirMenu->text(item)); 570// gotoCustomDir( customDirMenu->text(item));
571 } 571 }
572 break; 572 break;
573 573
574 }; 574 };
575} 575}
576 576
577void AdvancedFm::addCustomDir() { 577void AdvancedFm::addCustomDir() {
578 Config cfg("AdvancedFm"); 578 Config cfg("AdvancedFm");
579 cfg.setGroup("Menu"); 579 cfg.setGroup("Menu");
580 QString dir; 580 QString dir;
581 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 581 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
582 582
583 dir = CurrentDir()->canonicalPath(); 583 dir = CurrentDir()->canonicalPath();
584 584
585 bool addIt=true; 585 bool addIt=true;
586 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 586 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
587 if( dir == (*it)) { 587 if( dir == (*it)) {
588 addIt=false; 588 addIt=false;
589 } 589 }
590 } 590 }
591 if(addIt) { 591 if(addIt) {
592 menuButton->insertItem(dir); 592 menuButton->insertItem(dir);
593// customDirMenu->insertItem(dir); 593// customDirMenu->insertItem(dir);
594 list << dir; 594 list << dir;
595 } 595 }