Diffstat (limited to 'libopie2/opieui/fileselector/ofileselector.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h index 8bcd9ee..de2b98a 100644 --- a/libopie2/opieui/fileselector/ofileselector.h +++ b/libopie2/opieui/fileselector/ofileselector.h | |||
@@ -1,94 +1,95 @@ | |||
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 | #include <qlist.h> | ||
47 | 48 | ||
48 | class QLineEdit; | 49 | class QLineEdit; |
49 | class QComboBox; | 50 | class QComboBox; |
50 | class QWidgetStack; | 51 | class QWidgetStack; |
51 | class QHBox; | 52 | class QHBox; |
52 | 53 | ||
53 | typedef QMap<QString, QStringList> MimeTypes; | 54 | typedef QMap<QString, QStringList> MimeTypes; |
54 | 55 | ||
55 | namespace Opie { | 56 | namespace Opie { |
56 | namespace Ui { | 57 | namespace Ui { |
57 | 58 | ||
58 | namespace Internal { | 59 | namespace Internal { |
59 | class OFileViewInterface; | 60 | class OFileViewInterface; |
60 | class OFileViewFileListView; | 61 | class OFileViewFileListView; |
61 | } | 62 | } |
62 | 63 | ||
63 | 64 | ||
64 | /** | 65 | /** |
65 | * @short a dropin replacement for the FileSelector | 66 | * @short a dropin replacement for the FileSelector |
66 | * | 67 | * |
67 | * This class is first used insert the OFileDialog. | 68 | * This class is first used insert the OFileDialog. |
68 | * It supports multiple view and mimetype filtering for now. | 69 | * It supports multiple view and mimetype filtering for now. |
69 | * | 70 | * |
70 | * @see OFileDialog | 71 | * @see OFileDialog |
71 | * @see FileSelector | 72 | * @see FileSelector |
72 | * @author zecke | 73 | * @author zecke |
73 | * @version 0.1 | 74 | * @version 0.1 |
74 | */ | 75 | */ |
75 | class OFileSelector : public QWidget | 76 | class OFileSelector : public QWidget |
76 | { | 77 | { |
77 | Q_OBJECT | 78 | Q_OBJECT |
78 | friend class Internal::OFileViewInterface; | 79 | friend class Internal::OFileViewInterface; |
79 | friend class Internal::OFileViewFileListView; | 80 | friend class Internal::OFileViewFileListView; |
80 | 81 | ||
81 | public: | 82 | public: |
82 | /** | 83 | /** |
83 | * The Mode of the Fileselector | 84 | * The Mode of the Fileselector |
84 | * Open = Open A File | 85 | * Open = Open A File |
85 | * Save = Save a File | 86 | * Save = Save a File |
86 | * FILESELECTOR = As A GUI in a screen to select a file | 87 | * FILESELECTOR = As A GUI in a screen to select a file |
87 | */ | 88 | */ |
88 | enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; | 89 | enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; |
89 | // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; | 90 | // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; |
90 | /** | 91 | /** |
91 | * Normal = The old FileSelector | 92 | * Normal = The old FileSelector |
92 | * Extended = Dir View | 93 | * Extended = Dir View |
93 | * ExtendedAll = Dir View with all hidden files | 94 | * ExtendedAll = Dir View with all hidden files |
94 | * Default = What the vendor considers best | 95 | * Default = What the vendor considers best |
@@ -138,85 +139,94 @@ public: | |||
138 | 139 | ||
139 | signals: | 140 | signals: |
140 | /** | 141 | /** |
141 | * dirSelected is emitted whenever changed into a different dir | 142 | * dirSelected is emitted whenever changed into a different dir |
142 | */ | 143 | */ |
143 | void dirSelected( const QString& ); | 144 | void dirSelected( const QString& ); |
144 | 145 | ||
145 | /** | 146 | /** |
146 | * fileSelected is emitted when a file is selected | 147 | * fileSelected is emitted when a file is selected |
147 | * it uses a DocLnk as parameter | 148 | * it uses a DocLnk as parameter |
148 | */ | 149 | */ |
149 | void fileSelected( const DocLnk& ); | 150 | void fileSelected( const DocLnk& ); |
150 | 151 | ||
151 | /** | 152 | /** |
152 | * fileSelected is emitted when a file is selected | 153 | * fileSelected is emitted when a file is selected |
153 | * the complete path is a parameter | 154 | * the complete path is a parameter |
154 | */ | 155 | */ |
155 | void fileSelected( const QString& ); | 156 | void fileSelected( const QString& ); |
156 | 157 | ||
157 | /** | 158 | /** |
158 | * Create a new File with a DocLnk | 159 | * Create a new File with a DocLnk |
159 | */ | 160 | */ |
160 | void newSelected( const DocLnk& ); | 161 | void newSelected( const DocLnk& ); |
161 | 162 | ||
162 | void closeMe(); | 163 | void closeMe(); |
163 | 164 | ||
164 | /** | 165 | /** |
165 | * Ok is emitted on a Qt::Key_Return or Q::Key_Enter | 166 | * Ok is emitted on a Qt::Key_Return or Q::Key_Enter |
166 | * in the line edit | 167 | * in the line edit |
167 | */ | 168 | */ |
168 | void ok(); | 169 | void ok(); |
169 | void cancel(); | 170 | void cancel(); |
170 | 171 | ||
171 | /* used by the ViewInterface */ | 172 | /* used by the ViewInterface */ |
172 | private: | 173 | private: |
173 | bool showNew()const; | 174 | bool showNew()const; |
174 | bool showClose()const; | 175 | bool showClose()const; |
175 | MimeTypes mimeTypes()const; | 176 | MimeTypes mimeTypes()const; |
176 | QStringList currentMimeType()const; | 177 | QStringList currentMimeType()const; |
177 | 178 | ||
178 | private: | 179 | private: |
179 | /* inits the Widgets */ | 180 | /* inits the Widgets */ |
180 | void initUI(); | 181 | void initUI(); |
181 | /* inits the MimeType ComboBox content + connects signals and slots */ | 182 | /* inits the MimeType ComboBox content + connects signals and slots */ |
182 | void initMime(); | 183 | void initMime(); |
183 | /* init the Views :) */ | 184 | /* init the Views :) */ |
184 | void initViews(); | 185 | void initViews(); |
185 | 186 | ||
187 | |||
188 | /* | ||
189 | * register a view for deletion. | ||
190 | * This happens on creation of a OFileViewInterface | ||
191 | */ | ||
192 | void registerView( const Internal::OFileViewInterface* ); | ||
193 | |||
186 | private: | 194 | private: |
187 | QLineEdit* m_lneEdit; // the LineEdit for the Name | 195 | QLineEdit* m_lneEdit; // the LineEdit for the Name |
188 | QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType | 196 | QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType |
189 | QWidgetStack* m_stack; // our widget stack which will contain the views | 197 | QWidgetStack* m_stack; // our widget stack which will contain the views |
190 | Internal::OFileViewInterface* currentView() const; // returns the currentView | 198 | Internal::OFileViewInterface* currentView() const; // returns the currentView |
191 | Internal::OFileViewInterface* m_current; // here is the view saved | 199 | Internal::OFileViewInterface* m_current; // here is the view saved |
192 | bool m_shNew : 1; // should we show New? | 200 | bool m_shNew : 1; // should we show New? |
193 | bool m_shClose : 1; // should we show Close? | 201 | bool m_shClose : 1; // should we show Close? |
194 | MimeTypes m_mimeType; // list of mimetypes | 202 | MimeTypes m_mimeType; // list of mimetypes |
195 | 203 | ||
196 | QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr | 204 | QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr |
205 | /* views register themselves automatically */ | ||
206 | QList<Internal::OFileViewInterface> m_viewsPtr; | ||
197 | QHBox* m_nameBox; // the LineEdit + Label is hold here | 207 | QHBox* m_nameBox; // the LineEdit + Label is hold here |
198 | QHBox* m_cmbBox; // this holds the two combo boxes | 208 | QHBox* m_cmbBox; // this holds the two combo boxes |
199 | 209 | ||
200 | QString m_startDir; | 210 | QString m_startDir; |
201 | int m_mode; | 211 | int m_mode; |
202 | int m_selector; | 212 | int m_selector; |
203 | 213 | ||
204 | struct Data; // used for future versions | 214 | struct Data; // used for future versions |
205 | Data *d; | 215 | Data *d; |
206 | 216 | ||
207 | private slots: | 217 | private slots: |
208 | void slotMimeTypeChanged(); | 218 | void slotMimeTypeChanged(); |
209 | 219 | ||
210 | /* will set the text of the lineedit and emit a fileChanged signal */ | 220 | /* will set the text of the lineedit and emit a fileChanged signal */ |
211 | void slotDocLnkBridge( const DocLnk& ); | 221 | void slotDocLnkBridge( const DocLnk& ); |
212 | void slotFileBridge( const QString& ); | 222 | void slotFileBridge( const QString& ); |
213 | void slotViewChange( const QString& ); | 223 | void slotViewChange( const QString& ); |
214 | 224 | ||
215 | bool eventFilter (QObject *o, QEvent *e); | 225 | bool eventFilter (QObject *o, QEvent *e); |
216 | 226 | ||
217 | }; | 227 | }; |
218 | 228 | ||
219 | } | 229 | } |
220 | } | 230 | } |
221 | 231 | ||
222 | #endif | 232 | #endif |