summaryrefslogtreecommitdiff
authorzecke <zecke>2004-02-07 09:58:31 (UTC)
committer zecke <zecke>2004-02-07 09:58:31 (UTC)
commita41eba9e8404fb6321097e86736e23fbce4ead7a (patch) (unidiff)
treebae6341fa67fdbccaf21e470fa8bb5f13a9460af
parentd4a72f6f428cb764330f07e9499ef9a4795b8228 (diff)
downloadopie-a41eba9e8404fb6321097e86736e23fbce4ead7a.zip
opie-a41eba9e8404fb6321097e86736e23fbce4ead7a.tar.gz
opie-a41eba9e8404fb6321097e86736e23fbce4ead7a.tar.bz2
Forward port the recent API docu of the FileSelector
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp72
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h60
2 files changed, 131 insertions, 1 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 71d765c..600daff 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -430,665 +430,737 @@ void OFileViewFileListView::reread( bool all )
430 // now go through all files 430 // now go through all files
431 const QFileInfoList *list = dir.entryInfoList(); 431 const QFileInfoList *list = dir.entryInfoList();
432 if (!list) 432 if (!list)
433 { 433 {
434 cdUP(); 434 cdUP();
435 return; 435 return;
436 } 436 }
437 437
438 QFileInfoListIterator it( *list ); 438 QFileInfoListIterator it( *list );
439 QFileInfo *fi; 439 QFileInfo *fi;
440 while( (fi=it.current() ) ) 440 while( (fi=it.current() ) )
441 { 441 {
442 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) 442 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") )
443 { 443 {
444 ++it; 444 ++it;
445 continue; 445 continue;
446 } 446 }
447 447
448 /* 448 /*
449 * It is a symlink we try to resolve it now but don't let us attack by DOS 449 * It is a symlink we try to resolve it now but don't let us attack by DOS
450 * 450 *
451 */ 451 */
452 if( fi->isSymLink() ) 452 if( fi->isSymLink() )
453 { 453 {
454 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 454 QString file = fi->dirPath( true ) + "/" + fi->readLink();
455 for( int i = 0; i<=4; i++) 455 for( int i = 0; i<=4; i++)
456 { // 5 tries to prevent dos 456 { // 5 tries to prevent dos
457 QFileInfo info( file ); 457 QFileInfo info( file );
458 if( !info.exists() ) 458 if( !info.exists() )
459 { 459 {
460 addSymlink( fi, TRUE ); 460 addSymlink( fi, TRUE );
461 break; 461 break;
462 } 462 }
463 else if( info.isDir() ) 463 else if( info.isDir() )
464 { 464 {
465 addDir( fi, TRUE ); 465 addDir( fi, TRUE );
466 break; 466 break;
467 } 467 }
468 else if( info.isFile() ) 468 else if( info.isFile() )
469 { 469 {
470 addFile( fi, TRUE ); 470 addFile( fi, TRUE );
471 break; 471 break;
472 } 472 }
473 else if( info.isSymLink() ) 473 else if( info.isSymLink() )
474 { 474 {
475 file = info.dirPath(true ) + "/" + info.readLink() ; 475 file = info.dirPath(true ) + "/" + info.readLink() ;
476 break; 476 break;
477 } 477 }
478 else if( i == 4) 478 else if( i == 4)
479 { // couldn't resolve symlink add it as symlink 479 { // couldn't resolve symlink add it as symlink
480 addSymlink( fi ); 480 addSymlink( fi );
481 } 481 }
482 } // off for loop for symlink resolving 482 } // off for loop for symlink resolving
483 } 483 }
484 else if( fi->isDir() ) 484 else if( fi->isDir() )
485 addDir( fi ); 485 addDir( fi );
486 else if( fi->isFile() ) 486 else if( fi->isFile() )
487 addFile( fi ); 487 addFile( fi );
488 488
489 ++it; 489 ++it;
490 } // of while loop 490 } // of while loop
491 m_view->sort(); 491 m_view->sort();
492 492
493} 493}
494int OFileViewFileListView::fileCount()const 494int OFileViewFileListView::fileCount()const
495{ 495{
496 return m_view->childCount(); 496 return m_view->childCount();
497} 497}
498 498
499QString OFileViewFileListView::currentDir()const 499QString OFileViewFileListView::currentDir()const
500{ 500{
501 return m_currentDir; 501 return m_currentDir;
502} 502}
503 503
504OFileSelector* OFileViewFileListView::selector() 504OFileSelector* OFileViewFileListView::selector()
505{ 505{
506 return m_sel; 506 return m_sel;
507} 507}
508 508
509bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) 509bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e)
510{ 510{
511 if ( e->type() == QEvent::KeyPress ) 511 if ( e->type() == QEvent::KeyPress )
512 { 512 {
513 QKeyEvent *k = (QKeyEvent *)e; 513 QKeyEvent *k = (QKeyEvent *)e;
514 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 514 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
515 { 515 {
516 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 516 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
517 return true; 517 return true;
518 } 518 }
519 } 519 }
520 return false; 520 return false;
521} 521}
522 522
523void OFileViewFileListView::connectSlots() 523void OFileViewFileListView::connectSlots()
524{ 524{
525 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 525 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
526 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 526 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
527 connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), 527 connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ),
528 this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); 528 this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) );
529} 529}
530 530
531void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 531void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
532{ 532{
533 if (!item) 533 if (!item)
534 return; 534 return;
535#if 0 535#if 0
536 536
537 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 537 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
538 538
539 if (!sel->isDir() ) 539 if (!sel->isDir() )
540 { 540 {
541 selector()->m_lneEdit->setText( sel->text(1) ); 541 selector()->m_lneEdit->setText( sel->text(1) );
542 // if in fileselector mode we will emit selected 542 // if in fileselector mode we will emit selected
543 if ( selector()->mode() == OFileSelector::FileSelector ) 543 if ( selector()->mode() == OFileSelector::FileSelector )
544 { 544 {
545 qWarning("slot Current Changed"); 545 qWarning("slot Current Changed");
546 QStringList str = QStringList::split("->", sel->text(1) ); 546 QStringList str = QStringList::split("->", sel->text(1) );
547 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 547 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
548 emit selector()->fileSelected( path ); 548 emit selector()->fileSelected( path );
549 DocLnk lnk( path ); 549 DocLnk lnk( path );
550 emit selector()->fileSelected( lnk ); 550 emit selector()->fileSelected( lnk );
551 } 551 }
552 } 552 }
553#endif 553#endif
554} 554}
555 555
556void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) 556void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int )
557{ 557{
558 if (!item || ( button != Qt::LeftButton) ) 558 if (!item || ( button != Qt::LeftButton) )
559 return; 559 return;
560 560
561 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 561 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
562 if (!sel->isLocked() ) 562 if (!sel->isLocked() )
563 { 563 {
564 QStringList str = QStringList::split("->", sel->text(1) ); 564 QStringList str = QStringList::split("->", sel->text(1) );
565 if (sel->isDir() ) 565 if (sel->isDir() )
566 { 566 {
567 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 567 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
568 emit selector()->dirSelected( m_currentDir ); 568 emit selector()->dirSelected( m_currentDir );
569 reread( m_all ); 569 reread( m_all );
570 } 570 }
571 else 571 else
572 { // file 572 { // file
573 qWarning("slot Clicked"); 573 qWarning("slot Clicked");
574 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 574 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
575 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 575 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
576 emit selector()->fileSelected( path ); 576 emit selector()->fileSelected( path );
577 DocLnk lnk( path ); 577 DocLnk lnk( path );
578 emit selector()->fileSelected( lnk ); 578 emit selector()->fileSelected( lnk );
579 } 579 }
580 } // not locked 580 } // not locked
581} 581}
582 582
583void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) 583void OFileViewFileListView::addFile( QFileInfo* info, bool symlink )
584{ 584{
585 MimeType type( info->absFilePath() ); 585 MimeType type( info->absFilePath() );
586 if (!compliesMime( type.id() ) ) 586 if (!compliesMime( type.id() ) )
587 return; 587 return;
588 588
589 QPixmap pix = type.pixmap(); 589 QPixmap pix = type.pixmap();
590 QString dir, name; bool locked; 590 QString dir, name; bool locked;
591 if ( pix.isNull() ) 591 if ( pix.isNull() )
592 { 592 {
593 QWMatrix matrix; 593 QWMatrix matrix;
594 QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); 594 QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
595 matrix.scale( .4, .4 ); 595 matrix.scale( .4, .4 );
596 pix = pixer.xForm( matrix ); 596 pix = pixer.xForm( matrix );
597 } 597 }
598 dir = info->dirPath( true ); 598 dir = info->dirPath( true );
599 locked = false; 599 locked = false;
600 if ( symlink ) 600 if ( symlink )
601 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 601 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
602 else 602 else
603 { 603 {
604 name = info->fileName(); 604 name = info->fileName();
605 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || 605 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
606 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) 606 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) )
607 { 607 {
608 locked = true; pix = Resource::loadPixmap("locked"); 608 locked = true; pix = Resource::loadPixmap("locked");
609 } 609 }
610 } 610 }
611 (void)new OFileSelectorItem( m_view, pix, name, 611 (void)new OFileSelectorItem( m_view, pix, name,
612 info->lastModified().toString(), QString::number( info->size() ), 612 info->lastModified().toString(), QString::number( info->size() ),
613 dir, locked ); 613 dir, locked );
614} 614}
615 615
616void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) 616void OFileViewFileListView::addDir( QFileInfo* info, bool symlink )
617{ 617{
618 bool locked = false; QString name; QPixmap pix; 618 bool locked = false; QString name; QPixmap pix;
619 619
620 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || 620 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
621 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) 621 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) )
622 { 622 {
623 locked = true; 623 locked = true;
624 if ( symlink ) 624 if ( symlink )
625 pix = Resource::loadPixmap( "opie/symlink" ); 625 pix = Resource::loadPixmap( "opie/symlink" );
626 else 626 else
627 pix = Resource::loadPixmap( "lockedfolder" ); 627 pix = Resource::loadPixmap( "lockedfolder" );
628 } 628 }
629 else 629 else
630 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); 630 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder");
631 631
632 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : 632 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() :
633 info->fileName(); 633 info->fileName();
634 634
635 (void)new OFileSelectorItem( m_view, pix, name, 635 (void)new OFileSelectorItem( m_view, pix, name,
636 info->lastModified().toString(), 636 info->lastModified().toString(),
637 QString::number( info->size() ), 637 QString::number( info->size() ),
638 info->dirPath( true ), locked, true ); 638 info->dirPath( true ), locked, true );
639 639
640 640
641} 641}
642 642
643void OFileViewFileListView::addSymlink( QFileInfo* , bool ) 643void OFileViewFileListView::addSymlink( QFileInfo* , bool )
644{ 644{
645} 645}
646 646
647void OFileViewFileListView::cdUP() 647void OFileViewFileListView::cdUP()
648{ 648{
649 QDir dir( m_currentDir ); 649 QDir dir( m_currentDir );
650 dir.cdUp(); 650 dir.cdUp();
651 651
652 if (!dir.exists() ) 652 if (!dir.exists() )
653 m_currentDir = "/"; 653 m_currentDir = "/";
654 else 654 else
655 m_currentDir = dir.absPath(); 655 m_currentDir = dir.absPath();
656 656
657 emit selector()->dirSelected( m_currentDir ); 657 emit selector()->dirSelected( m_currentDir );
658 reread( m_all ); 658 reread( m_all );
659} 659}
660 660
661void OFileViewFileListView::cdHome() 661void OFileViewFileListView::cdHome()
662{ 662{
663 m_currentDir = QDir::homeDirPath(); 663 m_currentDir = QDir::homeDirPath();
664 emit selector()->dirSelected( m_currentDir ); 664 emit selector()->dirSelected( m_currentDir );
665 reread( m_all ); 665 reread( m_all );
666} 666}
667 667
668void OFileViewFileListView::cdDoc() 668void OFileViewFileListView::cdDoc()
669{ 669{
670 m_currentDir = QPEApplication::documentDir(); 670 m_currentDir = QPEApplication::documentDir();
671 emit selector()->dirSelected( m_currentDir ); 671 emit selector()->dirSelected( m_currentDir );
672 reread( m_all ); 672 reread( m_all );
673} 673}
674 674
675void OFileViewFileListView::changeDir( const QString& dir ) 675void OFileViewFileListView::changeDir( const QString& dir )
676{ 676{
677 m_currentDir = dir; 677 m_currentDir = dir;
678 emit selector()->dirSelected( m_currentDir ); 678 emit selector()->dirSelected( m_currentDir );
679 reread( m_all ); 679 reread( m_all );
680} 680}
681 681
682void OFileViewFileListView::slotFSActivated( int id ) 682void OFileViewFileListView::slotFSActivated( int id )
683{ 683{
684 changeDir ( m_dev[m_fsPop->text(id)] ); 684 changeDir ( m_dev[m_fsPop->text(id)] );
685} 685}
686 686
687/* check if the mimetype in mime 687/* check if the mimetype in mime
688 * complies with the one which is current 688 * complies with the one which is current
689 */ 689 */
690/* 690/*
691 * We've the mimetype of the file 691 * We've the mimetype of the file
692 * We need to get the stringlist of the current mimetype 692 * We need to get the stringlist of the current mimetype
693 * 693 *
694 * mime = image@slashjpeg 694 * mime = image@slashjpeg
695 * QStringList = 'image@slash*' 695 * QStringList = 'image@slash*'
696 * or QStringList = image/jpeg;image/png;application/x-ogg 696 * or QStringList = image/jpeg;image/png;application/x-ogg
697 * or QStringList = application/x-ogg;image@slash*; 697 * or QStringList = application/x-ogg;image@slash*;
698 * with all these mime filters it should get acceptes 698 * with all these mime filters it should get acceptes
699 * to do so we need to look if mime is contained inside 699 * to do so we need to look if mime is contained inside
700 * the stringlist 700 * the stringlist
701 * if it's contained return true 701 * if it's contained return true
702 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' 702 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*'
703 * is contained in the mimefilter and then we will 703 * is contained in the mimefilter and then we will
704 * look if both are equal until the '/' 704 * look if both are equal until the '/'
705 */ 705 */
706 706
707bool OFileViewFileListView::compliesMime( const QString& str) 707bool OFileViewFileListView::compliesMime( const QString& str)
708{ 708{
709 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) 709 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() )
710 return true; 710 return true;
711 711
712 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) 712 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it )
713 { 713 {
714 QRegExp reg( (*it) ); 714 QRegExp reg( (*it) );
715 reg.setWildcard( true ); 715 reg.setWildcard( true );
716 if ( str.find( reg ) != -1 ) 716 if ( str.find( reg ) != -1 )
717 return true; 717 return true;
718 718
719 } 719 }
720 return false; 720 return false;
721} 721}
722/* 722/*
723 * The listView giving access to the file system! 723 * The listView giving access to the file system!
724 */ 724 */
725 725
726class OFileViewFileSystem : public OFileViewInterface 726class OFileViewFileSystem : public OFileViewInterface
727{ 727{
728public: 728public:
729 OFileViewFileSystem( OFileSelector* ); 729 OFileViewFileSystem( OFileSelector* );
730 ~OFileViewFileSystem(); 730 ~OFileViewFileSystem();
731 731
732 QString selectedName() const; 732 QString selectedName() const;
733 QString selectedPath() const; 733 QString selectedPath() const;
734 734
735 QString directory()const; 735 QString directory()const;
736 void reread(); 736 void reread();
737 int fileCount()const; 737 int fileCount()const;
738 738
739 QWidget* widget( QWidget* parent ); 739 QWidget* widget( QWidget* parent );
740 void activate( const QString& ); 740 void activate( const QString& );
741private: 741private:
742 OFileViewFileListView* m_view; 742 OFileViewFileListView* m_view;
743 bool m_all : 1; 743 bool m_all : 1;
744}; 744};
745 745
746OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) 746OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel)
747 : OFileViewInterface( sel ) 747 : OFileViewInterface( sel )
748{ 748{
749 m_view = 0; 749 m_view = 0;
750 m_all = false; 750 m_all = false;
751} 751}
752 752
753OFileViewFileSystem::~OFileViewFileSystem() 753OFileViewFileSystem::~OFileViewFileSystem()
754{ 754{
755} 755}
756 756
757QString OFileViewFileSystem::selectedName()const 757QString OFileViewFileSystem::selectedName()const
758{ 758{
759 if (!m_view ) 759 if (!m_view )
760 return QString::null; 760 return QString::null;
761 761
762 QString cFN=currentFileName(); 762 QString cFN=currentFileName();
763 if (cFN.startsWith("/")) return cFN; 763 if (cFN.startsWith("/")) return cFN;
764 return m_view->currentDir() + "/" + cFN; 764 return m_view->currentDir() + "/" + cFN;
765} 765}
766 766
767QString OFileViewFileSystem::selectedPath()const 767QString OFileViewFileSystem::selectedPath()const
768{ 768{
769 return QString::null; 769 return QString::null;
770} 770}
771 771
772QString OFileViewFileSystem::directory()const 772QString OFileViewFileSystem::directory()const
773{ 773{
774 if (!m_view) 774 if (!m_view)
775 return QString::null; 775 return QString::null;
776 776
777 OFileSelectorItem* item = m_view->currentItem(); 777 OFileSelectorItem* item = m_view->currentItem();
778 if (!item ) 778 if (!item )
779 return QString::null; 779 return QString::null;
780 780
781 return QDir(item->directory() ).absPath(); 781 return QDir(item->directory() ).absPath();
782} 782}
783 783
784void OFileViewFileSystem::reread() 784void OFileViewFileSystem::reread()
785{ 785{
786 if (!m_view) 786 if (!m_view)
787 return; 787 return;
788 788
789 m_view->reread( m_all ); 789 m_view->reread( m_all );
790} 790}
791 791
792int OFileViewFileSystem::fileCount()const 792int OFileViewFileSystem::fileCount()const
793{ 793{
794 if (!m_view ) 794 if (!m_view )
795 return -1; 795 return -1;
796 return m_view->fileCount(); 796 return m_view->fileCount();
797} 797}
798 798
799QWidget* OFileViewFileSystem::widget( QWidget* parent ) 799QWidget* OFileViewFileSystem::widget( QWidget* parent )
800{ 800{
801 if (!m_view ) 801 if (!m_view )
802 { 802 {
803 m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); 803 m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
804 } 804 }
805 return m_view; 805 return m_view;
806} 806}
807 807
808void OFileViewFileSystem::activate( const QString& str) 808void OFileViewFileSystem::activate( const QString& str)
809{ 809{
810 m_all = (str != QObject::tr("Files") ); 810 m_all = (str != QObject::tr("Files") );
811} 811}
812 812
813/* Selector */ 813/* Selector */
814/**
815 * @short new and complete c'tor
816 *
817 * Create a OFileSelector to let the user select a file. It can
818 * either be used to open a file, select a save name in a dir or
819 * as a dropin for the FileSelector.
820 *
821 * <pre>
822 * QMap<QString, QStringList> mimeTypes;
823 * QStringList types;
824 * types << "text@slash* ";
825 * types << "audio@slash*";
826 * mimeTypes.insert( tr("Audio and Text"), types );
827 * mimeTypes.insert( tr("All"), "*@slash*);
828 *
829 * now you could create your fileselector
830 * </pre>
831 *
832 *
833 * @param parent the parent of this widget
834 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR)
835 * @param sel The selector to be used
836 * @param dirName The name of the dir to start int
837 * @param fileName The fileName placed in the fileselector lineedit
838 * @param mimetypes The MimeType map of used mimetypes
839 * @param showNew Show a New Button. Most likely to be used in the FileSelector view.
840 * @param showClose Show a Close Button. Most likely to be used in FileSelector view.
841 *
842 */
814OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, 843OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
815 const QString& dirName, const QString& fileName, 844 const QString& dirName, const QString& fileName,
816 const MimeTypes& mimetypes, 845 const MimeTypes& mimetypes,
817 bool showNew, bool showClose) 846 bool showNew, bool showClose)
818 :QWidget( parent, "OFileSelector" ) 847 :QWidget( parent, "OFileSelector" )
819{ 848{
820 m_current = 0; 849 m_current = 0;
821 m_shNew = showNew; 850 m_shNew = showNew;
822 m_shClose = showClose; 851 m_shClose = showClose;
823 m_mimeType = mimetypes; 852 m_mimeType = mimetypes;
824 m_startDir = dirName; 853 m_startDir = dirName;
825 854
826 m_mode = mode; 855 m_mode = mode;
827 m_selector = sel; 856 m_selector = sel;
828 857
829 initUI(); 858 initUI();
830 m_lneEdit->setText( fileName ); 859 m_lneEdit->setText( fileName );
831 initMime(); 860 initMime();
832 initViews(); 861 initViews();
833 862
834 QString str; 863 QString str;
835 switch ( m_selector ) 864 switch ( m_selector )
836 { 865 {
837 default: 866 default:
838 case Normal: 867 case Normal:
839 str = QObject::tr("Documents"); 868 str = QObject::tr("Documents");
840 m_cmbView->setCurrentItem( 0 ); 869 m_cmbView->setCurrentItem( 0 );
841 break; 870 break;
842 case Extended: 871 case Extended:
843 str = QObject::tr("Files"); 872 str = QObject::tr("Files");
844 m_cmbView->setCurrentItem( 1 ); 873 m_cmbView->setCurrentItem( 1 );
845 break; 874 break;
846 case ExtendedAll: 875 case ExtendedAll:
847 str = QObject::tr("All Files"); 876 str = QObject::tr("All Files");
848 m_cmbView->setCurrentItem( 2 ); 877 m_cmbView->setCurrentItem( 2 );
849 break; 878 break;
850 } 879 }
851 slotViewChange( str ); 880 slotViewChange( str );
852 881
853} 882}
854 883
884
885/**
886 * This a convience c'tor to just substitute the use of FileSelector
887 */
855OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, 888OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name,
856 bool showNew, bool showClose ) 889 bool showNew, bool showClose )
857 : QWidget( parent, name ) 890 : QWidget( parent, name )
858{ 891{
859 m_current = 0; 892 m_current = 0;
860 m_shNew = showNew; 893 m_shNew = showNew;
861 m_shClose = showClose; 894 m_shClose = showClose;
862 m_startDir = QPEApplication::documentDir(); 895 m_startDir = QPEApplication::documentDir();
863 896
864 if (!mimeFilter.isEmpty() ) 897 if (!mimeFilter.isEmpty() )
865 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); 898 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) );
866 899
867 m_mode = OFileSelector::FileSelector; 900 m_mode = OFileSelector::FileSelector;
868 m_selector = OFileSelector::Normal; 901 m_selector = OFileSelector::Normal;
869 902
870 initUI(); 903 initUI();
871 initMime(); 904 initMime();
872 initViews(); 905 initViews();
873 m_cmbView->setCurrentItem( 0 ); 906 m_cmbView->setCurrentItem( 0 );
874 slotViewChange( QObject::tr("Documents") ); 907 slotViewChange( QObject::tr("Documents") );
875} 908}
876 909
877/* 910/*
878 * INIT UI will set up the basic GUI 911 * INIT UI will set up the basic GUI
879 * Layout: Simple VBoxLayout 912 * Layout: Simple VBoxLayout
880 * On top a WidgetStack containing the Views... 913 * On top a WidgetStack containing the Views...
881 * - List View 914 * - List View
882 * - Document View 915 * - Document View
883 * Below we will have a Label + LineEdit 916 * Below we will have a Label + LineEdit
884 * Below we will have two ComoBoxes one for choosing the view one for 917 * Below we will have two ComoBoxes one for choosing the view one for
885 * choosing the mimetype 918 * choosing the mimetype
886 */ 919 */
887void OFileSelector::initUI() 920void OFileSelector::initUI()
888{ 921{
889 QVBoxLayout* lay = new QVBoxLayout( this ); 922 QVBoxLayout* lay = new QVBoxLayout( this );
890 923
891 m_stack = new QWidgetStack( this ); 924 m_stack = new QWidgetStack( this );
892 lay->addWidget( m_stack, 1000 ); 925 lay->addWidget( m_stack, 1000 );
893 926
894 m_nameBox = new QHBox( this ); 927 m_nameBox = new QHBox( this );
895 (void)new QLabel( tr("Name:"), m_nameBox ); 928 (void)new QLabel( tr("Name:"), m_nameBox );
896 m_lneEdit = new QLineEdit( m_nameBox ); 929 m_lneEdit = new QLineEdit( m_nameBox );
897 m_lneEdit ->installEventFilter(this); 930 m_lneEdit ->installEventFilter(this);
898 lay->addWidget( m_nameBox ); 931 lay->addWidget( m_nameBox );
899 932
900 m_cmbBox = new QHBox( this ); 933 m_cmbBox = new QHBox( this );
901 m_cmbView = new QComboBox( m_cmbBox ); 934 m_cmbView = new QComboBox( m_cmbBox );
902 m_cmbMime = new QComboBox( m_cmbBox ); 935 m_cmbMime = new QComboBox( m_cmbBox );
903 lay->addWidget( m_cmbBox ); 936 lay->addWidget( m_cmbBox );
904} 937}
905 938
906/* 939/*
907 * This will make sure that the return key in the name edit causes dialogs to close 940 * This will make sure that the return key in the name edit causes dialogs to close
908 */ 941 */
909 942
910bool OFileSelector::eventFilter (QObject *o, QEvent *e) 943bool OFileSelector::eventFilter (QObject *o, QEvent *e)
911{ 944{
912 if ( e->type() == QEvent::KeyPress ) 945 if ( e->type() == QEvent::KeyPress )
913 { 946 {
914 QKeyEvent *k = (QKeyEvent *)e; 947 QKeyEvent *k = (QKeyEvent *)e;
915 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 948 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
916 { 949 {
917 emit ok(); 950 emit ok();
918 return true; 951 return true;
919 } 952 }
920 } 953 }
921 return false; 954 return false;
922} 955}
923 956
924/* 957/*
925 * This will insert the MimeTypes into the Combo Box 958 * This will insert the MimeTypes into the Combo Box
926 * And also connect the changed signal 959 * And also connect the changed signal
927 * 960 *
928 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes 961 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes
929 */ 962 */
930void OFileSelector::initMime() 963void OFileSelector::initMime()
931{ 964{
932 MimeTypes::Iterator it; 965 MimeTypes::Iterator it;
933 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) 966 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it )
934 { 967 {
935 m_cmbMime->insertItem( it.key() ); 968 m_cmbMime->insertItem( it.key() );
936 } 969 }
937 m_cmbMime->setCurrentItem( 0 ); 970 m_cmbMime->setCurrentItem( 0 );
938 971
939 connect( m_cmbMime, SIGNAL(activated(int) ), 972 connect( m_cmbMime, SIGNAL(activated(int) ),
940 this, SLOT(slotMimeTypeChanged() ) ); 973 this, SLOT(slotMimeTypeChanged() ) );
941 974
942} 975}
943 976
944void OFileSelector::initViews() 977void OFileSelector::initViews()
945{ 978{
946 m_cmbView->insertItem( QObject::tr("Documents") ); 979 m_cmbView->insertItem( QObject::tr("Documents") );
947 m_cmbView->insertItem( QObject::tr("Files") ); 980 m_cmbView->insertItem( QObject::tr("Files") );
948 m_cmbView->insertItem( QObject::tr("All Files") ); 981 m_cmbView->insertItem( QObject::tr("All Files") );
949 connect(m_cmbView, SIGNAL(activated( const QString& ) ), 982 connect(m_cmbView, SIGNAL(activated( const QString& ) ),
950 this, SLOT(slotViewChange( const QString& ) ) ); 983 this, SLOT(slotViewChange( const QString& ) ) );
951 984
952 985
953 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); 986 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
954 987
955 /* see above why add both */ 988 /* see above why add both */
956 OFileViewInterface* in = new OFileViewFileSystem( this ); 989 OFileViewInterface* in = new OFileViewFileSystem( this );
957 m_views.insert( QObject::tr("Files"), in ); 990 m_views.insert( QObject::tr("Files"), in );
958 m_views.insert( QObject::tr("All Files"), in ); 991 m_views.insert( QObject::tr("All Files"), in );
959} 992}
960 993
994/**
995 * d'tor
996 */
961OFileSelector::~OFileSelector() 997OFileSelector::~OFileSelector()
962{ 998{
963} 999}
964 1000
1001
1002
1003/**
1004 * Convience function for the fileselector
1005 * make sure to delete the DocLnk
1006 *
1007 * @see DocLnk
1008 * @todo remove in ODP
1009 */
965const DocLnk* OFileSelector::selected() 1010const DocLnk* OFileSelector::selected()
966{ 1011{
967 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); 1012 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() );
968 return lnk; 1013 return lnk;
969} 1014}
970 1015
1016/**
1017 *
1018 * @return the name of the selected file
1019 */
971QString OFileSelector::selectedName()const 1020QString OFileSelector::selectedName()const
972{ 1021{
973 return currentView()->selectedName(); 1022 return currentView()->selectedName();
974} 1023}
975 1024
1025
1026/**
1027 * @return the selected path
1028 */
976QString OFileSelector::selectedPath()const 1029QString OFileSelector::selectedPath()const
977{ 1030{
978 return currentView()->selectedPath(); 1031 return currentView()->selectedPath();
979} 1032}
980 1033
1034/**
1035 * @return the directory name
1036 */
981QString OFileSelector::directory()const 1037QString OFileSelector::directory()const
982{ 1038{
983 return currentView()->directory(); 1039 return currentView()->directory();
984} 1040}
985 1041
1042/**
1043 * @return a DocLnk for the selected document
1044 */
986DocLnk OFileSelector::selectedDocument()const 1045DocLnk OFileSelector::selectedDocument()const
987{ 1046{
988 return currentView()->selectedDocument(); 1047 return currentView()->selectedDocument();
989} 1048}
990 1049
1050/**
1051 * @return the number of items for the current view
1052 */
991int OFileSelector::fileCount()const 1053int OFileSelector::fileCount()const
992{ 1054{
993 return currentView()->fileCount(); 1055 return currentView()->fileCount();
994} 1056}
995 1057
1058/**
1059 * @return reparse the file content
1060 */
996void OFileSelector::reread() 1061void OFileSelector::reread()
997{ 1062{
998 return currentView()->reread(); 1063 return currentView()->reread();
999} 1064}
1000 1065
1001OFileViewInterface* OFileSelector::currentView()const 1066OFileViewInterface* OFileSelector::currentView()const
1002{ 1067{
1003 return m_current; 1068 return m_current;
1004} 1069}
1005 1070
1006bool OFileSelector::showNew()const 1071bool OFileSelector::showNew()const
1007{ 1072{
1008 return m_shNew; 1073 return m_shNew;
1009} 1074}
1010 1075
1011bool OFileSelector::showClose()const 1076bool OFileSelector::showClose()const
1012{ 1077{
1013 return m_shClose; 1078 return m_shClose;
1014} 1079}
1015 1080
1016MimeTypes OFileSelector::mimeTypes()const 1081MimeTypes OFileSelector::mimeTypes()const
1017{ 1082{
1018 return m_mimeType; 1083 return m_mimeType;
1019} 1084}
1020 1085
1086/**
1087 * @return the Mode of the OFileSelector
1088 */
1021int OFileSelector::mode()const 1089int OFileSelector::mode()const
1022{ 1090{
1023 return m_mode; 1091 return m_mode;
1024} 1092}
1025 1093
1094
1095/**
1096 * @return the Selector of the OFileSelector
1097 */
1026int OFileSelector::selector()const 1098int OFileSelector::selector()const
1027{ 1099{
1028 return m_selector; 1100 return m_selector;
1029} 1101}
1030 1102
1031QStringList OFileSelector::currentMimeType()const 1103QStringList OFileSelector::currentMimeType()const
1032{ 1104{
1033 return m_mimeType[m_cmbMime->currentText()]; 1105 return m_mimeType[m_cmbMime->currentText()];
1034} 1106}
1035 1107
1036void OFileSelector::slotMimeTypeChanged() 1108void OFileSelector::slotMimeTypeChanged()
1037{ 1109{
1038 reread(); 1110 reread();
1039} 1111}
1040 1112
1041void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) 1113void OFileSelector::slotDocLnkBridge( const DocLnk& lnk)
1042{ 1114{
1043 m_lneEdit->setText( lnk.name() ); 1115 m_lneEdit->setText( lnk.name() );
1044 emit fileSelected( lnk ); 1116 emit fileSelected( lnk );
1045 emit fileSelected( lnk.name() ); 1117 emit fileSelected( lnk.name() );
1046} 1118}
1047 1119
1048void OFileSelector::slotFileBridge( const QString& str) 1120void OFileSelector::slotFileBridge( const QString& str)
1049{ 1121{
1050 DocLnk lnk( str ); 1122 DocLnk lnk( str );
1051 emit fileSelected( lnk ); 1123 emit fileSelected( lnk );
1052} 1124}
1053 1125
1054void OFileSelector::slotViewChange( const QString& view ) 1126void OFileSelector::slotViewChange( const QString& view )
1055{ 1127{
1056 OFileViewInterface* interface = m_views[view]; 1128 OFileViewInterface* interface = m_views[view];
1057 if (!interface) 1129 if (!interface)
1058 return; 1130 return;
1059 1131
1060 interface->activate( view ); 1132 interface->activate( view );
1061 if (m_current) 1133 if (m_current)
1062 m_stack->removeWidget( m_current->widget( m_stack ) ); 1134 m_stack->removeWidget( m_current->widget( m_stack ) );
1063 1135
1064 static int id = 1; 1136 static int id = 1;
1065 1137
1066 m_stack->addWidget( interface->widget(m_stack), id ); 1138 m_stack->addWidget( interface->widget(m_stack), id );
1067 m_stack->raiseWidget( id ); 1139 m_stack->raiseWidget( id );
1068 1140
1069 interface->reread(); 1141 interface->reread();
1070 m_current = interface; 1142 m_current = interface;
1071 1143
1072 id++; 1144 id++;
1073} 1145}
1074 1146
1075void OFileSelector::setNewVisible( bool b ) 1147void OFileSelector::setNewVisible( bool b )
1076{ 1148{
1077 m_shNew = b; 1149 m_shNew = b;
1078 currentView()->reread(); 1150 currentView()->reread();
1079} 1151}
1080 1152
1081void OFileSelector::setCloseVisible( bool b ) 1153void OFileSelector::setCloseVisible( bool b )
1082{ 1154{
1083 m_shClose = b; 1155 m_shClose = b;
1084 currentView()->reread(); 1156 currentView()->reread();
1085} 1157}
1086 1158
1087void OFileSelector::setNameVisible( bool b ) 1159void OFileSelector::setNameVisible( bool b )
1088{ 1160{
1089 if ( b ) 1161 if ( b )
1090 m_nameBox->show(); 1162 m_nameBox->show();
1091 else 1163 else
1092 m_nameBox->hide(); 1164 m_nameBox->hide();
1093} 1165}
1094 1166
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
index 7abe8b7..7fa657b 100644
--- a/libopie2/opieui/fileselector/ofileselector.h
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -1,161 +1,219 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29/* 29/*
30 This is based on code and ideas of 30 This is based on code and ideas of
31 L. J. Potter ljp@llornkcor.com 31 L. J. Potter ljp@llornkcor.com
32 Thanks a lot 32 Thanks a lot
33*/ 33*/
34 34
35#ifndef OFILESELECTOR_H 35#ifndef OFILESELECTOR_H
36#define OFILESELECTOR_H 36#define OFILESELECTOR_H
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/applnk.h> 39#include <qpe/applnk.h>
40 40
41/* QT */ 41/* QT */
42#include <qlist.h> 42#include <qlist.h>
43#include <qwidget.h> 43#include <qwidget.h>
44#include <qmap.h> 44#include <qmap.h>
45#include <qvaluelist.h> 45#include <qvaluelist.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47 47
48class QLineEdit; 48class QLineEdit;
49class QComboBox; 49class QComboBox;
50class QWidgetStack; 50class QWidgetStack;
51class QHBox; 51class QHBox;
52 52
53typedef QMap<QString, QStringList> MimeTypes; 53typedef QMap<QString, QStringList> MimeTypes;
54 54
55namespace Opie 55namespace Opie
56{ 56{
57 57
58class OFileViewInterface; 58class OFileViewInterface;
59class OFileViewFileListView; 59class OFileViewFileListView;
60 60
61
62/**
63 * @short a dropin replacement for the FileSelector
64 *
65 * This class is first used insert the OFileDialog.
66 * It supports multiple view and mimetype filtering for now.
67 *
68 * @see OFileDialog
69 * @see FileSelector
70 * @author zecke
71 * @version 0.1
72 */
61class OFileSelector : public QWidget 73class OFileSelector : public QWidget
62{ 74{
63 Q_OBJECT 75 Q_OBJECT
64 friend class Opie::OFileViewInterface; 76 friend class Opie::OFileViewInterface;
65 friend class Opie::OFileViewFileListView; 77 friend class Opie::OFileViewFileListView;
66 78
67public: 79public:
80 /**
81 * The Mode of the Fileselector
82 * Open = Open A File
83 * Save = Save a File
84 * FILESELECTOR = As A GUI in a screen to select a file
85 */
68 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; 86 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
69 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; 87 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
88 /**
89 * Normal = The old FileSelector
90 * Extended = Dir View
91 * ExtendedAll = Dir View with all hidden files
92 * Default = What the vendor considers best
93 */
70 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; 94 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
71 // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; 95 // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
72 96
73 OFileSelector(QWidget* parent, int mode, int selector, 97 OFileSelector(QWidget* parent, int mode, int selector,
74 const QString& dirName, 98 const QString& dirName,
75 const QString& fileName, 99 const QString& fileName,
76 const MimeTypes& mimetypes = MimeTypes(), 100 const MimeTypes& mimetypes = MimeTypes(),
77 bool newVisible = FALSE, bool closeVisible = FALSE ); 101 bool newVisible = FALSE, bool closeVisible = FALSE );
78 102
79 OFileSelector(const QString& mimeFilter, QWidget* parent, 103 OFileSelector(const QString& mimeFilter, QWidget* parent,
80 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); 104 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
81 ~OFileSelector(); 105 ~OFileSelector();
82 106
83 const DocLnk* selected(); 107 const DocLnk* selected();
84 108
85 QString selectedName()const; 109 QString selectedName()const;
86 QString selectedPath()const; 110 QString selectedPath()const;
87 QString directory()const; 111 QString directory()const;
88 112
89 DocLnk selectedDocument()const; 113 DocLnk selectedDocument()const;
90 114
91 int fileCount()const; 115 int fileCount()const;
92 void reread(); 116 void reread();
93 117
94 int mode()const; 118 int mode()const;
95 int selector()const; 119 int selector()const;
96 120
97 121 /**
122 * Set the Icon visible
123 * @param b Show or Hide the New Button
124 */
98 void setNewVisible( bool b ); 125 void setNewVisible( bool b );
126
127 /**
128 * Set the Icon visible
129 */
99 void setCloseVisible( bool b ); 130 void setCloseVisible( bool b );
131
132 /**
133 * Set the Name Line visible
134 */
100 void setNameVisible( bool b ); 135 void setNameVisible( bool b );
101 136
102signals: 137signals:
138 /**
139 * dirSelected is emitted whenever changed into a different dir
140 */
103 void dirSelected( const QString& ); 141 void dirSelected( const QString& );
142
143 /**
144 * fileSelected is emitted when a file is selected
145 * it uses a DocLnk as parameter
146 */
104 void fileSelected( const DocLnk& ); 147 void fileSelected( const DocLnk& );
148
149 /**
150 * fileSelected is emitted when a file is selected
151 * the complete path is a parameter
152 */
105 void fileSelected( const QString& ); 153 void fileSelected( const QString& );
154
155 /**
156 * Create a new File with a DocLnk
157 */
106 void newSelected( const DocLnk& ); 158 void newSelected( const DocLnk& );
159
107 void closeMe(); 160 void closeMe();
161
162 /**
163 * Ok is emitted on a Qt::Key_Return or Q::Key_Enter
164 * in the line edit
165 */
108 void ok(); 166 void ok();
109 void cancel(); 167 void cancel();
110 168
111 /* used by the ViewInterface */ 169 /* used by the ViewInterface */
112private: 170private:
113 bool showNew()const; 171 bool showNew()const;
114 bool showClose()const; 172 bool showClose()const;
115 MimeTypes mimeTypes()const; 173 MimeTypes mimeTypes()const;
116 QStringList currentMimeType()const; 174 QStringList currentMimeType()const;
117 175
118private: 176private:
119 /* inits the Widgets */ 177 /* inits the Widgets */
120 void initUI(); 178 void initUI();
121 /* inits the MimeType ComboBox content + connects signals and slots */ 179 /* inits the MimeType ComboBox content + connects signals and slots */
122 void initMime(); 180 void initMime();
123 /* init the Views :) */ 181 /* init the Views :) */
124 void initViews(); 182 void initViews();
125 183
126private: 184private:
127 QLineEdit* m_lneEdit; // the LineEdit for the Name 185 QLineEdit* m_lneEdit; // the LineEdit for the Name
128 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType 186 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
129 QWidgetStack* m_stack; // our widget stack which will contain the views 187 QWidgetStack* m_stack; // our widget stack which will contain the views
130 OFileViewInterface* currentView() const; // returns the currentView 188 OFileViewInterface* currentView() const; // returns the currentView
131 OFileViewInterface* m_current; // here is the view saved 189 OFileViewInterface* m_current; // here is the view saved
132 bool m_shNew : 1; // should we show New? 190 bool m_shNew : 1; // should we show New?
133 bool m_shClose : 1; // should we show Close? 191 bool m_shClose : 1; // should we show Close?
134 MimeTypes m_mimeType; // list of mimetypes 192 MimeTypes m_mimeType; // list of mimetypes
135 193
136 QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr 194 QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
137 QHBox* m_nameBox; // the LineEdit + Label is hold here 195 QHBox* m_nameBox; // the LineEdit + Label is hold here
138 QHBox* m_cmbBox; // this holds the two combo boxes 196 QHBox* m_cmbBox; // this holds the two combo boxes
139 197
140 QString m_startDir; 198 QString m_startDir;
141 int m_mode; 199 int m_mode;
142 int m_selector; 200 int m_selector;
143 201
144 struct Data; // used for future versions 202 struct Data; // used for future versions
145 Data *d; 203 Data *d;
146 204
147private slots: 205private slots:
148 void slotMimeTypeChanged(); 206 void slotMimeTypeChanged();
149 207
150 /* will set the text of the lineedit and emit a fileChanged signal */ 208 /* will set the text of the lineedit and emit a fileChanged signal */
151 void slotDocLnkBridge( const DocLnk& ); 209 void slotDocLnkBridge( const DocLnk& );
152 void slotFileBridge( const QString& ); 210 void slotFileBridge( const QString& );
153 void slotViewChange( const QString& ); 211 void slotViewChange( const QString& );
154 212
155 bool eventFilter (QObject *o, QEvent *e); 213 bool eventFilter (QObject *o, QEvent *e);
156 214
157}; 215};
158 216
159}; 217};
160 218
161#endif 219#endif