summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp32
-rw-r--r--noncore/apps/advancedfm/advancedfm.h2
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
@@ -61,24 +61,26 @@
#include <qregexp.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <dirent.h>
#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" ) );
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 2);
layout->setMargin( 2);
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
@@ -295,25 +297,25 @@ void AdvancedFm::tabChanged(QWidget *w)
}
void AdvancedFm::populateLocalView()
{
QPixmap pm;
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() ) {
QString symLink=fi->readLink();
QFileInfo sym( symLink);
fileS.sprintf( "%10li", sym.size() );
fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
fileDate = sym.lastModified().toString();
} else {
@@ -393,25 +395,25 @@ void AdvancedFm::populateLocalView()
void AdvancedFm::populateRemoteView()
{
QPixmap pm;
Remote_View->clear();
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() ){
QString symLink=fi->readLink();
// qDebug("Symlink detected "+symLink);
QFileInfo sym( symLink);
fileS.sprintf( "%10li", sym.size() );
fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
fileDate = sym.lastModified().toString();
@@ -1457,24 +1459,26 @@ void AdvancedFm::runCommand() {
qDebug("Could not execute '" + command + "'! err=%d", fp);
QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
pclose(fp);
return;
} else {
while ( fgets( line, sizeof line, fp)) {
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) {
if( Local_View->currentItem())
curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
} else {
if(Remote_View->currentItem())
curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0);
}
@@ -1512,24 +1516,25 @@ void AdvancedFm::fileStatus() {
qDebug("Could not execute '" + command + "'! err=%d", fp);
QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
pclose(fp);
return;
} else {
while ( fgets( line, sizeof line, fp)) {
outDlg->OutputEdit->append(line);
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
}
}
+ pclose(fp);
}
void AdvancedFm::mkDir() {
if (TabWidget->currentPageIndex() == 0)
localMakDir();
else
remoteMakDir();
}
void AdvancedFm::rn() {
if (TabWidget->currentPageIndex() == 0)
@@ -1827,19 +1832,38 @@ void AdvancedFm::showFileMenu() {
m->setItemChecked(m->idAt(0),TRUE);
else
m->setItemChecked(m->idAt(0),FALSE);
if(Ir::supported())
m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
m->setFocus();
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
@@ -104,25 +104,25 @@ protected slots:
void switchToLocalTab();
void switchToRemoteTab();
protected:
QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
QStringList remoteDirPathStringList, localDirPathStringList;
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();
void CFButtonPushed();
void QPEButtonPushed();
void upDir();
void currentPathComboChanged();
void copy();
void copyAs();