summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 73d0d57..48332b7 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -281,243 +281,245 @@ void AdvancedFm::refreshCurrentTab() {
281} 281}
282 282
283void AdvancedFm::switchToLocalTab() { 283void AdvancedFm::switchToLocalTab() {
284 TabWidget->setCurrentWidget(0); 284 TabWidget->setCurrentWidget(0);
285 Local_View->setFocus(); 285 Local_View->setFocus();
286 whichTab = 1; 286 whichTab = 1;
287} 287}
288 288
289void AdvancedFm::switchToRemoteTab() { 289void AdvancedFm::switchToRemoteTab() {
290 TabWidget->setCurrentWidget(1); 290 TabWidget->setCurrentWidget(1);
291 Remote_View->setFocus(); 291 Remote_View->setFocus();
292 whichTab = 2; 292 whichTab = 2;
293} 293}
294 294
295void AdvancedFm::currentPathComboChanged() { 295void AdvancedFm::currentPathComboChanged() {
296 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 296 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
297 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 297 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
298 populateView(); 298 populateView();
299 } else { 299 } else {
300 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 300 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
301 } 301 }
302} 302}
303 303
304void AdvancedFm::fillCombo(const QString &currentPath) { 304void AdvancedFm::fillCombo(const QString &currentPath) {
305 305
306 if ( TabWidget->currentWidget() == tab) { 306 if ( TabWidget->currentWidget() == tab) {
307// if ( whichTab == 1) { 307// if ( whichTab == 1) {
308 currentPathCombo->lineEdit()->setText( currentPath); 308 currentPathCombo->lineEdit()->setText( currentPath);
309 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 309 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
310 currentPathCombo->clear(); 310 currentPathCombo->clear();
311 localDirPathStringList.prepend( currentPath ); 311 localDirPathStringList.prepend( currentPath );
312 currentPathCombo->insertStringList( localDirPathStringList,-1); 312 currentPathCombo->insertStringList( localDirPathStringList,-1);
313 } 313 }
314 } else { 314 } else {
315 currentPathCombo->lineEdit()->setText( currentPath); 315 currentPathCombo->lineEdit()->setText( currentPath);
316 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 316 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
317 currentPathCombo->clear(); 317 currentPathCombo->clear();
318 remoteDirPathStringList.prepend( currentPath ); 318 remoteDirPathStringList.prepend( currentPath );
319 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 319 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
320 } 320 }
321 } 321 }
322} 322}
323 323
324void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 324void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
325 chdir( currentPath.latin1() ); 325 chdir( currentPath.latin1() );
326 CurrentDir()->cd( currentPath, TRUE); 326 CurrentDir()->cd( currentPath, TRUE);
327 populateView(); 327 populateView();
328 update(); 328 update();
329} 329}
330 330
331QStringList AdvancedFm::getPath() { 331QStringList AdvancedFm::getPath() {
332 QStringList strList; 332 QStringList strList;
333 QListView *thisView=CurrentView(); 333 QListView *thisView=CurrentView();
334 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 334 QList<QListViewItem> * getSelectedItems( QListView * thisView );
335 QListViewItemIterator it( thisView ); 335 QListViewItemIterator it( thisView );
336 for ( ; it.current(); ++it ) { 336 for ( ; it.current(); ++it ) {
337 if ( it.current()->isSelected() ) { 337 if ( it.current()->isSelected() ) {
338 strList << it.current()->text(0); 338 strList << it.current()->text(0);
339// odebug << it.current()->text(0) << oendl; 339// odebug << it.current()->text(0) << oendl;
340 } 340 }
341 } 341 }
342 return strList; 342 return strList;
343} 343}
344 344
345void AdvancedFm::changeTo(QString dir) { 345void AdvancedFm::changeTo(QString dir) {
346 chdir( dir.latin1()); 346 chdir( dir.latin1());
347 CurrentDir()->cd(dir, TRUE); 347 CurrentDir()->cd(dir, TRUE);
348 populateView(); 348 populateView();
349 update(); 349 update();
350} 350}
351 351
352void AdvancedFm::homeButtonPushed() { 352void AdvancedFm::homeButtonPushed() {
353 changeTo(QDir::homeDirPath()); 353 changeTo(QDir::homeDirPath());
354} 354}
355 355
356void AdvancedFm::docButtonPushed() { 356void AdvancedFm::docButtonPushed() {
357 changeTo(QPEApplication::documentDir()); 357 changeTo(QPEApplication::documentDir());
358} 358}
359 359
360void AdvancedFm::SDButtonPushed() { 360void AdvancedFm::SDButtonPushed() {
361 changeTo("/mnt/card");// this can change so fix 361 changeTo("/mnt/card");// this can change so fix
362} 362}
363 363
364void AdvancedFm::CFButtonPushed() { 364void AdvancedFm::CFButtonPushed() {
365 if(zaurusDevice) 365 if(zaurusDevice)
366 changeTo("/mnt/cf"); //zaurus 366 changeTo("/mnt/cf"); //zaurus
367 else 367 else
368 changeTo("/mnt/hda"); //ipaq 368 changeTo("/mnt/hda"); //ipaq
369} 369}
370 370
371 371
372void AdvancedFm::doAbout() { 372void AdvancedFm::doAbout() {
373 QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); 373 QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>"));
374} 374}
375 375
376void AdvancedFm::keyPressEvent( QKeyEvent *e) { 376void AdvancedFm::keyPressEvent( QKeyEvent *e) {
377 qDebug("keypressevent");
378}
379
380void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
381 qDebug("key release");
382 if( CurrentView()->hasFocus() )
383 e->ignore();
377 if( e->key() == Key_Left ) 384 if( e->key() == Key_Left )
378 upDir(); 385 upDir();
379 else if( e->key() == Key_Return || e->key() == Key_Enter) 386 else if( e->key() == Key_Return || e->key() == Key_Enter)
380 navigateToSelected(); 387 navigateToSelected();
381 else if( e->key() == Key_Tab) 388 else if( e->key() == Key_Tab)
382 setOtherTabCurrent(); 389 setOtherTabCurrent();
383 else if( e->key() == Key_Delete ) 390 else if( e->key() == Key_Delete )
384 del(); 391 del();
385 else if( e->key() == Key_A) 392 else if( e->key() == Key_A)
386 copyAs(); 393 copyAs();
387 else if( e->key() == Key_C) 394 else if( e->key() == Key_C)
388 copy(); 395 copy();
389 else if( e->key() == Key_E) 396 else if( e->key() == Key_E)
390 runThis(); 397 runThis();
391 else if( e->key() == Key_G) 398 else if( e->key() == Key_G)
392 currentPathCombo->lineEdit()->setFocus(); 399 currentPathCombo->lineEdit()->setFocus();
393 else if( e->key() == Key_H ) 400 else if( e->key() == Key_H )
394 showHidden(); 401 showHidden();
395 else if( e->key() == Key_I) 402 else if( e->key() == Key_I)
396 fileStatus(); 403 fileStatus();
397 else if( e->key() == Key_M) 404 else if( e->key() == Key_M)
398 move(); 405 move();
399 else if( e->key() == Key_N ) 406 else if( e->key() == Key_N )
400 mkDir(); 407 mkDir();
401 else if( e->key() == Key_P) 408 else if( e->key() == Key_P)
402 filePerms(); 409 filePerms();
403 else if( e->key() == Key_R ) 410 else if( e->key() == Key_R )
404 rn(); 411 rn();
405 else if( e->key() == Key_U ) 412 else if( e->key() == Key_U )
406 upDir(); 413 upDir();
407 else if( e->key() == Key_1) 414 else if( e->key() == Key_1)
408 switchToLocalTab(); 415 switchToLocalTab();
409 else if( e->key() == Key_2) 416 else if( e->key() == Key_2)
410 switchToRemoteTab(); 417 switchToRemoteTab();
411 else if( e->key() == Key_3) 418 else if( e->key() == Key_3)
412 CFButtonPushed(); 419 CFButtonPushed();
413 else if( e->key() == Key_4) 420 else if( e->key() == Key_4)
414 SDButtonPushed(); 421 SDButtonPushed();
415 else if( e->key() == Key_5 ) 422 else if( e->key() == Key_5 )
416 homeButtonPushed(); 423 homeButtonPushed();
417 else if( e->key() == Key_6 ) 424 else if( e->key() == Key_6 )
418 docButtonPushed(); 425 docButtonPushed();
419 else 426 else
420 e->accept(); 427 e->accept();
421} 428}
422 429
423void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
424 if( CurrentView()->hasFocus() )
425 e->ignore();
426}
427
428 430
429void AdvancedFm::QPEButtonPushed() { 431void AdvancedFm::QPEButtonPushed() {
430 QString current = QPEApplication::qpeDir(); 432 QString current = QPEApplication::qpeDir();
431 chdir( current.latin1() ); 433 chdir( current.latin1() );
432 CurrentDir()->cd( current, TRUE); 434 CurrentDir()->cd( current, TRUE);
433 populateView(); 435 populateView();
434 update(); 436 update();
435} 437}
436 438
437void AdvancedFm::parsetab(const QString &fileName) { 439void AdvancedFm::parsetab(const QString &fileName) {
438 440
439 fileSystemTypeList.clear(); 441 fileSystemTypeList.clear();
440 fsList.clear(); 442 fsList.clear();
441 struct mntent *me; 443 struct mntent *me;
442 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 444 FILE *mntfp = setmntent( fileName.latin1(), "r" );
443 if ( mntfp ) { 445 if ( mntfp ) {
444 while ( (me = getmntent( mntfp )) != 0 ) { 446 while ( (me = getmntent( mntfp )) != 0 ) {
445 QString deviceName = me->mnt_fsname; 447 QString deviceName = me->mnt_fsname;
446 QString filesystemType = me->mnt_type; 448 QString filesystemType = me->mnt_type;
447 QString mountDir = me->mnt_dir; 449 QString mountDir = me->mnt_dir;
448 if(deviceName != "none") { 450 if(deviceName != "none") {
449 if( fsList.contains(filesystemType) == 0 451 if( fsList.contains(filesystemType) == 0
450 & filesystemType.find("proc",0,TRUE) == -1 452 & filesystemType.find("proc",0,TRUE) == -1
451 & filesystemType.find("cramfs",0,TRUE) == -1 453 & filesystemType.find("cramfs",0,TRUE) == -1
452 & filesystemType.find("auto",0,TRUE) == -1) 454 & filesystemType.find("auto",0,TRUE) == -1)
453 fsList << filesystemType; 455 fsList << filesystemType;
454 fileSystemTypeList << mountDir+"::"+filesystemType; 456 fileSystemTypeList << mountDir+"::"+filesystemType;
455 } 457 }
456 } 458 }
457 } 459 }
458 endmntent( mntfp ); 460 endmntent( mntfp );
459} 461}
460 462
461QString AdvancedFm::getFileSystemType(const QString &currentText) { 463QString AdvancedFm::getFileSystemType(const QString &currentText) {
462 parsetab("/etc/mtab"); //why did TT forget filesystem type? 464 parsetab("/etc/mtab"); //why did TT forget filesystem type?
463 QString current = currentText;//.right( currentText.length()-1); 465 QString current = currentText;//.right( currentText.length()-1);
464 QString baseFs; 466 QString baseFs;
465 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 467 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
466 QString temp = (*it); 468 QString temp = (*it);
467 QString path = temp.left(temp.find("::",0,TRUE) ); 469 QString path = temp.left(temp.find("::",0,TRUE) );
468 path = path.right( path.length()-1); 470 path = path.right( path.length()-1);
469 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 471 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
470 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 472 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
471 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 473 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
472 } 474 }
473 } 475 }
474 return baseFs; 476 return baseFs;
475} 477}
476 478
477QString AdvancedFm::getDiskSpace( const QString &path) { 479QString AdvancedFm::getDiskSpace( const QString &path) {
478 struct statfs fss; 480 struct statfs fss;
479 if ( !statfs( path.latin1(), &fss ) ) { 481 if ( !statfs( path.latin1(), &fss ) ) {
480 int blkSize = fss.f_bsize; 482 int blkSize = fss.f_bsize;
481 // int totalBlks = fs.f_blocks; 483 // int totalBlks = fs.f_blocks;
482 int availBlks = fss.f_bavail; 484 int availBlks = fss.f_bavail;
483 485
484 long mult = blkSize / 1024; 486 long mult = blkSize / 1024;
485 long div = 1024 / blkSize; 487 long div = 1024 / blkSize;
486 if ( !mult ) mult = 1; 488 if ( !mult ) mult = 1;
487 if ( !div ) div = 1; 489 if ( !div ) div = 1;
488 490
489 return QString::number(availBlks * mult / div); 491 return QString::number(availBlks * mult / div);
490 } 492 }
491 return ""; 493 return "";
492} 494}
493 495
494 496
495void AdvancedFm::showFileMenu() { 497void AdvancedFm::showFileMenu() {
496 QString curApp; 498 QString curApp;
497 curApp = CurrentView()->currentItem()->text(0); 499 curApp = CurrentView()->currentItem()->text(0);
498 500
499 MimeType mt(curApp); 501 MimeType mt(curApp);
500 const AppLnk* app = mt.application(); 502 const AppLnk* app = mt.application();
501 QFile fi(curApp); 503 QFile fi(curApp);
502 QPopupMenu *m = new QPopupMenu(0); 504 QPopupMenu *m = new QPopupMenu(0);
503 QPopupMenu *n = new QPopupMenu(0); 505 QPopupMenu *n = new QPopupMenu(0);
504 // QPopupMenu *o = new QPopupMenu(0); 506 // QPopupMenu *o = new QPopupMenu(0);
505 m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); 507 m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden()));
506 508
507 if ( QFileInfo(fi).isDir()) { 509 if ( QFileInfo(fi).isDir()) {
508 m->insertSeparator(); 510 m->insertSeparator();
509 m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); 511 m->insertItem(tr("Change Directory"),this,SLOT(doDirChange()));
510 } else { 512 } else {
511 513
512 if (app) 514 if (app)
513 m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); 515 m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis()));
514 else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 516 else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
515 m->insertItem(tr("Execute"),this,SLOT(runThis())); 517 m->insertItem(tr("Execute"),this,SLOT(runThis()));
516 m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); 518 m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText()));
517 } 519 }
518 520
519 m->insertItem(tr("Actions"),n); 521 m->insertItem(tr("Actions"),n);
520 n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); 522 n->insertItem(tr("Make Directory"),this,SLOT(makeDir()));
521 523
522 n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); 524 n->insertItem(tr("Make Symlink"),this,SLOT(mkSym()));
523 525