author | eilers <eilers> | 2003-08-08 15:09:29 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-08 15:09:29 (UTC) |
commit | b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16 (patch) (unidiff) | |
tree | b0f96db67cfb1b9d2476530ecec9a2ba6eacbab1 /libopie/ofileselector.h | |
parent | 14d394e6c107b037a09a31a92605034fe50f7813 (diff) | |
download | opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.zip opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.gz opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.bz2 |
Merging all changes from BRANCH_1_0.
-rw-r--r-- | libopie/ofileselector.h | 362 |
1 files changed, 99 insertions, 263 deletions
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index d06aa0a..bdb3e56 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | 6 | ||
7 | =. This file is part of the OPIE Project | 7 | =. This file is part of the OPIE Project |
8 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 8 | .=l. Copyright (c) 2002,2003 Holger Freyther <zecke@handhelds.org> |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This library is free software; you can | 10 | _;:, .> :=|. This library is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
@@ -31,284 +31,120 @@ | |||
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef opiefileselector_h | ||
35 | #define opiefileselector_h | ||
36 | 34 | ||
35 | #ifndef OPIE_OFILESELECTOR_FOO_H | ||
36 | #define OPIE_OFILESELECTOR_FOO_H | ||
37 | |||
38 | #include <qlist.h> | ||
37 | #include <qwidget.h> | 39 | #include <qwidget.h> |
38 | #include <qstring.h> | ||
39 | #include <qpixmap.h> | ||
40 | #include <qstringlist.h> | ||
41 | #include <qmap.h> | 40 | #include <qmap.h> |
42 | #include <qvaluelist.h> | 41 | #include <qvaluelist.h> |
42 | #include <qstringlist.h> | ||
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qlistview.h> | ||
46 | 45 | ||
46 | typedef QMap<QString, QStringList> MimeTypes; | ||
47 | 47 | ||
48 | class DocLnk; | 48 | class OFileViewInterface; |
49 | class QCheckBox; | 49 | class OFileViewFileListView; |
50 | class QComboBox; | ||
51 | class QPushButton; | ||
52 | class FileSelector; | ||
53 | class QGridLayout; | ||
54 | class QLineEdit; | 50 | class QLineEdit; |
55 | class QLabel; | 51 | class QComboBox; |
56 | class QWidgetStack; | 52 | class QWidgetStack; |
57 | class QHBoxLayout; | ||
58 | class QVBoxLayout; | ||
59 | class QPopupMenu; | ||
60 | class QFileInfo; | ||
61 | class QHBox; | 53 | class QHBox; |
62 | // | ||
63 | |||
64 | typedef QMap< QString, QStringList> MimeTypes; | ||
65 | |||
66 | /** | ||
67 | * This is OPIEs FileDialog Widget. You can use it | ||
68 | * as a dropin replacement of the fileselector and | ||
69 | * or use any of the new features. | ||
70 | * This is also a complete FileSave and FileLoad widget | ||
71 | * If you look for a Dialog check OFileDialog | ||
72 | * | ||
73 | * NOTE THAT the API will change to be more extendable! | ||
74 | */ | ||
75 | class OFileSelector : public QWidget { | 54 | class OFileSelector : public QWidget { |
76 | Q_OBJECT | 55 | Q_OBJECT |
77 | public: | 56 | friend class OFileViewInterface; |
78 | /** | 57 | friend class OFileViewFileListView; |
79 | * The mode of the file selector | 58 | public: |
80 | * Either open, save, fileselector or dir browsing mode | 59 | enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; |
81 | * | 60 | // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; |
82 | */ | 61 | enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; |
83 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; | 62 | // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; |
84 | 63 | ||
85 | /** | 64 | OFileSelector(QWidget* parent, int mode, int selector, |
86 | * Selector. Either NORMAL for the one shipped with | 65 | const QString& dirName, |
87 | * libqpe or EXTENDED. for the EXTENDED | 66 | const QString& fileName, |
88 | * EXTENDED_ALL also shows 'hidden' files | 67 | const MimeTypes& mimetypes = MimeTypes(), |
89 | */ | 68 | bool newVisible = FALSE, bool closeVisible = FALSE ); |
90 | enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 }; | 69 | |
91 | 70 | OFileSelector(const QString& mimeFilter, QWidget* parent, | |
92 | /** | 71 | const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); |
93 | * This is reserved for futrue views | 72 | ~OFileSelector(); |
94 | */ | 73 | |
95 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; | 74 | const DocLnk* selected(); |
96 | 75 | ||
97 | /** | 76 | QString selectedName()const; |
98 | * A c'tor which should be used for advanced mode | 77 | QString selectedPath()const; |
99 | * @param wid the parent | 78 | QString directory()const; |
100 | * @param mode the Mode of the Selector | 79 | |
101 | * @param selector the current View of the Selector | 80 | DocLnk selectedDocument()const; |
102 | * @param dirName in which dir to start | 81 | |
103 | * @param fileName a proposed filename | 82 | int fileCount()const; |
104 | * @param mimetypes A list of mimetypes \ | 83 | void reread(); |
105 | * QString is for a identifier name like "Text files" | 84 | |
106 | * the coresponding QStringList is used for the mimetypes | 85 | int mode()const; |
107 | * if empty it'll fill the list of mimetypes depending | 86 | int selector()const; |
108 | * on the content of the current directory | 87 | |
109 | */ | 88 | |
110 | 89 | void setNewVisible( bool b ); | |
111 | OFileSelector(QWidget *wid, int mode, int selector, | 90 | void setCloseVisible( bool b ); |
112 | const QString &dirName, | 91 | void setNameVisible( bool b ); |
113 | const QString &fileName = QString::null, | 92 | |
114 | const MimeTypes &mimetypes = MimeTypes() ); | 93 | signals: |
115 | 94 | void dirSelected( const QString& ); | |
116 | 95 | void fileSelected( const DocLnk& ); | |
117 | /** | 96 | void fileSelected( const QString& ); |
118 | * This is a QPE compatible c'tor | 97 | void newSelected( const DocLnk& ); |
119 | */ | 98 | void closeMe(); |
120 | OFileSelector(const QString &mimeFilter, QWidget *parent, | 99 | void ok(); |
121 | const char *name, bool newVisible = TRUE, | 100 | void cancel(); |
122 | bool closeVisible = FALSE ); | 101 | |
123 | 102 | /* used by the ViewInterface */ | |
124 | ~OFileSelector(); | 103 | private: |
125 | 104 | bool showNew()const; | |
126 | // currently only for the FILESELECTOR Mode | 105 | bool showClose()const; |
127 | /** | 106 | MimeTypes mimeTypes()const; |
128 | */ | 107 | QStringList currentMimeType()const; |
129 | void setNewVisible( bool /*b*/ ); | 108 | |
130 | void setCloseVisible(bool /*b*/ ); | 109 | private: |
131 | 110 | /* inits the Widgets */ | |
132 | // end file selector mode | 111 | void initUI(); |
133 | // deprecated | 112 | /* inits the MimeType ComboBox content + connects signals and slots */ |
134 | void reread(); | 113 | void initMime(); |
135 | // make sure not to leak please | 114 | /* init the Views :) */ |
136 | const DocLnk *selected(); | 115 | void initViews(); |
137 | // end deprecated | 116 | |
138 | 117 | private: | |
139 | bool isToolbarVisible() const { return m_shTool; }; | 118 | QLineEdit* m_lneEdit; // the LineEdit for the Name |
140 | bool isPermissionBarVisible() const { return m_shPerm; }; | 119 | QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType |
141 | bool isLineEditVisible()const { return m_shLne; }; | 120 | QWidgetStack* m_stack; // our widget stack which will contain the views |
142 | bool isChooserVisible( )const { return m_shChooser; }; | 121 | OFileViewInterface* currentView()const; // returns the currentView |
143 | bool isYesCancelVisible()const { return m_shYesNo; }; | 122 | OFileViewInterface* m_current; // here is the view saved |
144 | void setYesCancelVisible( bool show ); | 123 | bool m_shNew : 1; // should we show New? |
145 | void setToolbarVisible( bool show ); | 124 | bool m_shClose : 1; // should we show Close? |
146 | void setPermissionBarVisible( bool show ); | 125 | MimeTypes m_mimeType; // list of mimetypes |
147 | void setLineEditVisible(bool show) ; | 126 | |
148 | void setChooserVisible( bool chooser ); | 127 | QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr |
149 | 128 | QHBox* m_nameBox; // the LineEdit + Label is hold here | |
150 | QCheckBox* permissionCheckbox(); | 129 | QHBox* m_cmbBox; // this holds the two combo boxes |
151 | bool setPermission() const; | 130 | |
152 | void setPermissionChecked( bool check ); | 131 | QString m_startDir; |
153 | 132 | int m_mode; | |
154 | void setMode( int ); | 133 | int m_selector; |
155 | 134 | ||
156 | bool showDirs()const { return m_dir; } | 135 | struct Data; // used for future versions |
157 | void setShowDirs(bool ); | 136 | Data *d; |
158 | |||
159 | const QListView* listView() { return m_View; }; | ||
160 | |||
161 | bool isCaseSensetive()const { return m_case; } | ||
162 | void setCaseSensetive(bool caSe ); | ||
163 | |||
164 | bool showFiles()const { return m_files; }; | ||
165 | void setShowFiles(bool ); | ||
166 | bool cd(const QString &path ); | ||
167 | 137 | ||
138 | private slots: | ||
139 | void slotMimeTypeChanged(); | ||
168 | 140 | ||
169 | int mode()const { return m_mode; }; | 141 | /* will set the text of the lineedit and emit a fileChanged signal */ |
170 | int selector()const { return m_selector; }; | 142 | void slotDocLnkBridge( const DocLnk& ); |
171 | void setSelector( int ); | 143 | void slotFileBridge( const QString& ); |
172 | 144 | void slotViewChange( const QString& ); | |
173 | bool showPopup()const { return m_showPopup; }; | ||
174 | void setShowPopup( bool pop ) { m_showPopup = pop; }; | ||
175 | void setPopupMenu( QPopupMenu * ); | ||
176 | |||
177 | // void updateLay(); | ||
178 | |||
179 | void reparse(); // re reads the dir | ||
180 | |||
181 | QString selectedName( )const; | ||
182 | QStringList selectedNames()const; | ||
183 | |||
184 | QString selectedPath() const; | ||
185 | QStringList selectedPaths() const; | ||
186 | |||
187 | QString directory()const; | ||
188 | int fileCount() const; | ||
189 | |||
190 | /* the user needs to delete it */ | ||
191 | DocLnk selectedDocument()const; | ||
192 | /* the user needs to delete it */ | ||
193 | QValueList<DocLnk> selectedDocuments()const; | ||
194 | |||
195 | signals: | ||
196 | void fileSelected( const DocLnk & ); | ||
197 | void fileSelected( const QString & ); | ||
198 | void dirSelected(const QString &dir ); | ||
199 | void closeMe(); | ||
200 | void ok(); | ||
201 | void cancel(); | ||
202 | void contextMenu(); | ||
203 | |||
204 | private slots: | ||
205 | void slotTest() { qWarning("slotTest" ); setLineEditVisible(false ); }; | ||
206 | void slotOk(); | ||
207 | void slotCancel(); | ||
208 | void slotViewCheck(const QString & ); | ||
209 | void slotMimeCheck(const QString & ); | ||
210 | void slotLocationActivated(const QString & ); | ||
211 | void slotInsertLocationPath(const QString &, int); | ||
212 | void locationComboChanged(); | ||
213 | |||
214 | private: | ||
215 | void init(); | ||
216 | void updateMimes(); | ||
217 | |||
218 | protected: | ||
219 | |||
220 | private: | ||
221 | int m_mode, m_selector; | ||
222 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | ||
223 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | ||
224 | QPushButton *m_reread, *m_up, *m_new, *m_close; | ||
225 | QListView *m_View; | ||
226 | QCheckBox *m_checkPerm; | ||
227 | QWidget *m_pseudo; | ||
228 | QVBoxLayout *m_pseudoLayout; | ||
229 | |||
230 | QString m_currentDir; | ||
231 | QString m_name; | ||
232 | // QStringList m_mimetypes; | ||
233 | QMap<QString, QStringList> m_mimetypes; | ||
234 | |||
235 | FileSelector *m_select; | ||
236 | QWidgetStack *m_stack; | ||
237 | QVBoxLayout *m_lay; | ||
238 | QGridLayout *m_Oselector; | ||
239 | |||
240 | QHBox *m_boxToolbar; | ||
241 | QHBox *m_boxOk; // (no layout anymore) wait | ||
242 | QHBox *m_boxName; // (no Layout anymore) wait | ||
243 | QHBox *m_boxView; | ||
244 | |||
245 | QPopupMenu *m_custom; | ||
246 | |||
247 | QLineEdit *m_edit; | ||
248 | QLabel *m_fnLabel; | ||
249 | |||
250 | bool m_shClose : 1; | ||
251 | bool m_shNew : 1; | ||
252 | bool m_shTool : 1; | ||
253 | bool m_shPerm : 1; | ||
254 | bool m_shLne : 1; | ||
255 | bool m_shChooser : 1; | ||
256 | bool m_shYesNo : 1; | ||
257 | bool m_boCheckPerm : 1; | ||
258 | bool m_autoMime : 1; | ||
259 | bool m_case : 1; | ||
260 | bool m_dir : 1; | ||
261 | bool m_files : 1; | ||
262 | bool m_showPopup : 1; | ||
263 | |||
264 | void initVars(); | ||
265 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); | ||
266 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); | ||
267 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; | ||
268 | void delItems(); | ||
269 | void initializeName(); | ||
270 | void initializeYes(); | ||
271 | void initializeChooser(); | ||
272 | void initializeListView(); | ||
273 | void initializePerm(); | ||
274 | void initPics(); | ||
275 | bool compliesMime(const QString &path, | ||
276 | const QString &mime); | ||
277 | bool compliesMime(const QString& mime ); | ||
278 | /** | ||
279 | * Updates the QComboBox with the current mimetypes | ||
280 | */ | ||
281 | void updateMimeCheck(); | ||
282 | 145 | ||
283 | /** | 146 | bool eventFilter (QObject *o, QEvent *e); |
284 | * Returns the current mimetype | ||
285 | */ | ||
286 | QString currentMimeType()const; | ||
287 | class OFileSelectorPrivate; | ||
288 | OFileSelectorPrivate *d; | ||
289 | static QMap<QString,QPixmap> *m_pixmaps; | ||
290 | 147 | ||
291 | private slots: | ||
292 | void slotFileSelected(const QString & ); // not really meant to be a slot | ||
293 | void slotFileBridgeSelected( const DocLnk & ); | ||
294 | virtual void slotSelectionChanged(); | ||
295 | virtual void slotCurrentChanged(QListViewItem* ); | ||
296 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); | ||
297 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); | ||
298 | virtual void slotContextMenu( QListViewItem *item); | ||
299 | // listview above | ||
300 | // popup below | ||
301 | virtual void slotChangedDir(); | ||
302 | virtual void slotOpen(); | ||
303 | virtual void slotRescan(); | ||
304 | virtual void slotRename(); | ||
305 | virtual void slotDelete(); | ||
306 | virtual void cdUP(); | ||
307 | virtual void slotHome(); | ||
308 | virtual void slotDoc(); | ||
309 | virtual void slotNavigate( ); | ||
310 | }; | 148 | }; |
311 | 149 | ||
312 | |||
313 | #endif | 150 | #endif |
314 | |||