summaryrefslogtreecommitdiff
path: root/noncore
authorllornkcor <llornkcor>2002-04-30 12:31:39 (UTC)
committer llornkcor <llornkcor>2002-04-30 12:31:39 (UTC)
commitaae6ce64221457dbed804d7ebce095a621ea892a (patch) (side-by-side diff)
tree20baaeeab39b2862628dc99d5ebb365cb2e26077 /noncore
parent99ae08c3e872fb9dcbba8057ee98f9f1687d0af1 (diff)
downloadopie-aae6ce64221457dbed804d7ebce095a621ea892a.zip
opie-aae6ce64221457dbed804d7ebce095a621ea892a.tar.gz
opie-aae6ce64221457dbed804d7ebce095a621ea892a.tar.bz2
used a slot that didn't exist, took out some unused variables
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp216
-rw-r--r--noncore/apps/advancedfm/advancedfm.h6
2 files changed, 141 insertions, 81 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index b5fcccf..ee3f736 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -64,2 +64,5 @@
#include <fcntl.h>
+#include <mntent.h>
+#include <string.h>
+#include <errno.h>
@@ -273,11 +276,2 @@ void AdvancedFm::populateLocalView()
{
-// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
-// QListViewItemIterator it( Local_View );
-// for ( ; it.current(); ++it ) {
-// if ( it.current()->isSelected() ) {
-// QString strItem = it.current()->text(0);
-// QString localFile = currentDir.canonicalPath()+"/"+strItem;
-// QFileInfo fi(localFile);
-// }
-// }
QPixmap pm;
@@ -289,3 +283,6 @@ void AdvancedFm::populateLocalView()
// qDebug(currentDir.canonicalPath());
-
+// struct stat buf;
+// mode_t mode;
+ QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
+ setCaption("AdvancedFm :: "+fs);
bool isDir=FALSE;
@@ -306,3 +303,3 @@ void AdvancedFm::populateLocalView()
fileDate= fi->lastModified().toString();
- if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
+ if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
@@ -312,6 +309,9 @@ void AdvancedFm::populateLocalView()
}
+ QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
if(fileL !="./" && fi->exists()) {
item= new QListViewItem( Local_View, fileL, fileS , fileDate);
+
if(isDir || fileL.find("/",0,TRUE) != -1) {
- if( !QDir( fi->filePath() ).isReadable())
+
+ if( !QDir( fi->filePath() ).isReadable()) //is directory
pm = Resource::loadPixmap( "lockedfolder" );
@@ -319,22 +319,18 @@ void AdvancedFm::populateLocalView()
pm= Resource::loadPixmap( "folder" );
- item->setPixmap( 0,pm );
- } else {
-// if(fi->isExecutable()) {
-// pm = Resource::loadPixmap( "exec");
-// item->setPixmap( 0,pm);
-// }
- if( !fi->isReadable() ) {
- pm = Resource::loadPixmap( "locked" );
- item->setPixmap( 0,pm);
-
- }
- else {
- MimeType mt(fi->filePath());
- pm=mt.pixmap(); //sets the correct pixmap for mimetype
- if(pm.isNull())
- pm = Resource::loadPixmap( "UnknownDocument-14" );
- item->setPixmap( 0,pm);
- }
+// item->setPixmap( 0,pm );
+ } else if( fileInfo.isExecutable() || fs == "vfat" && fi->filePath().contains("/bin") ) { //is exec
+ pm = Resource::loadPixmap( "exec");
+// item->setPixmap( 0,pm);
+ } else if( !fi->isReadable() ) {
+ pm = Resource::loadPixmap( "locked" );
+// item->setPixmap( 0,pm);
+ } else { //everything else goes by mimetype
+ MimeType mt(fi->filePath());
+ pm=mt.pixmap(); //sets the correct pixmap for mimetype
+ if(pm.isNull())
+ pm = Resource::loadPixmap( "UnknownDocument-14" );
+// item->setPixmap( 0,pm);
}
- if( fileL.find("->",0,TRUE) != -1) {
+ item->setPixmap( 0,pm);
+ if( fi->isSymLink() &&fileL.find("->",0,TRUE) != -1) {
// overlay link image
@@ -347,3 +343,4 @@ void AdvancedFm::populateLocalView()
}
- } isDir=FALSE;
+ }
+ isDir=FALSE;
++it;
@@ -353,9 +350,9 @@ void AdvancedFm::populateLocalView()
struct stat buf;
- struct stat st;
+// struct stat st;
dev_t devT;
- mode_t mode;
+// mode_t mode;
DIR *dir;
- int fd = 0;
+// int fd = 0;
struct dirent *mydirent;
- int i = 1;
+// int i = 1;
if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
@@ -403,2 +400,5 @@ void AdvancedFm::populateRemoteView()
QString fileL, fileS, fileDate;
+
+ QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
+ setCaption("AdvancedFm :: "+fs);
bool isDir=FALSE;
@@ -435,29 +435,28 @@ void AdvancedFm::populateRemoteView()
pm= Resource::loadPixmap( "folder" );
- item->setPixmap( 0,pm );
+// item->setPixmap( 0,pm );
+ } else if( fi->isExecutable() || fs == "vfat" && fi->filePath().contains("/bin") ) {
+ pm = Resource::loadPixmap( "exec");
+// item->setPixmap( 0,pm);
+ } else if( !fi->isReadable() ) {
+ pm = Resource::loadPixmap( "locked" );
+// item->setPixmap( 0,pm);
} else {
-// if(fi->isExecutable()) {
-// pm = Resource::loadPixmap( "exec");
+ MimeType mt(fi->filePath());
+ pm=mt.pixmap(); //sets the correct pixmap for mimetype
+ if(pm.isNull())
+ pm = Resource::loadPixmap( "UnknownDocument-14" );
// item->setPixmap( 0,pm);
-// }
- if( !fi->isReadable() ) {
- pm = Resource::loadPixmap( "locked" );
- item->setPixmap( 0,pm);
- } else {
- MimeType mt(fi->filePath());
- pm=mt.pixmap(); //sets the correct pixmap for mimetype
- if(pm.isNull())
- pm = Resource::loadPixmap( "UnknownDocument-14" );
- item->setPixmap( 0,pm);
- }
- }
- if( fileL.find("->",0,TRUE) != -1) {
- // overlay link image
- pm= Resource::loadPixmap( "folder" );
- QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
- QPainter painter( &pm );
- painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
- pm.setMask( pm.createHeuristicMask( FALSE ) );
- item->setPixmap( 0, pm);
}
- } isDir=FALSE;
+ if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
+ // overlay link image
+ pm= Resource::loadPixmap( "folder" );
+ QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
+ QPainter painter( &pm );
+ painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
+ pm.setMask( pm.createHeuristicMask( FALSE ) );
+// item->setPixmap( 0, pm);
+ }
+ item->setPixmap( 0, pm);
+ }
+ isDir=FALSE;
++it;
@@ -467,8 +466,8 @@ void AdvancedFm::populateRemoteView()
struct stat buf;
- struct stat st;
- mode_t mode;
+// struct stat st;
+// mode_t mode;
DIR *dir;
- int fd = 0;
+// int fd = 0;
struct dirent *mydirent;
- int i = 1;
+// int i = 1;
if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
@@ -662,2 +661,3 @@ void AdvancedFm::showLocalMenu(QListViewItem * item)
m.insertSeparator();
+ m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() ));
m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
@@ -697,2 +697,3 @@ void AdvancedFm::showRemoteMenu(QListViewItem * item)
m.insertSeparator();
+ m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() ));
m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
@@ -715,9 +716,13 @@ void AdvancedFm::runThis() {
// QFileInfo *fi;
+QString fs;
if (TabWidget->currentPageIndex() == 0) {
QString curFile = Local_View->currentItem()->text(0);
+
+ fs= getFileSystemType((const QString &) currentDir.canonicalPath());
QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
-// if(fileInfo.isExecutable()) {
-// QCopEnvelope e("QPE/System", "execute(QString)" );
-// e << curFile;
-// } else {
+ qDebug( fileInfo.owner());
+ if( fileInfo.isExecutable() || fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
+ QCopEnvelope e("QPE/System", "execute(QString)" );
+ e << curFile;
+ } else {
curFile = currentDir.canonicalPath()+"/"+curFile;
@@ -730,3 +735,3 @@ void AdvancedFm::runThis() {
}
-// }
+ }
// MimeType mt( curFile);
@@ -734,7 +739,9 @@ void AdvancedFm::runThis() {
QString curFile = Remote_View->currentItem()->text(0);
+ fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
+ qDebug("Filesystemtype is "+fs);
QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
-// if(fileInfo.isExecutable()) {
-// QCopEnvelope e("QPE/System", "execute(QString)" );
-// e << curFile;
-// } else {
+ if(fileInfo.isExecutable() || fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
+ QCopEnvelope e("QPE/System", "execute(QString)" );
+ e << curFile;
+ } else {
curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
@@ -747,3 +754,3 @@ void AdvancedFm::runThis() {
}
-// }
+ }
// MimeType mt( curFile);
@@ -1346,3 +1353,3 @@ void AdvancedFm::runCommand() {
- int err=0;
+// int err=0;
Output *outDlg;
@@ -1404,3 +1411,3 @@ void AdvancedFm::fileStatus() {
QString command = " stat -l "+ curFile +" 2>&1";
- int err=0;
+// int err=0;
Output *outDlg;
@@ -1521,7 +1528,3 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
break;
-
-
-
}
-
}
@@ -1569,3 +1572,56 @@ void AdvancedFm::QPEButtonPushed() {
update();
+}
+void AdvancedFm::parsetab(const QString &fileName) {
+
+ fileSystemTypeList.clear();
+ fsList.clear();
+ struct mntent *me;
+// if(fileName == "/etc/mtab") {
+ 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;
+// deviceList << deviceName;
+// qDebug(mountDir+"::"+filesystemType);
+ fileSystemTypeList << mountDir+"::"+filesystemType;
+ }
+ }
+ }
+ endmntent( mntfp );
}
+
+QString AdvancedFm::getFileSystemType(const QString &currentText) {
+ 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;
+}
+
+
+// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
+// QListViewItemIterator it( Local_View );
+// for ( ; it.current(); ++it ) {
+// if ( it.current()->isSelected() ) {
+// QString strItem = it.current()->text(0);
+// QString localFile = currentDir.canonicalPath()+"/"+strItem;
+// QFileInfo fi(localFile);
+// }
+// }
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 5c2719e..90619ba 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -60,2 +60,3 @@ public:
bool b;
+ QStringList fileSystemTypeList, fsList;
int currentServerConfig;
@@ -104,3 +105,6 @@ protected:
QStringList remoteDirPathStringList, localDirPathStringList;
- void keyReleaseEvent( QKeyEvent *);
+ void keyReleaseEvent( QKeyEvent *);
+ QString getFileSystemType(const QString &);
+ void parsetab(const QString &fileName);
+
protected slots: