summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfmMenu.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp114
1 files changed, 87 insertions, 27 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index ed280aa..9181810 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -13,6 +13,7 @@
13#include "advancedfm.h" 13#include "advancedfm.h"
14#include "output.h" 14#include "output.h"
15#include "filePermissions.h" 15#include "filePermissions.h"
16#include "fileInfoDialog.h"
16 17
17/* OPIE */ 18/* OPIE */
18#include <opie2/odebug.h> 19#include <opie2/odebug.h>
@@ -26,6 +27,7 @@ using namespace Opie::Core;
26#include <qmessagebox.h> 27#include <qmessagebox.h>
27#include <qpopupmenu.h> 28#include <qpopupmenu.h>
28#include <qlistview.h> 29#include <qlistview.h>
30#include <qlabel.h>
29 31
30/* STD */ 32/* STD */
31 33
@@ -653,33 +655,91 @@ void AdvancedFm::runCommandStd() {
653} 655}
654 656
655void AdvancedFm::fileStatus() { 657void AdvancedFm::fileStatus() {
656 if( !CurrentView()->currentItem()) return; 658 if( !CurrentView()->currentItem()) return;
657 QString curFile; 659
658 curFile = CurrentView()->currentItem()->text(0); 660 QString curFile;
659 if(QFileInfo("/usr/bin/stat").exists()) { 661 curFile = CurrentView()->currentItem()->text(0);
660 QStringList command; 662
661 command << "/bin/sh"; 663 QFileInfo curFileInfo(curFile);
662 command << "-c"; 664
663 command << "stat -l "+ curFile; 665 FileInfoDialog *infoDlg = new FileInfoDialog(this);
664 Output *outDlg; 666 infoDlg->setCaption(tr("Info for %1").arg(curFile));
665 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 667
666 QPEApplication::execDialog( outDlg ); 668 uint size = curFileInfo.size();
667 } else { 669 QString sizestr;
668/* struct stat buf; 670 if( size > 1048576 )
669 stat( curFile.local8bit(), &buf); 671 sizestr = tr("%1MB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1048576.0)).arg(size);
670 672 else if( size > 1024 )
671 st_dev dev; 673 sizestr = tr("%1kB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1024.0)).arg(size);
672 st_uid uid; 674 else
673 st_gid gid; 675 sizestr = tr("%1 bytes").arg(size);
674 st_size size; 676
675 st_atime atime; 677 infoDlg->sizeLabel->setText(sizestr);
676 st_mtime mtime; 678
677 st_ctime ctime; 679 if(curFileInfo.isSymLink())
678 st_mode mode; 680 infoDlg->typeLabel->setText(tr("symbolic link"));
679*/ 681 else if(curFileInfo.isFile()) {
680 } 682 if(curFileInfo.isExecutable())
681 683 infoDlg->typeLabel->setText(tr("executable file"));
682 qApp->processEvents(); 684 else
685 infoDlg->typeLabel->setText(tr("file"));
686 }
687 else if(curFileInfo.isDir())
688 infoDlg->typeLabel->setText(tr("directory"));
689 else
690 infoDlg->typeLabel->setText(tr("unknown"));
691
692 infoDlg->ownerLabel->setText( QString("%1 (%2)").arg(curFileInfo.owner()).arg(curFileInfo.ownerId()) );
693 infoDlg->groupLabel->setText( QString("%1 (%2)").arg(curFileInfo.group()).arg(curFileInfo.groupId()) );
694
695 infoDlg->lastReadLabel->setText( curFileInfo.lastRead().toString() );
696 infoDlg->lastModifiedLabel->setText( curFileInfo.lastModified().toString() );
697
698 QString perms;
699 // User
700 if(curFileInfo.permission(QFileInfo::ReadUser))
701 perms += "r";
702 else
703 perms += "-";
704 if(curFileInfo.permission(QFileInfo::WriteUser))
705 perms += "w";
706 else
707 perms += "-";
708 if(curFileInfo.permission(QFileInfo::ExeUser))
709 perms += "x";
710 else
711 perms += "-";
712 // Group
713 if(curFileInfo.permission(QFileInfo::ReadGroup))
714 perms += "r";
715 else
716 perms += "-";
717 if(curFileInfo.permission(QFileInfo::WriteGroup))
718 perms += "w";
719 else
720 perms += "-";
721 if(curFileInfo.permission(QFileInfo::ExeGroup))
722 perms += "x";
723 else
724 perms += "-";
725 // Other
726 if(curFileInfo.permission(QFileInfo::ReadOther))
727 perms += "r";
728 else
729 perms += "-";
730 if(curFileInfo.permission(QFileInfo::WriteOther))
731 perms += "w";
732 else
733 perms += "-";
734 if(curFileInfo.permission(QFileInfo::ExeOther))
735 perms += "x";
736 else
737 perms += "-";
738 infoDlg->permsLabel->setText( perms );
739
740 QPEApplication::execDialog( infoDlg );
741
742 qApp->processEvents();
683} 743}
684 744
685 745