-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 32 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 2 |
2 files changed, 29 insertions, 5 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 96a2d0a..16dc7da 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -67,12 +67,14 @@ #include <stdio.h> #include <time.h> #include <fcntl.h> #include <mntent.h> #include <string.h> #include <errno.h> +#include <sys/vfs.h> +#include <mntent.h> AdvancedFm::AdvancedFm( ) : QMainWindow( ) { setCaption( tr( "AdvancedFm" ) ); @@ -301,13 +303,13 @@ void AdvancedFm::populateLocalView() Local_View->clear(); currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentDir.setMatchAllDirs(TRUE); currentDir.setNameFilter(filterStr); QString fileL, fileS, fileDate; QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); - setCaption("AdvancedFm :: "+fs); + setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); bool isDir=FALSE; const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); QFileInfoListIterator it(*list); QFileInfo *fi; while ( (fi=it.current()) ) { if (fi->isSymLink() ) { @@ -399,13 +401,13 @@ void AdvancedFm::populateRemoteView() currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentRemoteDir.setMatchAllDirs(TRUE); currentRemoteDir.setNameFilter(filterStr); QString fileL, fileS, fileDate; QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); - setCaption("AdvancedFm :: "+fs); + setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); bool isDir=FALSE; const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); QFileInfoListIterator it(*list); QFileInfo *fi; while ( (fi=it.current()) ) { if (fi->isSymLink() ){ @@ -1463,12 +1465,14 @@ void AdvancedFm::runCommand() { QString lineStr = line; lineStr=lineStr.left(lineStr.length()-1); outDlg->OutputEdit->append(lineStr); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); } } + pclose(fp); + } } void AdvancedFm::runCommandStd() { QString curFile; if (TabWidget->currentPageIndex() == 0) { @@ -1518,12 +1522,13 @@ void AdvancedFm::fileStatus() { outDlg->OutputEdit->append(line); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); } } + pclose(fp); } void AdvancedFm::mkDir() { if (TabWidget->currentPageIndex() == 0) localMakDir(); else @@ -1833,13 +1838,32 @@ void AdvancedFm::showFileMenu() { m->exec( QCursor::pos() ); sleep(1); if(m) delete m; } -void AdvancedFm::cancelMenuTimer() -{ +void AdvancedFm::cancelMenuTimer() { qDebug("selectionChanged: cancel menu timer"); if( menuTimer.isActive() ) menuTimer.stop(); } + +QString AdvancedFm::checkDiskSpace(const QString &path) { + + struct statfs fss; + if ( !statfs( path.latin1(), &fss ) ) { + int blkSize = fss.f_bsize; +// int totalBlks = fs.f_blocks; + int availBlks = fss.f_bavail; + + long mult = blkSize / 1024; + long div = 1024 / blkSize; + if ( !mult ) mult = 1; + if ( !div ) div = 1; + + + return QString::number(availBlks * mult / div); + } + return ""; +} + diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 45f00ad..78f0bad 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -110,13 +110,13 @@ protected: void keyReleaseEvent( QKeyEvent *); QString getFileSystemType(const QString &); QString getDiskSpace(const QString &); void parsetab(const QString &fileName); - +QString checkDiskSpace(const QString &); protected slots: void showFileMenu(); void cancelMenuTimer(); void homeButtonPushed(); void docButtonPushed(); void SDButtonPushed(); |