author | zecke <zecke> | 2004-02-02 16:05:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-02 16:05:42 (UTC) |
commit | 44e49951c71b277bd05ecc9857ec39d73a61b35e (patch) (unidiff) | |
tree | 1e55939962663d1b135bc4a23f5458d9751880bc | |
parent | 63746d6ac570b5935a75556a05fe92dacbc2d6ae (diff) | |
download | opie-44e49951c71b277bd05ecc9857ec39d73a61b35e.zip opie-44e49951c71b277bd05ecc9857ec39d73a61b35e.tar.gz opie-44e49951c71b277bd05ecc9857ec39d73a61b35e.tar.bz2 |
Add some API Docu
-rw-r--r-- | libopie/ofileselector.cpp | 78 | ||||
-rw-r--r-- | libopie/ofileselector.h | 62 |
2 files changed, 139 insertions, 1 deletions
diff --git a/libopie/ofileselector.cpp b/libopie/ofileselector.cpp index 577e916..9afe9c7 100644 --- a/libopie/ofileselector.cpp +++ b/libopie/ofileselector.cpp | |||
@@ -623,16 +623,45 @@ QWidget* OFileViewFileSystem::widget( QWidget* parent ) { | |||
623 | } | 623 | } |
624 | void OFileViewFileSystem::activate( const QString& str) { | 624 | 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 | */ | ||
631 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 660 | OFileSelector::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 | { |
637 | m_current = 0; | 666 | m_current = 0; |
638 | m_shNew = showNew; | 667 | m_shNew = showNew; |
@@ -662,16 +691,20 @@ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | |||
662 | case ExtendedAll: | 691 | case ExtendedAll: |
663 | str = QObject::tr("All Files"); | 692 | str = QObject::tr("All Files"); |
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 | */ | ||
670 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 703 | OFileSelector::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; |
676 | m_shClose = showClose; | 709 | m_shClose = showClose; |
677 | m_startDir = QPEApplication::documentDir(); | 710 | m_startDir = QPEApplication::documentDir(); |
@@ -758,56 +791,101 @@ void OFileSelector::initViews() { | |||
758 | 791 | ||
759 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); | 792 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); |
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 | */ | ||
766 | OFileSelector::~OFileSelector() { | 803 | OFileSelector::~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 | */ | ||
769 | const DocLnk* OFileSelector::selected() { | 814 | const 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 | */ | ||
773 | QString OFileSelector::selectedName()const{ | 823 | QString OFileSelector::selectedName()const{ |
774 | return currentView()->selectedName(); | 824 | return currentView()->selectedName(); |
775 | } | 825 | } |
826 | |||
827 | /** | ||
828 | * @return the selected path | ||
829 | */ | ||
776 | QString OFileSelector::selectedPath()const { | 830 | QString OFileSelector::selectedPath()const { |
777 | return currentView()->selectedPath(); | 831 | return currentView()->selectedPath(); |
778 | } | 832 | } |
833 | |||
834 | /** | ||
835 | * @return the directory name | ||
836 | */ | ||
779 | QString OFileSelector::directory()const { | 837 | QString OFileSelector::directory()const { |
780 | return currentView()->directory(); | 838 | return currentView()->directory(); |
781 | } | 839 | } |
840 | |||
841 | /** | ||
842 | * @return a DocLnk for the selected document | ||
843 | */ | ||
782 | DocLnk OFileSelector::selectedDocument()const { | 844 | DocLnk 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 | */ | ||
785 | int OFileSelector::fileCount()const { | 851 | int OFileSelector::fileCount()const { |
786 | return currentView()->fileCount(); | 852 | return currentView()->fileCount(); |
787 | } | 853 | } |
854 | |||
855 | /** | ||
856 | * @return reparse the file content | ||
857 | */ | ||
788 | void OFileSelector::reread() { | 858 | void OFileSelector::reread() { |
789 | return currentView()->reread(); | 859 | return currentView()->reread(); |
790 | } | 860 | } |
791 | OFileViewInterface* OFileSelector::currentView()const{ | 861 | OFileViewInterface* OFileSelector::currentView()const{ |
792 | return m_current; | 862 | return m_current; |
793 | } | 863 | } |
794 | bool OFileSelector::showNew()const { | 864 | bool OFileSelector::showNew()const { |
795 | return m_shNew; | 865 | return m_shNew; |
796 | } | 866 | } |
797 | bool OFileSelector::showClose()const { | 867 | bool OFileSelector::showClose()const { |
798 | return m_shClose; | 868 | return m_shClose; |
799 | } | 869 | } |
800 | MimeTypes OFileSelector::mimeTypes()const { | 870 | MimeTypes OFileSelector::mimeTypes()const { |
801 | return m_mimeType; | 871 | return m_mimeType; |
802 | } | 872 | } |
873 | |||
874 | /** | ||
875 | * @return the Mode of the OFileSelector | ||
876 | */ | ||
803 | int OFileSelector::mode()const{ | 877 | int OFileSelector::mode()const{ |
804 | return m_mode; | 878 | return m_mode; |
805 | } | 879 | } |
880 | |||
881 | /** | ||
882 | * @return the Selector of the OFileSelector | ||
883 | */ | ||
806 | int OFileSelector::selector()const{ | 884 | int OFileSelector::selector()const{ |
807 | return m_selector; | 885 | return m_selector; |
808 | } | 886 | } |
809 | QStringList OFileSelector::currentMimeType()const { | 887 | QStringList OFileSelector::currentMimeType()const { |
810 | return m_mimeType[m_cmbMime->currentText()]; | 888 | return m_mimeType[m_cmbMime->currentText()]; |
811 | } | 889 | } |
812 | void OFileSelector::slotMimeTypeChanged() { | 890 | void OFileSelector::slotMimeTypeChanged() { |
813 | reread(); | 891 | reread(); |
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index bdb3e56..767455c 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -46,26 +46,52 @@ | |||
46 | typedef QMap<QString, QStringList> MimeTypes; | 46 | typedef QMap<QString, QStringList> MimeTypes; |
47 | 47 | ||
48 | class OFileViewInterface; | 48 | class OFileViewInterface; |
49 | class OFileViewFileListView; | 49 | class OFileViewFileListView; |
50 | class QLineEdit; | 50 | class QLineEdit; |
51 | class QComboBox; | 51 | class QComboBox; |
52 | class QWidgetStack; | 52 | class QWidgetStack; |
53 | class QHBox; | 53 | class QHBox; |
54 | |||
55 | |||
56 | /** | ||
57 | * @short a dropin replacement for the FileSelector | ||
58 | * | ||
59 | * This class is first used insert the OFileDialog. | ||
60 | * It supports multiple view and mimetype filtering for now. | ||
61 | * | ||
62 | * @see OFileDialog | ||
63 | * @see FileSelector | ||
64 | * @author zecke | ||
65 | * @version 0.1 | ||
66 | */ | ||
54 | class OFileSelector : public QWidget { | 67 | class OFileSelector : public QWidget { |
55 | Q_OBJECT | 68 | Q_OBJECT |
56 | friend class OFileViewInterface; | 69 | friend class OFileViewInterface; |
57 | friend class OFileViewFileListView; | 70 | friend class OFileViewFileListView; |
58 | public: | 71 | public: |
72 | /** | ||
73 | * The Mode of the Fileselector | ||
74 | * Open = Open A File | ||
75 | * Save = Save a File | ||
76 | * FILESELECTOR = As A GUI in a screen to select a file | ||
77 | */ | ||
59 | enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; | 78 | enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; |
60 | // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; | 79 | // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; |
80 | /** | ||
81 | * Normal = The old FileSelector | ||
82 | * Extended = Dir View | ||
83 | * ExtendedAll = Dir View with all hidden files | ||
84 | * Default = What the vendor considers best | ||
85 | */ | ||
61 | enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; | 86 | enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; |
62 | // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; | 87 | // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; |
63 | 88 | ||
89 | |||
64 | OFileSelector(QWidget* parent, int mode, int selector, | 90 | OFileSelector(QWidget* parent, int mode, int selector, |
65 | const QString& dirName, | 91 | const QString& dirName, |
66 | const QString& fileName, | 92 | const QString& fileName, |
67 | const MimeTypes& mimetypes = MimeTypes(), | 93 | const MimeTypes& mimetypes = MimeTypes(), |
68 | bool newVisible = FALSE, bool closeVisible = FALSE ); | 94 | bool newVisible = FALSE, bool closeVisible = FALSE ); |
69 | 95 | ||
70 | OFileSelector(const QString& mimeFilter, QWidget* parent, | 96 | OFileSelector(const QString& mimeFilter, QWidget* parent, |
71 | const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); | 97 | const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); |
@@ -80,27 +106,61 @@ public: | |||
80 | DocLnk selectedDocument()const; | 106 | DocLnk selectedDocument()const; |
81 | 107 | ||
82 | int fileCount()const; | 108 | int fileCount()const; |
83 | void reread(); | 109 | void reread(); |
84 | 110 | ||
85 | int mode()const; | 111 | int mode()const; |
86 | int selector()const; | 112 | int selector()const; |
87 | 113 | ||
88 | 114 | /** | |
115 | * Set the Icon visible | ||
116 | * @param b Show or Hide the New Button | ||
117 | */ | ||
89 | void setNewVisible( bool b ); | 118 | void setNewVisible( bool b ); |
119 | |||
120 | /** | ||
121 | * Set the Icon visible | ||
122 | */ | ||
90 | void setCloseVisible( bool b ); | 123 | void setCloseVisible( bool b ); |
124 | |||
125 | /** | ||
126 | * Set the Name Line visible | ||
127 | */ | ||
91 | void setNameVisible( bool b ); | 128 | void setNameVisible( bool b ); |
92 | 129 | ||
93 | signals: | 130 | signals: |
131 | /** | ||
132 | * dirSelected is emitted whenever changed into a different dir | ||
133 | */ | ||
94 | void dirSelected( const QString& ); | 134 | void dirSelected( const QString& ); |
135 | |||
136 | /** | ||
137 | * fileSelected is emitted when a file is selected | ||
138 | * it uses a DocLnk as parameter | ||
139 | */ | ||
95 | void fileSelected( const DocLnk& ); | 140 | void fileSelected( const DocLnk& ); |
141 | |||
142 | /** | ||
143 | * fileSelected is emitted when a file is selected | ||
144 | * the complete path is a parameter | ||
145 | */ | ||
96 | void fileSelected( const QString& ); | 146 | void fileSelected( const QString& ); |
147 | |||
148 | /** | ||
149 | * Create a new File with a DocLnk | ||
150 | */ | ||
97 | void newSelected( const DocLnk& ); | 151 | void newSelected( const DocLnk& ); |
152 | |||
98 | void closeMe(); | 153 | void closeMe(); |
154 | |||
155 | /** | ||
156 | * Ok is emitted on a Qt::Key_Return or Q::Key_Enter | ||
157 | * in the line edit | ||
158 | */ | ||
99 | void ok(); | 159 | void ok(); |
100 | void cancel(); | 160 | void cancel(); |
101 | 161 | ||
102 | /* used by the ViewInterface */ | 162 | /* used by the ViewInterface */ |
103 | private: | 163 | private: |
104 | bool showNew()const; | 164 | bool showNew()const; |
105 | bool showClose()const; | 165 | bool showClose()const; |
106 | MimeTypes mimeTypes()const; | 166 | MimeTypes mimeTypes()const; |