author | llornkcor <llornkcor> | 2002-08-06 13:59:45 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-06 13:59:45 (UTC) |
commit | 64888e9cd2f4c8f40f08a6712e2fd27220ff14ad (patch) (side-by-side diff) | |
tree | 862bcda0849bf79b3eeb6fbab1ef18d08b005dc9 | |
parent | b980135ff5ce5447ca41411b6ace74ce2803fadb (diff) | |
download | opie-64888e9cd2f4c8f40f08a6712e2fd27220ff14ad.zip opie-64888e9cd2f4c8f40f08a6712e2fd27220ff14ad.tar.gz opie-64888e9cd2f4c8f40f08a6712e2fd27220ff14ad.tar.bz2 |
re-add missing diskspace function
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 22 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.pro | 28 |
2 files changed, 31 insertions, 19 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index b169a79..7ee78c0 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -1,117 +1,117 @@ /*************************************************************************** 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. * ***************************************************************************/ #define DEVELOPERS_VERSION #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties #include "advancedfm.h" #include "inputDialog.h" #include "filePermissions.h" #include "output.h" -#include <opie/ofileselector.h> -#include <opie/ofiledialog.h> +// #include <opie/ofileselector.h> +// #include <opie/ofiledialog.h> #include <qpe/lnkproperties.h> #include <qpe/filemanager.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/config.h> #include <qpe/mimetype.h> #include <qpe/applnk.h> #include <qpe/ir.h> //#include <opie/ofileselector.h> #include <qmultilineedit.h> #include <qtextstream.h> #include <qpushbutton.h> #include <qtoolbutton.h> #include <qdatetime.h> #include <qdir.h> #include <qfile.h> #include <qstring.h> #include <qcombobox.h> #include <qpopupmenu.h> #include <qlistview.h> #include <qmainwindow.h> #include <qlabel.h> #include <qprogressbar.h> #include <qspinbox.h> #include <qtabwidget.h> #include <qwidget.h> #include <qlayout.h> #include <qimage.h> #include <qpixmap.h> #include <qmessagebox.h> #include <qlineedit.h> #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()) ); QPEMenuBar *menuBar = new QPEMenuBar(this); fileMenu = new QPopupMenu( this ); viewMenu = new QPopupMenu( this ); layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); menuBar->insertItem( tr( "File" ), fileMenu); menuBar->insertItem( tr( "View" ), viewMenu); qpeDirButton= new QToolButton(this,"QPEButton"); qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); cfButton = new QToolButton( this,"CFButton"); cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); cfButton ->setFixedSize( QSize( 20, 20 ) ); connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); sdButton = new QToolButton( this,"SDButton"); sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard")); sdButton->setFixedSize( QSize( 20, 20 ) ); connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); cdUpButton = new QToolButton( this,"cdUpButton"); cdUpButton->setPixmap(Resource::loadPixmap("up")); cdUpButton ->setFixedSize( QSize( 20, 20 ) ); connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); @@ -1639,250 +1639,262 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) case Key_9: break; case Key_0: break; } } void AdvancedFm::mkSym() { QString cmd; QStringList curFileList = getPath(); if( curFileList.count() > 0) { if (TabWidget->currentPageIndex() == 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); if(destName.right(1) == "/") destName = destName.left( destName.length() -1); QString curFile = currentDir.canonicalPath()+"/"+(*it); if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); cmd = "ln -s "+curFile+" "+destName; qDebug(cmd); system(cmd.latin1() ); } populateRemoteView(); TabWidget->setCurrentPage(1); } else { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString destName = currentDir.canonicalPath()+"/"+(*it); if(destName.right(1) == "/") destName = destName.left( destName.length() -1); QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); cmd = "ln -s "+curFile+" "+destName; qDebug(cmd); system(cmd.latin1() ); } populateLocalView(); TabWidget->setCurrentPage(0); } } } void AdvancedFm::QPEButtonPushed() { QString current = QPEApplication::qpeDir(); chdir( current.latin1() ); if (TabWidget->currentPageIndex() == 0) { currentDir.cd( current, TRUE); populateLocalView(); } else { currentRemoteDir.cd( current, TRUE); populateRemoteView(); } update(); } void AdvancedFm::parsetab(const QString &fileName) { fileSystemTypeList.clear(); fsList.clear(); struct mntent *me; FILE *mntfp = setmntent( fileName.latin1(), "r" ); if ( mntfp ) { while ( (me = getmntent( mntfp )) != 0 ) { QString deviceName = me->mnt_fsname; QString filesystemType = me->mnt_type; QString mountDir = me->mnt_dir; if(deviceName != "none") { if( fsList.contains(filesystemType) == 0 & filesystemType.find("proc",0,TRUE) == -1 & filesystemType.find("cramfs",0,TRUE) == -1 & filesystemType.find("auto",0,TRUE) == -1) fsList << filesystemType; fileSystemTypeList << mountDir+"::"+filesystemType; } } } endmntent( mntfp ); } QString AdvancedFm::getFileSystemType(const QString ¤tText) { parsetab("/etc/mtab"); //why did TT forget filesystem type? QString current = currentText;//.right( currentText.length()-1); QString baseFs; for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { QString temp = (*it); QString path = temp.left(temp.find("::",0,TRUE) ); path = path.right( path.length()-1); if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); } } return baseFs; } -QString AdvancedFm::getDiskSpace( const QString &) { - +QString AdvancedFm::getDiskSpace( 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 ""; } void AdvancedFm::doBeam() { Ir ir; if(!ir.supported()){ } else { QStringList curFileList = getPath(); if( curFileList.count() > 0) { if (TabWidget->currentPageIndex() == 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString curFile = currentDir.canonicalPath()+"/"+(*it); if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); Ir *file = new Ir(this, "IR"); connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); file->send( curFile, curFile ); } } else { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); Ir *file = new Ir(this, "IR"); connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); file->send( curFile, curFile ); } } } } } void AdvancedFm::fileBeamFinished( Ir *ir) { QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); } void AdvancedFm::showFileMenu() { QString curApp; bool isLocalView = false; if (TabWidget->currentPageIndex() == 0) { isLocalView = TRUE; curApp = Local_View->currentItem()->text(0); } else { curApp = Remote_View->currentItem()->text(0); } MimeType mt( curApp ); const AppLnk* app = mt.application(); QFile fi(curApp); QPopupMenu *m = new QPopupMenu(0); m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); m->insertSeparator(); if ( QFileInfo(fi).isDir() ) { m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); } else { if ( app ) m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); else if( QFileInfo(fi).isExecutable() ) m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); } m->insertSeparator(); if(isLocalView) m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); else m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); m->insertSeparator(); if(isLocalView) m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); else m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); m->insertItem( tr( "Copy" ), this, SLOT( copy() )); m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); m->insertItem( tr( "Move" ), this, SLOT( move() )); m->insertSeparator(); if(isLocalView) m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); else m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); m->insertSeparator(); if(isLocalView) m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); else m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); m->insertSeparator(); m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); m->setCheckable(TRUE); if (!b) 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() { 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.pro b/noncore/apps/advancedfm/advancedfm.pro index e99ab12..0f0f770 100644 --- a/noncore/apps/advancedfm/advancedfm.pro +++ b/noncore/apps/advancedfm/advancedfm.pro @@ -1,25 +1,25 @@ TEMPLATE = app CONFIG += qt warn_on release HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h SOURCES = advancedfm.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp TARGET = advancedfm REQUIRES=medium-config INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include DESTDIR = $(OPIEDIR)/bin -LIBS += -lqpe -lopie +LIBS += -lqpe TRANSLATIONS = ../../../i18n/de/advancedfm.ts \ - ../../../i18n/en/advancedfm.ts \ - ../../../i18n/es/advancedfm.ts \ - ../../../i18n/fr/advancedfm.ts \ - ../../../i18n/hu/advancedfm.ts \ - ../../../i18n/ja/advancedfm.ts \ - ../../../i18n/ko/advancedfm.ts \ - ../../../i18n/no/advancedfm.ts \ - ../../../i18n/pl/advancedfm.ts \ - ../../../i18n/pt/advancedfm.ts \ - ../../../i18n/pt_BR/advancedfm.ts \ - ../../../i18n/sl/advancedfm.ts \ - ../../../i18n/zh_CN/advancedfm.ts \ - ../../../i18n/zh_TW/advancedfm.ts + ../../../i18n/en/advancedfm.ts \ + ../../../i18n/es/advancedfm.ts \ + ../../../i18n/fr/advancedfm.ts \ + ../../../i18n/hu/advancedfm.ts \ + ../../../i18n/ja/advancedfm.ts \ + ../../../i18n/ko/advancedfm.ts \ + ../../../i18n/no/advancedfm.ts \ + ../../../i18n/pl/advancedfm.ts \ + ../../../i18n/pt/advancedfm.ts \ + ../../../i18n/pt_BR/advancedfm.ts \ + ../../../i18n/sl/advancedfm.ts \ + ../../../i18n/zh_CN/advancedfm.ts \ + ../../../i18n/zh_TW/advancedfm.ts |