summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.cpp74
1 files changed, 37 insertions, 37 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp
index 10e50f0..7dabdb6 100644
--- a/noncore/unsupported/filebrowser/filebrowser.cpp
+++ b/noncore/unsupported/filebrowser/filebrowser.cpp
@@ -353,402 +353,402 @@ void FileView::generateDir( const QString & dir )
353} 353}
354 354
355void FileView::rename() 355void FileView::rename()
356{ 356{
357 itemToRename = (FileItem *) currentItem(); 357 itemToRename = (FileItem *) currentItem();
358 const QPixmap * pm; 358 const QPixmap * pm;
359 int pmw; 359 int pmw;
360 360
361 if( itemToRename == NULL ) return; 361 if( itemToRename == NULL ) return;
362 362
363 if( ( pm = itemToRename->pixmap( 0 ) ) == NULL ) 363 if( ( pm = itemToRename->pixmap( 0 ) ) == NULL )
364 pmw = 0; 364 pmw = 0;
365 else 365 else
366 pmw = pm->width(); 366 pmw = pm->width();
367 367
368 ensureItemVisible( itemToRename ); 368 ensureItemVisible( itemToRename );
369 horizontalScrollBar()->setValue( 0 ); 369 horizontalScrollBar()->setValue( 0 );
370 horizontalScrollBar()->setEnabled( FALSE ); 370 horizontalScrollBar()->setEnabled( FALSE );
371 verticalScrollBar()->setEnabled( FALSE ); 371 verticalScrollBar()->setEnabled( FALSE );
372 372
373 selected = isSelected( itemToRename ); 373 selected = isSelected( itemToRename );
374 setSelected( itemToRename, FALSE ); 374 setSelected( itemToRename, FALSE );
375 375
376 if( le == NULL ){ 376 if( le == NULL ){
377 le = new InlineEdit( this ); 377 le = new InlineEdit( this );
378 le->setFrame( FALSE ); 378 le->setFrame( FALSE );
379 connect( le, SIGNAL( lostFocus() ), SLOT( endRenaming() ) ); 379 connect( le, SIGNAL( lostFocus() ), SLOT( endRenaming() ) );
380 } 380 }
381 381
382 QRect r = itemRect( itemToRename ); 382 QRect r = itemRect( itemToRename );
383 r.setTop( r.top() + frameWidth() + 1 ); 383 r.setTop( r.top() + frameWidth() + 1 );
384 r.setLeft( r.left() + frameWidth() + pmw ); 384 r.setLeft( r.left() + frameWidth() + pmw );
385 r.setBottom( r.bottom() + frameWidth() ); 385 r.setBottom( r.bottom() + frameWidth() );
386 r.setWidth( columnWidth( 0 ) - pmw ); 386 r.setWidth( columnWidth( 0 ) - pmw );
387 387
388 le->setGeometry( r ); 388 le->setGeometry( r );
389 le->setText( itemToRename->text( 0 ) ); 389 le->setText( itemToRename->text( 0 ) );
390 le->selectAll(); 390 le->selectAll();
391 le->show(); 391 le->show();
392 le->setFocus(); 392 le->setFocus();
393} 393}
394 394
395void FileView::endRenaming() 395void FileView::endRenaming()
396{ 396{
397 if( le && itemToRename ){ 397 if( le && itemToRename ){
398 le->hide(); 398 le->hide();
399 setSelected( itemToRename, selected ); 399 setSelected( itemToRename, selected );
400 400
401 if( !itemToRename->rename( le->text() ) ){ 401 if( !itemToRename->rename( le->text() ) ){
402 QMessageBox::warning( this, tr( "Rename file" ), 402 QMessageBox::warning( this, tr( "Rename file" ),
403 tr( "Rename failed!" ), tr( "&Ok" ) ); 403 tr( "Rename failed!" ), tr( "&Ok" ) );
404 } else { 404 } else {
405 updateDir(); 405 updateDir();
406 } 406 }
407 itemToRename = NULL; 407 itemToRename = NULL;
408 horizontalScrollBar()->setEnabled( TRUE ); 408 horizontalScrollBar()->setEnabled( TRUE );
409 verticalScrollBar()->setEnabled( TRUE ); 409 verticalScrollBar()->setEnabled( TRUE );
410 } 410 }
411} 411}
412 412
413void FileView::copy() 413void FileView::copy()
414{ 414{
415 // dont keep cut files any longer than necessary 415 // dont keep cut files any longer than necessary
416 // ##### a better inmplementation might be to rename the CUT file 416 // ##### a better inmplementation might be to rename the CUT file
417 // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. 417 // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it.
418 system ( "rm -rf /tmp/qpemoving" ); 418 system ( "rm -rf /tmp/qpemoving" );
419 419
420 FileItem * i; 420 FileItem * i;
421 421
422 if((i = (FileItem *) firstChild()) == 0) return; 422 if((i = (FileItem *) firstChild()) == 0) return;
423 423
424 flist.clear(); 424 flist.clear();
425 while( i ){ 425 while( i ){
426 if( i->isSelected() /*&& !i->isDir()*/ ){ 426 if( i->isSelected() /*&& !i->isDir()*/ ){
427 flist += i->getFilePath(); 427 flist += i->getFilePath();
428 } 428 }
429 i = (FileItem *) i->nextSibling(); 429 i = (FileItem *) i->nextSibling();
430 } 430 }
431} 431}
432 432
433void FileView::paste() 433void FileView::paste()
434{ 434{
435 int i, err; 435 int i, err;
436 QString cmd, dest, basename, cd = currentDir; 436 QString cmd, dest, basename, cd = currentDir;
437 437
438 if(cd == "/") cd = ""; 438 if(cd == "/") cd = "";
439 439
440 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { 440 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) {
441 basename = (*it).mid((*it).findRev("/") + 1, (*it).length()); 441 basename = (*it).mid((*it).findRev("/") + 1, (*it).length());
442 442
443 dest = cd + "/" + basename; 443 dest = cd + "/" + basename;
444 if( QFile( dest ).exists() ){ 444 if( QFile( dest ).exists() ){
445 i = 1; 445 i = 1;
446 dest = cd + "/Copy of " + basename; 446 dest = cd + "/Copy of " + basename;
447 while( QFile( dest ).exists() ){ 447 while( QFile( dest ).exists() ){
448 dest.sprintf( "%s/Copy (%d) of %s", (const char *) cd, i++, 448 dest.sprintf( "%s/Copy (%d) of %s", (const char *) cd, i++,
449 (const char *) basename ); 449 (const char *) basename );
450 } 450 }
451 } 451 }
452 452
453 // 453 //
454 // Copy a directory recursively using the "cp" command - 454 // Copy a directory recursively using the "cp" command -
455 // may have to be changed 455 // may have to be changed
456 // 456 //
457 if( QFileInfo( (*it) ).isDir() ){ 457 if( QFileInfo( (*it) ).isDir() ){
458 cmd = "/bin/cp -fpR \"" + (*it) +"\" " + "\"" + dest + "\""; 458 cmd = "/bin/cp -fpR \"" + (*it) +"\" " + "\"" + dest + "\"";
459 err = system( (const char *) cmd ); 459 err = system( (const char *) cmd );
460 } else if( !copyFile( dest, (*it) ) ){ 460 } else if( !copyFile( dest, (*it) ) ){
461 err = -1; 461 err = -1;
462 } else { 462 } else {
463 err = 0; 463 err = 0;
464 } 464 }
465 465
466 if ( err != 0 ) { 466 if ( err != 0 ) {
467 QMessageBox::warning( this, tr("Paste file"), tr("Paste failed!"), 467 QMessageBox::warning( this, tr("Paste file"), tr("Paste failed!"),
468 tr("Ok") ); 468 tr("Ok") );
469 break; 469 break;
470 } else { 470 } else {
471 updateDir(); 471 updateDir();
472 QListViewItem * i = firstChild(); 472 QListViewItem * i = firstChild();
473 basename = dest.mid( dest.findRev("/") + 1, dest.length() ); 473 basename = dest.mid( dest.findRev("/") + 1, dest.length() );
474 474
475 while( i ){ 475 while( i ){
476 if( i->text(0) == basename ){ 476 if( i->text(0) == basename ){
477 setCurrentItem( i ); 477 setCurrentItem( i );
478 ensureItemVisible( i ); 478 ensureItemVisible( i );
479 break; 479 break;
480 } 480 }
481 i = i->nextSibling(); 481 i = i->nextSibling();
482 } 482 }
483 } 483 }
484 } 484 }
485} 485}
486 486
487bool FileView::copyFile( const QString & dest, const QString & src ) 487bool FileView::copyFile( const QString & dest, const QString & src )
488{ 488{
489 char bf[ 50000 ]; 489 char bf[ 50000 ];
490 int bytesRead; 490 int bytesRead;
491 bool success = TRUE; 491 bool success = TRUE;
492 struct stat status; 492 struct stat status;
493 493
494 QFile s( src ); 494 QFile s( src );
495 QFile d( dest ); 495 QFile d( dest );
496 496
497 if( s.open( IO_ReadOnly | IO_Raw ) && 497 if( s.open( IO_ReadOnly | IO_Raw ) &&
498 d.open( IO_WriteOnly | IO_Raw ) ) 498 d.open( IO_WriteOnly | IO_Raw ) )
499 { 499 {
500 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == 500 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) ==
501 sizeof( bf ) ) 501 sizeof( bf ) )
502 { 502 {
503 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 503 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
504 success = FALSE; 504 success = FALSE;
505 break; 505 break;
506 } 506 }
507 } 507 }
508 if( success && (bytesRead > 0) ){ 508 if( success && (bytesRead > 0) ){
509 d.writeBlock( bf, bytesRead ); 509 d.writeBlock( bf, bytesRead );
510 } 510 }
511 } else { 511 } else {
512 success = FALSE; 512 success = FALSE;
513 } 513 }
514 514
515 // Set file permissions 515 // Set file permissions
516 if( stat( (const char *) src, &status ) == 0 ){ 516 if( stat( (const char *) src, &status ) == 0 ){
517 chmod( (const char *) dest, status.st_mode ); 517 chmod( (const char *) dest, status.st_mode );
518 } 518 }
519 519
520 return success; 520 return success;
521} 521}
522 522
523void FileView::cut() 523void FileView::cut()
524{ 524{
525 int err; 525 int err;
526 // ##### a better inmplementation might be to rename the CUT file 526 // ##### a better inmplementation might be to rename the CUT file
527 // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. 527 // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it.
528 QString cmd, dest, basename, cd = "/tmp/qpemoving"; 528 QString cmd, dest, basename, cd = "/tmp/qpemoving";
529 QStringList newflist; 529 QStringList newflist;
530 newflist.clear(); 530 newflist.clear();
531 531
532 cmd = "rm -rf " + cd; 532 cmd = "rm -rf " + cd;
533 system ( (const char *) cmd ); 533 system ( (const char *) cmd );
534 cmd = "mkdir " + cd; 534 cmd = "mkdir " + cd;
535 system( (const char *) cmd ); 535 system( (const char *) cmd );
536 536
537// get the names of the files to cut 537// get the names of the files to cut
538 FileItem * item; 538 FileItem * item;
539 539
540 if((item = (FileItem *) firstChild()) == 0) return; 540 if((item = (FileItem *) firstChild()) == 0) return;
541 541
542 flist.clear(); 542 flist.clear();
543 while( item ){ 543 while( item ){
544 if( ite 544 if( ite
545 // ##### a better inmplementation might be to rename the CUT file 545 // ##### a better inmplementation might be to rename the CUT file
546 // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. 546 // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it.
547 QString cmd, dest, basename, cd = "/tmp/qpemoving"; 547 QString cmd, dest, basename, cd = "/tmp/qpemoving";
548 QStringList newflist; 548 QStringList newflist;
549 newflist.clear(); 549 newflist.clear();
550 550
551 cmd = "rm -rf " + cd; 551 cmd = "rm -rf " + cd;
552 system ( (const char *) cmd ); 552 system ( (const char *) cmd );
553 cmd = "mkdir " + cd; 553 cmd = "mkdir " + cd;
554 system( (const char *) cmd ); 554 system( (const char *) cmd );
555 555
556// get the names of the files to cut 556// get the names of the files to cut
557 FileItem * item; 557 FileItem * item;
558 558
559 if((item = (FileItem *) firstChild()) == 0) return; 559 if((item = (FileItem *) firstChild()) == 0) return;
560 560
561 flist.clear(); 561 flist.clear();
562 while( item ){ 562 while( item ){
563 if( item->isSelected() /*&& !item->isDir()*/ ){ 563 if( item->isSelected() /*&& !item->isDir()*/ ){
564 flist += item->getFilePath(); 564 flist += item->getFilePath();
565 } 565 }
566 item = (FileItem *) item->nextSibling(); 566 item = (FileItem *) item->nextSibling();
567 } 567 }
568 568
569// move these files into a tmp dir 569// move these files into a tmp dir
570 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { 570 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) {
571 basename = (*it).mid((*it).findRev("/") + 1, (*it).length()); 571 basename = (*it).mid((*it).findRev("/") + 1, (*it).length());
572 572
573 dest = cd + "/" + basename; 573 dest = cd + "/" + basename;
574 574
575 newflist += dest; 575 newflist += dest;
576 576
577 cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\""; 577 cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\"";
578 err = system( (const char *) cmd ); 578 err = system( (const char *) cmd );
579 579
580 if ( err != 0 ) { 580 if ( err != 0 ) {
581 QMessageBox::warning( this, tr("Cut file"), tr("Cut failed!"), 581 QMessageBox::warning( this, tr("Cut file"), tr("Cut failed!"),
582 tr("Ok") ); 582 tr("Ok") );
583 break; 583 break;
584 } else { 584 } else {
585 updateDir(); 585 updateDir();
586 QListViewItem * im = firstChild(); 586 QListViewItem * im = firstChild();
587 basename = dest.mid( dest.findRev("/") + 1, dest.length() ); 587 basename = dest.mid( dest.findRev("/") + 1, dest.length() );
588 588
589 while( im ){ 589 while( im ){
590 if( im->text(0) == basename ){ 590 if( im->text(0) == basename ){
591 setCurrentItem( im ); 591 setCurrentItem( im );
592 ensureItemVisible( im ); 592 ensureItemVisible( im );
593 break; 593 break;
594 } 594 }
595 im = im->nextSibling(); 595 im = im->nextSibling();
596 } 596 }
597 } 597 }
598 } 598 }
599 599
600 // update the filelist to point to tmp dir so paste works nicely 600 // update the filelist to point to tmp dir so paste works nicely
601 flist = newflist; 601 flist = newflist;
602} 602}
603 603
604void FileView::del() 604void FileView::del()
605{ 605{
606 FileItem * i; 606 FileItem * i;
607 QStringList fl; 607 QStringList fl;
608 QString cmd; 608 QString cmd;
609 int err; 609 int err;
610 610
611 if((i = (FileItem *) firstChild()) == 0) return; 611 if((i = (FileItem *) firstChild()) == 0) return;
612 612
613 while( i ){ 613 while( i ){
614 if( i->isSelected() ){ 614 if( i->isSelected() ){
615 fl += i->getFilePath(); 615 fl += i->getFilePath();
616 } 616 }
617 i = (FileItem *) i->nextSibling(); 617 i = (FileItem *) i->nextSibling();
618 } 618 }
619 if( fl.count() < 1 ) return; 619 if( fl.count() < 1 ) return;
620 620
621 if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"), 621 if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"),
622 tr("Yes"), tr("No") ) == 0) 622 tr("Yes"), tr("No") ) == 0)
623 { 623 {
624 // 624 //
625 // Dependant upon the "rm" command - will probably have to be replaced 625 // Dependant upon the "rm" command - will probably have to be replaced
626 // 626 //
627 for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { 627 for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) {
628 cmd = "/bin/rm -rf \"" + (*it) + "\""; 628 cmd = "/bin/rm -rf \"" + (*it) + "\"";
629 err = system( (const char *) cmd ); 629 err = system( (const char *) cmd );
630 if ( err != 0 ) { 630 if ( err != 0 ) {
631 QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), 631 QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"),
632 tr("Ok") ); 632 tr("Ok") );
633 break; 633 break;
634 } 634 }
635 } 635 }
636 updateDir(); 636 updateDir();
637 } 637 }
638} 638}
639 639
640void FileView::newFolder() 640void FileView::newFolder()
641{ 641{
642 int t = 1; 642 int t = 1;
643 FileItem * i; 643 FileItem * i;
644 QString nd = currentDir + "/NewFolder"; 644 QString nd = currentDir + "/NewFolder";
645 645
646 while( QFile( nd ).exists() ){ 646 while( QFile( nd ).exists() ){
647 nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); 647 nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ );
648 } 648 }
649 649
650 if( mkdir( (const char *) nd, 0777 ) != 0){ 650 if( mkdir( (const char *) nd, 0777 ) != 0){
651 QMessageBox::warning( this, tr( "New folder" ), 651 QMessageBox::warning( this, tr( "New folder" ),
652 tr( "Folder creation failed!" ), 652 tr( "Folder creation failed!" ),
653 tr( "Ok" ) ); 653 tr( "Ok" ) );
654 return; 654 return;
655 } 655 }
656 updateDir(); 656 updateDir();
657 657
658 if((i = (FileItem *) firstChild()) == 0) return; 658 if((i = (FileItem *) firstChild()) == 0) return;
659 659
660 while( i ){ 660 while( i ){
661 if( i->isDir() && ( i->getFilePath() == nd ) ){ 661 if( i->isDir() && ( i->getFilePath() == nd ) ){
662 setCurrentItem( i ); 662 setCurrentItem( i );
663 rename(); 663 rename();
664 break; 664 break;
665 } 665 }
666 i = (FileItem *) i->nextSibling(); 666 i = (FileItem *) i->nextSibling();
667 } 667 }
668} 668}
669 669
670void FileView::viewAsText() 670void FileView::viewAsText()
671{ 671{
672 FileItem * i = (FileItem *) currentItem(); 672 FileItem * i = (FileItem *) currentItem();
673 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); 673 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)");
674 e << i->getFilePath(); 674 e << i->getFilePath();
675// Global::execute( "textedit -f ", i->getFilePath() ); 675// Global::execute( "textedit -f ", i->getFilePath() );
676} 676}
677 677
678void FileView::itemClicked( QListViewItem * i) 678void FileView::itemClicked( QListViewItem * i)
679{ 679{
680 FileItem * t = (FileItem *) i; 680 FileItem * t = (FileItem *) i;
681 681
682 if( t == NULL ) return; 682 if( t == NULL ) return;
683 if( t->isDir() ){ 683 if( t->isDir() ){
684 setDir( t->getFilePath() ); 684 setDir( t->getFilePath() );
685 } 685 }
686} 686}
687 687
688void FileView::itemDblClicked( QListViewItem * i) 688void FileView::itemDblClicked( QListViewItem * i)
689{ 689{
690 if(menuKeepsOpen){ 690 if(menuKeepsOpen){
691 cancelMenuTimer(); 691 cancelMenuTimer();
692 } 692 }
693 693
694 FileItem * t = (FileItem *) i; 694 FileItem * t = (FileItem *) i;
695 695
696 if(t == NULL) return; 696 if(t == NULL) return;
697 if(t->launch() == -1){ 697 if(t->launch() == -1){
698 QMessageBox::warning( this, tr( "Launch Application" ), 698 QMessageBox::warning( this, tr( "Launch Application" ),
699 tr( "Launch failed!" ), tr( "Ok" ) ); 699 tr( "Launch failed!" ), tr( "Ok" ) );
700 } 700 }
701} 701}
702 702
703void FileView::parentDir() 703void FileView::parentDir()
704{ 704{
705 setDir( currentDir + "./.." ); 705 setDir( currentDir + "./.." );
706} 706}
707 707
708void FileView::lastDir() 708void FileView::lastDir()
709{ 709{
710 if( dirHistory.count() == 0 ) return; 710 if( dirHistory.count() == 0 ) return;
711 711
712 QString newDir = dirHistory.last(); 712 QString newDir = dirHistory.last();
713 dirHistory.remove( dirHistory.last() ); 713 dirHistory.remove( dirHistory.last() );
714 generateDir( newDir ); 714 generateDir( newDir );
715} 715}
716 716
717void FileView::contentsMousePressEvent( QMouseEvent * e ) 717void FileView::contentsMousePressEvent( QMouseEvent * e )
718{ 718{
719 QListView::contentsMousePressEvent( e ); 719 QListView::contentsMousePressEvent( e );
720 menuTimer.start( 750, TRUE ); 720 menuTimer.start( 750, TRUE );
721} 721}
722 722
723void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) 723void FileView::contentsMouseReleaseEvent( QMouseEvent * e )
724{ 724{
725 QListView::contentsMouseReleaseEvent( e ); 725 QListView::contentsMouseReleaseEvent( e );
726 if(!menuKeepsOpen){ 726 if(!menuKeepsOpen){
727 menuTimer.stop(); 727 menuTimer.stop();
728 } 728 }
729 729
730} 730}
731 731
732void FileView::cancelMenuTimer() 732void FileView::cancelMenuTimer()
733{ 733{
734 if( menuTimer.isActive() ) 734 if( menuTimer.isActive() )
735 menuTimer.stop(); 735 menuTimer.stop();
736} 736}
737 737
738void FileView::addToDocuments() 738void FileView::addToDocuments()
739{ 739{
740 FileItem * i = (FileItem *) currentItem(); 740 FileItem * i = (FileItem *) currentItem();
741 DocLnk f; 741 DocLnk f;
742 QString n = i->text(0); 742 QString n = i->text(0);
743 n.replace(QRegExp("\\..*"),""); 743 n.replace(QRegExp("\\..*"),"");
744 f.setName( n ); 744 f.setName( n );
745 f.setFile( i->getFilePath() ); 745 f.setFile( i->getFilePath() );
746 f.writeLink(); 746 f.writeLink();
747} 747}
748 748
749void FileView::run() 749void FileView::run()
750{ 750{
751 FileItem * i = (FileItem *) currentItem(); 751 FileItem * i = (FileItem *) currentItem();
752 i->launch(); 752 i->launch();
753} 753}
754 754
@@ -919,211 +919,211 @@ void FileBrowser::init(const QString & dir)
919 pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), 919 pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ),
920 QString::null, 0, this, 0 ); 920 QString::null, 0, this, 0 );
921 connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); 921 connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) );
922 pasteAction->addTo( toolBar ); 922 pasteAction->addTo( toolBar );
923 923
924// dirLabel = new QLabel(this, "DirLabel"); 924// dirLabel = new QLabel(this, "DirLabel");
925 925
926 connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) ); 926 connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) );
927 updateDirMenu(); 927 updateDirMenu();
928 928
929 QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); 929 QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this );
930 connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), 930 connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)),
931 this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); 931 this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) );
932} 932}
933 933
934void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) 934void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &)
935{ 935{
936 if ( msg == "mtabChanged()" ) { 936 if ( msg == "mtabChanged()" ) {
937 // ## Only really needed if current dir is on a card 937 // ## Only really needed if current dir is on a card
938 fileView->updateDir(); 938 fileView->updateDir();
939 } 939 }
940} 940}
941 941
942void FileBrowser::changeCaption(const QString & dir) { 942void FileBrowser::changeCaption(const QString & dir) {
943 setCaption( dir); 943 setCaption( dir);
944} 944}
945 945
946void FileBrowser::dirSelected( int id ) 946void FileBrowser::dirSelected( int id )
947{ 947{
948 int i = 0, j; 948 int i = 0, j;
949 QString dir; 949 QString dir;
950 950
951 // Bulid target dir from menu 951 // Bulid target dir from menu
952 while( (j = dirMenu->idAt( i )) != id ){ 952 while( (j = dirMenu->idAt( i )) != id ){
953 dir += dirMenu->text( j ).stripWhiteSpace(); 953 dir += dirMenu->text( j ).stripWhiteSpace();
954 if( dirMenu->text( j ) != "/" ) dir += "/"; 954 if( dirMenu->text( j ) != "/" ) dir += "/";
955 i++; 955 i++;
956 } 956 }
957 dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); 957 dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace();
958 958
959 fileView->setDir( dir ); 959 fileView->setDir( dir );
960} 960}
961 961
962void FileBrowser::updateDirMenu() 962void FileBrowser::updateDirMenu()
963{ 963{
964 QString spc, cd = fileView->cd(); 964 QString spc, cd = fileView->cd();
965 QStringList l = QStringList::split( "/", cd ); 965 QStringList l = QStringList::split( "/", cd );
966 int i = 0; 966 int i = 0;
967 967
968 dirMenu->clear(); 968 dirMenu->clear();
969 dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) ); 969 dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) );
970 970
971 for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { 971 for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
972 spc.fill( ' ', i++); 972 spc.fill( ' ', i++);
973 dirMenu->insertItem( spc + (*it), this, 973 dirMenu->insertItem( spc + (*it), this,
974 SLOT( dirSelected(int) ) ); 974 SLOT( dirSelected(int) ) );
975 } 975 }
976 dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); 976 dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE );
977 977
978 lastAction->setEnabled( fileView->history().count() != 0 ); 978 lastAction->setEnabled( fileView->history().count() != 0 );
979 upAction->setEnabled( cd != "/" ); 979 upAction->setEnabled( cd != "/" );
980} 980}
981 981
982void FileBrowser::sortName() 982void FileBrowser::sortName()
983{ 983{
984 fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 984 fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
985 fileView->sort(); 985 fileView->sort();
986 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); 986 sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE );
987 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); 987 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE );
988 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); 988 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE );
989 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); 989 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE );
990} 990}
991 991
992void FileBrowser::sortSize() 992void FileBrowser::sortSize()
993{ 993{
994 fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 994 fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
995 fileView->sort(); 995 fileView->sort();
996 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); 996 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE );
997 sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE ); 997 sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE );
998 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); 998 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE );
999 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); 999 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE );
1000} 1000}
1001 1001
1002void FileBrowser::sortDate() 1002void FileBrowser::sortDate()
1003{ 1003{
1004 fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 1004 fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
1005 fileView->sort(); 1005 fileView->sort();
1006 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); 1006 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE );
1007 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); 1007 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE );
1008 sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); 1008 sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE );
1009 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); 1009 sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE );
1010} 1010}
1011 1011
1012void FileBrowser::sortType() 1012void FileBrowser::sortType()
1013{ 1013{
1014 fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 1014 fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
1015 fileView->sort(); 1015 fileView->sort();
1016 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); 1016 sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE );
1017 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); 1017 sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE );
1018 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); 1018 sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE );
1019 sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); 1019 sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE );
1020} 1020}
1021 1021
1022void FileBrowser::updateSorting() 1022void FileBrowser::updateSorting()
1023{ 1023{
1024 sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); 1024 sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) );
1025 1025
1026 if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) 1026 if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) )
1027 sortName(); 1027 sortName();
1028 else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) 1028 else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) )
1029 sortSize(); 1029 sortSize();
1030 else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) 1030 else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) )
1031 sortDate(); 1031 sortDate();
1032 else 1032 else
1033 sortType(); 1033 sortType();
1034} 1034}
1035 1035
1036void FileView::chPerm() { 1036void FileView::chPerm() {
1037 FileItem * i; 1037 FileItem * i;
1038 QStringList fl; 1038 QStringList fl;
1039 QString cmd; 1039 QString cmd;
1040 1040
1041 if((i = (FileItem *) firstChild()) == 0) return; 1041 if((i = (FileItem *) firstChild()) == 0) return;
1042 1042
1043 while( i ){ 1043 while( i ){
1044 if( i->isSelected() ){ 1044 if( i->isSelected() ){
1045 fl += i->getFilePath(); 1045 fl += i->getFilePath();
1046 } 1046 }
1047 i = (FileItem *) i->nextSibling(); 1047 i = (FileItem *) i->nextSibling();
1048 } 1048 }
1049 if( fl.count() < 1 ) return; 1049 if( fl.count() < 1 ) return;
1050 if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), 1050 if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"),
1051 tr("Yes"), tr("No") ) == 0) { 1051 tr("Yes"), tr("No") ) == 0) {
1052 for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { 1052 for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) {
1053 filePermissions *filePerm; 1053 filePermissions *filePerm;
1054 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); 1054 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it));
1055 filePerm->exec(); 1055 filePerm->exec();
1056 if( filePerm) 1056 if( filePerm)
1057 delete filePerm; 1057 delete filePerm;
1058 break; 1058 break;
1059 } 1059 }
1060 updateDir(); 1060 updateDir();
1061 } 1061 }
1062} 1062}
1063 1063
1064void FileBrowser::updateShowHidden() 1064void FileBrowser::updateShowHidden()
1065{ 1065{
1066 bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) ); 1066 bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) );
1067 valShowHidden=!valShowHidden; 1067 valShowHidden=!valShowHidden;
1068 viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden ); 1068 viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden );
1069 fileView->setShowHidden(valShowHidden); 1069 fileView->setShowHidden(valShowHidden);
1070 1070
1071 Config cfg("Filebrowser"); 1071 Config cfg("Filebrowser");
1072 cfg.setGroup("View"); 1072 cfg.setGroup("View");
1073 cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE"); 1073 cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE");
1074 1074
1075 fileView->updateDir(); 1075 fileView->updateDir();
1076} 1076}
1077 1077
1078void FileBrowser::updateShowSymlinks() 1078void FileBrowser::updateShowSymlinks()
1079{ 1079{
1080 bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) ); 1080 bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) );
1081 valShowSymlinks=!valShowSymlinks; 1081 valShowSymlinks=!valShowSymlinks;
1082 viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks ); 1082 viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks );
1083 fileView->setShowSymlinks(valShowSymlinks); 1083 fileView->setShowSymlinks(valShowSymlinks);
1084 1084
1085 Config cfg("Filebrowser"); 1085 Config cfg("Filebrowser");
1086 cfg.setGroup("View"); 1086 cfg.setGroup("View");
1087 cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE"); 1087 cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE");
1088 1088
1089 fileView->updateDir(); 1089 fileView->updateDir();
1090} 1090}
1091 1091
1092void FileBrowser::updateShowThumbnails() 1092void FileBrowser::updateShowThumbnails()
1093{ 1093{
1094 bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); 1094 bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) );
1095 valShowThumbnails=!valShowThumbnails; 1095 valShowThumbnails=!valShowThumbnails;
1096 viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); 1096 viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails );
1097 fileView->setShowThumbnails(valShowThumbnails); 1097 fileView->setShowThumbnails(valShowThumbnails);
1098 1098
1099 Config cfg("Filebrowser"); 1099 Config cfg("Filebrowser");
1100 cfg.setGroup("View"); 1100 cfg.setGroup("View");
1101 cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); 1101 cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE");
1102 1102
1103 fileView->updateDir(); 1103 fileView->updateDir();
1104} 1104}
1105 1105
1106void FileBrowser::cleanUp() { 1106void FileBrowser::cleanUp() {
1107 QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; 1107 QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache";
1108// qDebug("exit"); 1108// qDebug("exit");
1109 system(cmdr.latin1()); 1109 system(cmdr.latin1());
1110} 1110}
1111 1111
1112{ 1112{
1113 bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); 1113 bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) );
1114 valShowThumbnails=!valShowThumbnails; 1114 valShowThumbnails=!valShowThumbnails;
1115 viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); 1115 viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails );
1116 fileView->setShowThumbnails(valShowThumbnails); 1116 fileView->setShowThumbnails(valShowThumbnails);
1117 1117
1118 Config cfg("Filebrowser"); 1118 Config cfg("Filebrowser");
1119 cfg.setGroup("View"); 1119 cfg.setGroup("View");
1120 cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); 1120 cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE");
1121 1121
1122 fileView->updateDir(); 1122 fileView->updateDir();
1123} 1123}
1124 1124
1125void FileBrowser::cleanUp() { 1125void FileBrowser::cleanUp() {
1126 QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; 1126 QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache";
1127// qDebug("exit"); 1127// qDebug("exit");
1128 system(cmdr.latin1()); 1128 system(cmdr.latin1());
1129} 1129}