summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-01 01:48:02 (UTC)
committer zecke <zecke>2002-04-01 01:48:02 (UTC)
commit9a68bd2411e65eb6c51aead50a5b0b670174458d (patch) (unidiff)
tree05ab085d430edc2e821ea890da600774abc30f01
parent84850cd8811fc29aa39ecd2452884bf48ea27e92 (diff)
downloadopie-9a68bd2411e65eb6c51aead50a5b0b670174458d.zip
opie-9a68bd2411e65eb6c51aead50a5b0b670174458d.tar.gz
opie-9a68bd2411e65eb6c51aead50a5b0b670174458d.tar.bz2
Almost done ||
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc23
-rw-r--r--libopie/ofileselector.h4
2 files changed, 25 insertions, 2 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 14f035e..fbe69ed 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -366,694 +366,715 @@ void OFileSelector::updateLay()
366 delete m_fnLabel; 366 delete m_fnLabel;
367 m_fnLabel = 0; 367 m_fnLabel = 0;
368 delete m_ok; 368 delete m_ok;
369 m_ok = 0; 369 m_ok = 0;
370 delete m_cancel; 370 delete m_cancel;
371 m_cancel = 0; 371 m_cancel = 0;
372 delete m_mimeCheck; 372 delete m_mimeCheck;
373 m_mimeCheck = 0; 373 m_mimeCheck = 0;
374 delete m_viewCheck; 374 delete m_viewCheck;
375 m_viewCheck = 0; 375 m_viewCheck = 0;
376 delete m_select; // test 376 delete m_select; // test
377 delete m_stack; 377 delete m_stack;
378 //delete m_list; 378 //delete m_list;
379 init(); 379 init();
380 if( m_shLne ) 380 if( m_shLne )
381 m_edit->setText(text ); 381 m_edit->setText(text );
382 if( m_shPerm ) 382 if( m_shPerm )
383 m_checkPerm->setChecked(check ); 383 m_checkPerm->setChecked(check );
384} 384}
385// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve 385// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve
386// insert QListViewItems with the right options 386// insert QListViewItems with the right options
387bool OFileSelector::compliesMime(const QString &path, const QString &mime ) 387bool OFileSelector::compliesMime(const QString &path, const QString &mime )
388{ 388{
389 if( mime == "All" ) 389 if( mime == "All" )
390 return true; 390 return true;
391 MimeType type( path ); 391 MimeType type( path );
392 if( type.id() == mime ) 392 if( type.id() == mime )
393 return true; 393 return true;
394 return false; 394 return false;
395} 395}
396 396
397void OFileSelector::reparse() 397void OFileSelector::reparse()
398{ 398{
399 if(m_View== 0 || m_selector == NORMAL) 399 if(m_View== 0 || m_selector == NORMAL)
400 return; 400 return;
401 401
402 m_View->clear(); 402 m_View->clear();
403 403
404 404
405 QString currMime =m_mimeCheck->currentText(); 405 QString currMime =m_mimeCheck->currentText();
406 // update the mimetype now 406 // update the mimetype now
407 if( m_autoMime ) { 407 if( m_autoMime ) {
408 QDir dir( m_currentDir ); 408 QDir dir( m_currentDir );
409 m_mimetypes.clear(); 409 m_mimetypes.clear();
410 m_mimeCheck->clear(); 410 m_mimeCheck->clear();
411 dir.setFilter( QDir::Files | QDir::Readable ); 411 dir.setFilter( QDir::Files | QDir::Readable );
412 dir.setSorting(QDir::Size ); 412 dir.setSorting(QDir::Size );
413 const QFileInfoList *list = dir.entryInfoList(); 413 const QFileInfoList *list = dir.entryInfoList();
414 QFileInfoListIterator it( *list ); 414 QFileInfoListIterator it( *list );
415 QFileInfo *fi; 415 QFileInfo *fi;
416 while( (fi=it.current()) ){ 416 while( (fi=it.current()) ){
417 if(fi->extension() == QString::fromLatin1("desktop") ){ 417 if(fi->extension() == QString::fromLatin1("desktop") ){
418 ++it; 418 ++it;
419 continue; 419 continue;
420 } 420 }
421 MimeType type(fi->filePath() ); 421 MimeType type(fi->filePath() );
422 if( !m_mimetypes.contains( type.id() ) ) 422 if( !m_mimetypes.contains( type.id() ) )
423 m_mimetypes.append( type.id() ); 423 m_mimetypes.append( type.id() );
424 424
425 ++it; 425 ++it;
426 } 426 }
427 m_mimetypes.prepend("All" ); 427 m_mimetypes.prepend("All" );
428 m_mimeCheck->insertStringList(m_mimetypes ); 428 m_mimeCheck->insertStringList(m_mimetypes );
429 // set it to the current mimetype 429 // set it to the current mimetype
430 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); 430 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
431 }; 431 };
432 QDir dir( m_currentDir ); 432 QDir dir( m_currentDir );
433 //dir.setFilter(-1 ); 433 //dir.setFilter(-1 );
434 int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; 434 int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed;
435 if( m_case ) 435 if( m_case )
436 sort = QDir::IgnoreCase; 436 sort = QDir::IgnoreCase;
437 dir.setSorting( sort ); 437 dir.setSorting( sort );
438 438
439 int filter; 439 int filter;
440 /* if( m_dir && !m_files) 440 /* if( m_dir && !m_files)
441 filter |= QDir::Dirs; 441 filter |= QDir::Dirs;
442 else if( !m_dir && m_files ) 442 else if( !m_dir && m_files )
443 filter |= QDir::Files; 443 filter |= QDir::Files;
444 else 444 else
445 filter |= QDir::All; 445 filter |= QDir::All;
446 */ 446 */
447 if( m_selector == EXTENDED_ALL ) 447 if( m_selector == EXTENDED_ALL )
448 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 448 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
449 else 449 else
450 filter = QDir::Files | QDir::Dirs | QDir::All; 450 filter = QDir::Files | QDir::Dirs | QDir::All;
451 dir.setFilter( filter ); 451 dir.setFilter( filter );
452 452
453 const QFileInfoList *list = dir.entryInfoList(); 453 const QFileInfoList *list = dir.entryInfoList();
454 QFileInfoListIterator it( *list ); 454 QFileInfoListIterator it( *list );
455 QFileInfo *fi; 455 QFileInfo *fi;
456 while( (fi=it.current()) ){ 456 while( (fi=it.current()) ){
457 if(fi->fileName() == ".." || fi->fileName() == "." ){ 457 if(fi->fileName() == ".." || fi->fileName() == "." ){
458 ++it; 458 ++it;
459 continue; 459 continue;
460 } 460 }
461 qWarning("Test: %s", fi->fileName().latin1() ); 461 qWarning("Test: %s", fi->fileName().latin1() );
462 if(fi->isSymLink() ){ 462 if(fi->isSymLink() ){
463 qWarning("Symlink %s", fi->fileName().latin1() ); 463 qWarning("Symlink %s", fi->fileName().latin1() );
464 QString file = fi->dirPath(true)+"/"+ fi->readLink(); 464 QString file = fi->dirPath(true)+"/"+ fi->readLink();
465 qWarning("File ->%s", file.latin1() ); 465 qWarning("File ->%s", file.latin1() );
466 for(int i=0; i<=4; i++ ){ // prepend from dos 466 for(int i=0; i<=4; i++ ){ // prepend from dos
467 QFileInfo info( file ); 467 QFileInfo info( file );
468 if( !info.exists() ){ 468 if( !info.exists() ){
469 qWarning("does not exist" ); 469 qWarning("does not exist" );
470 addSymlink(currMime, fi, TRUE ); 470 addSymlink(currMime, fi, TRUE );
471 break; 471 break;
472 }else if( info.isDir() ){ 472 }else if( info.isDir() ){
473 qWarning("isDir" ); 473 qWarning("isDir" );
474 addDir(currMime, fi, TRUE ); 474 addDir(currMime, fi, TRUE );
475 break; 475 break;
476 }else if( info.isFile() ){ 476 }else if( info.isFile() ){
477 qWarning("isFile" ); 477 qWarning("isFile" );
478 addFile(currMime, fi, TRUE ); 478 addFile(currMime, fi, TRUE );
479 break; 479 break;
480 }else if( info.isSymLink() ){ 480 }else if( info.isSymLink() ){
481 file = info.dirPath(true)+ "/"+ info.readLink(); 481 file = info.dirPath(true)+ "/"+ info.readLink();
482 qWarning("isSymlink again %s", file.latin1() ); 482 qWarning("isSymlink again %s", file.latin1() );
483 }else if( i == 4 ){ // just insert it and have the symlink symbol 483 }else if( i == 4 ){ // just insert it and have the symlink symbol
484 addSymlink(currMime, fi ); 484 addSymlink(currMime, fi );
485 qWarning("level too deep" ); 485 qWarning("level too deep" );
486 } 486 }
487 } 487 }
488 }else if( fi->isDir() ){ 488 }else if( fi->isDir() ){
489 addDir(currMime, fi ); 489 addDir(currMime, fi );
490 }else if( fi->isFile() ) { // file ? 490 }else if( fi->isFile() ) { // file ?
491 addFile(currMime, fi ); 491 addFile(currMime, fi );
492 } 492 }
493 ++it; 493 ++it;
494 } 494 }
495 m_View->sort(); 495 m_View->sort();
496} 496}
497QString OFileSelector::directory()const 497QString OFileSelector::directory()const
498{ 498{
499 return m_currentDir; 499 return m_currentDir;
500} 500}
501int OFileSelector::fileCount() 501int OFileSelector::fileCount()
502{ 502{
503 return 0; 503 return 0;
504} 504}
505void OFileSelector::slotOk( ) 505void OFileSelector::slotOk( )
506{ 506{
507 emit ok(); 507 emit ok();
508} 508}
509void OFileSelector::slotCancel( ) 509void OFileSelector::slotCancel( )
510{ 510{
511 emit cancel(); 511 emit cancel();
512} 512}
513 513
514void OFileSelector::initializeName() 514void OFileSelector::initializeName()
515{ 515{
516 m_boxName = new QHBoxLayout(this ); 516 m_boxName = new QHBoxLayout(this );
517 m_edit = new QLineEdit(this ); 517 m_edit = new QLineEdit(this );
518 m_fnLabel = new QLabel(this ); 518 m_fnLabel = new QLabel(this );
519 m_fnLabel->setText(tr("Name:") ); 519 m_fnLabel->setText(tr("Name:") );
520 m_boxName->addWidget(m_fnLabel ); 520 m_boxName->addWidget(m_fnLabel );
521 m_boxName->insertSpacing(1, 8 ); 521 m_boxName->insertSpacing(1, 8 );
522 m_boxName->addWidget(m_edit, 100 ); 522 m_boxName->addWidget(m_edit, 100 );
523 523
524 m_lay->addLayout(m_boxName); 524 m_lay->addLayout(m_boxName);
525} 525}
526void OFileSelector::initializeYes() 526void OFileSelector::initializeYes()
527{ 527{
528 m_ok = new QPushButton("&Save", this, "save" ); 528 m_ok = new QPushButton("&Save", this, "save" );
529 m_cancel = new QPushButton("C&ancel", this, "cancel" ); 529 m_cancel = new QPushButton("C&ancel", this, "cancel" );
530 m_boxOk = new QHBoxLayout(this ); 530 m_boxOk = new QHBoxLayout(this );
531 m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); 531 m_boxOk->addWidget( m_ok, Qt::AlignHCenter );
532 m_boxOk->insertSpacing(1, 8 ); 532 m_boxOk->insertSpacing(1, 8 );
533 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); 533 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter);
534 m_lay->addLayout(m_boxOk ); 534 m_lay->addLayout(m_boxOk );
535 connect(m_ok, SIGNAL(clicked() ), 535 connect(m_ok, SIGNAL(clicked() ),
536 this, SLOT(slotOk() ) ); 536 this, SLOT(slotOk() ) );
537 connect(m_cancel, SIGNAL(clicked() ), 537 connect(m_cancel, SIGNAL(clicked() ),
538 this, SLOT(slotCancel() ) ); 538 this, SLOT(slotCancel() ) );
539 539
540} 540}
541void OFileSelector::initializeChooser() 541void OFileSelector::initializeChooser()
542{ 542{
543 m_boxView = new QHBoxLayout(this ); 543 m_boxView = new QHBoxLayout(this );
544 544
545 m_mimeCheck = new QComboBox(this, "mime check"); 545 m_mimeCheck = new QComboBox(this, "mime check");
546 m_viewCheck = new QComboBox(this, "view check"); 546 m_viewCheck = new QComboBox(this, "view check");
547 m_boxView->addWidget(m_viewCheck, 0 ); 547 m_boxView->addWidget(m_viewCheck, 0 );
548 m_boxView->insertSpacing(1, 8 ); 548 m_boxView->insertSpacing(1, 8 );
549 m_boxView->addWidget(m_mimeCheck, 0 ); 549 m_boxView->addWidget(m_mimeCheck, 0 );
550 m_lay->addLayout(m_boxView ); 550 m_lay->addLayout(m_boxView );
551 551
552 m_viewCheck->insertItem(tr("Documents") ); 552 m_viewCheck->insertItem(tr("Documents") );
553 m_viewCheck->insertItem(tr("Files") ); 553 m_viewCheck->insertItem(tr("Files") );
554 m_viewCheck->insertItem(tr("All Files") ); 554 m_viewCheck->insertItem(tr("All Files") );
555 555
556 if(!m_autoMime ) 556 if(!m_autoMime )
557 m_mimeCheck->insertItem(m_mimetypes.join("," ) ); 557 m_mimeCheck->insertItem(m_mimetypes.join("," ) );
558 else{ // check 558 else{ // check
559 updateMimes(); 559 updateMimes();
560 m_mimeCheck->insertStringList( m_mimetypes ); 560 m_mimeCheck->insertStringList( m_mimetypes );
561 } 561 }
562 562
563 connect( m_viewCheck, SIGNAL(activated(const QString &) ), 563 connect( m_viewCheck, SIGNAL(activated(const QString &) ),
564 this, SLOT(slotViewCheck(const QString & ) ) ); 564 this, SLOT(slotViewCheck(const QString & ) ) );
565 565
566 connect( m_mimeCheck, SIGNAL(activated(const QString &) ), 566 connect( m_mimeCheck, SIGNAL(activated(const QString &) ),
567 this, SLOT(slotMimeCheck(const QString & ) ) ); 567 this, SLOT(slotMimeCheck(const QString & ) ) );
568} 568}
569void OFileSelector::slotMimeCheck(const QString &view ){ 569void OFileSelector::slotMimeCheck(const QString &view ){
570 if(m_selector == NORMAL ){ 570 if(m_selector == NORMAL ){
571 delete m_select; 571 delete m_select;
572 m_select = new FileSelector(view == "All" ? QString::null : view 572 m_select = new FileSelector(view == "All" ? QString::null : view
573 , m_stack, "fileselector", FALSE, FALSE ); 573 , m_stack, "fileselector", FALSE, FALSE );
574 m_stack->addWidget( m_select, NORMAL ); 574 m_stack->addWidget( m_select, NORMAL );
575 m_stack->raiseWidget( NORMAL ); 575 m_stack->raiseWidget( NORMAL );
576 }else{ 576 }else{
577 reparse(); 577 reparse();
578 } 578 }
579} 579}
580 580
581void OFileSelector::slotViewCheck(const QString &view ){ 581void OFileSelector::slotViewCheck(const QString &view ){
582 qWarning("changed: show %s", view.latin1() ); 582 qWarning("changed: show %s", view.latin1() );
583 // if the current view is the one 583 // if the current view is the one
584 QString currMime = m_mimeCheck->currentText(); 584 QString currMime = m_mimeCheck->currentText();
585 if( view == QString::fromLatin1("Documents") ){ 585 if( view == QString::fromLatin1("Documents") ){
586 // get the mimetype now 586 // get the mimetype now
587 // check if we're the current widget and return 587 // check if we're the current widget and return
588 if( m_View != 0) { // delete 0 shouldn't crash but it did :( 588 if( m_View != 0) { // delete 0 shouldn't crash but it did :(
589 delete m_View; 589 delete m_View;
590 delete m_boxToolbar; 590 delete m_boxToolbar;
591 delete m_homeButton; 591 delete m_homeButton;
592 delete m_docButton; 592 delete m_docButton;
593 delete m_location; 593 delete m_location;
594 delete m_up; 594 delete m_up;
595 delete m_pseudo; 595 delete m_pseudo;
596 delete m_pseudoLayout; 596 delete m_pseudoLayout;
597 } 597 }
598 m_View = 0; 598 m_View = 0;
599 m_boxToolbar = 0; 599 m_boxToolbar = 0;
600 m_homeButton = 0; 600 m_homeButton = 0;
601 m_docButton = 0; 601 m_docButton = 0;
602 m_location = 0; 602 m_location = 0;
603 m_up = 0; 603 m_up = 0;
604 m_pseudo = 0; 604 m_pseudo = 0;
605 m_pseudoLayout = 0; 605 m_pseudoLayout = 0;
606 606
607 delete m_select; 607 delete m_select;
608 m_select = new FileSelector( currMime == "All" ? QString::null : currMime, 608 m_select = new FileSelector( currMime == "All" ? QString::null : currMime,
609 m_stack,"fileselector", FALSE, FALSE ); 609 m_stack,"fileselector", FALSE, FALSE );
610 m_stack->addWidget( m_select, NORMAL ); 610 m_stack->addWidget( m_select, NORMAL );
611 m_mimeCheck->clear(); 611 m_mimeCheck->clear();
612 m_selector = NORMAL; 612 m_selector = NORMAL;
613 updateMimes(); 613 updateMimes();
614 m_mimeCheck->insertStringList( m_mimetypes ); 614 m_mimeCheck->insertStringList( m_mimetypes );
615 m_stack->raiseWidget( NORMAL ); 615 m_stack->raiseWidget( NORMAL );
616 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 616 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
617 617
618 }else if(view == QString::fromLatin1("Files") ){ 618 }else if(view == QString::fromLatin1("Files") ){
619 // remove from the stack 619 // remove from the stack
620 delete m_select; 620 delete m_select;
621 m_select = 0; 621 m_select = 0;
622 delete m_View; 622 delete m_View;
623 m_View = 0; 623 m_View = 0;
624 624
625 delete m_boxToolbar; 625 delete m_boxToolbar;
626 delete m_homeButton; 626 delete m_homeButton;
627 delete m_docButton; 627 delete m_docButton;
628 delete m_location; 628 delete m_location;
629 delete m_up; 629 delete m_up;
630 delete m_pseudo; 630 delete m_pseudo;
631 delete m_pseudoLayout; 631 delete m_pseudoLayout;
632 m_boxToolbar = 0; 632 m_boxToolbar = 0;
633 m_homeButton = 0; 633 m_homeButton = 0;
634 m_docButton = 0; 634 m_docButton = 0;
635 m_location = 0; 635 m_location = 0;
636 m_up = 0; 636 m_up = 0;
637 m_pseudo = 0; 637 m_pseudo = 0;
638 m_pseudoLayout = 0; 638 m_pseudoLayout = 0;
639 639
640 m_selector = EXTENDED; 640 m_selector = EXTENDED;
641 // create the ListView or IconView 641 // create the ListView or IconView
642 initializeListView(); 642 initializeListView();
643 643
644 reparse(); 644 reparse();
645 }else if(view == QString::fromLatin1("All Files") ) { 645 }else if(view == QString::fromLatin1("All Files") ) {
646 // remove from the stack 646 // remove from the stack
647 delete m_select; 647 delete m_select;
648 m_select = 0; 648 m_select = 0;
649 delete m_View; 649 delete m_View;
650 m_View = 0; 650 m_View = 0;
651 delete m_boxToolbar; 651 delete m_boxToolbar;
652 delete m_homeButton; 652 delete m_homeButton;
653 delete m_docButton; 653 delete m_docButton;
654 delete m_location; 654 delete m_location;
655 delete m_up; 655 delete m_up;
656 delete m_pseudo; 656 delete m_pseudo;
657 delete m_pseudoLayout; 657 delete m_pseudoLayout;
658 m_boxToolbar = 0; 658 m_boxToolbar = 0;
659 m_homeButton = 0; 659 m_homeButton = 0;
660 m_docButton = 0; 660 m_docButton = 0;
661 m_location = 0; 661 m_location = 0;
662 m_up = 0; 662 m_up = 0;
663 m_pseudo = 0; 663 m_pseudo = 0;
664 m_pseudoLayout = 0; 664 m_pseudoLayout = 0;
665 665
666 m_selector = EXTENDED_ALL; 666 m_selector = EXTENDED_ALL;
667 initializeListView(); 667 initializeListView();
668 reparse(); 668 reparse();
669 }; 669 };
670}; 670};
671 671
672 672
673void OFileSelector::updateMimes() // lets check which mode is active 673void OFileSelector::updateMimes() // lets check which mode is active
674 // check the current dir for items then 674 // check the current dir for items then
675{ 675{
676 m_mimetypes.clear(); 676 m_mimetypes.clear();
677 m_mimetypes.append("All" ); 677 m_mimetypes.append("All" );
678 if( m_selector == NORMAL ){ 678 if( m_selector == NORMAL ){
679 DocLnkSet set; 679 DocLnkSet set;
680 Global::findDocuments(&set, QString::null ); 680 Global::findDocuments(&set, QString::null );
681 QListIterator<DocLnk> dit( set.children() ); 681 QListIterator<DocLnk> dit( set.children() );
682 for ( ; dit.current(); ++dit ) { 682 for ( ; dit.current(); ++dit ) {
683 if( !m_mimetypes.contains((*dit)->type() ) ) 683 if( !m_mimetypes.contains((*dit)->type() ) )
684 m_mimetypes.append( (*dit)->type() ); 684 m_mimetypes.append( (*dit)->type() );
685 } 685 }
686 }else{ 686 }else{
687 // should be allreday updatet 687 // should be allreday updatet
688 ; 688 ;
689 } 689 }
690}; 690};
691void OFileSelector::initializeListView() 691void OFileSelector::initializeListView()
692{ 692{
693 // just to make sure but clean it up better FIXME 693 // just to make sure but clean it up better FIXME
694 delete m_View; 694 delete m_View;
695 m_View = 0; 695 m_View = 0;
696 delete m_boxToolbar; 696 delete m_boxToolbar;
697 delete m_homeButton; 697 delete m_homeButton;
698 delete m_docButton; 698 delete m_docButton;
699 delete m_location; 699 delete m_location;
700 delete m_up; 700 delete m_up;
701 delete m_pseudo; 701 delete m_pseudo;
702 delete m_pseudoLayout; 702 delete m_pseudoLayout;
703 m_boxToolbar = 0; 703 m_boxToolbar = 0;
704 m_homeButton = 0; 704 m_homeButton = 0;
705 m_docButton = 0; 705 m_docButton = 0;
706 m_location = 0; 706 m_location = 0;
707 m_up = 0; 707 m_up = 0;
708 m_pseudo = 0; 708 m_pseudo = 0;
709 m_pseudoLayout = 0; 709 m_pseudoLayout = 0;
710 // time for the toolbar 710 // time for the toolbar
711 m_pseudo = new QWidget(m_stack, "Pseudo Widget"); 711 m_pseudo = new QWidget(m_stack, "Pseudo Widget");
712 m_pseudoLayout = new QVBoxLayout(m_pseudo ); 712 m_pseudoLayout = new QVBoxLayout(m_pseudo );
713 if(m_shTool ){ 713 if(m_shTool ){
714 m_boxToolbar = new QHBoxLayout( ); 714 m_boxToolbar = new QHBoxLayout( );
715 m_boxToolbar->setAutoAdd( true ); 715 m_boxToolbar->setAutoAdd( true );
716 m_location = new QComboBox(m_pseudo ); 716 m_location = new QComboBox(m_pseudo );
717 717
718 m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); 718 m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton");
719 m_up->setMinimumSize( QSize( 20, 20 ) ); 719 m_up->setMinimumSize( QSize( 20, 20 ) );
720 m_up->setMaximumSize( QSize( 20, 20 ) ); 720 m_up->setMaximumSize( QSize( 20, 20 ) );
721 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); 721 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
722 m_up->setFlat(TRUE); 722 m_up->setFlat(TRUE);
723 723
724 m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); 724 m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo);
725 m_homeButton->setMinimumSize( QSize( 20, 20 ) ); 725 m_homeButton->setMinimumSize( QSize( 20, 20 ) );
726 m_homeButton->setMaximumSize( QSize( 20, 20 ) ); 726 m_homeButton->setMaximumSize( QSize( 20, 20 ) );
727 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); 727 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
728 m_homeButton->setFlat(TRUE); 728 m_homeButton->setFlat(TRUE);
729 729
730 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); 730 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton");
731 m_docButton->setMinimumSize( QSize( 20, 20 ) ); 731 m_docButton->setMinimumSize( QSize( 20, 20 ) );
732 m_docButton->setMaximumSize( QSize( 20, 20 ) ); 732 m_docButton->setMaximumSize( QSize( 20, 20 ) );
733 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); 733 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
734 m_docButton->setFlat(TRUE); 734 m_docButton->setFlat(TRUE);
735 735
736 m_boxToolbar->addWidget(m_location ); 736 m_boxToolbar->addWidget(m_location );
737 m_boxToolbar->addWidget(m_up ); 737 m_boxToolbar->addWidget(m_up );
738 m_boxToolbar->addWidget(m_homeButton ); 738 m_boxToolbar->addWidget(m_homeButton );
739 m_boxToolbar->addWidget(m_docButton ); 739 m_boxToolbar->addWidget(m_docButton );
740 m_pseudoLayout->addLayout(m_boxToolbar ); 740 m_pseudoLayout->addLayout(m_boxToolbar );
741 // lets fill the combobox 741 // lets fill the combobox
742 StorageInfo storage; 742 StorageInfo storage;
743 const QList<FileSystem> &fs = storage.fileSystems(); 743 const QList<FileSystem> &fs = storage.fileSystems();
744 QListIterator<FileSystem> it ( fs ); 744 QListIterator<FileSystem> it ( fs );
745 for( ; it.current(); ++it ){ 745 for( ; it.current(); ++it ){
746 const QString disk = (*it)->name(); 746 const QString disk = (*it)->name();
747 const QString path = (*it)->path(); 747 const QString path = (*it)->path();
748 m_location->insertItem(path+ "<-"+disk ); 748 m_location->insertItem(path+ "<-"+disk );
749 } 749 }
750 int count = m_location->count();
751 m_location->insertItem(m_currentDir );
752 m_location->setCurrentItem( count );
750 }; 753 };
751 m_View = new QListView(m_pseudo, "Extended view" ); 754 m_View = new QListView(m_pseudo, "Extended view" );
752 m_stack->addWidget( m_pseudo, EXTENDED ); 755 m_stack->addWidget( m_pseudo, EXTENDED );
753 m_stack->raiseWidget( EXTENDED ); 756 m_stack->raiseWidget( EXTENDED );
754 m_pseudoLayout->addWidget(m_View ); 757 m_pseudoLayout->addWidget(m_View );
755 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); 758 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold);
756 // set up the stuff 759 // set up the stuff
757 // Pixmap Name Date Size mime 760 // Pixmap Name Date Size mime
758 //(m_View->header() )->hide(); 761 //(m_View->header() )->hide();
759 //m_View->setRootIsDecorated(false); 762 //m_View->setRootIsDecorated(false);
760 m_View->addColumn(" "); 763 m_View->addColumn(" ");
761 m_View->addColumn(tr("Name") ); 764 m_View->addColumn(tr("Name") );
762 m_View->addColumn(tr("Size") ); 765 m_View->addColumn(tr("Size") );
763 m_View->addColumn(tr("Date"), 60 ); 766 m_View->addColumn(tr("Date"), 60 );
764 m_View->addColumn(tr("Mime Type") ); 767 m_View->addColumn(tr("Mime Type") );
765 QHeader *header = m_View->header(); 768 QHeader *header = m_View->header();
766 header->hide(); 769 header->hide();
767 m_View->setSorting(1 ); 770 m_View->setSorting(1 );
768 // connect now 771 // connect now
769 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) ); 772 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) );
770 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); 773 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
771 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), 774 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
772 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); 775 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
773 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), 776 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
774 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); 777 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
775 778
776 779
777}; 780};
778/* If a item is locked depends on the mode 781/* If a item is locked depends on the mode
779 if we're in OPEN !isReadable is locked 782 if we're in OPEN !isReadable is locked
780 if we're in SAVE !isWriteable is locked 783 if we're in SAVE !isWriteable is locked
781 784
782 785
783 */ 786 */
784 787
785 788
786void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ 789void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){
787 qWarning("Add Files" ); 790 qWarning("Add Files" );
788 if( !m_files ){ 791 if( !m_files ){
789 qWarning("not mfiles" ); 792 qWarning("not mfiles" );
790 return; 793 return;
791 } 794 }
792 795
793 MimeType type( info->filePath() ); 796 MimeType type( info->filePath() );
794 QString name; 797 QString name;
795 QString dir; 798 QString dir;
796 bool locked= false; 799 bool locked= false;
797 if(mime == "All" ){ 800 if(mime == "All" ){
798 ; 801 ;
799 }else if( type.id() != mime ) { 802 }else if( type.id() != mime ) {
800 return; 803 return;
801 } 804 }
802 QPixmap pix = type.pixmap(); 805 QPixmap pix = type.pixmap();
803 if(pix.isNull() ) 806 if(pix.isNull() )
804 pix = Resource::loadPixmap( "UnknownDocument-14" ); 807 pix = Resource::loadPixmap( "UnknownDocument-14" );
805 dir = info->dirPath( true ); 808 dir = info->dirPath( true );
806 if( symlink ) { // check if the readLink is readable 809 if( symlink ) { // check if the readLink is readable
807 // do it right later 810 // do it right later
808 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 811 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
809 }else{ // keep track of the icons 812 }else{ // keep track of the icons
810 name = info->fileName(); 813 name = info->fileName();
811 if( m_mode == OPEN ){ 814 if( m_mode == OPEN ){
812 if( !info->isReadable() ){ 815 if( !info->isReadable() ){
813 locked = true; 816 locked = true;
814 pix = Resource::loadPixmap("locked" ); 817 pix = Resource::loadPixmap("locked" );
815 } 818 }
816 }else if( m_mode == SAVE ){ 819 }else if( m_mode == SAVE ){
817 if( !info->isWritable() ){ 820 if( !info->isWritable() ){
818 locked = true; 821 locked = true;
819 pix = Resource::loadPixmap("locked" ); 822 pix = Resource::loadPixmap("locked" );
820 } 823 }
821 } 824 }
822 } 825 }
823 new OFileSelectorItem( m_View, pix, name, 826 new OFileSelectorItem( m_View, pix, name,
824 info->lastModified().toString(), 827 info->lastModified().toString(),
825 QString::number( info->size() ), 828 QString::number( info->size() ),
826 dir, locked ); 829 dir, locked );
827} 830}
828void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) 831void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
829{ 832{
830 if(!m_dir ) 833 if(!m_dir )
831 return; 834 return;
832 //if( showDirs ) 835 //if( showDirs )
833 { 836 {
834 bool locked=false; 837 bool locked=false;
835 QString name; 838 QString name;
836 QPixmap pix; 839 QPixmap pix;
837 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ 840 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
838 locked = true; 841 locked = true;
839 if( symlink ){ 842 if( symlink ){
840 pix = (*m_pixmaps)["symlinkedlocked"]; 843 pix = (*m_pixmaps)["symlinkedlocked"];
841 }else{ 844 }else{
842 pix = Resource::loadPixmap("lockedfolder" ); 845 pix = Resource::loadPixmap("lockedfolder" );
843 } 846 }
844 }else{ 847 }else{
845 if( symlink ){ 848 if( symlink ){
846 pix = (*m_pixmaps)["dirsymlink" ]; 849 pix = (*m_pixmaps)["dirsymlink" ];
847 }else{ 850 }else{
848 pix = Resource::loadPixmap("folder" ); 851 pix = Resource::loadPixmap("folder" );
849 } 852 }
850 } 853 }
851 if( symlink){ 854 if( symlink){
852 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); 855 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink();
853 856
854 }else{ 857 }else{
855 //if(info->isReadable() ) 858 //if(info->isReadable() )
856 name = info->fileName(); 859 name = info->fileName();
857 } 860 }
858 861
859 new OFileSelectorItem(m_View, pix, 862 new OFileSelectorItem(m_View, pix,
860 name, info->lastModified().toString(), 863 name, info->lastModified().toString(),
861 QString::number(info->size() ),info->dirPath(true), locked, true ); 864 QString::number(info->size() ),info->dirPath(true), locked, true );
862 865
863 } 866 }
864} 867}
865void OFileSelector::setShowDirs(bool dir ) 868void OFileSelector::setShowDirs(bool dir )
866{ 869{
867 m_dir = dir; 870 m_dir = dir;
868 reparse(); 871 reparse();
869} 872}
870 873
871void OFileSelector::slotFileSelected(const QString &string ) 874void OFileSelector::slotFileSelected(const QString &string )
872{ 875{
873 if(m_shLne ) 876 if(m_shLne )
874 m_edit->setText( string ); 877 m_edit->setText( string );
875 878
876 emit fileSelected( string ); 879 emit fileSelected( string );
877 // do AppLnk stuff 880 // do AppLnk stuff
878} 881}
879void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 882void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
880{ 883{
881 slotFileSelected(lnk.name() ); 884 slotFileSelected(lnk.name() );
882 emit fileSelected( lnk ); 885 emit fileSelected( lnk );
883} 886}
884void OFileSelector::slotSelectionChanged() // get the current items 887void OFileSelector::slotSelectionChanged() // get the current items
885 // fixme 888 // fixme
886{ 889{
887 qWarning("selection changed" ); 890 qWarning("selection changed" );
888} 891}
889void OFileSelector::slotCurrentChanged(QListViewItem *item ) 892void OFileSelector::slotCurrentChanged(QListViewItem *item )
890{ 893{
891 qWarning("current changed" ); 894 qWarning("current changed" );
892 if( item == 0 ) 895 if( item == 0 )
893 return; 896 return;
894 897
895 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 898 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
896 OFileSelectorItem *sel = (OFileSelectorItem*)item; 899 OFileSelectorItem *sel = (OFileSelectorItem*)item;
897 if(!sel->isDir() ){ 900 if(!sel->isDir() ){
898 qWarning("is not dir" ); 901 qWarning("is not dir" );
899 if(m_shLne ){ 902 if(m_shLne ){
900 m_edit->setText(sel->text(1) ); 903 m_edit->setText(sel->text(1) );
901 qWarning("setTexy" ); 904 qWarning("setTexy" );
902 } 905 }
903 } 906 }
904 }else { 907 }else {
905 qWarning("mode not extended" ); 908 qWarning("mode not extended" );
906 } 909 }
907} 910}
908// either select or change dir 911// either select or change dir
909void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) 912void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int )
910{ 913{
911 if( item == 0 ) 914 if( item == 0 )
912 return; 915 return;
913 916
914 if( button != Qt::LeftButton ) 917 if( button != Qt::LeftButton )
915 return; 918 return;
916 919
917 qWarning("clicked" ); 920 qWarning("clicked" );
918 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 921 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
919 qWarning("inside" ); 922 qWarning("inside" );
920 OFileSelectorItem *sel = (OFileSelectorItem*)item; 923 OFileSelectorItem *sel = (OFileSelectorItem*)item;
921 if(!sel->isLocked() ){ // not locked either changedir or open 924 if(!sel->isLocked() ){ // not locked either changedir or open
922 QStringList str = QStringList::split("->", sel->text(1) ); 925 QStringList str = QStringList::split("->", sel->text(1) );
923 if(sel->isDir() ){ 926 if(sel->isDir() ){
924 cd( sel->directory() + "/" + str[0] ); 927 cd( sel->directory() + "/" + str[0] );
925 }else{ 928 }else{
926 qWarning("file" ); 929 qWarning("file" );
927 if(m_shLne ) 930 if(m_shLne )
928 m_edit->setText(str[0] ); 931 m_edit->setText(str[0] );
929 emit fileSelected(str[0] ); 932 emit fileSelected(str[0] );
930 // emit DocLnk need to do it 933 // emit DocLnk need to do it
931 } 934 }
932 }else{ 935 }else{
933 qWarning( "locked" ); 936 qWarning( "locked" );
934 } 937 }
935 }; 938 };
936} 939}
937void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 940void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
938{ 941{
939 if (item == 0 ) 942 if (item == 0 )
940 return; 943 return;
941 944
942 if( button != Qt::RightButton ) 945 if( button != Qt::RightButton )
943 return; 946 return;
944 qWarning("right button" ); 947 qWarning("right button" );
945 slotContextMenu(item); 948 slotContextMenu(item);
946} 949}
947void OFileSelector::slotContextMenu(QListViewItem *item) 950void OFileSelector::slotContextMenu(QListViewItem *item)
948{ 951{
949 qWarning("context menu" ); 952 qWarning("context menu" );
950 if( item ==0 || !m_showPopup ) 953 if( item ==0 || !m_showPopup )
951 return; 954 return;
952 955
953 if( m_custom !=0){ 956 if( m_custom !=0){
954 m_custom->exec(); 957 m_custom->exec();
955 }else{ 958 }else{
956 QPopupMenu menu; 959 QPopupMenu menu;
957 QAction up; 960 QAction up;
958 up.setText("cd up"); 961 up.setText("cd up");
959 up.addTo( &menu ); 962 up.addTo( &menu );
960 connect(&up, SIGNAL(activated() ), 963 connect(&up, SIGNAL(activated() ),
961 this, SLOT(cdUP() ) ); 964 this, SLOT(cdUP() ) );
962 965
963 QAction act; 966 QAction act;
964 OFileSelectorItem *sel = (OFileSelectorItem*)item; 967 OFileSelectorItem *sel = (OFileSelectorItem*)item;
965 if(sel->isDir() ){ 968 if(sel->isDir() ){
966 act.setText( tr("Change Directory") ); 969 act.setText( tr("Change Directory") );
967 act.addTo(&menu ); 970 act.addTo(&menu );
968 connect(&act, SIGNAL(activated() ), 971 connect(&act, SIGNAL(activated() ),
969 this, SLOT(slotChangedDir() ) ); 972 this, SLOT(slotChangedDir() ) );
970 }else{ 973 }else{
971 act.setText( tr("Open file" ) ); 974 act.setText( tr("Open file" ) );
972 act.addTo( &menu ); 975 act.addTo( &menu );
973 connect(&act, SIGNAL(activated() ), 976 connect(&act, SIGNAL(activated() ),
974 this, SLOT(slotOpen() ) ); 977 this, SLOT(slotOpen() ) );
975 } 978 }
976 QAction rescan; 979 QAction rescan;
977 rescan.setText( tr("Rescan") ); 980 rescan.setText( tr("Rescan") );
978 rescan.addTo( &menu ); 981 rescan.addTo( &menu );
979 connect(&rescan, SIGNAL(activated() ), 982 connect(&rescan, SIGNAL(activated() ),
980 this, SLOT(slotRescan() ) ); 983 this, SLOT(slotRescan() ) );
981 984
982 QAction rename; 985 QAction rename;
983 rename.setText( tr("Rename") ); 986 rename.setText( tr("Rename") );
984 rename.addTo( &menu ); 987 rename.addTo( &menu );
985 connect(&rename, SIGNAL(activated() ), 988 connect(&rename, SIGNAL(activated() ),
986 this, SLOT(slotRename() ) ); 989 this, SLOT(slotRename() ) );
987 990
988 menu.insertSeparator(); 991 menu.insertSeparator();
989 QAction delItem; 992 QAction delItem;
990 delItem.setText( tr("Delete") ); 993 delItem.setText( tr("Delete") );
991 delItem.addTo(&menu ); 994 delItem.addTo(&menu );
992 connect(&delItem, SIGNAL(activated() ), 995 connect(&delItem, SIGNAL(activated() ),
993 this, SLOT(slotDelete() ) ); 996 this, SLOT(slotDelete() ) );
994 997
995 menu.exec(QCursor::pos() ); 998 menu.exec(QCursor::pos() );
996 } 999 }
997} 1000}
998bool OFileSelector::cd(const QString &str ) 1001bool OFileSelector::cd(const QString &str )
999{ 1002{
1000 qWarning(" dir %s", str.latin1() ); 1003 qWarning(" dir %s", str.latin1() );
1001 QDir dir( str); 1004 QDir dir( str);
1002 if(dir.exists() ){ 1005 if(dir.exists() ){
1003 m_currentDir = str; 1006 m_currentDir = str;
1004 reparse(); 1007 reparse();
1008 if(m_shTool ){
1009 int count = m_location->count();
1010 m_location->insertItem(str );
1011 m_location->setCurrentItem( count );
1012 }
1005 return true; 1013 return true;
1006 } 1014 }
1007 return false; 1015 return false;
1008} 1016}
1009 1017
1010void OFileSelector::slotChangedDir() 1018void OFileSelector::slotChangedDir()
1011{ 1019{
1012 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1020 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1013 if(sel->isDir() ){ 1021 if(sel->isDir() ){
1014 QStringList str = QStringList::split("->", sel->text(1) ); 1022 QStringList str = QStringList::split("->", sel->text(1) );
1015 cd( sel->directory() + "/" + str[0] ); 1023 cd( sel->directory() + "/" + str[0] );
1016 } 1024 }
1017} 1025}
1018void OFileSelector::slotOpen() 1026void OFileSelector::slotOpen()
1019{ 1027{
1020 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1028 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1021 if(!sel->isDir() ){ 1029 if(!sel->isDir() ){
1022 QStringList str = QStringList::split("->", sel->text(1) ); 1030 QStringList str = QStringList::split("->", sel->text(1) );
1023 slotFileSelected( str[0] ); 1031 slotFileSelected( str[0] );
1024 } 1032 }
1025} 1033}
1026void OFileSelector::slotRescan() 1034void OFileSelector::slotRescan()
1027{ 1035{
1028 reparse(); 1036 reparse();
1029} 1037}
1030void OFileSelector::slotRename() 1038void OFileSelector::slotRename()
1031{ 1039{
1032 // rename inline 1040 // rename inline
1033} 1041}
1034void OFileSelector::slotDelete() 1042void OFileSelector::slotDelete()
1035{ 1043{
1036 qWarning("delete slot" ); 1044 qWarning("delete slot" );
1037 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1045 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1038 QStringList list = QStringList::split("->", sel->text(1) ); 1046 QStringList list = QStringList::split("->", sel->text(1) );
1039 if( sel->isDir() ){ 1047 if( sel->isDir() ){
1040 QString str = QString::fromLatin1("rm -rf ") + list[0]; 1048 QString str = QString::fromLatin1("rm -rf ") + list[0];
1041 ::system(str.utf8().data() ); 1049 ::system(str.utf8().data() );
1042 }else{ 1050 }else{
1043 QFile::remove( list[0] ); 1051 QFile::remove( list[0] );
1044 } 1052 }
1045 m_View->takeItem( sel ); 1053 m_View->takeItem( sel );
1046 delete sel; 1054 delete sel;
1047} 1055}
1048 1056
1049void OFileSelector::cdUP() 1057void OFileSelector::cdUP()
1050{ 1058{
1051 QDir dir( m_currentDir ); 1059 QDir dir( m_currentDir );
1052 dir.cdUp(); 1060 dir.cdUp();
1053 if(dir.exists() ){ 1061 if(dir.exists() ){
1054 m_currentDir = dir.absPath(); 1062 m_currentDir = dir.absPath();
1055 reparse(); 1063 reparse();
1064 int count = m_location->count();
1065 m_location->insertItem(m_currentDir );
1066 m_location->setCurrentItem( count );
1056 } 1067 }
1057} 1068}
1069void OFileSelector::slotHome()
1070{
1071 cd(QDir::homeDirPath() );
1072}
1073void OFileSelector::slotDoc()
1074{
1075 cd(QDir::homeDirPath() + "/Documents" );
1076}
1077void OFileSelector::slotNavigate()
1078{
1058 1079
1059 1080}
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index b91c0ea..bf3cb48 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -1,275 +1,277 @@
1/* 1/*
2 This is based on code and idea of 2 This is based on code and idea of
3 L. J. Potter ljp@llornkcor.com 3 L. J. Potter ljp@llornkcor.com
4 Thanks a lot 4 Thanks a lot
5 5
6 6
7               =. This file is part of the OPIE Project 7               =. This file is part of the OPIE Project
8             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 8             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This library is free software; you can 10 _;:,     .>    :=|. This library is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This library is distributed in the hope that 17    .i_,=:_.      -<s. This library is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef opiefileselector_h 34#ifndef opiefileselector_h
35#define opiefileselector_h 35#define opiefileselector_h
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qstringlist.h> 40#include <qstringlist.h>
41#include <qmap.h> 41#include <qmap.h>
42#include <qvaluelist.h> 42#include <qvaluelist.h>
43 43
44#include <qpe/applnk.h> 44#include <qpe/applnk.h>
45#include <qlistview.h> 45#include <qlistview.h>
46/** This is OPIEs FileDialog Widget. You can use it 46/** This is OPIEs FileDialog Widget. You can use it
47 * as a dropin replacement of the fileselector and 47 * as a dropin replacement of the fileselector and
48 * or use any of the new features. 48 * or use any of the new features.
49 * This is also a complete FileSave and FileLoad widget 49 * This is also a complete FileSave and FileLoad widget
50 * If you look for a Dialog check OFileDialog 50 * If you look for a Dialog check OFileDialog
51 * 51 *
52 */ 52 */
53class DocLnk; 53class DocLnk;
54class QCheckBox; 54class QCheckBox;
55class QComboBox; 55class QComboBox;
56class QPushButton; 56class QPushButton;
57class FileSelector; 57class FileSelector;
58class QGridLayout; 58class QGridLayout;
59class QLineEdit; 59class QLineEdit;
60class QLabel; 60class QLabel;
61class QWidgetStack; 61class QWidgetStack;
62class QHBoxLayout; 62class QHBoxLayout;
63class QVBoxLayout; 63class QVBoxLayout;
64class QPopupMenu; 64class QPopupMenu;
65class QFileInfo; 65class QFileInfo;
66// 66//
67class OFileSelectorItem : public QListViewItem { 67class OFileSelectorItem : public QListViewItem {
68 public: 68 public:
69 OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, 69 OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path,
70 const QString &date, const QString &size, const QString &mDir, 70 const QString &date, const QString &size, const QString &mDir,
71 bool isLocked=false, bool isDir=false ): QListViewItem(view) { 71 bool isLocked=false, bool isDir=false ): QListViewItem(view) {
72 setPixmap(0, pixmap ); 72 setPixmap(0, pixmap );
73 setText(1, path ); 73 setText(1, path );
74 setText(2, size ); 74 setText(2, size );
75 setText(3, date ); 75 setText(3, date );
76 //setText(4, mDir ); 76 //setText(4, mDir );
77 m_dir = mDir; 77 m_dir = mDir;
78 dir = isDir; 78 dir = isDir;
79 mLocked = isLocked; 79 mLocked = isLocked;
80 } 80 }
81 bool isLocked() const{ 81 bool isLocked() const{
82 return mLocked; 82 return mLocked;
83 } 83 }
84 QString directory()const{ 84 QString directory()const{
85 return m_dir; 85 return m_dir;
86 } 86 }
87 bool isDir()const{ 87 bool isDir()const{
88 return dir; 88 return dir;
89 } 89 }
90 QString path()const{ 90 QString path()const{
91 return text(1 ); 91 return text(1 );
92 } 92 }
93 QString key(int id, bool )const { 93 QString key(int id, bool )const {
94 QString ke; 94 QString ke;
95 if( id == 0 || id == 1 ){ // name 95 if( id == 0 || id == 1 ){ // name
96 if( dir ){ 96 if( dir ){
97 ke.append("0" ); 97 ke.append("0" );
98 ke.append( text(1) ); 98 ke.append( text(1) );
99 }else{ 99 }else{
100 ke.append("1" ); 100 ke.append("1" );
101 ke.append( text(1) ); 101 ke.append( text(1) );
102 } 102 }
103 }else if( id == 2 ){ // size 103 }else if( id == 2 ){ // size
104 return text(2); 104 return text(2);
105 }else if( id == 3 ){ // date 105 }else if( id == 3 ){ // date
106 return text(3); 106 return text(3);
107 } 107 }
108 return ke; 108 return ke;
109 }; 109 };
110 private: 110 private:
111 bool mLocked:1; 111 bool mLocked:1;
112 bool dir:1; 112 bool dir:1;
113 QString m_dir; 113 QString m_dir;
114}; 114};
115 115
116class OFileSelector : public QWidget { 116class OFileSelector : public QWidget {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Mode {OPEN=1, SAVE, FILESELECTOR }; 119 enum Mode {OPEN=1, SAVE, FILESELECTOR };
120 enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; 120 enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 };
121 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; 121 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 };
122 OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() ); 122 OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() );
123 123
124 bool isToolbarVisible() const { return m_shTool; }; 124 bool isToolbarVisible() const { return m_shTool; };
125 bool isPermissionBarVisible() const { return m_shPerm; }; 125 bool isPermissionBarVisible() const { return m_shPerm; };
126 bool isLineEditVisible()const { return m_shLne; }; 126 bool isLineEditVisible()const { return m_shLne; };
127 bool isChooserVisible( )const { return m_shChooser; }; 127 bool isChooserVisible( )const { return m_shChooser; };
128 bool isYesCancelVisible()const { return m_shYesNo; }; 128 bool isYesCancelVisible()const { return m_shYesNo; };
129 void setYesCancelVisible( bool show ); 129 void setYesCancelVisible( bool show );
130 void setToolbarVisible( bool show ); 130 void setToolbarVisible( bool show );
131 void setPermissionBarVisible( bool show ); 131 void setPermissionBarVisible( bool show );
132 void setLineEditVisible(bool show) ; 132 void setLineEditVisible(bool show) ;
133 void setChooserVisible( bool chooser ); 133 void setChooserVisible( bool chooser );
134 134
135 QCheckBox* permissionCheckbox(); 135 QCheckBox* permissionCheckbox();
136 bool setPermission() const; 136 bool setPermission() const;
137 void setPermissionChecked( bool check ); 137 void setPermissionChecked( bool check );
138 138
139 void setMode( int ); 139 void setMode( int );
140 140
141 bool showDirs()const { return m_dir; } 141 bool showDirs()const { return m_dir; }
142 void setShowDirs(bool ); 142 void setShowDirs(bool );
143 143
144 const QListView* listView() { return m_View; }; 144 const QListView* listView() { return m_View; };
145 145
146 bool isCaseSensetive()const { return m_case; } 146 bool isCaseSensetive()const { return m_case; }
147 void setCaseSensetive(bool caSe ); 147 void setCaseSensetive(bool caSe );
148 148
149 bool showFiles()const { return m_files; }; 149 bool showFiles()const { return m_files; };
150 void setShowFiles(bool ); 150 void setShowFiles(bool );
151 bool cd(const QString &path ); 151 bool cd(const QString &path );
152 152
153 153
154 int mode()const { return m_mode; }; 154 int mode()const { return m_mode; };
155 int selector()const { return m_selector; }; 155 int selector()const { return m_selector; };
156 void setSelector( int ); 156 void setSelector( int );
157 157
158 bool showPopup()const { return m_showPopup; }; 158 bool showPopup()const { return m_showPopup; };
159 void setShowPopup( bool pop ) { m_showPopup = pop; }; 159 void setShowPopup( bool pop ) { m_showPopup = pop; };
160 void setPopupMenu( QPopupMenu * ); 160 void setPopupMenu( QPopupMenu * );
161 161
162 void updateLay(); 162 void updateLay();
163 163
164 void reparse(); // re reads the dir 164 void reparse(); // re reads the dir
165 165
166 QString selectedName( )const; 166 QString selectedName( )const;
167 QStringList selectedNames()const; 167 QStringList selectedNames()const;
168 168
169 QString selectedPath() const; 169 QString selectedPath() const;
170 QStringList selectedPaths() const; 170 QStringList selectedPaths() const;
171 171
172 QString directory()const; 172 QString directory()const;
173 int fileCount(); 173 int fileCount();
174 174
175 /* the user needs to delete it */ 175 /* the user needs to delete it */
176 DocLnk selectedDocument()const; 176 DocLnk selectedDocument()const;
177 /* the user needs to delete it */ 177 /* the user needs to delete it */
178 QValueList<DocLnk> selectedDocuments()const; 178 QValueList<DocLnk> selectedDocuments()const;
179 179
180 signals: 180 signals:
181 void fileSelected( const DocLnk & ); 181 void fileSelected( const DocLnk & );
182 void fileSelected( const QString & ); 182 void fileSelected( const QString & );
183 void closeMe(); 183 void closeMe();
184 void ok(); 184 void ok();
185 void cancel(); 185 void cancel();
186 186
187 protected slots: 187 protected slots:
188 void slotOk(); 188 void slotOk();
189 void slotCancel(); 189 void slotCancel();
190 void slotViewCheck(const QString & ); 190 void slotViewCheck(const QString & );
191 void slotMimeCheck(const QString & ); 191 void slotMimeCheck(const QString & );
192 protected: 192 protected:
193 void init(); 193 void init();
194 void updateMimes(); 194 void updateMimes();
195 195
196 protected: 196 protected:
197 197
198 private: 198 private:
199 int m_mode, m_selector; 199 int m_mode, m_selector;
200 QComboBox *m_location, *m_mimeCheck, *m_viewCheck; 200 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
201 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; 201 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
202 QPushButton *m_reread, *m_up; 202 QPushButton *m_reread, *m_up;
203 QListView *m_View; 203 QListView *m_View;
204 QCheckBox *m_checkPerm; 204 QCheckBox *m_checkPerm;
205 QWidget *m_pseudo; 205 QWidget *m_pseudo;
206 QVBoxLayout *m_pseudoLayout; 206 QVBoxLayout *m_pseudoLayout;
207 207
208 QString m_currentDir; 208 QString m_currentDir;
209 QString m_name; 209 QString m_name;
210 QStringList m_mimetypes; 210 QStringList m_mimetypes;
211 211
212 FileSelector *m_select; 212 FileSelector *m_select;
213 QWidgetStack *m_stack; 213 QWidgetStack *m_stack;
214 QVBoxLayout *m_lay; 214 QVBoxLayout *m_lay;
215 QGridLayout *m_Oselector; 215 QGridLayout *m_Oselector;
216 216
217 QHBoxLayout *m_boxToolbar; 217 QHBoxLayout *m_boxToolbar;
218 QHBoxLayout *m_boxOk; 218 QHBoxLayout *m_boxOk;
219 QHBoxLayout *m_boxName; 219 QHBoxLayout *m_boxName;
220 QHBoxLayout *m_boxView; 220 QHBoxLayout *m_boxView;
221 221
222 QPopupMenu *m_custom; 222 QPopupMenu *m_custom;
223 223
224 QLineEdit *m_edit; 224 QLineEdit *m_edit;
225 QLabel *m_fnLabel; 225 QLabel *m_fnLabel;
226 bool m_shTool:1; 226 bool m_shTool:1;
227 bool m_shPerm:1; 227 bool m_shPerm:1;
228 bool m_shLne:1; 228 bool m_shLne:1;
229 bool m_shChooser:1; 229 bool m_shChooser:1;
230 bool m_shYesNo:1; 230 bool m_shYesNo:1;
231 bool m_boCheckPerm:1; 231 bool m_boCheckPerm:1;
232 bool m_autoMime:1; 232 bool m_autoMime:1;
233 bool m_case:1; 233 bool m_case:1;
234 bool m_dir:1; 234 bool m_dir:1;
235 bool m_files:1; 235 bool m_files:1;
236 bool m_showPopup:1; 236 bool m_showPopup:1;
237 237
238 // implementation todo 238 // implementation todo
239 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); 239 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE );
240 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); 240 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE );
241 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; 241 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){};
242 void delItems(); 242 void delItems();
243 void initializeName(); 243 void initializeName();
244 void initializeYes(); 244 void initializeYes();
245 void initializeChooser(); 245 void initializeChooser();
246 void initializeListView(); 246 void initializeListView();
247 void initPics(); 247 void initPics();
248 bool compliesMime(const QString &path, const QString &mime); 248 bool compliesMime(const QString &path, const QString &mime);
249 249
250 class OFileSelectorPrivate; 250 class OFileSelectorPrivate;
251 OFileSelectorPrivate *d; 251 OFileSelectorPrivate *d;
252 static QMap<QString,QPixmap> *m_pixmaps; 252 static QMap<QString,QPixmap> *m_pixmaps;
253 253
254private slots: 254private slots:
255 void slotFileSelected(const QString & ); // not really meant to be a slot 255 void slotFileSelected(const QString & ); // not really meant to be a slot
256 void slotFileBridgeSelected( const DocLnk & ); 256 void slotFileBridgeSelected( const DocLnk & );
257 virtual void slotSelectionChanged(); 257 virtual void slotSelectionChanged();
258 virtual void slotCurrentChanged(QListViewItem* ); 258 virtual void slotCurrentChanged(QListViewItem* );
259 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); 259 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int);
260 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); 260 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int );
261 virtual void slotContextMenu( QListViewItem *item); 261 virtual void slotContextMenu( QListViewItem *item);
262 // listview crap see above 262 // listview crap see above
263 // PopupMenu crap 263 // PopupMenu crap
264 virtual void slotChangedDir(); 264 virtual void slotChangedDir();
265 virtual void slotOpen(); 265 virtual void slotOpen();
266 virtual void slotRescan(); 266 virtual void slotRescan();
267 virtual void slotRename(); 267 virtual void slotRename();
268 virtual void slotDelete(); 268 virtual void slotDelete();
269 virtual void cdUP(); 269 virtual void cdUP();
270 270 virtual void slotHome();
271 virtual void slotDoc();
272 virtual void slotNavigate( );
271}; 273};
272 274
273 275
274#endif 276#endif
275 277