summaryrefslogtreecommitdiff
Unidiff
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
@@ -25,96 +25,98 @@
25#include <qpe/filemanager.h> 25#include <qpe/filemanager.h>
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#include <qpe/qpemenubar.h> 27#include <qpe/qpemenubar.h>
28#include <qpe/qpetoolbar.h> 28#include <qpe/qpetoolbar.h>
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/mimetype.h> 33#include <qpe/mimetype.h>
34#include <qpe/applnk.h> 34#include <qpe/applnk.h>
35#include <qpe/ir.h> 35#include <qpe/ir.h>
36 36
37//#include <opie/ofileselector.h> 37//#include <opie/ofileselector.h>
38#include <qmultilineedit.h> 38#include <qmultilineedit.h>
39 39
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qtoolbutton.h> 42#include <qtoolbutton.h>
43#include <qdatetime.h> 43#include <qdatetime.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qfile.h> 45#include <qfile.h>
46#include <qstring.h> 46#include <qstring.h>
47#include <qcombobox.h> 47#include <qcombobox.h>
48#include <qpopupmenu.h> 48#include <qpopupmenu.h>
49#include <qlistview.h> 49#include <qlistview.h>
50#include <qmainwindow.h> 50#include <qmainwindow.h>
51#include <qlabel.h> 51#include <qlabel.h>
52#include <qprogressbar.h> 52#include <qprogressbar.h>
53#include <qspinbox.h> 53#include <qspinbox.h>
54#include <qtabwidget.h> 54#include <qtabwidget.h>
55#include <qwidget.h> 55#include <qwidget.h>
56#include <qlayout.h> 56#include <qlayout.h>
57#include <qimage.h> 57#include <qimage.h>
58#include <qpixmap.h> 58#include <qpixmap.h>
59#include <qmessagebox.h> 59#include <qmessagebox.h>
60#include <qlineedit.h> 60#include <qlineedit.h>
61#include <qregexp.h> 61#include <qregexp.h>
62 62
63#include <unistd.h> 63#include <unistd.h>
64#include <stdlib.h> 64#include <stdlib.h>
65#include <sys/stat.h> 65#include <sys/stat.h>
66#include <dirent.h> 66#include <dirent.h>
67#include <stdio.h> 67#include <stdio.h>
68#include <time.h> 68#include <time.h>
69#include <fcntl.h> 69#include <fcntl.h>
70#include <mntent.h> 70#include <mntent.h>
71#include <string.h> 71#include <string.h>
72#include <errno.h> 72#include <errno.h>
73#include <sys/vfs.h>
74#include <mntent.h>
73 75
74AdvancedFm::AdvancedFm( ) 76AdvancedFm::AdvancedFm( )
75 : QMainWindow( ) 77 : QMainWindow( )
76{ 78{
77 setCaption( tr( "AdvancedFm" ) ); 79 setCaption( tr( "AdvancedFm" ) );
78 80
79 QGridLayout *layout = new QGridLayout( this ); 81 QGridLayout *layout = new QGridLayout( this );
80 layout->setSpacing( 2); 82 layout->setSpacing( 2);
81 layout->setMargin( 2); 83 layout->setMargin( 2);
82 84
83 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 85 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
84 86
85 QPEMenuBar *menuBar = new QPEMenuBar(this); 87 QPEMenuBar *menuBar = new QPEMenuBar(this);
86 fileMenu = new QPopupMenu( this ); 88 fileMenu = new QPopupMenu( this );
87 viewMenu = new QPopupMenu( this ); 89 viewMenu = new QPopupMenu( this );
88 90
89 layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); 91 layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 );
90 92
91 menuBar->insertItem( tr( "File" ), fileMenu); 93 menuBar->insertItem( tr( "File" ), fileMenu);
92 menuBar->insertItem( tr( "View" ), viewMenu); 94 menuBar->insertItem( tr( "View" ), viewMenu);
93 95
94 qpeDirButton= new QToolButton(this,"QPEButton"); 96 qpeDirButton= new QToolButton(this,"QPEButton");
95 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); 97 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton");
96 qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); 98 qpeDirButton ->setFixedSize( QSize( 20, 20 ) );
97 connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); 99 connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) );
98 layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); 100 layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2);
99 101
100 cfButton = new QToolButton( this,"CFButton"); 102 cfButton = new QToolButton( this,"CFButton");
101 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); 103 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia"));
102 cfButton ->setFixedSize( QSize( 20, 20 ) ); 104 cfButton ->setFixedSize( QSize( 20, 20 ) );
103 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); 105 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) );
104 layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); 106 layout->addMultiCellWidget( cfButton , 0, 0, 3, 3);
105 107
106 sdButton = new QToolButton( this,"SDButton"); 108 sdButton = new QToolButton( this,"SDButton");
107 sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard")); 109 sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard"));
108 sdButton->setFixedSize( QSize( 20, 20 ) ); 110 sdButton->setFixedSize( QSize( 20, 20 ) );
109 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); 111 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) );
110 layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); 112 layout->addMultiCellWidget( sdButton , 0, 0, 4, 4);
111 113
112 cdUpButton = new QToolButton( this,"cdUpButton"); 114 cdUpButton = new QToolButton( this,"cdUpButton");
113 cdUpButton->setPixmap(Resource::loadPixmap("up")); 115 cdUpButton->setPixmap(Resource::loadPixmap("up"));
114 cdUpButton ->setFixedSize( QSize( 20, 20 ) ); 116 cdUpButton ->setFixedSize( QSize( 20, 20 ) );
115 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 117 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
116 layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); 118 layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5);
117 119
118 docButton = new QToolButton( this,"docsButton"); 120 docButton = new QToolButton( this,"docsButton");
119 docButton->setPixmap(Resource::loadPixmap("DocsIcon")); 121 docButton->setPixmap(Resource::loadPixmap("DocsIcon"));
120 docButton->setFixedSize( QSize( 20, 20 ) ); 122 docButton->setFixedSize( QSize( 20, 20 ) );
@@ -259,97 +261,97 @@ AdvancedFm::AdvancedFm( )
259 261
260 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); 262 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
261 263
262 populateLocalView(); 264 populateLocalView();
263 populateRemoteView(); 265 populateRemoteView();
264 currentPathCombo->setFocus(); 266 currentPathCombo->setFocus();
265} 267}
266 268
267AdvancedFm::~AdvancedFm() 269AdvancedFm::~AdvancedFm()
268{ 270{
269} 271}
270 272
271void AdvancedFm::cleanUp() 273void AdvancedFm::cleanUp()
272{ 274{
273 QString sfile=QDir::homeDirPath(); 275 QString sfile=QDir::homeDirPath();
274 if(sfile.right(1) != "/") 276 if(sfile.right(1) != "/")
275 sfile+="/._temp"; 277 sfile+="/._temp";
276 else 278 else
277 sfile+="._temp"; 279 sfile+="._temp";
278 QFile file( sfile); 280 QFile file( sfile);
279 if(file.exists()) 281 if(file.exists())
280 file.remove(); 282 file.remove();
281} 283}
282 284
283void AdvancedFm::tabChanged(QWidget *w) 285void AdvancedFm::tabChanged(QWidget *w)
284{ 286{
285 if (TabWidget->currentPageIndex() == 0) { 287 if (TabWidget->currentPageIndex() == 0) {
286 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 288 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
287 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 289 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
288 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 290 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
289 } 291 }
290 if (TabWidget->currentPageIndex() == 1) { 292 if (TabWidget->currentPageIndex() == 1) {
291 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 293 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
292 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 294 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
293 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 295 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
294 } 296 }
295} 297}
296 298
297 299
298void AdvancedFm::populateLocalView() 300void AdvancedFm::populateLocalView()
299{ 301{
300 QPixmap pm; 302 QPixmap pm;
301 Local_View->clear(); 303 Local_View->clear();
302 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 304 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
303 currentDir.setMatchAllDirs(TRUE); 305 currentDir.setMatchAllDirs(TRUE);
304 currentDir.setNameFilter(filterStr); 306 currentDir.setNameFilter(filterStr);
305 QString fileL, fileS, fileDate; 307 QString fileL, fileS, fileDate;
306 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 308 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
307 setCaption("AdvancedFm :: "+fs); 309 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
308 bool isDir=FALSE; 310 bool isDir=FALSE;
309 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 311 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
310 QFileInfoListIterator it(*list); 312 QFileInfoListIterator it(*list);
311 QFileInfo *fi; 313 QFileInfo *fi;
312 while ( (fi=it.current()) ) { 314 while ( (fi=it.current()) ) {
313 if (fi->isSymLink() ) { 315 if (fi->isSymLink() ) {
314 QString symLink=fi->readLink(); 316 QString symLink=fi->readLink();
315 QFileInfo sym( symLink); 317 QFileInfo sym( symLink);
316 fileS.sprintf( "%10li", sym.size() ); 318 fileS.sprintf( "%10li", sym.size() );
317 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 319 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
318 fileDate = sym.lastModified().toString(); 320 fileDate = sym.lastModified().toString();
319 } else { 321 } else {
320 fileS.sprintf( "%10li", fi->size() ); 322 fileS.sprintf( "%10li", fi->size() );
321 fileL.sprintf( "%s",fi->fileName().data() ); 323 fileL.sprintf( "%s",fi->fileName().data() );
322 fileDate= fi->lastModified().toString(); 324 fileDate= fi->lastModified().toString();
323 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 325 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
324 fileL+="/"; 326 fileL+="/";
325 isDir=TRUE; 327 isDir=TRUE;
326 } 328 }
327 } 329 }
328 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 330 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
329 if(fileL !="./" && fi->exists()) { 331 if(fileL !="./" && fi->exists()) {
330 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 332 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
331 333
332 if(isDir || fileL.find("/",0,TRUE) != -1) { 334 if(isDir || fileL.find("/",0,TRUE) != -1) {
333 335
334 if( !QDir( fi->filePath() ).isReadable()) //is directory 336 if( !QDir( fi->filePath() ).isReadable()) //is directory
335 pm = Resource::loadPixmap( "lockedfolder" ); 337 pm = Resource::loadPixmap( "lockedfolder" );
336 else 338 else
337 pm= Resource::loadPixmap( "folder" ); 339 pm= Resource::loadPixmap( "folder" );
338 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 340 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
339 pm = Resource::loadPixmap( "exec"); 341 pm = Resource::loadPixmap( "exec");
340 } else if( (fileInfo.permission( QFileInfo::ExeUser) 342 } else if( (fileInfo.permission( QFileInfo::ExeUser)
341 | fileInfo.permission( QFileInfo::ExeGroup) 343 | fileInfo.permission( QFileInfo::ExeGroup)
342 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 344 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
343 pm = Resource::loadPixmap( "exec"); 345 pm = Resource::loadPixmap( "exec");
344 } else if( !fi->isReadable() ) { 346 } else if( !fi->isReadable() ) {
345 pm = Resource::loadPixmap( "locked" ); 347 pm = Resource::loadPixmap( "locked" );
346 } else { //everything else goes by mimetype 348 } else { //everything else goes by mimetype
347 MimeType mt(fi->filePath()); 349 MimeType mt(fi->filePath());
348 pm=mt.pixmap(); //sets the correct pixmap for mimetype 350 pm=mt.pixmap(); //sets the correct pixmap for mimetype
349 if(pm.isNull()) 351 if(pm.isNull())
350 pm = Resource::loadPixmap( "UnknownDocument-14" ); 352 pm = Resource::loadPixmap( "UnknownDocument-14" );
351 } 353 }
352 item->setPixmap( 0,pm); 354 item->setPixmap( 0,pm);
353 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 355 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
354 // overlay link image 356 // overlay link image
355 pm= Resource::loadPixmap( "folder" ); 357 pm= Resource::loadPixmap( "folder" );
@@ -357,97 +359,97 @@ void AdvancedFm::populateLocalView()
357 QPainter painter( &pm ); 359 QPainter painter( &pm );
358 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 360 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
359 pm.setMask( pm.createHeuristicMask( FALSE ) ); 361 pm.setMask( pm.createHeuristicMask( FALSE ) );
360 item->setPixmap( 0, pm); 362 item->setPixmap( 0, pm);
361 } 363 }
362 } 364 }
363 isDir=FALSE; 365 isDir=FALSE;
364 ++it; 366 ++it;
365 } 367 }
366 368
367 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 369 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
368 struct stat buf; 370 struct stat buf;
369 dev_t devT; 371 dev_t devT;
370 DIR *dir; 372 DIR *dir;
371 struct dirent *mydirent; 373 struct dirent *mydirent;
372 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 374 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
373 while ((mydirent = readdir(dir)) != NULL) { 375 while ((mydirent = readdir(dir)) != NULL) {
374 lstat( mydirent->d_name, &buf); 376 lstat( mydirent->d_name, &buf);
375 qDebug(mydirent->d_name); 377 qDebug(mydirent->d_name);
376 fileL.sprintf("%s", mydirent->d_name); 378 fileL.sprintf("%s", mydirent->d_name);
377 devT = buf.st_dev; 379 devT = buf.st_dev;
378 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 380 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
379 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 381 fileDate.sprintf("%s", ctime( &buf.st_mtime));
380 if( fileL.find(".") == -1 ){ 382 if( fileL.find(".") == -1 ){
381 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 383 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
382 pm = Resource::loadPixmap( "UnknownDocument-14" ); 384 pm = Resource::loadPixmap( "UnknownDocument-14" );
383 item->setPixmap( 0,pm); 385 item->setPixmap( 0,pm);
384 } 386 }
385 } 387 }
386 388
387 closedir(dir); 389 closedir(dir);
388 } 390 }
389 391
390 Local_View->setSorting( 3,FALSE); 392 Local_View->setSorting( 3,FALSE);
391 fillCombo( (const QString &) currentDir.canonicalPath()); 393 fillCombo( (const QString &) currentDir.canonicalPath());
392} 394}
393 395
394 396
395void AdvancedFm::populateRemoteView() 397void AdvancedFm::populateRemoteView()
396{ 398{
397 QPixmap pm; 399 QPixmap pm;
398 Remote_View->clear(); 400 Remote_View->clear();
399 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 401 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
400 currentRemoteDir.setMatchAllDirs(TRUE); 402 currentRemoteDir.setMatchAllDirs(TRUE);
401 currentRemoteDir.setNameFilter(filterStr); 403 currentRemoteDir.setNameFilter(filterStr);
402 QString fileL, fileS, fileDate; 404 QString fileL, fileS, fileDate;
403 405
404 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 406 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
405 setCaption("AdvancedFm :: "+fs); 407 setCaption("AdvancedFm :: "+fs+" :: "+checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
406 bool isDir=FALSE; 408 bool isDir=FALSE;
407 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 409 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
408 QFileInfoListIterator it(*list); 410 QFileInfoListIterator it(*list);
409 QFileInfo *fi; 411 QFileInfo *fi;
410 while ( (fi=it.current()) ) { 412 while ( (fi=it.current()) ) {
411 if (fi->isSymLink() ){ 413 if (fi->isSymLink() ){
412 QString symLink=fi->readLink(); 414 QString symLink=fi->readLink();
413 // qDebug("Symlink detected "+symLink); 415 // qDebug("Symlink detected "+symLink);
414 QFileInfo sym( symLink); 416 QFileInfo sym( symLink);
415 fileS.sprintf( "%10li", sym.size() ); 417 fileS.sprintf( "%10li", sym.size() );
416 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 418 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
417 fileDate = sym.lastModified().toString(); 419 fileDate = sym.lastModified().toString();
418 } else { 420 } else {
419 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 421 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
420 fileS.sprintf( "%10li", fi->size() ); 422 fileS.sprintf( "%10li", fi->size() );
421 fileL.sprintf( "%s",fi->fileName().data() ); 423 fileL.sprintf( "%s",fi->fileName().data() );
422 fileDate= fi->lastModified().toString(); 424 fileDate= fi->lastModified().toString();
423 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 425 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
424 fileL+="/"; 426 fileL+="/";
425 isDir=TRUE; 427 isDir=TRUE;
426 // qDebug( fileL); 428 // qDebug( fileL);
427 } 429 }
428 } 430 }
429 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); 431 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
430 if(fileL !="./" && fi->exists()) { 432 if(fileL !="./" && fi->exists()) {
431 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 433 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
432 QPixmap pm; 434 QPixmap pm;
433 435
434 if(isDir || fileL.find("/",0,TRUE) != -1) { 436 if(isDir || fileL.find("/",0,TRUE) != -1) {
435 if( !QDir( fi->filePath() ).isReadable()) 437 if( !QDir( fi->filePath() ).isReadable())
436 pm = Resource::loadPixmap( "lockedfolder" ); 438 pm = Resource::loadPixmap( "lockedfolder" );
437 else 439 else
438 pm= Resource::loadPixmap( "folder" ); 440 pm= Resource::loadPixmap( "folder" );
439 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 441 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
440 pm = Resource::loadPixmap( "exec"); 442 pm = Resource::loadPixmap( "exec");
441 } else if( (fileInfo.permission( QFileInfo::ExeUser) 443 } else if( (fileInfo.permission( QFileInfo::ExeUser)
442 | fileInfo.permission( QFileInfo::ExeGroup) 444 | fileInfo.permission( QFileInfo::ExeGroup)
443 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 445 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
444 pm = Resource::loadPixmap( "exec"); 446 pm = Resource::loadPixmap( "exec");
445 } else if( !fi->isReadable() ) { 447 } else if( !fi->isReadable() ) {
446 pm = Resource::loadPixmap( "locked" ); 448 pm = Resource::loadPixmap( "locked" );
447 } else { 449 } else {
448 MimeType mt(fi->filePath()); 450 MimeType mt(fi->filePath());
449 pm=mt.pixmap(); //sets the correct pixmap for mimetype 451 pm=mt.pixmap(); //sets the correct pixmap for mimetype
450 if(pm.isNull()) 452 if(pm.isNull())
451 pm = Resource::loadPixmap( "UnknownDocument-14" ); 453 pm = Resource::loadPixmap( "UnknownDocument-14" );
452 } 454 }
453 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 455 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
@@ -1421,151 +1423,154 @@ bool AdvancedFm::copyFile( const QString & dest, const QString & src )
1421 if( stat( (const char *) src, &status ) == 0 ){ 1423 if( stat( (const char *) src, &status ) == 0 ){
1422 chmod( (const char *) dest, status.st_mode ); 1424 chmod( (const char *) dest, status.st_mode );
1423 } 1425 }
1424 1426
1425 return success; 1427 return success;
1426} 1428}
1427 1429
1428void AdvancedFm::runCommand() { 1430void AdvancedFm::runCommand() {
1429 QString curFile; 1431 QString curFile;
1430 if (TabWidget->currentPageIndex() == 0) { 1432 if (TabWidget->currentPageIndex() == 0) {
1431 if( Local_View->currentItem()) 1433 if( Local_View->currentItem())
1432 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 1434 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
1433 } else { 1435 } else {
1434 if(Remote_View->currentItem()) 1436 if(Remote_View->currentItem())
1435 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); 1437 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
1436 } 1438 }
1437 1439
1438 InputDialog *fileDlg; 1440 InputDialog *fileDlg;
1439 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 1441 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1440 fileDlg->setInputText(curFile); 1442 fileDlg->setInputText(curFile);
1441 fileDlg->exec(); 1443 fileDlg->exec();
1442 QString command; 1444 QString command;
1443 if( fileDlg->result() == 1 ) { 1445 if( fileDlg->result() == 1 ) {
1444 command = fileDlg->LineEdit1->text(); 1446 command = fileDlg->LineEdit1->text();
1445 1447
1446 Output *outDlg; 1448 Output *outDlg;
1447 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1449 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1448 outDlg->showMaximized(); 1450 outDlg->showMaximized();
1449 outDlg->show(); 1451 outDlg->show();
1450 qApp->processEvents(); 1452 qApp->processEvents();
1451 FILE *fp; 1453 FILE *fp;
1452 char line[130]; 1454 char line[130];
1453 sleep(1); 1455 sleep(1);
1454 command +=" 2>&1"; 1456 command +=" 2>&1";
1455 fp = popen( (const char *) command, "r"); 1457 fp = popen( (const char *) command, "r");
1456 if ( !fp ) { 1458 if ( !fp ) {
1457 qDebug("Could not execute '" + command + "'! err=%d", fp); 1459 qDebug("Could not execute '" + command + "'! err=%d", fp);
1458 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 1460 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
1459 pclose(fp); 1461 pclose(fp);
1460 return; 1462 return;
1461 } else { 1463 } else {
1462 while ( fgets( line, sizeof line, fp)) { 1464 while ( fgets( line, sizeof line, fp)) {
1463 QString lineStr = line; 1465 QString lineStr = line;
1464 lineStr=lineStr.left(lineStr.length()-1); 1466 lineStr=lineStr.left(lineStr.length()-1);
1465 outDlg->OutputEdit->append(lineStr); 1467 outDlg->OutputEdit->append(lineStr);
1466 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1468 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1467 } 1469 }
1468 } 1470 }
1471 pclose(fp);
1472
1469 } 1473 }
1470} 1474}
1471 1475
1472void AdvancedFm::runCommandStd() { 1476void AdvancedFm::runCommandStd() {
1473 QString curFile; 1477 QString curFile;
1474 if (TabWidget->currentPageIndex() == 0) { 1478 if (TabWidget->currentPageIndex() == 0) {
1475 if( Local_View->currentItem()) 1479 if( Local_View->currentItem())
1476 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 1480 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
1477 } else { 1481 } else {
1478 if(Remote_View->currentItem()) 1482 if(Remote_View->currentItem())
1479 curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0); 1483 curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->currentItem()->text(0);
1480 } 1484 }
1481 1485
1482 InputDialog *fileDlg; 1486 InputDialog *fileDlg;
1483 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 1487 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1484 fileDlg->setInputText(curFile); 1488 fileDlg->setInputText(curFile);
1485 fileDlg->exec(); 1489 fileDlg->exec();
1486 QString command; 1490 QString command;
1487 if( fileDlg->result() == 1 ) { 1491 if( fileDlg->result() == 1 ) {
1488 qApp->processEvents(); 1492 qApp->processEvents();
1489 command = fileDlg->LineEdit1->text() + " &"; 1493 command = fileDlg->LineEdit1->text() + " &";
1490 system(command.latin1()); 1494 system(command.latin1());
1491 } 1495 }
1492} 1496}
1493 1497
1494void AdvancedFm::fileStatus() { 1498void AdvancedFm::fileStatus() {
1495 QString curFile; 1499 QString curFile;
1496 if (TabWidget->currentPageIndex() == 0) { 1500 if (TabWidget->currentPageIndex() == 0) {
1497 curFile = Local_View->currentItem()->text(0); 1501 curFile = Local_View->currentItem()->text(0);
1498 } else { 1502 } else {
1499 curFile = Remote_View->currentItem()->text(0); 1503 curFile = Remote_View->currentItem()->text(0);
1500 } 1504 }
1501 QString command = " stat -l "+ curFile +" 2>&1"; 1505 QString command = " stat -l "+ curFile +" 2>&1";
1502 Output *outDlg; 1506 Output *outDlg;
1503 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1507 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1504 outDlg->showMaximized(); 1508 outDlg->showMaximized();
1505 outDlg->show(); 1509 outDlg->show();
1506 qApp->processEvents(); 1510 qApp->processEvents();
1507 FILE *fp; 1511 FILE *fp;
1508 char line[130]; 1512 char line[130];
1509 sleep(1); 1513 sleep(1);
1510 fp = popen( (const char *) command, "r"); 1514 fp = popen( (const char *) command, "r");
1511 if ( !fp ) { 1515 if ( !fp ) {
1512 qDebug("Could not execute '" + command + "'! err=%d", fp); 1516 qDebug("Could not execute '" + command + "'! err=%d", fp);
1513 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 1517 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
1514 pclose(fp); 1518 pclose(fp);
1515 return; 1519 return;
1516 } else { 1520 } else {
1517 while ( fgets( line, sizeof line, fp)) { 1521 while ( fgets( line, sizeof line, fp)) {
1518 outDlg->OutputEdit->append(line); 1522 outDlg->OutputEdit->append(line);
1519 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1523 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1520 1524
1521 } 1525 }
1522 1526
1523 } 1527 }
1528 pclose(fp);
1524} 1529}
1525 1530
1526void AdvancedFm::mkDir() { 1531void AdvancedFm::mkDir() {
1527 if (TabWidget->currentPageIndex() == 0) 1532 if (TabWidget->currentPageIndex() == 0)
1528 localMakDir(); 1533 localMakDir();
1529 else 1534 else
1530 remoteMakDir(); 1535 remoteMakDir();
1531 1536
1532} 1537}
1533 1538
1534void AdvancedFm::rn() { 1539void AdvancedFm::rn() {
1535 if (TabWidget->currentPageIndex() == 0) 1540 if (TabWidget->currentPageIndex() == 0)
1536 localRename(); 1541 localRename();
1537 else 1542 else
1538 remoteRename(); 1543 remoteRename();
1539 1544
1540} 1545}
1541 1546
1542void AdvancedFm::del() { 1547void AdvancedFm::del() {
1543 if (TabWidget->currentPageIndex() == 0) 1548 if (TabWidget->currentPageIndex() == 0)
1544 localDelete(); 1549 localDelete();
1545 else 1550 else
1546 remoteDelete(); 1551 remoteDelete();
1547} 1552}
1548 1553
1549void AdvancedFm::doAbout() { 1554void AdvancedFm::doAbout() {
1550 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 1555 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
1551 "is copyright 2002 by\n" 1556 "is copyright 2002 by\n"
1552 "L.J.Potter<llornkcor@handhelds.org>\n" 1557 "L.J.Potter<llornkcor@handhelds.org>\n"
1553 "and is licensed by the GPL")); 1558 "and is licensed by the GPL"));
1554} 1559}
1555 1560
1556void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 1561void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
1557{ 1562{
1558 if( TabWidget->hasFocus()) 1563 if( TabWidget->hasFocus())
1559 switch ( e->key() ) { 1564 switch ( e->key() ) {
1560 case Key_Delete: 1565 case Key_Delete:
1561 del(); 1566 del();
1562 break; 1567 break;
1563 case Key_H: 1568 case Key_H:
1564 showHidden(); 1569 showHidden();
1565 break; 1570 break;
1566 case Key_E: 1571 case Key_E:
1567 runThis(); 1572 runThis();
1568 break; 1573 break;
1569 case Key_C: 1574 case Key_C:
1570 copy(); 1575 copy();
1571 break; 1576 break;
@@ -1791,55 +1796,74 @@ void AdvancedFm::showFileMenu() {
1791 1796
1792 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 1797 m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
1793 m->insertSeparator(); 1798 m->insertSeparator();
1794 1799
1795 if(isLocalView) 1800 if(isLocalView)
1796 m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 1801 m->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
1797 else 1802 else
1798 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 1803 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
1799 1804
1800 m->insertItem( tr( "Copy" ), this, SLOT( copy() )); 1805 m->insertItem( tr( "Copy" ), this, SLOT( copy() ));
1801 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 1806 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
1802 m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 1807 m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
1803 m->insertItem( tr( "Move" ), this, SLOT( move() )); 1808 m->insertItem( tr( "Move" ), this, SLOT( move() ));
1804 m->insertSeparator(); 1809 m->insertSeparator();
1805 1810
1806 if(isLocalView) 1811 if(isLocalView)
1807 m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); 1812 m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() ));
1808 else 1813 else
1809 m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); 1814 m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() ));
1810 1815
1811 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 1816 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
1812 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 1817 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
1813 m->insertSeparator(); 1818 m->insertSeparator();
1814 1819
1815 if(isLocalView) 1820 if(isLocalView)
1816 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 1821 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
1817 else 1822 else
1818 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 1823 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
1819 1824
1820 m->insertSeparator(); 1825 m->insertSeparator();
1821 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 1826 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
1822 1827
1823 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings 1828 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings
1824 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 1829 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1825 m->setCheckable(TRUE); 1830 m->setCheckable(TRUE);
1826 if (!b) 1831 if (!b)
1827 m->setItemChecked(m->idAt(0),TRUE); 1832 m->setItemChecked(m->idAt(0),TRUE);
1828 else 1833 else
1829 m->setItemChecked(m->idAt(0),FALSE); 1834 m->setItemChecked(m->idAt(0),FALSE);
1830 if(Ir::supported()) 1835 if(Ir::supported())
1831 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 1836 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
1832 m->setFocus(); 1837 m->setFocus();
1833 m->exec( QCursor::pos() ); 1838 m->exec( QCursor::pos() );
1834 sleep(1); 1839 sleep(1);
1835 if(m) delete m; 1840 if(m) delete m;
1836} 1841}
1837 1842
1838 1843
1839void AdvancedFm::cancelMenuTimer() 1844void AdvancedFm::cancelMenuTimer() {
1840{
1841 1845
1842 qDebug("selectionChanged: cancel menu timer"); 1846 qDebug("selectionChanged: cancel menu timer");
1843 if( menuTimer.isActive() ) 1847 if( menuTimer.isActive() )
1844 menuTimer.stop(); 1848 menuTimer.stop();
1845} 1849}
1850
1851QString AdvancedFm::checkDiskSpace(const QString &path) {
1852
1853 struct statfs fss;
1854 if ( !statfs( path.latin1(), &fss ) ) {
1855 int blkSize = fss.f_bsize;
1856// int totalBlks = fs.f_blocks;
1857 int availBlks = fss.f_bavail;
1858
1859 long mult = blkSize / 1024;
1860 long div = 1024 / blkSize;
1861 if ( !mult ) mult = 1;
1862 if ( !div ) div = 1;
1863
1864
1865 return QString::number(availBlks * mult / div);
1866 }
1867 return "";
1868}
1869
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
@@ -68,76 +68,76 @@ public:
68 int currentServerConfig; 68 int currentServerConfig;
69protected slots: 69protected slots:
70 void doLocalCd(); 70 void doLocalCd();
71 void doRemoteCd(); 71 void doRemoteCd();
72// void copy(); 72// void copy();
73 void mkDir(); 73 void mkDir();
74 void del(); 74 void del();
75 void rn(); 75 void rn();
76 void populateLocalView(); 76 void populateLocalView();
77 void populateRemoteView(); 77 void populateRemoteView();
78 void showHidden(); 78 void showHidden();
79 void showRemoteHidden(); 79 void showRemoteHidden();
80 void writeConfig(); 80 void writeConfig();
81 void readConfig(); 81 void readConfig();
82 void localListClicked(QListViewItem *); 82 void localListClicked(QListViewItem *);
83 void remoteListClicked(QListViewItem *); 83 void remoteListClicked(QListViewItem *);
84 void localListPressed( int, QListViewItem *, const QPoint&, int); 84 void localListPressed( int, QListViewItem *, const QPoint&, int);
85 void remoteListPressed( int, QListViewItem *, const QPoint&, int); 85 void remoteListPressed( int, QListViewItem *, const QPoint&, int);
86 void localMakDir(); 86 void localMakDir();
87 void localDelete(); 87 void localDelete();
88 void remoteMakDir(); 88 void remoteMakDir();
89 void remoteDelete(); 89 void remoteDelete();
90/* bool remoteDirList(const QString &); */ 90/* bool remoteDirList(const QString &); */
91/* bool remoteChDir(const QString &); */ 91/* bool remoteChDir(const QString &); */
92 void tabChanged(QWidget*); 92 void tabChanged(QWidget*);
93 void cleanUp(); 93 void cleanUp();
94 void remoteRename(); 94 void remoteRename();
95 void localRename(); 95 void localRename();
96 void runThis(); 96 void runThis();
97 void runText(); 97 void runText();
98 void filePerms(); 98 void filePerms();
99 void doProperties(); 99 void doProperties();
100 void runCommand(); 100 void runCommand();
101 void runCommandStd(); 101 void runCommandStd();
102 QStringList getPath(); 102 QStringList getPath();
103 void mkSym(); 103 void mkSym();
104 void switchToLocalTab(); 104 void switchToLocalTab();
105 void switchToRemoteTab(); 105 void switchToRemoteTab();
106 106
107protected: 107protected:
108 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; 108 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
109 QStringList remoteDirPathStringList, localDirPathStringList; 109 QStringList remoteDirPathStringList, localDirPathStringList;
110 110
111 void keyReleaseEvent( QKeyEvent *); 111 void keyReleaseEvent( QKeyEvent *);
112 QString getFileSystemType(const QString &); 112 QString getFileSystemType(const QString &);
113 QString getDiskSpace(const QString &); 113 QString getDiskSpace(const QString &);
114 114
115 void parsetab(const QString &fileName); 115 void parsetab(const QString &fileName);
116 116QString checkDiskSpace(const QString &);
117protected slots: 117protected slots:
118 void showFileMenu(); 118 void showFileMenu();
119 void cancelMenuTimer(); 119 void cancelMenuTimer();
120 void homeButtonPushed(); 120 void homeButtonPushed();
121 void docButtonPushed(); 121 void docButtonPushed();
122 void SDButtonPushed(); 122 void SDButtonPushed();
123 void CFButtonPushed(); 123 void CFButtonPushed();
124 void QPEButtonPushed(); 124 void QPEButtonPushed();
125 void upDir(); 125 void upDir();
126 void currentPathComboChanged(); 126 void currentPathComboChanged();
127 void copy(); 127 void copy();
128 void copyAs(); 128 void copyAs();
129 void copySameDir(); 129 void copySameDir();
130 void currentPathComboActivated(const QString &); 130 void currentPathComboActivated(const QString &);
131 void fillCombo(const QString &); 131 void fillCombo(const QString &);
132 bool copyFile( const QString & , const QString & ); 132 bool copyFile( const QString & , const QString & );
133 void move(); 133 void move();
134 void fileStatus(); 134 void fileStatus();
135 void doAbout(); 135 void doAbout();
136 void doBeam(); 136 void doBeam();
137 void fileBeamFinished( Ir *); 137 void fileBeamFinished( Ir *);
138 138
139private: 139private:
140 QTimer menuTimer; 140 QTimer menuTimer;
141}; 141};
142 142
143#endif // ADVANCEDFM_H 143#endif // ADVANCEDFM_H