summaryrefslogtreecommitdiff
path: root/libopie/ofileselector.cpp
Unidiff
Diffstat (limited to 'libopie/ofileselector.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie/ofileselector.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/libopie/ofileselector.cpp b/libopie/ofileselector.cpp
index 577e916..9afe9c7 100644
--- a/libopie/ofileselector.cpp
+++ b/libopie/ofileselector.cpp
@@ -625,12 +625,41 @@ void OFileViewFileSystem::activate( const QString& str) {
625 m_all = (str != QObject::tr("Files") ); 625 m_all = (str != QObject::tr("Files") );
626 626
627 627
628} 628}
629 629
630/* Selector */ 630/* Selector */
631/**
632 * @short new and complete c'tor
633 *
634 * Create a OFileSelector to let the user select a file. It can
635 * either be used to open a file, select a save name in a dir or
636 * as a dropin for the FileSelector.
637 *
638 * <pre>
639 * QMap<QString, QStringList> mimeTypes;
640 * QStringList types;
641 * types << "text[slash]* ";
642 * types << "audio[slash]*";
643 * mimeTypes.insert( tr("Audio and Text"), types );
644 * mimeTypes.insert( tr("All"), "*[slash]*);
645 *
646 * now you could create your fileselector
647 * </pre>
648 *
649 *
650 * @param parent the parent of this widget
651 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR)
652 * @param sel The selector to be used
653 * @param dirName The name of the dir to start int
654 * @param fileName The fileName placed in the fileselector lineedit
655 * @param mimetypes The MimeType map of used mimetypes
656 * @param showNew Show a New Button. Most likely to be used in the FileSelector view.
657 * @param showClose Show a Close Button. Most likely to be used in FileSelector view.
658 *
659 */
631OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, 660OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
632 const QString& dirName, const QString& fileName, 661 const QString& dirName, const QString& fileName,
633 const MimeTypes& mimetypes, 662 const MimeTypes& mimetypes,
634 bool showNew, bool showClose) 663 bool showNew, bool showClose)
635 : QWidget( parent, "OFileSelector" ) 664 : QWidget( parent, "OFileSelector" )
636{ 665{
@@ -664,12 +693,16 @@ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
664 m_cmbView->setCurrentItem( 2 ); 693 m_cmbView->setCurrentItem( 2 );
665 break; 694 break;
666 } 695 }
667 slotViewChange( str ); 696 slotViewChange( str );
668 697
669} 698}
699
700/**
701 * This a convience c'tor to just substitute the use of FileSelector
702 */
670OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, 703OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name,
671 bool showNew, bool showClose ) 704 bool showNew, bool showClose )
672 : QWidget( parent, name ) 705 : QWidget( parent, name )
673{ 706{
674 m_current = 0; 707 m_current = 0;
675 m_shNew = showNew; 708 m_shNew = showNew;
@@ -760,34 +793,71 @@ void OFileSelector::initViews() {
760 793
761 /* see above why add both */ 794 /* see above why add both */
762 OFileViewInterface* in = new OFileViewFileSystem( this ); 795 OFileViewInterface* in = new OFileViewFileSystem( this );
763 m_views.insert( QObject::tr("Files"), in ); 796 m_views.insert( QObject::tr("Files"), in );
764 m_views.insert( QObject::tr("All Files"), in ); 797 m_views.insert( QObject::tr("All Files"), in );
765} 798}
799
800/**
801 * d'tor
802 */
766OFileSelector::~OFileSelector() { 803OFileSelector::~OFileSelector() {
767 804
768} 805}
806
807/**
808 * Convience function for the fileselector
809 * make sure to delete the DocLnk
810 *
811 * @see DocLnk
812 * @todo remove in ODP
813 */
769const DocLnk* OFileSelector::selected() { 814const DocLnk* OFileSelector::selected() {
770 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); 815 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() );
771 return lnk; 816 return lnk;
772} 817}
818
819/**
820 *
821 * @return the name of the selected file
822 */
773QString OFileSelector::selectedName()const{ 823QString OFileSelector::selectedName()const{
774 return currentView()->selectedName(); 824 return currentView()->selectedName();
775} 825}
826
827/**
828 * @return the selected path
829 */
776QString OFileSelector::selectedPath()const { 830QString OFileSelector::selectedPath()const {
777 return currentView()->selectedPath(); 831 return currentView()->selectedPath();
778} 832}
833
834/**
835 * @return the directory name
836 */
779QString OFileSelector::directory()const { 837QString OFileSelector::directory()const {
780 return currentView()->directory(); 838 return currentView()->directory();
781} 839}
840
841/**
842 * @return a DocLnk for the selected document
843 */
782DocLnk OFileSelector::selectedDocument()const { 844DocLnk OFileSelector::selectedDocument()const {
783 return currentView()->selectedDocument(); 845 return currentView()->selectedDocument();
784} 846}
847
848/**
849 * @return the number of items for the current view
850 */
785int OFileSelector::fileCount()const { 851int OFileSelector::fileCount()const {
786 return currentView()->fileCount(); 852 return currentView()->fileCount();
787} 853}
854
855/**
856 * @return reparse the file content
857 */
788void OFileSelector::reread() { 858void OFileSelector::reread() {
789 return currentView()->reread(); 859 return currentView()->reread();
790} 860}
791OFileViewInterface* OFileSelector::currentView()const{ 861OFileViewInterface* OFileSelector::currentView()const{
792 return m_current; 862 return m_current;
793} 863}
@@ -797,15 +867,23 @@ bool OFileSelector::showNew()const {
797bool OFileSelector::showClose()const { 867bool OFileSelector::showClose()const {
798 return m_shClose; 868 return m_shClose;
799} 869}
800MimeTypes OFileSelector::mimeTypes()const { 870MimeTypes OFileSelector::mimeTypes()const {
801 return m_mimeType; 871 return m_mimeType;
802} 872}
873
874/**
875 * @return the Mode of the OFileSelector
876 */
803int OFileSelector::mode()const{ 877int OFileSelector::mode()const{
804 return m_mode; 878 return m_mode;
805} 879}
880
881/**
882 * @return the Selector of the OFileSelector
883 */
806int OFileSelector::selector()const{ 884int OFileSelector::selector()const{
807 return m_selector; 885 return m_selector;
808} 886}
809QStringList OFileSelector::currentMimeType()const { 887QStringList OFileSelector::currentMimeType()const {
810 return m_mimeType[m_cmbMime->currentText()]; 888 return m_mimeType[m_cmbMime->currentText()];
811} 889}