summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-30 12:31:39 (UTC)
committer llornkcor <llornkcor>2002-04-30 12:31:39 (UTC)
commitaae6ce64221457dbed804d7ebce095a621ea892a (patch) (unidiff)
tree20baaeeab39b2862628dc99d5ebb365cb2e26077
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 (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
@@ -33,64 +33,67 @@
33#include <qmultilineedit.h> 33#include <qmultilineedit.h>
34 34
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37#include <qtoolbutton.h> 37#include <qtoolbutton.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qfile.h> 40#include <qfile.h>
41#include <qstring.h> 41#include <qstring.h>
42#include <qcombobox.h> 42#include <qcombobox.h>
43#include <qpopupmenu.h> 43#include <qpopupmenu.h>
44#include <qlistview.h> 44#include <qlistview.h>
45#include <qmainwindow.h> 45#include <qmainwindow.h>
46#include <qlabel.h> 46#include <qlabel.h>
47#include <qprogressbar.h> 47#include <qprogressbar.h>
48#include <qspinbox.h> 48#include <qspinbox.h>
49#include <qtabwidget.h> 49#include <qtabwidget.h>
50#include <qwidget.h> 50#include <qwidget.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qimage.h> 52#include <qimage.h>
53#include <qpixmap.h> 53#include <qpixmap.h>
54#include <qmessagebox.h> 54#include <qmessagebox.h>
55#include <qlineedit.h> 55#include <qlineedit.h>
56#include <qregexp.h> 56#include <qregexp.h>
57 57
58#include <unistd.h> 58#include <unistd.h>
59#include <stdlib.h> 59#include <stdlib.h>
60#include <sys/stat.h> 60#include <sys/stat.h>
61#include <dirent.h> 61#include <dirent.h>
62#include <stdio.h> 62#include <stdio.h>
63#include <time.h> 63#include <time.h>
64#include <fcntl.h> 64#include <fcntl.h>
65#include <mntent.h>
66#include <string.h>
67#include <errno.h>
65 68
66AdvancedFm::AdvancedFm( ) 69AdvancedFm::AdvancedFm( )
67 : QMainWindow( ) 70 : QMainWindow( )
68{ 71{
69 setCaption( tr( "AdvancedFm" ) ); 72 setCaption( tr( "AdvancedFm" ) );
70 73
71 QGridLayout *layout = new QGridLayout( this ); 74 QGridLayout *layout = new QGridLayout( this );
72 layout->setSpacing( 2); 75 layout->setSpacing( 2);
73 layout->setMargin( 2); 76 layout->setMargin( 2);
74 77
75 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 78 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
76 79
77 QPEMenuBar *menuBar = new QPEMenuBar(this); 80 QPEMenuBar *menuBar = new QPEMenuBar(this);
78// fileMenu = new QPopupMenu( this ); 81// fileMenu = new QPopupMenu( this );
79 fileMenu = new QPopupMenu( this ); 82 fileMenu = new QPopupMenu( this );
80 viewMenu = new QPopupMenu( this ); 83 viewMenu = new QPopupMenu( this );
81 84
82 layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); 85 layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 );
83 86
84 menuBar->insertItem( tr( "File" ), fileMenu); 87 menuBar->insertItem( tr( "File" ), fileMenu);
85 menuBar->insertItem( tr( "View" ), viewMenu); 88 menuBar->insertItem( tr( "View" ), viewMenu);
86 89
87 qpeDirButton= new QPushButton(Resource::loadIconSet("go"),"",this,"QPEButton"); 90 qpeDirButton= new QPushButton(Resource::loadIconSet("go"),"",this,"QPEButton");
88 qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); 91 qpeDirButton ->setFixedSize( QSize( 20, 20 ) );
89 connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); 92 connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) );
90 qpeDirButton->setFlat(TRUE); 93 qpeDirButton->setFlat(TRUE);
91 layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); 94 layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2);
92 95
93 cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton"); 96 cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton");
94 cfButton ->setFixedSize( QSize( 20, 20 ) ); 97 cfButton ->setFixedSize( QSize( 20, 20 ) );
95 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); 98 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) );
96 cfButton->setFlat(TRUE); 99 cfButton->setFlat(TRUE);
@@ -242,264 +245,260 @@ AdvancedFm::~AdvancedFm()
242{ 245{
243} 246}
244 247
245void AdvancedFm::cleanUp() 248void AdvancedFm::cleanUp()
246{ 249{
247 QString sfile=QDir::homeDirPath(); 250 QString sfile=QDir::homeDirPath();
248 if(sfile.right(1) != "/") 251 if(sfile.right(1) != "/")
249 sfile+="/._temp"; 252 sfile+="/._temp";
250 else 253 else
251 sfile+="._temp"; 254 sfile+="._temp";
252 QFile file( sfile); 255 QFile file( sfile);
253 if(file.exists()) 256 if(file.exists())
254 file.remove(); 257 file.remove();
255} 258}
256 259
257void AdvancedFm::tabChanged(QWidget *w) 260void AdvancedFm::tabChanged(QWidget *w)
258{ 261{
259 if (TabWidget->currentPageIndex() == 0) { 262 if (TabWidget->currentPageIndex() == 0) {
260 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 263 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
261 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 264 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
262 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 265 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
263 } 266 }
264 if (TabWidget->currentPageIndex() == 1) { 267 if (TabWidget->currentPageIndex() == 1) {
265 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 268 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
266 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 269 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
267 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 270 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
268 } 271 }
269} 272}
270 273
271 274
272void AdvancedFm::populateLocalView() 275void AdvancedFm::populateLocalView()
273{ 276{
274// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
275// QListViewItemIterator it( Local_View );
276// for ( ; it.current(); ++it ) {
277// if ( it.current()->isSelected() ) {
278// QString strItem = it.current()->text(0);
279// QString localFile = currentDir.canonicalPath()+"/"+strItem;
280// QFileInfo fi(localFile);
281// }
282// }
283 QPixmap pm; 277 QPixmap pm;
284 Local_View->clear(); 278 Local_View->clear();
285 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 279 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
286 currentDir.setMatchAllDirs(TRUE); 280 currentDir.setMatchAllDirs(TRUE);
287 currentDir.setNameFilter(filterStr); 281 currentDir.setNameFilter(filterStr);
288 QString fileL, fileS, fileDate; 282 QString fileL, fileS, fileDate;
289// qDebug(currentDir.canonicalPath()); 283// qDebug(currentDir.canonicalPath());
290 284// struct stat buf;
285// mode_t mode;
286 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
287 setCaption("AdvancedFm :: "+fs);
291 bool isDir=FALSE; 288 bool isDir=FALSE;
292 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 289 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
293 QFileInfoListIterator it(*list); 290 QFileInfoListIterator it(*list);
294 QFileInfo *fi; 291 QFileInfo *fi;
295 while ( (fi=it.current()) ) { 292 while ( (fi=it.current()) ) {
296 if (fi->isSymLink() ) { 293 if (fi->isSymLink() ) {
297 QString symLink=fi->readLink(); 294 QString symLink=fi->readLink();
298// qDebug("Symlink detected "+symLink); 295// qDebug("Symlink detected "+symLink);
299 QFileInfo sym( symLink); 296 QFileInfo sym( symLink);
300 fileS.sprintf( "%10li", sym.size() ); 297 fileS.sprintf( "%10li", sym.size() );
301 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 298 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
302 fileDate = sym.lastModified().toString(); 299 fileDate = sym.lastModified().toString();
303 } else { 300 } else {
304 fileS.sprintf( "%10li", fi->size() ); 301 fileS.sprintf( "%10li", fi->size() );
305 fileL.sprintf( "%s",fi->fileName().data() ); 302 fileL.sprintf( "%s",fi->fileName().data() );
306 fileDate= fi->lastModified().toString(); 303 fileDate= fi->lastModified().toString();
307 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 304 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
308 fileL+="/"; 305 fileL+="/";
309 isDir=TRUE; 306 isDir=TRUE;
310// qDebug( fileL); 307// qDebug( fileL);
311 } 308 }
312 } 309 }
310 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
313 if(fileL !="./" && fi->exists()) { 311 if(fileL !="./" && fi->exists()) {
314 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 312 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
313
315 if(isDir || fileL.find("/",0,TRUE) != -1) { 314 if(isDir || fileL.find("/",0,TRUE) != -1) {
316 if( !QDir( fi->filePath() ).isReadable()) 315
316 if( !QDir( fi->filePath() ).isReadable()) //is directory
317 pm = Resource::loadPixmap( "lockedfolder" ); 317 pm = Resource::loadPixmap( "lockedfolder" );
318 else 318 else
319 pm= Resource::loadPixmap( "folder" ); 319 pm= Resource::loadPixmap( "folder" );
320 item->setPixmap( 0,pm ); 320// item->setPixmap( 0,pm );
321 } else { 321 } else if( fileInfo.isExecutable() || fs == "vfat" && fi->filePath().contains("/bin") ) { //is exec
322// if(fi->isExecutable()) { 322 pm = Resource::loadPixmap( "exec");
323// pm = Resource::loadPixmap( "exec"); 323// item->setPixmap( 0,pm);
324// item->setPixmap( 0,pm); 324 } else if( !fi->isReadable() ) {
325// } 325 pm = Resource::loadPixmap( "locked" );
326 if( !fi->isReadable() ) { 326// item->setPixmap( 0,pm);
327 pm = Resource::loadPixmap( "locked" ); 327 } else { //everything else goes by mimetype
328 item->setPixmap( 0,pm); 328 MimeType mt(fi->filePath());
329 329 pm=mt.pixmap(); //sets the correct pixmap for mimetype
330 } 330 if(pm.isNull())
331 else { 331 pm = Resource::loadPixmap( "UnknownDocument-14" );
332 MimeType mt(fi->filePath()); 332// item->setPixmap( 0,pm);
333 pm=mt.pixmap(); //sets the correct pixmap for mimetype
334 if(pm.isNull())
335 pm = Resource::loadPixmap( "UnknownDocument-14" );
336 item->setPixmap( 0,pm);
337 }
338 } 333 }
339 if( fileL.find("->",0,TRUE) != -1) { 334 item->setPixmap( 0,pm);
335 if( fi->isSymLink() &&fileL.find("->",0,TRUE) != -1) {
340 // overlay link image 336 // overlay link image
341 pm= Resource::loadPixmap( "folder" ); 337 pm= Resource::loadPixmap( "folder" );
342 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 338 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
343 QPainter painter( &pm ); 339 QPainter painter( &pm );
344 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 340 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
345 pm.setMask( pm.createHeuristicMask( FALSE ) ); 341 pm.setMask( pm.createHeuristicMask( FALSE ) );
346 item->setPixmap( 0, pm); 342 item->setPixmap( 0, pm);
347 } 343 }
348 } isDir=FALSE; 344 }
345 isDir=FALSE;
349 ++it; 346 ++it;
350 } 347 }
351 348
352 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 349 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
353 struct stat buf; 350 struct stat buf;
354 struct stat st; 351// struct stat st;
355 dev_t devT; 352 dev_t devT;
356 mode_t mode; 353// mode_t mode;
357 DIR *dir; 354 DIR *dir;
358 int fd = 0; 355// int fd = 0;
359 struct dirent *mydirent; 356 struct dirent *mydirent;
360 int i = 1; 357// int i = 1;
361 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 358 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
362 while ((mydirent = readdir(dir)) != NULL) { 359 while ((mydirent = readdir(dir)) != NULL) {
363 lstat( mydirent->d_name, &buf); 360 lstat( mydirent->d_name, &buf);
364 qDebug(mydirent->d_name); 361 qDebug(mydirent->d_name);
365// mode = buf.st_mode; 362// mode = buf.st_mode;
366 fileL.sprintf("%s", mydirent->d_name); 363 fileL.sprintf("%s", mydirent->d_name);
367// fileS.sprintf("%d, %d", ); //this isn't correct 364// fileS.sprintf("%d, %d", ); //this isn't correct
368 devT = buf.st_dev; 365 devT = buf.st_dev;
369 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 366 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
370// fileS.sprintf("%d,%d", devT, devT); 367// fileS.sprintf("%d,%d", devT, devT);
371 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 368 fileDate.sprintf("%s", ctime( &buf.st_mtime));
372 if( fileL.find(".") == -1 ){ 369 if( fileL.find(".") == -1 ){
373 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 370 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
374 pm = Resource::loadPixmap( "UnknownDocument-14" ); 371 pm = Resource::loadPixmap( "UnknownDocument-14" );
375 item->setPixmap( 0,pm); 372 item->setPixmap( 0,pm);
376 } 373 }
377 } 374 }
378 375
379 closedir(dir); 376 closedir(dir);
380 } 377 }
381 378
382 Local_View->setSorting( 3,FALSE); 379 Local_View->setSorting( 3,FALSE);
383 fillCombo( (const QString &) currentDir.canonicalPath()); 380 fillCombo( (const QString &) currentDir.canonicalPath());
384} 381}
385 382
386 383
387void AdvancedFm::populateRemoteView() 384void AdvancedFm::populateRemoteView()
388{ 385{
389// QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 386// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
390// QListViewItemIterator it( Remote_View ); 387// QListViewItemIterator it( Remote_View );
391// for ( ; it.current(); ++it ) { 388// for ( ; it.current(); ++it ) {
392// if ( it.current()->isSelected() ) { 389// if ( it.current()->isSelected() ) {
393// QString strItem = it.current()->text(0); 390// QString strItem = it.current()->text(0);
394// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; 391// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem;
395// QFileInfo fi(localFile); 392// QFileInfo fi(localFile);
396// } 393// }
397// } 394// }
398 QPixmap pm; 395 QPixmap pm;
399 Remote_View->clear(); 396 Remote_View->clear();
400 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 397 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
401 currentRemoteDir.setMatchAllDirs(TRUE); 398 currentRemoteDir.setMatchAllDirs(TRUE);
402 currentRemoteDir.setNameFilter(filterStr); 399 currentRemoteDir.setNameFilter(filterStr);
403 QString fileL, fileS, fileDate; 400 QString fileL, fileS, fileDate;
401
402 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
403 setCaption("AdvancedFm :: "+fs);
404 bool isDir=FALSE; 404 bool isDir=FALSE;
405 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 405 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
406 QFileInfoListIterator it(*list); 406 QFileInfoListIterator it(*list);
407 QFileInfo *fi; 407 QFileInfo *fi;
408 while ( (fi=it.current()) ) { 408 while ( (fi=it.current()) ) {
409 if (fi->isSymLink() ){ 409 if (fi->isSymLink() ){
410 QString symLink=fi->readLink(); 410 QString symLink=fi->readLink();
411// qDebug("Symlink detected "+symLink); 411// qDebug("Symlink detected "+symLink);
412 QFileInfo sym( symLink); 412 QFileInfo sym( symLink);
413 fileS.sprintf( "%10li", sym.size() ); 413 fileS.sprintf( "%10li", sym.size() );
414 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 414 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
415 fileDate = sym.lastModified().toString(); 415 fileDate = sym.lastModified().toString();
416 } else { 416 } else {
417// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 417// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
418 fileS.sprintf( "%10li", fi->size() ); 418 fileS.sprintf( "%10li", fi->size() );
419 fileL.sprintf( "%s",fi->fileName().data() ); 419 fileL.sprintf( "%s",fi->fileName().data() );
420 fileDate= fi->lastModified().toString(); 420 fileDate= fi->lastModified().toString();
421 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 421 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
422 fileL+="/"; 422 fileL+="/";
423 isDir=TRUE; 423 isDir=TRUE;
424// qDebug( fileL); 424// qDebug( fileL);
425 } 425 }
426 } 426 }
427 if(fileL !="./" && fi->exists()) { 427 if(fileL !="./" && fi->exists()) {
428 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 428 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
429 QPixmap pm; 429 QPixmap pm;
430 430
431 if(isDir || fileL.find("/",0,TRUE) != -1) { 431 if(isDir || fileL.find("/",0,TRUE) != -1) {
432 if( !QDir( fi->filePath() ).isReadable()) 432 if( !QDir( fi->filePath() ).isReadable())
433 pm = Resource::loadPixmap( "lockedfolder" ); 433 pm = Resource::loadPixmap( "lockedfolder" );
434 else 434 else
435 pm= Resource::loadPixmap( "folder" ); 435 pm= Resource::loadPixmap( "folder" );
436 item->setPixmap( 0,pm ); 436// item->setPixmap( 0,pm );
437 } else if( fi->isExecutable() || fs == "vfat" && fi->filePath().contains("/bin") ) {
438 pm = Resource::loadPixmap( "exec");
439// item->setPixmap( 0,pm);
440 } else if( !fi->isReadable() ) {
441 pm = Resource::loadPixmap( "locked" );
442// item->setPixmap( 0,pm);
437 } else { 443 } else {
438// if(fi->isExecutable()) { 444 MimeType mt(fi->filePath());
439// pm = Resource::loadPixmap( "exec"); 445 pm=mt.pixmap(); //sets the correct pixmap for mimetype
446 if(pm.isNull())
447 pm = Resource::loadPixmap( "UnknownDocument-14" );
440// item->setPixmap( 0,pm); 448// item->setPixmap( 0,pm);
441// }
442 if( !fi->isReadable() ) {
443 pm = Resource::loadPixmap( "locked" );
444 item->setPixmap( 0,pm);
445 } else {
446 MimeType mt(fi->filePath());
447 pm=mt.pixmap(); //sets the correct pixmap for mimetype
448 if(pm.isNull())
449 pm = Resource::loadPixmap( "UnknownDocument-14" );
450 item->setPixmap( 0,pm);
451 }
452 }
453 if( fileL.find("->",0,TRUE) != -1) {
454 // overlay link image
455 pm= Resource::loadPixmap( "folder" );
456 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
457 QPainter painter( &pm );
458 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
459 pm.setMask( pm.createHeuristicMask( FALSE ) );
460 item->setPixmap( 0, pm);
461 } 449 }
462 } isDir=FALSE; 450 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
451 // overlay link image
452 pm= Resource::loadPixmap( "folder" );
453 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
454 QPainter painter( &pm );
455 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
456 pm.setMask( pm.createHeuristicMask( FALSE ) );
457// item->setPixmap( 0, pm);
458 }
459 item->setPixmap( 0, pm);
460 }
461 isDir=FALSE;
463 ++it; 462 ++it;
464 } 463 }
465 464
466 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 465 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
467 struct stat buf; 466 struct stat buf;
468 struct stat st; 467// struct stat st;
469 mode_t mode; 468// mode_t mode;
470 DIR *dir; 469 DIR *dir;
471 int fd = 0; 470// int fd = 0;
472 struct dirent *mydirent; 471 struct dirent *mydirent;
473 int i = 1; 472// int i = 1;
474 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 473 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
475 while ((mydirent = readdir(dir)) != NULL) { 474 while ((mydirent = readdir(dir)) != NULL) {
476 lstat( mydirent->d_name, &buf); 475 lstat( mydirent->d_name, &buf);
477 qDebug(mydirent->d_name); 476 qDebug(mydirent->d_name);
478// mode = buf.st_mode; 477// mode = buf.st_mode;
479 fileL.sprintf("%s", mydirent->d_name); 478 fileL.sprintf("%s", mydirent->d_name);
480// fileS.sprintf("%d, %d", ); //this isn't correct 479// fileS.sprintf("%d, %d", ); //this isn't correct
481 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 480 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
482 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 481 fileDate.sprintf("%s", ctime( &buf.st_mtime));
483 if( fileL.find(".") == -1 ){ 482 if( fileL.find(".") == -1 ){
484 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 483 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
485 pm = Resource::loadPixmap( "UnknownDocument-14" ); 484 pm = Resource::loadPixmap( "UnknownDocument-14" );
486 item->setPixmap( 0,pm); 485 item->setPixmap( 0,pm);
487 } 486 }
488 } 487 }
489 488
490 closedir(dir); 489 closedir(dir);
491 } 490 }
492 491
493 Remote_View->setSorting( 3,FALSE); 492 Remote_View->setSorting( 3,FALSE);
494 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 493 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
495} 494}
496 495
497void AdvancedFm::localListClicked(QListViewItem *selectedItem) 496void AdvancedFm::localListClicked(QListViewItem *selectedItem)
498{ 497{
499 if(selectedItem) { 498 if(selectedItem) {
500 QString strItem=selectedItem->text(0); 499 QString strItem=selectedItem->text(0);
501 QString strSize=selectedItem->text(1); 500 QString strSize=selectedItem->text(1);
502 strSize=strSize.stripWhiteSpace(); 501 strSize=strSize.stripWhiteSpace();
503 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 502 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
504 // is symlink 503 // is symlink
505 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 504 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
@@ -631,150 +630,158 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint
631 630
632void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 631void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
633{ 632{
634 switch (mouse) { 633 switch (mouse) {
635 case 1: 634 case 1:
636 break; 635 break;
637 case 2: 636 case 2:
638 showRemoteMenu(item); 637 showRemoteMenu(item);
639 Remote_View->clearSelection(); 638 Remote_View->clearSelection();
640 break; 639 break;
641 }; 640 };
642} 641}
643 642
644void AdvancedFm::showLocalMenu(QListViewItem * item) 643void AdvancedFm::showLocalMenu(QListViewItem * item)
645{ 644{
646 if(item) { 645 if(item) {
647 QPopupMenu m; 646 QPopupMenu m;
648 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 647 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
649 m.insertSeparator(); 648 m.insertSeparator();
650 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 649 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
651 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 650 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
652 else 651 else
653 m.insertItem( tr( "Open" ), this, SLOT( runThis() )); 652 m.insertItem( tr( "Open" ), this, SLOT( runThis() ));
654 m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); 653 m.insertItem( tr( "Open as Text" ), this, SLOT( runText() ));
655 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 654 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
656 m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 655 m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
657 m.insertSeparator(); 656 m.insertSeparator();
658 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 657 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
659 m.insertItem( tr( "Copy" ), this, SLOT( copy() )); 658 m.insertItem( tr( "Copy" ), this, SLOT( copy() ));
660 m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 659 m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
661 m.insertItem( tr( "Move" ), this, SLOT( move() )); 660 m.insertItem( tr( "Move" ), this, SLOT( move() ));
662 m.insertSeparator(); 661 m.insertSeparator();
662 m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() ));
663 m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 663 m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
664 m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 664 m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
665 m.insertSeparator(); 665 m.insertSeparator();
666 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 666 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
667 m.insertSeparator(); 667 m.insertSeparator();
668 m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 668 m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
669 m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 669 m.insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
670 m.setCheckable(TRUE); 670 m.setCheckable(TRUE);
671 if (!b) 671 if (!b)
672 m.setItemChecked(m.idAt(0),TRUE); 672 m.setItemChecked(m.idAt(0),TRUE);
673 else 673 else
674 m.setItemChecked(m.idAt(0),FALSE); 674 m.setItemChecked(m.idAt(0),FALSE);
675 m.exec( QCursor::pos() ); 675 m.exec( QCursor::pos() );
676 } 676 }
677} 677}
678 678
679void AdvancedFm::showRemoteMenu(QListViewItem * item) 679void AdvancedFm::showRemoteMenu(QListViewItem * item)
680{ 680{
681 if(item) { 681 if(item) {
682 QPopupMenu m; 682 QPopupMenu m;
683 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); 683 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() ));
684 m.insertSeparator(); 684 m.insertSeparator();
685 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 685 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
686 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 686 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
687 else 687 else
688 m.insertItem( tr( "Open" ), this, SLOT( runThis() )); 688 m.insertItem( tr( "Open" ), this, SLOT( runThis() ));
689 m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); 689 m.insertItem( tr( "Open as Text" ), this, SLOT( runText() ));
690 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 690 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
691 m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 691 m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
692 m.insertSeparator(); 692 m.insertSeparator();
693 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 693 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
694 m.insertItem( tr( "Copy" ), this, SLOT( copy() )); 694 m.insertItem( tr( "Copy" ), this, SLOT( copy() ));
695 m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 695 m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
696 m.insertItem( tr( "Move" ), this, SLOT( move() )); 696 m.insertItem( tr( "Move" ), this, SLOT( move() ));
697 m.insertSeparator(); 697 m.insertSeparator();
698 m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() ));
698 m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 699 m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
699 m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 700 m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
700 m.insertSeparator(); 701 m.insertSeparator();
701 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 702 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
702 m.insertSeparator(); 703 m.insertSeparator();
703 m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 704 m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
704 m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 705 m.insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
705 m.setCheckable(TRUE); 706 m.setCheckable(TRUE);
706 if (!b) 707 if (!b)
707 m.setItemChecked(m.idAt(0),TRUE); 708 m.setItemChecked(m.idAt(0),TRUE);
708 else 709 else
709 m.setItemChecked(m.idAt(0),FALSE); 710 m.setItemChecked(m.idAt(0),FALSE);
710 m.exec( QCursor::pos() ); 711 m.exec( QCursor::pos() );
711 } 712 }
712} 713}
713 714
714void AdvancedFm::runThis() { 715void AdvancedFm::runThis() {
715// QFileInfo *fi; 716// QFileInfo *fi;
717QString fs;
716 if (TabWidget->currentPageIndex() == 0) { 718 if (TabWidget->currentPageIndex() == 0) {
717 QString curFile = Local_View->currentItem()->text(0); 719 QString curFile = Local_View->currentItem()->text(0);
720
721 fs= getFileSystemType((const QString &) currentDir.canonicalPath());
718 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); 722 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
719// if(fileInfo.isExecutable()) { 723 qDebug( fileInfo.owner());
720// QCopEnvelope e("QPE/System", "execute(QString)" ); 724 if( fileInfo.isExecutable() || fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
721// e << curFile; 725 QCopEnvelope e("QPE/System", "execute(QString)" );
722// } else { 726 e << curFile;
727 } else {
723 curFile = currentDir.canonicalPath()+"/"+curFile; 728 curFile = currentDir.canonicalPath()+"/"+curFile;
724 DocLnk nf(curFile); 729 DocLnk nf(curFile);
725 QString execStr = nf.exec(); 730 QString execStr = nf.exec();
726 qDebug( execStr); 731 qDebug( execStr);
727 if( execStr.isEmpty() ) { 732 if( execStr.isEmpty() ) {
728 } else { 733 } else {
729 nf.execute(); 734 nf.execute();
730 } 735 }
731// } 736 }
732// MimeType mt( curFile); 737// MimeType mt( curFile);
733 } else { 738 } else {
734 QString curFile = Remote_View->currentItem()->text(0); 739 QString curFile = Remote_View->currentItem()->text(0);
740 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
741 qDebug("Filesystemtype is "+fs);
735 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); 742 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
736// if(fileInfo.isExecutable()) { 743 if(fileInfo.isExecutable() || fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
737// QCopEnvelope e("QPE/System", "execute(QString)" ); 744 QCopEnvelope e("QPE/System", "execute(QString)" );
738// e << curFile; 745 e << curFile;
739// } else { 746 } else {
740 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 747 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
741 DocLnk nf(curFile); 748 DocLnk nf(curFile);
742 QString execStr = nf.exec(); 749 QString execStr = nf.exec();
743 qDebug(execStr); 750 qDebug(execStr);
744 if( execStr.isEmpty() ) { 751 if( execStr.isEmpty() ) {
745 } else { 752 } else {
746 nf.execute(); 753 nf.execute();
747 } 754 }
748// } 755 }
749// MimeType mt( curFile); 756// MimeType mt( curFile);
750 } 757 }
751} 758}
752 759
753void AdvancedFm::runText() { 760void AdvancedFm::runText() {
754 if (TabWidget->currentPageIndex() == 0) { 761 if (TabWidget->currentPageIndex() == 0) {
755 QString curFile = Local_View->currentItem()->text(0); 762 QString curFile = Local_View->currentItem()->text(0);
756 curFile = currentDir.canonicalPath()+"/"+curFile; 763 curFile = currentDir.canonicalPath()+"/"+curFile;
757 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 764 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
758 e << curFile; 765 e << curFile;
759 } else { 766 } else {
760 QString curFile = Remote_View->currentItem()->text(0); 767 QString curFile = Remote_View->currentItem()->text(0);
761 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 768 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
762 DocLnk nf(curFile); 769 DocLnk nf(curFile);
763 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 770 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
764 e << curFile; 771 e << curFile;
765 } 772 }
766} 773}
767 774
768void AdvancedFm::localMakDir() 775void AdvancedFm::localMakDir()
769{ 776{
770 InputDialog *fileDlg; 777 InputDialog *fileDlg;
771 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 778 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
772 fileDlg->exec(); 779 fileDlg->exec();
773 if( fileDlg->result() == 1 ) { 780 if( fileDlg->result() == 1 ) {
774 QString filename = fileDlg->LineEdit1->text(); 781 QString filename = fileDlg->LineEdit1->text();
775 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 782 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
776 } 783 }
777 populateLocalView(); 784 populateLocalView();
778} 785}
779 786
780void AdvancedFm::remoteMakDir() 787void AdvancedFm::remoteMakDir()
@@ -1315,123 +1322,123 @@ void AdvancedFm::move() {
1315 d.writeBlock( bf, bytesRead ); 1322 d.writeBlock( bf, bytesRead );
1316 } 1323 }
1317 } else { 1324 } else {
1318 success = FALSE; 1325 success = FALSE;
1319 } 1326 }
1320 1327
1321 // Set file permissions 1328 // Set file permissions
1322 if( stat( (const char *) src, &status ) == 0 ){ 1329 if( stat( (const char *) src, &status ) == 0 ){
1323 chmod( (const char *) dest, status.st_mode ); 1330 chmod( (const char *) dest, status.st_mode );
1324 } 1331 }
1325 1332
1326 return success; 1333 return success;
1327} 1334}
1328 1335
1329void AdvancedFm::runCommand() { 1336void AdvancedFm::runCommand() {
1330 QString curFile; 1337 QString curFile;
1331 if (TabWidget->currentPageIndex() == 0) { 1338 if (TabWidget->currentPageIndex() == 0) {
1332 if( Local_View->currentItem()) 1339 if( Local_View->currentItem())
1333 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); 1340 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0);
1334 } else { 1341 } else {
1335 if(Remote_View->currentItem()) 1342 if(Remote_View->currentItem())
1336 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); 1343 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0);
1337 } 1344 }
1338 1345
1339 InputDialog *fileDlg; 1346 InputDialog *fileDlg;
1340 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 1347 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1341 fileDlg->setInputText(curFile); 1348 fileDlg->setInputText(curFile);
1342 fileDlg->exec(); 1349 fileDlg->exec();
1343 QString command; 1350 QString command;
1344 if( fileDlg->result() == 1 ) { 1351 if( fileDlg->result() == 1 ) {
1345 command = fileDlg->LineEdit1->text(); 1352 command = fileDlg->LineEdit1->text();
1346 1353
1347 int err=0; 1354// int err=0;
1348 Output *outDlg; 1355 Output *outDlg;
1349 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1356 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1350 outDlg->showMaximized(); 1357 outDlg->showMaximized();
1351 outDlg->show(); 1358 outDlg->show();
1352 qApp->processEvents(); 1359 qApp->processEvents();
1353 FILE *fp; 1360 FILE *fp;
1354 char line[130]; 1361 char line[130];
1355 sleep(1); 1362 sleep(1);
1356// if(command.find("2>",0,TRUE) != -1) 1363// if(command.find("2>",0,TRUE) != -1)
1357 command +=" 2>&1"; 1364 command +=" 2>&1";
1358 fp = popen( (const char *) command, "r"); 1365 fp = popen( (const char *) command, "r");
1359 if ( !fp ) { 1366 if ( !fp ) {
1360 qDebug("Could not execute '" + command + "'! err=%d", fp); 1367 qDebug("Could not execute '" + command + "'! err=%d", fp);
1361 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); 1368 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") );
1362 pclose(fp); 1369 pclose(fp);
1363 return; 1370 return;
1364 } else { 1371 } else {
1365 while ( fgets( line, sizeof line, fp)) { 1372 while ( fgets( line, sizeof line, fp)) {
1366 QString lineStr = line; 1373 QString lineStr = line;
1367 lineStr=lineStr.left(lineStr.length()-1); 1374 lineStr=lineStr.left(lineStr.length()-1);
1368 outDlg->OutputEdit->append(lineStr); 1375 outDlg->OutputEdit->append(lineStr);
1369 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1376 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1370 } 1377 }
1371 } 1378 }
1372 } 1379 }
1373} 1380}
1374 1381
1375void AdvancedFm::runCommandStd() { 1382void AdvancedFm::runCommandStd() {
1376 QString curFile; 1383 QString curFile;
1377 if (TabWidget->currentPageIndex() == 0) { 1384 if (TabWidget->currentPageIndex() == 0) {
1378 if( Local_View->currentItem()) 1385 if( Local_View->currentItem())
1379 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); 1386 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0);
1380 } else { 1387 } else {
1381 if(Remote_View->currentItem()) 1388 if(Remote_View->currentItem())
1382 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); 1389 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0);
1383 } 1390 }
1384 1391
1385 InputDialog *fileDlg; 1392 InputDialog *fileDlg;
1386 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 1393 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1387 fileDlg->setInputText(curFile); 1394 fileDlg->setInputText(curFile);
1388 fileDlg->exec(); 1395 fileDlg->exec();
1389 QString command; 1396 QString command;
1390 if( fileDlg->result() == 1 ) { 1397 if( fileDlg->result() == 1 ) {
1391 qApp->processEvents(); 1398 qApp->processEvents();
1392 command = fileDlg->LineEdit1->text() + " &"; 1399 command = fileDlg->LineEdit1->text() + " &";
1393 system(command.latin1()); 1400 system(command.latin1());
1394 } 1401 }
1395} 1402}
1396 1403
1397void AdvancedFm::fileStatus() { 1404void AdvancedFm::fileStatus() {
1398 QString curFile; 1405 QString curFile;
1399 if (TabWidget->currentPageIndex() == 0) { 1406 if (TabWidget->currentPageIndex() == 0) {
1400 curFile = Local_View->currentItem()->text(0); 1407 curFile = Local_View->currentItem()->text(0);
1401 } else { 1408 } else {
1402 curFile = Remote_View->currentItem()->text(0); 1409 curFile = Remote_View->currentItem()->text(0);
1403 } 1410 }
1404 QString command = " stat -l "+ curFile +" 2>&1"; 1411 QString command = " stat -l "+ curFile +" 2>&1";
1405 int err=0; 1412// int err=0;
1406 Output *outDlg; 1413 Output *outDlg;
1407 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 1414 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
1408 outDlg->showMaximized(); 1415 outDlg->showMaximized();
1409 outDlg->show(); 1416 outDlg->show();
1410 qApp->processEvents(); 1417 qApp->processEvents();
1411 FILE *fp; 1418 FILE *fp;
1412 char line[130]; 1419 char line[130];
1413 sleep(1); 1420 sleep(1);
1414 fp = popen( (const char *) command, "r"); 1421 fp = popen( (const char *) command, "r");
1415 if ( !fp ) { 1422 if ( !fp ) {
1416 qDebug("Could not execute '" + command + "'! err=%d", fp); 1423 qDebug("Could not execute '" + command + "'! err=%d", fp);
1417 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); 1424 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") );
1418 pclose(fp); 1425 pclose(fp);
1419 return; 1426 return;
1420 } else { 1427 } else {
1421 while ( fgets( line, sizeof line, fp)) { 1428 while ( fgets( line, sizeof line, fp)) {
1422 outDlg->OutputEdit->append(line); 1429 outDlg->OutputEdit->append(line);
1423 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 1430 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1424 1431
1425 } 1432 }
1426 1433
1427 } 1434 }
1428} 1435}
1429 1436
1430void AdvancedFm::mkDir() { 1437void AdvancedFm::mkDir() {
1431 if (TabWidget->currentPageIndex() == 0) 1438 if (TabWidget->currentPageIndex() == 0)
1432 localMakDir(); 1439 localMakDir();
1433 else 1440 else
1434 remoteMakDir(); 1441 remoteMakDir();
1435 1442
1436} 1443}
1437 1444
@@ -1490,82 +1497,131 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
1490 case Key_P: 1497 case Key_P:
1491 filePerms(); 1498 filePerms();
1492 break; 1499 break;
1493 case Key_N: 1500 case Key_N:
1494 mkDir(); 1501 mkDir();
1495 break; 1502 break;
1496 case Key_1: 1503 case Key_1:
1497 switchToLocalTab(); 1504 switchToLocalTab();
1498 break; 1505 break;
1499 case Key_2: 1506 case Key_2:
1500 switchToRemoteTab(); 1507 switchToRemoteTab();
1501 break; 1508 break;
1502 case Key_3: 1509 case Key_3:
1503 CFButtonPushed(); 1510 CFButtonPushed();
1504 break; 1511 break;
1505 case Key_4: 1512 case Key_4:
1506 SDButtonPushed(); 1513 SDButtonPushed();
1507 break; 1514 break;
1508 case Key_5: 1515 case Key_5:
1509 homeButtonPushed(); 1516 homeButtonPushed();
1510 break; 1517 break;
1511 case Key_6: 1518 case Key_6:
1512 docButtonPushed(); 1519 docButtonPushed();
1513 break; 1520 break;
1514 case Key_7: 1521 case Key_7:
1515 break; 1522 break;
1516 case Key_8: 1523 case Key_8:
1517 break; 1524 break;
1518 case Key_9: 1525 case Key_9:
1519 break; 1526 break;
1520 case Key_0: 1527 case Key_0:
1521 break; 1528 break;
1522
1523
1524
1525 } 1529 }
1526
1527} 1530}
1528 1531
1529void AdvancedFm::mkSym() { 1532void AdvancedFm::mkSym() {
1530 QString cmd; 1533 QString cmd;
1531 QStringList curFileList = getPath(); 1534 QStringList curFileList = getPath();
1532 1535
1533 if (TabWidget->currentPageIndex() == 0) { 1536 if (TabWidget->currentPageIndex() == 0) {
1534 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1537 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1535 1538
1536 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); 1539 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
1537 QString curFile = currentDir.canonicalPath()+"/"+(*it); 1540 QString curFile = currentDir.canonicalPath()+"/"+(*it);
1538 cmd = "ln -s "+curFile+" "+destName; 1541 cmd = "ln -s "+curFile+" "+destName;
1539 qDebug(cmd); 1542 qDebug(cmd);
1540 system(cmd.latin1() ); 1543 system(cmd.latin1() );
1541 } 1544 }
1542 populateRemoteView(); 1545 populateRemoteView();
1543 TabWidget->setCurrentPage(1); 1546 TabWidget->setCurrentPage(1);
1544 } else { 1547 } else {
1545 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1548 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1546 1549
1547 QString destName = currentDir.canonicalPath()+"/"+(*it); 1550 QString destName = currentDir.canonicalPath()+"/"+(*it);
1548 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1551 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1549 1552
1550 cmd = "ln -s "+curFile+" "+destName; 1553 cmd = "ln -s "+curFile+" "+destName;
1551 qDebug(cmd); 1554 qDebug(cmd);
1552 system(cmd.latin1() ); 1555 system(cmd.latin1() );
1553 } 1556 }
1554 populateLocalView(); 1557 populateLocalView();
1555 TabWidget->setCurrentPage(0); 1558 TabWidget->setCurrentPage(0);
1556 } 1559 }
1557} 1560}
1558 1561
1559void AdvancedFm::QPEButtonPushed() { 1562void AdvancedFm::QPEButtonPushed() {
1560 QString current = QPEApplication::qpeDir(); 1563 QString current = QPEApplication::qpeDir();
1561 chdir( current.latin1() ); 1564 chdir( current.latin1() );
1562 if (TabWidget->currentPageIndex() == 0) { 1565 if (TabWidget->currentPageIndex() == 0) {
1563 currentDir.cd( current, TRUE); 1566 currentDir.cd( current, TRUE);
1564 populateLocalView(); 1567 populateLocalView();
1565 } else { 1568 } else {
1566 currentRemoteDir.cd( current, TRUE); 1569 currentRemoteDir.cd( current, TRUE);
1567 populateRemoteView(); 1570 populateRemoteView();
1568 } 1571 }
1569 update(); 1572 update();
1573}
1570 1574
1575void AdvancedFm::parsetab(const QString &fileName) {
1576
1577 fileSystemTypeList.clear();
1578 fsList.clear();
1579 struct mntent *me;
1580// if(fileName == "/etc/mtab") {
1581 FILE *mntfp = setmntent( fileName.latin1(), "r" );
1582 if ( mntfp ) {
1583 while ( (me = getmntent( mntfp )) != 0 ) {
1584 QString deviceName = me->mnt_fsname;
1585 QString filesystemType = me->mnt_type;
1586 QString mountDir = me->mnt_dir;
1587 if(deviceName != "none") {
1588 if( fsList.contains(filesystemType) == 0
1589 & filesystemType.find("proc",0,TRUE) == -1
1590 & filesystemType.find("cramfs",0,TRUE) == -1
1591 & filesystemType.find("auto",0,TRUE) == -1)
1592 fsList << filesystemType;
1593// deviceList << deviceName;
1594// qDebug(mountDir+"::"+filesystemType);
1595 fileSystemTypeList << mountDir+"::"+filesystemType;
1596 }
1597 }
1598 }
1599 endmntent( mntfp );
1571} 1600}
1601
1602QString AdvancedFm::getFileSystemType(const QString &currentText) {
1603 parsetab("/etc/mtab"); //why did TT forget filesystem type?
1604 QString current = currentText;//.right( currentText.length()-1);
1605 QString baseFs;
1606 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
1607 QString temp = (*it);
1608 QString path = temp.left(temp.find("::",0,TRUE) );
1609 path = path.right( path.length()-1);
1610 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
1611 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
1612 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
1613 }
1614 }
1615 return baseFs;
1616}
1617
1618
1619// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
1620// QListViewItemIterator it( Local_View );
1621// for ( ; it.current(); ++it ) {
1622// if ( it.current()->isSelected() ) {
1623// QString strItem = it.current()->text(0);
1624// QString localFile = currentDir.canonicalPath()+"/"+strItem;
1625// QFileInfo fi(localFile);
1626// }
1627// }
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
@@ -29,96 +29,100 @@ class QListviewItem;
29class QLabel; 29class QLabel;
30class QProgressBar; 30class QProgressBar;
31class QSpinBox; 31class QSpinBox;
32class QTabWidget; 32class QTabWidget;
33class QWidget; 33class QWidget;
34class QPEToolBar; 34class QPEToolBar;
35class QPEMenuBar; 35class QPEMenuBar;
36class QPopupMenu; 36class QPopupMenu;
37class QFile; 37class QFile;
38class QListViewItem; 38class QListViewItem;
39class QLineEdit; 39class QLineEdit;
40class QPushButton; 40class QPushButton;
41 41
42class AdvancedFm : public QMainWindow 42class AdvancedFm : public QMainWindow
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45public: 45public:
46 AdvancedFm(); 46 AdvancedFm();
47 ~AdvancedFm(); 47 ~AdvancedFm();
48 48
49 QTabWidget *TabWidget; 49 QTabWidget *TabWidget;
50 QWidget *tab, *tab_2, *tab_3; 50 QWidget *tab, *tab_2, *tab_3;
51 QListView *Local_View, *Remote_View; 51 QListView *Local_View, *Remote_View;
52 52
53 QLineEdit *currentPathEdit; 53 QLineEdit *currentPathEdit;
54 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; 54 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu;
55 QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; 55 QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
56 QDir currentDir, currentRemoteDir; 56 QDir currentDir, currentRemoteDir;
57 QComboBox *currentPathCombo; 57 QComboBox *currentPathCombo;
58 QString filterStr; 58 QString filterStr;
59 QListViewItem * item; 59 QListViewItem * item;
60 bool b; 60 bool b;
61 QStringList fileSystemTypeList, fsList;
61 int currentServerConfig; 62 int currentServerConfig;
62protected slots: 63protected slots:
63 void showLocalMenu( QListViewItem *); 64 void showLocalMenu( QListViewItem *);
64 void showRemoteMenu( QListViewItem *); 65 void showRemoteMenu( QListViewItem *);
65 void doLocalCd(); 66 void doLocalCd();
66 void doRemoteCd(); 67 void doRemoteCd();
67// void copy(); 68// void copy();
68 void mkDir(); 69 void mkDir();
69 void del(); 70 void del();
70 void rn(); 71 void rn();
71 void populateLocalView(); 72 void populateLocalView();
72 void populateRemoteView(); 73 void populateRemoteView();
73 void showHidden(); 74 void showHidden();
74 void showRemoteHidden(); 75 void showRemoteHidden();
75 void writeConfig(); 76 void writeConfig();
76 void readConfig(); 77 void readConfig();
77 void localListClicked(QListViewItem *); 78 void localListClicked(QListViewItem *);
78 void remoteListClicked(QListViewItem *); 79 void remoteListClicked(QListViewItem *);
79 void localListPressed( int, QListViewItem *, const QPoint&, int); 80 void localListPressed( int, QListViewItem *, const QPoint&, int);
80 void remoteListPressed( int, QListViewItem *, const QPoint&, int); 81 void remoteListPressed( int, QListViewItem *, const QPoint&, int);
81 void localMakDir(); 82 void localMakDir();
82 void localDelete(); 83 void localDelete();
83 void remoteMakDir(); 84 void remoteMakDir();
84 void remoteDelete(); 85 void remoteDelete();
85/* bool remoteDirList(const QString &); */ 86/* bool remoteDirList(const QString &); */
86/* bool remoteChDir(const QString &); */ 87/* bool remoteChDir(const QString &); */
87 void tabChanged(QWidget*); 88 void tabChanged(QWidget*);
88 void cleanUp(); 89 void cleanUp();
89 void remoteRename(); 90 void remoteRename();
90 void localRename(); 91 void localRename();
91 void runThis(); 92 void runThis();
92 void runText(); 93 void runText();
93 void filePerms(); 94 void filePerms();
94 void doProperties(); 95 void doProperties();
95 void runCommand(); 96 void runCommand();
96 void runCommandStd(); 97 void runCommandStd();
97 QStringList getPath(); 98 QStringList getPath();
98 void mkSym(); 99 void mkSym();
99 void switchToLocalTab(); 100 void switchToLocalTab();
100 void switchToRemoteTab(); 101 void switchToRemoteTab();
101 102
102protected: 103protected:
103 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; 104 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
104 QStringList remoteDirPathStringList, localDirPathStringList; 105 QStringList remoteDirPathStringList, localDirPathStringList;
105 void keyReleaseEvent( QKeyEvent *); 106 void keyReleaseEvent( QKeyEvent *);
107 QString getFileSystemType(const QString &);
108 void parsetab(const QString &fileName);
109
106protected slots: 110protected slots:
107 void homeButtonPushed(); 111 void homeButtonPushed();
108 void docButtonPushed(); 112 void docButtonPushed();
109 void SDButtonPushed(); 113 void SDButtonPushed();
110 void CFButtonPushed(); 114 void CFButtonPushed();
111 void QPEButtonPushed(); 115 void QPEButtonPushed();
112 void upDir(); 116 void upDir();
113 void currentPathComboChanged(); 117 void currentPathComboChanged();
114 void copy(); 118 void copy();
115 void copyAs(); 119 void copyAs();
116 void currentPathComboActivated(const QString &); 120 void currentPathComboActivated(const QString &);
117 void fillCombo(const QString &); 121 void fillCombo(const QString &);
118 bool copyFile( const QString & , const QString & ); 122 bool copyFile( const QString & , const QString & );
119 void move(); 123 void move();
120 void fileStatus(); 124 void fileStatus();
121 void doAbout(); 125 void doAbout();
122}; 126};
123 127
124#endif // ADVANCEDFM_H 128#endif // ADVANCEDFM_H