From 188c44c1196c3597a84189c2d148813df16dfe95 Mon Sep 17 00:00:00 2001 From: korovkin Date: Sat, 30 Dec 2006 18:15:58 +0000 Subject: Fix for bug# 0001553 Submited by Paul Eggleton avancedfm uses FileInfoDialog and QFileInfo to display the selected file information. --- (limited to 'noncore') diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro index 396f912..90d29e3 100644 --- a/noncore/apps/advancedfm/advancedfm.pro +++ b/noncore/apps/advancedfm/advancedfm.pro @@ -3,6 +3,7 @@ CONFIG += qte warn_on quick-app debug HEADERS = advancedfm.h filePermissions.h output.h SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp TARGET = advancedfm +INTERFACES += fileInfoDialog.ui INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -lopieui2 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 @@ #include "advancedfm.h" #include "output.h" #include "filePermissions.h" +#include "fileInfoDialog.h" /* OPIE */ #include @@ -26,6 +27,7 @@ using namespace Opie::Core; #include #include #include +#include /* STD */ @@ -653,33 +655,91 @@ void AdvancedFm::runCommandStd() { } void AdvancedFm::fileStatus() { - if( !CurrentView()->currentItem()) return; - QString curFile; - curFile = CurrentView()->currentItem()->text(0); - if(QFileInfo("/usr/bin/stat").exists()) { - QStringList command; - command << "/bin/sh"; - command << "-c"; - command << "stat -l "+ curFile; - Output *outDlg; - outDlg = new Output( command, this, tr("AdvancedFm Output"), true); - QPEApplication::execDialog( outDlg ); - } else { -/* struct stat buf; - stat( curFile.local8bit(), &buf); - - st_dev dev; - st_uid uid; - st_gid gid; - st_size size; - st_atime atime; - st_mtime mtime; - st_ctime ctime; - st_mode mode; -*/ - } - - qApp->processEvents(); + if( !CurrentView()->currentItem()) return; + + QString curFile; + curFile = CurrentView()->currentItem()->text(0); + + QFileInfo curFileInfo(curFile); + + FileInfoDialog *infoDlg = new FileInfoDialog(this); + infoDlg->setCaption(tr("Info for %1").arg(curFile)); + + uint size = curFileInfo.size(); + QString sizestr; + if( size > 1048576 ) + sizestr = tr("%1MB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1048576.0)).arg(size); + else if( size > 1024 ) + sizestr = tr("%1kB (%2 bytes)").arg(QString().sprintf("%.0f", size / 1024.0)).arg(size); + else + sizestr = tr("%1 bytes").arg(size); + + infoDlg->sizeLabel->setText(sizestr); + + if(curFileInfo.isSymLink()) + infoDlg->typeLabel->setText(tr("symbolic link")); + else if(curFileInfo.isFile()) { + if(curFileInfo.isExecutable()) + infoDlg->typeLabel->setText(tr("executable file")); + else + infoDlg->typeLabel->setText(tr("file")); + } + else if(curFileInfo.isDir()) + infoDlg->typeLabel->setText(tr("directory")); + else + infoDlg->typeLabel->setText(tr("unknown")); + + infoDlg->ownerLabel->setText( QString("%1 (%2)").arg(curFileInfo.owner()).arg(curFileInfo.ownerId()) ); + infoDlg->groupLabel->setText( QString("%1 (%2)").arg(curFileInfo.group()).arg(curFileInfo.groupId()) ); + + infoDlg->lastReadLabel->setText( curFileInfo.lastRead().toString() ); + infoDlg->lastModifiedLabel->setText( curFileInfo.lastModified().toString() ); + + QString perms; + // User + if(curFileInfo.permission(QFileInfo::ReadUser)) + perms += "r"; + else + perms += "-"; + if(curFileInfo.permission(QFileInfo::WriteUser)) + perms += "w"; + else + perms += "-"; + if(curFileInfo.permission(QFileInfo::ExeUser)) + perms += "x"; + else + perms += "-"; + // Group + if(curFileInfo.permission(QFileInfo::ReadGroup)) + perms += "r"; + else + perms += "-"; + if(curFileInfo.permission(QFileInfo::WriteGroup)) + perms += "w"; + else + perms += "-"; + if(curFileInfo.permission(QFileInfo::ExeGroup)) + perms += "x"; + else + perms += "-"; + // Other + if(curFileInfo.permission(QFileInfo::ReadOther)) + perms += "r"; + else + perms += "-"; + if(curFileInfo.permission(QFileInfo::WriteOther)) + perms += "w"; + else + perms += "-"; + if(curFileInfo.permission(QFileInfo::ExeOther)) + perms += "x"; + else + perms += "-"; + infoDlg->permsLabel->setText( perms ); + + QPEApplication::execDialog( infoDlg ); + + qApp->processEvents(); } diff --git a/noncore/apps/advancedfm/fileInfoDialog.ui b/noncore/apps/advancedfm/fileInfoDialog.ui new file mode 100644 index 0000000..c8997fc --- a/dev/null +++ b/noncore/apps/advancedfm/fileInfoDialog.ui @@ -0,0 +1,418 @@ + +FileInfoDialog + + QDialog + + name + FileInfoDialog + + + geometry + + 0 + 0 + 225 + 303 + + + + caption + FileInfoDialog + + + + margin + 11 + + + spacing + 6 + + + QGroupBox + + name + GroupBox1 + + + sizePolicy + + 5 + 5 + + + + title + General + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + typeLabel + + + sizePolicy + + 1 + 1 + + + + text + executable file + + + + QLabel + + name + sizeLabel + + + sizePolicy + + 1 + 1 + + + + text + 3kb (3100 bytes) + + + + QLabel + + name + ownerLabel + + + sizePolicy + + 1 + 1 + + + + maximumSize + + 32767 + 32767 + + + + text + bill (100) + + + alignment + AlignVCenter|AlignLeft + + + hAlign + + + + QLabel + + name + ownerCaptionLabel + + + sizePolicy + + 1 + 1 + + + + maximumSize + + 32767 + 32767 + + + + text + Owner: + + + alignment + AlignVCenter|AlignLeft + + + hAlign + + + + QLabel + + name + sizeCaptionLabel + + + sizePolicy + + 1 + 1 + + + + maximumSize + + 32767 + 32767 + + + + text + Size: + + + + QLabel + + name + typeCaptionLabel + + + sizePolicy + + 1 + 1 + + + + maximumSize + + 60 + 32767 + + + + text + Type: + + + + QLabel + + name + groupCaptionLabel + + + sizePolicy + + 1 + 1 + + + + text + Group: + + + + QLabel + + name + groupLabel + + + sizePolicy + + 1 + 1 + + + + text + users (500) + + + + QLabel + + name + permsCaptionLabel + + + sizePolicy + + 1 + 1 + + + + text + Permissions: + + + + QLabel + + name + permsLabel + + + sizePolicy + + 1 + 1 + + + + text + rwxrwxrwx + + + + + + QGroupBox + + name + GroupBox2 + + + title + Times + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + lastReadLabel + + + text + users (500) + + + + QLabel + + name + lastModifiedLabel + + + sizePolicy + + 1 + 1 + + + + maximumSize + + 32767 + 32767 + + + + text + users (500) + + + alignment + AlignVCenter|AlignLeft + + + hAlign + + + + QLabel + + name + lastReadCaptionLabel + + + sizePolicy + + 1 + 1 + + + + maximumSize + + 60 + 32767 + + + + text + Accessed: + + + alignment + AlignVCenter|AlignLeft + + + hAlign + + + + QLabel + + name + lastModifiedCaptionLabel + + + sizePolicy + + 1 + 1 + + + + text + Modified: + + + + + + + name + Spacer1 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + -- cgit v0.9.0.2