author | zecke <zecke> | 2004-02-07 09:58:31 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-07 09:58:31 (UTC) |
commit | a41eba9e8404fb6321097e86736e23fbce4ead7a (patch) (unidiff) | |
tree | bae6341fa67fdbccaf21e470fa8bb5f13a9460af | |
parent | d4a72f6f428cb764330f07e9499ef9a4795b8228 (diff) | |
download | opie-a41eba9e8404fb6321097e86736e23fbce4ead7a.zip opie-a41eba9e8404fb6321097e86736e23fbce4ead7a.tar.gz opie-a41eba9e8404fb6321097e86736e23fbce4ead7a.tar.bz2 |
Forward port the recent API docu of the FileSelector
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 72 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.h | 60 |
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 | |||
@@ -782,105 +782,138 @@ QString OFileViewFileSystem::directory()const | |||
782 | } | 782 | } |
783 | 783 | ||
784 | void OFileViewFileSystem::reread() | 784 | void 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 | ||
792 | int OFileViewFileSystem::fileCount()const | 792 | int 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 | ||
799 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) | 799 | QWidget* 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 | ||
808 | void OFileViewFileSystem::activate( const QString& str) | 808 | void 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 | */ | ||
814 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 843 | OFileSelector::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 | */ | ||
855 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 888 | OFileSelector::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 | */ |
@@ -929,129 +962,168 @@ bool OFileSelector::eventFilter (QObject *o, QEvent *e) | |||
929 | */ | 962 | */ |
930 | void OFileSelector::initMime() | 963 | void 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 | ||
944 | void OFileSelector::initViews() | 977 | void 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 | */ | ||
961 | OFileSelector::~OFileSelector() | 997 | OFileSelector::~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 | */ | ||
965 | const DocLnk* OFileSelector::selected() | 1010 | const 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 | */ | ||
971 | QString OFileSelector::selectedName()const | 1020 | QString 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 | */ | ||
976 | QString OFileSelector::selectedPath()const | 1029 | QString OFileSelector::selectedPath()const |
977 | { | 1030 | { |
978 | return currentView()->selectedPath(); | 1031 | return currentView()->selectedPath(); |
979 | } | 1032 | } |
980 | 1033 | ||
1034 | /** | ||
1035 | * @return the directory name | ||
1036 | */ | ||
981 | QString OFileSelector::directory()const | 1037 | QString 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 | */ | ||
986 | DocLnk OFileSelector::selectedDocument()const | 1045 | DocLnk 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 | */ | ||
991 | int OFileSelector::fileCount()const | 1053 | int 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 | */ | ||
996 | void OFileSelector::reread() | 1061 | void OFileSelector::reread() |
997 | { | 1062 | { |
998 | return currentView()->reread(); | 1063 | return currentView()->reread(); |
999 | } | 1064 | } |
1000 | 1065 | ||
1001 | OFileViewInterface* OFileSelector::currentView()const | 1066 | OFileViewInterface* OFileSelector::currentView()const |
1002 | { | 1067 | { |
1003 | return m_current; | 1068 | return m_current; |
1004 | } | 1069 | } |
1005 | 1070 | ||
1006 | bool OFileSelector::showNew()const | 1071 | bool OFileSelector::showNew()const |
1007 | { | 1072 | { |
1008 | return m_shNew; | 1073 | return m_shNew; |
1009 | } | 1074 | } |
1010 | 1075 | ||
1011 | bool OFileSelector::showClose()const | 1076 | bool OFileSelector::showClose()const |
1012 | { | 1077 | { |
1013 | return m_shClose; | 1078 | return m_shClose; |
1014 | } | 1079 | } |
1015 | 1080 | ||
1016 | MimeTypes OFileSelector::mimeTypes()const | 1081 | MimeTypes 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 | */ | ||
1021 | int OFileSelector::mode()const | 1089 | int 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 | */ | ||
1026 | int OFileSelector::selector()const | 1098 | int OFileSelector::selector()const |
1027 | { | 1099 | { |
1028 | return m_selector; | 1100 | return m_selector; |
1029 | } | 1101 | } |
1030 | 1102 | ||
1031 | QStringList OFileSelector::currentMimeType()const | 1103 | QStringList OFileSelector::currentMimeType()const |
1032 | { | 1104 | { |
1033 | return m_mimeType[m_cmbMime->currentText()]; | 1105 | return m_mimeType[m_cmbMime->currentText()]; |
1034 | } | 1106 | } |
1035 | 1107 | ||
1036 | void OFileSelector::slotMimeTypeChanged() | 1108 | void OFileSelector::slotMimeTypeChanged() |
1037 | { | 1109 | { |
1038 | reread(); | 1110 | reread(); |
1039 | } | 1111 | } |
1040 | 1112 | ||
1041 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) | 1113 | void 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 | ||
1048 | void OFileSelector::slotFileBridge( const QString& str) | 1120 | void 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 | ||
1054 | void OFileSelector::slotViewChange( const QString& view ) | 1126 | void 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) |
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 | |||
@@ -29,111 +29,169 @@ | |||
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 | ||
48 | class QLineEdit; | 48 | class QLineEdit; |
49 | class QComboBox; | 49 | class QComboBox; |
50 | class QWidgetStack; | 50 | class QWidgetStack; |
51 | class QHBox; | 51 | class QHBox; |
52 | 52 | ||
53 | typedef QMap<QString, QStringList> MimeTypes; | 53 | typedef QMap<QString, QStringList> MimeTypes; |
54 | 54 | ||
55 | namespace Opie | 55 | namespace Opie |
56 | { | 56 | { |
57 | 57 | ||
58 | class OFileViewInterface; | 58 | class OFileViewInterface; |
59 | class OFileViewFileListView; | 59 | class 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 | */ | ||
61 | class OFileSelector : public QWidget | 73 | class 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 | ||
67 | public: | 79 | public: |
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 | ||
102 | signals: | 137 | signals: |
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 */ |
112 | private: | 170 | private: |
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 | ||
118 | private: | 176 | private: |
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 | ||
126 | private: | 184 | private: |
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 | ||