-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp index 384d7da..eaf5eeb 100644 --- a/noncore/unsupported/filebrowser/filebrowser.cpp +++ b/noncore/unsupported/filebrowser/filebrowser.cpp | |||
@@ -401,480 +401,480 @@ bool FileView::copyFile( const QString & dest, const QString & src ) | |||
401 | } | 401 | } |
402 | } | 402 | } |
403 | if( success && (bytesRead > 0) ){ | 403 | if( success && (bytesRead > 0) ){ |
404 | d.writeBlock( bf, bytesRead ); | 404 | d.writeBlock( bf, bytesRead ); |
405 | } | 405 | } |
406 | } else { | 406 | } else { |
407 | success = FALSE; | 407 | success = FALSE; |
408 | } | 408 | } |
409 | 409 | ||
410 | // Set file permissions | 410 | // Set file permissions |
411 | if( stat( (const char *) src, &status ) == 0 ){ | 411 | if( stat( (const char *) src, &status ) == 0 ){ |
412 | chmod( (const char *) dest, status.st_mode ); | 412 | chmod( (const char *) dest, status.st_mode ); |
413 | } | 413 | } |
414 | 414 | ||
415 | return success; | 415 | return success; |
416 | } | 416 | } |
417 | 417 | ||
418 | void FileView::cut() | 418 | void FileView::cut() |
419 | { | 419 | { |
420 | int err; | 420 | int err; |
421 | // ##### a better inmplementation might be to rename the CUT file | 421 | // ##### a better inmplementation might be to rename the CUT file |
422 | // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. | 422 | // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. |
423 | QString cmd, dest, basename, cd = "/tmp/qpemoving"; | 423 | QString cmd, dest, basename, cd = "/tmp/qpemoving"; |
424 | QStringList newflist; | 424 | QStringList newflist; |
425 | newflist.clear(); | 425 | newflist.clear(); |
426 | 426 | ||
427 | cmd = "rm -rf " + cd; | 427 | cmd = "rm -rf " + cd; |
428 | system ( (const char *) cmd ); | 428 | system ( (const char *) cmd ); |
429 | cmd = "mkdir " + cd; | 429 | cmd = "mkdir " + cd; |
430 | system( (const char *) cmd ); | 430 | system( (const char *) cmd ); |
431 | 431 | ||
432 | // get the names of the files to cut | 432 | // get the names of the files to cut |
433 | FileItem * item; | 433 | FileItem * item; |
434 | 434 | ||
435 | if((item = (FileItem *) firstChild()) == 0) return; | 435 | if((item = (FileItem *) firstChild()) == 0) return; |
436 | 436 | ||
437 | flist.clear(); | 437 | flist.clear(); |
438 | while( item ){ | 438 | while( item ){ |
439 | if( item->isSelected() /*&& !item->isDir()*/ ){ | 439 | if( item->isSelected() /*&& !item->isDir()*/ ){ |
440 | flist += item->getFilePath(); | 440 | flist += item->getFilePath(); |
441 | } | 441 | } |
442 | item = (FileItem *) item->nextSibling(); | 442 | item = (FileItem *) item->nextSibling(); |
443 | } | 443 | } |
444 | 444 | ||
445 | // move these files into a tmp dir | 445 | // move these files into a tmp dir |
446 | for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { | 446 | for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { |
447 | basename = (*it).mid((*it).findRev("/") + 1, (*it).length()); | 447 | basename = (*it).mid((*it).findRev("/") + 1, (*it).length()); |
448 | 448 | ||
449 | dest = cd + "/" + basename; | 449 | dest = cd + "/" + basename; |
450 | 450 | ||
451 | newflist += dest; | 451 | newflist += dest; |
452 | 452 | ||
453 | cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\""; | 453 | cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\""; |
454 | err = system( (const char *) cmd ); | 454 | err = system( (const char *) cmd ); |
455 | 455 | ||
456 | if ( err != 0 ) { | 456 | if ( err != 0 ) { |
457 | QMessageBox::warning( this, tr("Cut file"), tr("Cut failed!"), | 457 | QMessageBox::warning( this, tr("Cut file"), tr("Cut failed!"), |
458 | tr("Ok") ); | 458 | tr("Ok") ); |
459 | break; | 459 | break; |
460 | } else { | 460 | } else { |
461 | updateDir(); | 461 | updateDir(); |
462 | QListViewItem * im = firstChild(); | 462 | QListViewItem * im = firstChild(); |
463 | basename = dest.mid( dest.findRev("/") + 1, dest.length() ); | 463 | basename = dest.mid( dest.findRev("/") + 1, dest.length() ); |
464 | 464 | ||
465 | while( im ){ | 465 | while( im ){ |
466 | if( im->text(0) == basename ){ | 466 | if( im->text(0) == basename ){ |
467 | setCurrentItem( im ); | 467 | setCurrentItem( im ); |
468 | ensureItemVisible( im ); | 468 | ensureItemVisible( im ); |
469 | break; | 469 | break; |
470 | } | 470 | } |
471 | im = im->nextSibling(); | 471 | im = im->nextSibling(); |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | // update the filelist to point to tmp dir so paste works nicely | 476 | // update the filelist to point to tmp dir so paste works nicely |
477 | flist = newflist; | 477 | flist = newflist; |
478 | } | 478 | } |
479 | 479 | ||
480 | void FileView::del() | 480 | void FileView::del() |
481 | { | 481 | { |
482 | FileItem * i; | 482 | FileItem * i; |
483 | QStringList fl; | 483 | QStringList fl; |
484 | QString cmd; | 484 | QString cmd; |
485 | int err; | 485 | int err; |
486 | 486 | ||
487 | if((i = (FileItem *) firstChild()) == 0) return; | 487 | if((i = (FileItem *) firstChild()) == 0) return; |
488 | 488 | ||
489 | while( i ){ | 489 | while( i ){ |
490 | if( i->isSelected() ){ | 490 | if( i->isSelected() ){ |
491 | fl += i->getFilePath(); | 491 | fl += i->getFilePath(); |
492 | } | 492 | } |
493 | i = (FileItem *) i->nextSibling(); | 493 | i = (FileItem *) i->nextSibling(); |
494 | } | 494 | } |
495 | if( fl.count() < 1 ) return; | 495 | if( fl.count() < 1 ) return; |
496 | 496 | ||
497 | if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"), | 497 | if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"), |
498 | tr("Yes"), tr("No") ) == 0) | 498 | tr("Yes"), tr("No") ) == 0) |
499 | { | 499 | { |
500 | // | 500 | // |
501 | // Dependant upon the "rm" command - will probably have to be replaced | 501 | // Dependant upon the "rm" command - will probably have to be replaced |
502 | // | 502 | // |
503 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { | 503 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { |
504 | cmd = "/bin/rm -rf \"" + (*it) + "\""; | 504 | cmd = "/bin/rm -rf \"" + (*it) + "\""; |
505 | err = system( (const char *) cmd ); | 505 | err = system( (const char *) cmd ); |
506 | if ( err != 0 ) { | 506 | if ( err != 0 ) { |
507 | QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), | 507 | QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), |
508 | tr("Ok") ); | 508 | tr("Ok") ); |
509 | break; | 509 | break; |
510 | } | 510 | } |
511 | } | 511 | } |
512 | updateDir(); | 512 | updateDir(); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | void FileView::newFolder() | 516 | void FileView::newFolder() |
517 | { | 517 | { |
518 | int t = 1; | 518 | int t = 1; |
519 | FileItem * i; | 519 | FileItem * i; |
520 | QString nd = currentDir + "/NewFolder"; | 520 | QString nd = currentDir + "/NewFolder"; |
521 | 521 | ||
522 | while( QFile( nd ).exists() ){ | 522 | while( QFile( nd ).exists() ){ |
523 | nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); | 523 | nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); |
524 | } | 524 | } |
525 | 525 | ||
526 | if( mkdir( (const char *) nd, 0777 ) != 0){ | 526 | if( mkdir( (const char *) nd, 0777 ) != 0){ |
527 | QMessageBox::warning( this, tr( "New folder" ), | 527 | QMessageBox::warning( this, tr( "New folder" ), |
528 | tr( "Folder creation failed!" ), | 528 | tr( "Folder creation failed!" ), |
529 | tr( "Ok" ) ); | 529 | tr( "Ok" ) ); |
530 | return; | 530 | return; |
531 | } | 531 | } |
532 | updateDir(); | 532 | updateDir(); |
533 | 533 | ||
534 | if((i = (FileItem *) firstChild()) == 0) return; | 534 | if((i = (FileItem *) firstChild()) == 0) return; |
535 | 535 | ||
536 | while( i ){ | 536 | while( i ){ |
537 | if( i->isDir() && ( i->getFilePath() == nd ) ){ | 537 | if( i->isDir() && ( i->getFilePath() == nd ) ){ |
538 | setCurrentItem( i ); | 538 | setCurrentItem( i ); |
539 | rename(); | 539 | rename(); |
540 | break; | 540 | break; |
541 | } | 541 | } |
542 | i = (FileItem *) i->nextSibling(); | 542 | i = (FileItem *) i->nextSibling(); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | 545 | ||
546 | void FileView::viewAsText() | 546 | void FileView::viewAsText() |
547 | { | 547 | { |
548 | FileItem * i = (FileItem *) currentItem(); | 548 | FileItem * i = (FileItem *) currentItem(); |
549 | Global::execute( "textedit -f ", i->getFilePath() ); | 549 | Global::execute( "textedit -f ", i->getFilePath() ); |
550 | } | 550 | } |
551 | 551 | ||
552 | void FileView::itemClicked( QListViewItem * i) | 552 | void FileView::itemClicked( QListViewItem * i) |
553 | { | 553 | { |
554 | FileItem * t = (FileItem *) i; | 554 | FileItem * t = (FileItem *) i; |
555 | 555 | ||
556 | if( t == NULL ) return; | 556 | if( t == NULL ) return; |
557 | if( t->isDir() ){ | 557 | if( t->isDir() ){ |
558 | setDir( t->getFilePath() ); | 558 | setDir( t->getFilePath() ); |
559 | } | 559 | } |
560 | } | 560 | } |
561 | 561 | ||
562 | void FileView::itemDblClicked( QListViewItem * i) | 562 | void FileView::itemDblClicked( QListViewItem * i) |
563 | { | 563 | { |
564 | FileItem * t = (FileItem *) i; | 564 | FileItem * t = (FileItem *) i; |
565 | 565 | ||
566 | if(t == NULL) return; | 566 | if(t == NULL) return; |
567 | if(t->launch() == -1){ | 567 | if(t->launch() == -1){ |
568 | QMessageBox::warning( this, tr( "Launch Application" ), | 568 | QMessageBox::warning( this, tr( "Launch Application" ), |
569 | tr( "Launch failed!" ), tr( "Ok" ) ); | 569 | tr( "Launch failed!" ), tr( "Ok" ) ); |
570 | } | 570 | } |
571 | } | 571 | } |
572 | 572 | ||
573 | void FileView::parentDir() | 573 | void FileView::parentDir() |
574 | { | 574 | { |
575 | setDir( currentDir + "./.." ); | 575 | setDir( currentDir + "./.." ); |
576 | } | 576 | } |
577 | 577 | ||
578 | void FileView::lastDir() | 578 | void FileView::lastDir() |
579 | { | 579 | { |
580 | if( dirHistory.count() == 0 ) return; | 580 | if( dirHistory.count() == 0 ) return; |
581 | 581 | ||
582 | QString newDir = dirHistory.last(); | 582 | QString newDir = dirHistory.last(); |
583 | dirHistory.remove( dirHistory.last() ); | 583 | dirHistory.remove( dirHistory.last() ); |
584 | generateDir( newDir ); | 584 | generateDir( newDir ); |
585 | } | 585 | } |
586 | 586 | ||
587 | void FileView::contentsMousePressEvent( QMouseEvent * e ) | 587 | void FileView::contentsMousePressEvent( QMouseEvent * e ) |
588 | { | 588 | { |
589 | QListView::contentsMousePressEvent( e ); | 589 | QListView::contentsMousePressEvent( e ); |
590 | menuTimer.start( 750, TRUE ); | 590 | menuTimer.start( 750, TRUE ); |
591 | } | 591 | } |
592 | 592 | ||
593 | void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) | 593 | void FileView::contentsMouseReleaseEvent( QMouseEvent * e ) |
594 | { | 594 | { |
595 | QListView::contentsMouseReleaseEvent( e ); | 595 | QListView::contentsMouseReleaseEvent( e ); |
596 | menuTimer.stop(); | 596 | menuTimer.stop(); |
597 | } | 597 | } |
598 | 598 | ||
599 | void FileView::cancelMenuTimer() | 599 | void FileView::cancelMenuTimer() |
600 | { | 600 | { |
601 | if( menuTimer.isActive() ) | 601 | if( menuTimer.isActive() ) |
602 | menuTimer.stop(); | 602 | menuTimer.stop(); |
603 | } | 603 | } |
604 | 604 | ||
605 | void FileView::addToDocuments() | 605 | void FileView::addToDocuments() |
606 | { | 606 | { |
607 | FileItem * i = (FileItem *) currentItem(); | 607 | FileItem * i = (FileItem *) currentItem(); |
608 | DocLnk f; | 608 | DocLnk f; |
609 | QString n = i->text(0); | 609 | QString n = i->text(0); |
610 | n.replace(QRegExp("\\..*"),""); | 610 | n.replace(QRegExp("\\..*"),""); |
611 | f.setName( n ); | 611 | f.setName( n ); |
612 | f.setFile( i->getFilePath() ); | 612 | f.setFile( i->getFilePath() ); |
613 | f.writeLink(); | 613 | f.writeLink(); |
614 | } | 614 | } |
615 | 615 | ||
616 | void FileView::run() | 616 | void FileView::run() |
617 | { | 617 | { |
618 | FileItem * i = (FileItem *) currentItem(); | 618 | FileItem * i = (FileItem *) currentItem(); |
619 | i->launch(); | 619 | i->launch(); |
620 | } | 620 | } |
621 | 621 | ||
622 | void FileView::showFileMenu() | 622 | void FileView::showFileMenu() |
623 | { | 623 | { |
624 | FileItem * i = (FileItem *) currentItem(); | 624 | FileItem * i = (FileItem *) currentItem(); |
625 | if ( !i ) | 625 | if ( !i ) |
626 | return; | 626 | return; |
627 | 627 | ||
628 | QPopupMenu * m = new QPopupMenu( this ); | 628 | QPopupMenu * m = new QPopupMenu( this ); |
629 | 629 | ||
630 | if ( !i->isDir() ) { | 630 | if ( !i->isDir() ) { |
631 | m->insertItem( tr( "Add to Documents" ), this, SLOT( addToDocuments() ) ); | 631 | m->insertItem( tr( "Add to Documents" ), this, SLOT( addToDocuments() ) ); |
632 | m->insertSeparator(); | 632 | m->insertSeparator(); |
633 | } | 633 | } |
634 | 634 | ||
635 | MimeType mt(i->getFilePath()); | 635 | MimeType mt(i->getFilePath()); |
636 | const AppLnk* app = mt.application(); | 636 | const AppLnk* app = mt.application(); |
637 | 637 | ||
638 | if ( !i->isDir() ) { | 638 | if ( !i->isDir() ) { |
639 | if ( app ) | 639 | if ( app ) |
640 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( run() ) ); | 640 | m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( run() ) ); |
641 | else if( i->isExecutable() ) | 641 | else if( i->isExecutable() ) |
642 | m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) ); | 642 | m->insertItem( Resource::loadPixmap( i->text( 0 ) ), tr( "Run" ), this, SLOT( run() ) ); |
643 | 643 | ||
644 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ), | 644 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "View as text" ), |
645 | this, SLOT( viewAsText() ) ); | 645 | this, SLOT( viewAsText() ) ); |
646 | 646 | ||
647 | m->insertSeparator(); | 647 | m->insertSeparator(); |
648 | } | 648 | } |
649 | 649 | ||
650 | m->insertItem( tr( "Rename" ), this, SLOT( rename() ) ); | 650 | m->insertItem( tr( "Rename" ), this, SLOT( rename() ) ); |
651 | m->insertItem( Resource::loadPixmap("cut"), | 651 | m->insertItem( Resource::loadPixmap("cut"), |
652 | tr( "Cut" ), this, SLOT( cut() ) ); | 652 | tr( "Cut" ), this, SLOT( cut() ) ); |
653 | m->insertItem( Resource::loadPixmap("copy"), | 653 | m->insertItem( Resource::loadPixmap("copy"), |
654 | tr( "Copy" ), this, SLOT( copy() ) ); | 654 | tr( "Copy" ), this, SLOT( copy() ) ); |
655 | m->insertItem( Resource::loadPixmap("paste"), | 655 | m->insertItem( Resource::loadPixmap("paste"), |
656 | tr( "Paste" ), this, SLOT( paste() ) ); | 656 | tr( "Paste" ), this, SLOT( paste() ) ); |
657 | m->insertItem( tr( "change permissions" ), this, SLOT( chPerm() ) ); | 657 | m->insertItem( tr( "Change Permissions" ), this, SLOT( chPerm() ) ); |
658 | m->insertItem( tr( "Delete" ), this, SLOT( del() ) ); | 658 | m->insertItem( tr( "Delete" ), this, SLOT( del() ) ); |
659 | m->insertSeparator(); | 659 | m->insertSeparator(); |
660 | m->insertItem( tr( "Select all" ), this, SLOT( selectAll() ) ); | 660 | m->insertItem( tr( "Select all" ), this, SLOT( selectAll() ) ); |
661 | m->insertItem( tr( "Deselect all" ), this, SLOT( deselectAll() ) ); | 661 | m->insertItem( tr( "Deselect all" ), this, SLOT( deselectAll() ) ); |
662 | m->popup( QCursor::pos() ); | 662 | m->popup( QCursor::pos() ); |
663 | } | 663 | } |
664 | 664 | ||
665 | // | 665 | // |
666 | // FileBrowser | 666 | // FileBrowser |
667 | // | 667 | // |
668 | 668 | ||
669 | FileBrowser::FileBrowser( QWidget * parent, | 669 | FileBrowser::FileBrowser( QWidget * parent, |
670 | const char * name, WFlags f ) : | 670 | const char * name, WFlags f ) : |
671 | QMainWindow( parent, name, f ) | 671 | QMainWindow( parent, name, f ) |
672 | { | 672 | { |
673 | init( QDir::current().canonicalPath() ); | 673 | init( QDir::current().canonicalPath() ); |
674 | } | 674 | } |
675 | 675 | ||
676 | FileBrowser::FileBrowser( const QString & dir, QWidget * parent, | 676 | FileBrowser::FileBrowser( const QString & dir, QWidget * parent, |
677 | const char * name, WFlags f ) : | 677 | const char * name, WFlags f ) : |
678 | QMainWindow( parent, name, f ) | 678 | QMainWindow( parent, name, f ) |
679 | { | 679 | { |
680 | init( dir ); | 680 | init( dir ); |
681 | } | 681 | } |
682 | 682 | ||
683 | void FileBrowser::init(const QString & dir) | 683 | void FileBrowser::init(const QString & dir) |
684 | { | 684 | { |
685 | setCaption( tr("File Manager") ); | 685 | setCaption( tr("File Manager") ); |
686 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); | 686 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); |
687 | 687 | ||
688 | fileView = new FileView( dir, this ); | 688 | fileView = new FileView( dir, this ); |
689 | fileView->setAllColumnsShowFocus( TRUE ); | 689 | fileView->setAllColumnsShowFocus( TRUE ); |
690 | 690 | ||
691 | setCentralWidget( fileView ); | 691 | setCentralWidget( fileView ); |
692 | setToolBarsMovable( FALSE ); | 692 | setToolBarsMovable( FALSE ); |
693 | 693 | ||
694 | QPEToolBar* toolBar = new QPEToolBar( this ); | 694 | QPEToolBar* toolBar = new QPEToolBar( this ); |
695 | toolBar->setHorizontalStretchable( TRUE ); | 695 | toolBar->setHorizontalStretchable( TRUE ); |
696 | 696 | ||
697 | QPEMenuBar* menuBar = new QPEMenuBar( toolBar ); | 697 | QPEMenuBar* menuBar = new QPEMenuBar( toolBar ); |
698 | 698 | ||
699 | dirMenu = new QPopupMenu( this ); | 699 | dirMenu = new QPopupMenu( this ); |
700 | menuBar->insertItem( tr( "Dir" ), dirMenu ); | 700 | menuBar->insertItem( tr( "Dir" ), dirMenu ); |
701 | 701 | ||
702 | sortMenu = new QPopupMenu( this ); | 702 | sortMenu = new QPopupMenu( this ); |
703 | menuBar->insertItem( tr( "Sort" ), sortMenu ); | 703 | menuBar->insertItem( tr( "Sort" ), sortMenu ); |
704 | sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); | 704 | sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); |
705 | sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); | 705 | sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); |
706 | sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); | 706 | sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); |
707 | sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); | 707 | sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); |
708 | sortMenu->insertSeparator(); | 708 | sortMenu->insertSeparator(); |
709 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); | 709 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); |
710 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); | 710 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); |
711 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); | 711 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); |
712 | 712 | ||
713 | toolBar = new QPEToolBar( this ); | 713 | toolBar = new QPEToolBar( this ); |
714 | 714 | ||
715 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), | 715 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), |
716 | QString::null, 0, this, 0 ); | 716 | QString::null, 0, this, 0 ); |
717 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); | 717 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); |
718 | lastAction->addTo( toolBar ); | 718 | lastAction->addTo( toolBar ); |
719 | lastAction->setEnabled( FALSE ); | 719 | lastAction->setEnabled( FALSE ); |
720 | 720 | ||
721 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), | 721 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), |
722 | QString::null, 0, this, 0 ); | 722 | QString::null, 0, this, 0 ); |
723 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); | 723 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); |
724 | upAction->addTo( toolBar ); | 724 | upAction->addTo( toolBar ); |
725 | 725 | ||
726 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), | 726 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), |
727 | QString::null, 0, this, 0 ); | 727 | QString::null, 0, this, 0 ); |
728 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); | 728 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); |
729 | a->addTo( toolBar ); | 729 | a->addTo( toolBar ); |
730 | 730 | ||
731 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), | 731 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), |
732 | QString::null, 0, this, 0 ); | 732 | QString::null, 0, this, 0 ); |
733 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); | 733 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); |
734 | a->addTo( toolBar ); | 734 | a->addTo( toolBar ); |
735 | 735 | ||
736 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), | 736 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), |
737 | QString::null, 0, this, 0 ); | 737 | QString::null, 0, this, 0 ); |
738 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); | 738 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); |
739 | a->addTo( toolBar ); | 739 | a->addTo( toolBar ); |
740 | 740 | ||
741 | pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), | 741 | pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), |
742 | QString::null, 0, this, 0 ); | 742 | QString::null, 0, this, 0 ); |
743 | connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); | 743 | connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); |
744 | pasteAction->addTo( toolBar ); | 744 | pasteAction->addTo( toolBar ); |
745 | 745 | ||
746 | 746 | ||
747 | connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) ); | 747 | connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) ); |
748 | updateDirMenu(); | 748 | updateDirMenu(); |
749 | 749 | ||
750 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 750 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
751 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 751 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
752 | this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); | 752 | this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); |
753 | } | 753 | } |
754 | 754 | ||
755 | void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) | 755 | void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) |
756 | { | 756 | { |
757 | if ( msg == "mtabChanged()" ) { | 757 | if ( msg == "mtabChanged()" ) { |
758 | // ## Only really needed if current dir is on a card | 758 | // ## Only really needed if current dir is on a card |
759 | fileView->updateDir(); | 759 | fileView->updateDir(); |
760 | } | 760 | } |
761 | } | 761 | } |
762 | 762 | ||
763 | void FileBrowser::dirSelected( int id ) | 763 | void FileBrowser::dirSelected( int id ) |
764 | { | 764 | { |
765 | int i = 0, j; | 765 | int i = 0, j; |
766 | QString dir; | 766 | QString dir; |
767 | 767 | ||
768 | // Bulid target dir from menu | 768 | // Bulid target dir from menu |
769 | while( (j = dirMenu->idAt( i )) != id ){ | 769 | while( (j = dirMenu->idAt( i )) != id ){ |
770 | dir += dirMenu->text( j ).stripWhiteSpace(); | 770 | dir += dirMenu->text( j ).stripWhiteSpace(); |
771 | if( dirMenu->text( j ) != "/" ) dir += "/"; | 771 | if( dirMenu->text( j ) != "/" ) dir += "/"; |
772 | i++; | 772 | i++; |
773 | } | 773 | } |
774 | dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); | 774 | dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); |
775 | 775 | ||
776 | fileView->setDir( dir ); | 776 | fileView->setDir( dir ); |
777 | } | 777 | } |
778 | 778 | ||
779 | void FileBrowser::updateDirMenu() | 779 | void FileBrowser::updateDirMenu() |
780 | { | 780 | { |
781 | QString spc, cd = fileView->cd(); | 781 | QString spc, cd = fileView->cd(); |
782 | QStringList l = QStringList::split( "/", cd ); | 782 | QStringList l = QStringList::split( "/", cd ); |
783 | int i = 0; | 783 | int i = 0; |
784 | 784 | ||
785 | dirMenu->clear(); | 785 | dirMenu->clear(); |
786 | dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) ); | 786 | dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) ); |
787 | 787 | ||
788 | for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { | 788 | for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { |
789 | spc.fill( ' ', i++); | 789 | spc.fill( ' ', i++); |
790 | dirMenu->insertItem( spc + (*it), this, | 790 | dirMenu->insertItem( spc + (*it), this, |
791 | SLOT( dirSelected(int) ) ); | 791 | SLOT( dirSelected(int) ) ); |
792 | } | 792 | } |
793 | dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); | 793 | dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); |
794 | 794 | ||
795 | lastAction->setEnabled( fileView->history().count() != 0 ); | 795 | lastAction->setEnabled( fileView->history().count() != 0 ); |
796 | upAction->setEnabled( cd != "/" ); | 796 | upAction->setEnabled( cd != "/" ); |
797 | } | 797 | } |
798 | 798 | ||
799 | void FileBrowser::sortName() | 799 | void FileBrowser::sortName() |
800 | { | 800 | { |
801 | fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 801 | fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
802 | fileView->sort(); | 802 | fileView->sort(); |
803 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); | 803 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); |
804 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 804 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
805 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 805 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
806 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 806 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
807 | } | 807 | } |
808 | 808 | ||
809 | void FileBrowser::sortSize() | 809 | void FileBrowser::sortSize() |
810 | { | 810 | { |
811 | fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 811 | fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
812 | fileView->sort(); | 812 | fileView->sort(); |
813 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 813 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
814 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE ); | 814 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE ); |
815 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 815 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
816 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 816 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
817 | } | 817 | } |
818 | 818 | ||
819 | void FileBrowser::sortDate() | 819 | void FileBrowser::sortDate() |
820 | { | 820 | { |
821 | fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 821 | fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
822 | fileView->sort(); | 822 | fileView->sort(); |
823 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 823 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
824 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 824 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
825 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); | 825 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); |
826 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 826 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
827 | } | 827 | } |
828 | 828 | ||
829 | void FileBrowser::sortType() | 829 | void FileBrowser::sortType() |
830 | { | 830 | { |
831 | fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 831 | fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
832 | fileView->sort(); | 832 | fileView->sort(); |
833 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 833 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
834 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 834 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
835 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 835 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
836 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); | 836 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); |
837 | } | 837 | } |
838 | 838 | ||
839 | void FileBrowser::updateSorting() | 839 | void FileBrowser::updateSorting() |
840 | { | 840 | { |
841 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 841 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
842 | 842 | ||
843 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) | 843 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) |
844 | sortName(); | 844 | sortName(); |
845 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) | 845 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) |
846 | sortSize(); | 846 | sortSize(); |
847 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) | 847 | else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) |
848 | sortDate(); | 848 | sortDate(); |
849 | else | 849 | else |
850 | sortType(); | 850 | sortType(); |
851 | } | 851 | } |
852 | 852 | ||
853 | void FileView::chPerm() { | 853 | void FileView::chPerm() { |
854 | FileItem * i; | 854 | FileItem * i; |
855 | QStringList fl; | 855 | QStringList fl; |
856 | QString cmd; | 856 | QString cmd; |
857 | int err; | 857 | int err; |
858 | 858 | ||
859 | if((i = (FileItem *) firstChild()) == 0) return; | 859 | if((i = (FileItem *) firstChild()) == 0) return; |
860 | 860 | ||
861 | while( i ){ | 861 | while( i ){ |
862 | if( i->isSelected() ){ | 862 | if( i->isSelected() ){ |
863 | fl += i->getFilePath(); | 863 | fl += i->getFilePath(); |
864 | } | 864 | } |
865 | i = (FileItem *) i->nextSibling(); | 865 | i = (FileItem *) i->nextSibling(); |
866 | } | 866 | } |
867 | if( fl.count() < 1 ) return; | 867 | if( fl.count() < 1 ) return; |
868 | if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), | 868 | if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), |
869 | tr("Yes"), tr("No") ) == 0) { | 869 | tr("Yes"), tr("No") ) == 0) { |
870 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { | 870 | for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { |
871 | filePermissions *filePerm; | 871 | filePermissions *filePerm; |
872 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); | 872 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); |
873 | filePerm->exec(); | 873 | filePerm->exec(); |
874 | if( filePerm) | 874 | if( filePerm) |
875 | delete filePerm; | 875 | delete filePerm; |
876 | break; | 876 | break; |
877 | } | 877 | } |
878 | updateDir(); | 878 | updateDir(); |
879 | } | 879 | } |
880 | } | 880 | } |