author | korovkin <korovkin> | 2006-12-30 18:15:58 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-12-30 18:15:58 (UTC) |
commit | 188c44c1196c3597a84189c2d148813df16dfe95 (patch) (side-by-side diff) | |
tree | 15cecf27f6db8ce2b42c182e1cec87706ba01ef9 | |
parent | bb6f32ae999168fc44d50d3523c3ef232824185a (diff) | |
download | opie-188c44c1196c3597a84189c2d148813df16dfe95.zip opie-188c44c1196c3597a84189c2d148813df16dfe95.tar.gz opie-188c44c1196c3597a84189c2d148813df16dfe95.tar.bz2 |
Fix for bug# 0001553 Submited by Paul Eggleton
avancedfm uses FileInfoDialog and QFileInfo to display the selected
file information.
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.pro | 1 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 114 | ||||
-rw-r--r-- | noncore/apps/advancedfm/fileInfoDialog.ui | 418 |
3 files changed, 506 insertions, 27 deletions
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 @@ -1,15 +1,16 @@ TEMPLATE = app 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 !contains(CONFIG,quick-app) { DESTDIR = $(OPIEDIR)/bin DEFINES += NOQUICKLAUNCH } include( $(OPIEDIR)/include.pro ) 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 @@ -1,92 +1,94 @@ /*************************************************************************** AdvancedFm.cpp ------------------- ** Created: Sat Mar 9 23:33:09 2002 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "advancedfm.h" #include "output.h" #include "filePermissions.h" +#include "fileInfoDialog.h" /* OPIE */ #include <opie2/odebug.h> #include <qpe/lnkproperties.h> #include <qpe/qpeapplication.h> #include <qpe/applnk.h> using namespace Opie::Core; /* QT*/ #include <qmessagebox.h> #include <qpopupmenu.h> #include <qlistview.h> +#include <qlabel.h> /* STD */ #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <dirent.h> #include <sys/sendfile.h> #include <fcntl.h> void AdvancedFm::doDirChange() { QString pathItem = CurrentView()->currentItem()->text(0); if( pathItem == "../") { ListClicked( CurrentView()->currentItem()); } else { if( pathItem.find(" -> ",0,TRUE) != -1) pathItem = dealWithSymName((const QString&)pathItem)+"/"; // owarn << pathItem << oendl; changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); } } void AdvancedFm::showMenuHidden() { if (b) { CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); } else { CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); } b = !b; populateView(); } void AdvancedFm::showHidden() { if (b) { CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); } else { CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); } populateView(); } QString AdvancedFm::dealWithSymName(const QString &fileName) { QString strItem = fileName; return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); } void AdvancedFm::runThis() { if( !CurrentView()->currentItem()) return; QString fs; QDir *thisDir = CurrentDir(); QString curFile = CurrentView()->currentItem()->text(0); QString path = thisDir->canonicalPath(); if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink curFile = dealWithSymName((const QString&)curFile); @@ -592,155 +594,213 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { } else { success = false; } } else { success = false; } srcFile.close(); destFile.close(); // Set file permissions if( stat( QFile::encodeName(src), &status ) == 0 ) { chmod( QFile::encodeName(dest), status.st_mode ); } return success; } void AdvancedFm::runCommand() { if( !CurrentView()->currentItem()) return; QDir *thisDir = CurrentDir(); QString curFile; curFile = thisDir->canonicalPath() +"/"+ CurrentView()->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 ) { // odebug << fileDlg->LineEdit1->text() << oendl; QStringList command; command << "/bin/sh"; command << "-c"; command << fileDlg->LineEdit1->text(); Output *outDlg; outDlg = new Output( command, this, tr("AdvancedFm Output"), true); QPEApplication::execDialog( outDlg ); qApp->processEvents(); } } void AdvancedFm::runCommandStd() { if( !CurrentView()->currentItem()) return; QString curFile; QDir *thisDir = CurrentDir(); QListView *thisView = CurrentView(); if( thisView->currentItem()) curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); fileDlg->setInputText(curFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { qApp->processEvents(); startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); } } 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(); } void AdvancedFm::mkDir() { makeDir(); } void AdvancedFm::rn() { renameIt(); } void AdvancedFm::del() { doDelete(); } void AdvancedFm::mkSym() { QString cmd; QStringList curFileList = getPath(); if( curFileList.count() > 0) { QDir *thisDir = CurrentDir(); QDir * thatDir = OtherDir(); for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString destName = thatDir->canonicalPath()+"/"+(*it); if(destName.right(1) == "/") { destName = destName.left( destName.length() -1); } QString curFile = thisDir->canonicalPath()+"/"+(*it); if( curFile.right(1) == "/") { curFile = curFile.left( curFile.length() -1); } cmd = "ln -s "+curFile+" "+destName; // odebug << cmd << oendl; startProcess( (const QString)cmd ); } rePopulate(); setOtherTabCurrent(); } } void AdvancedFm::doBeam() { Ir ir; if(!ir.supported()) { } else { QStringList curFileList = getPath(); if( curFileList.count() > 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString curFile = (*it); QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; if( curFilePath.right(1) == "/") { curFilePath = curFilePath.left( curFilePath.length() -1); } Ir *file = new Ir(this, "IR"); connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); file->send( curFilePath, curFile ); } } } } 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 @@ +<!DOCTYPE UI><UI> +<class>FileInfoDialog</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>FileInfoDialog</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>225</width> + <height>303</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>FileInfoDialog</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox1</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>title</name> + <string>General</string> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>typeLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>executable file</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>sizeLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>3kb (3100 bytes)</string> + </property> + </widget> + <widget row="2" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>ownerLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property stdset="1"> + <name>text</name> + <string>bill (100)</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignVCenter|AlignLeft</set> + </property> + <property> + <name>hAlign</name> + </property> + </widget> + <widget row="2" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>ownerCaptionLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property stdset="1"> + <name>text</name> + <string>Owner:</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignVCenter|AlignLeft</set> + </property> + <property> + <name>hAlign</name> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>sizeCaptionLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property stdset="1"> + <name>text</name> + <string>Size:</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>typeCaptionLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>60</width> + <height>32767</height> + </size> + </property> + <property stdset="1"> + <name>text</name> + <string>Type:</string> + </property> + </widget> + <widget row="3" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>groupCaptionLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Group:</string> + </property> + </widget> + <widget row="3" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>groupLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>users (500)</string> + </property> + </widget> + <widget row="4" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>permsCaptionLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Permissions:</string> + </property> + </widget> + <widget row="4" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>permsLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>rwxrwxrwx</string> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox2</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Times</string> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>lastReadLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>users (500)</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>lastModifiedLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property stdset="1"> + <name>text</name> + <string>users (500)</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignVCenter|AlignLeft</set> + </property> + <property> + <name>hAlign</name> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>lastReadCaptionLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>60</width> + <height>32767</height> + </size> + </property> + <property stdset="1"> + <name>text</name> + <string>Accessed:</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignVCenter|AlignLeft</set> + </property> + <property> + <name>hAlign</name> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>lastModifiedCaptionLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Modified:</string> + </property> + </widget> + </grid> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer1</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> +</widget> +</UI> |