summaryrefslogtreecommitdiff
path: root/libopie/ofileselector/ofileselector.h
authorzecke <zecke>2002-09-15 17:52:30 (UTC)
committer zecke <zecke>2002-09-15 17:52:30 (UTC)
commit1c5780f34ec9b4dc004714488b46997fe1a0909b (patch) (unidiff)
tree524719fe92e4738dbcebf4bc792d6901cf215df9 /libopie/ofileselector/ofileselector.h
parent8c161a2699a842e527ade4410189fd18964d1c31 (diff)
downloadopie-1c5780f34ec9b4dc004714488b46997fe1a0909b.zip
opie-1c5780f34ec9b4dc004714488b46997fe1a0909b.tar.gz
opie-1c5780f34ec9b4dc004714488b46997fe1a0909b.tar.bz2
Ok the demand for filters, listers and views were great so I'm currently
implementing it This OFileSelector will be in a different subdir but it'll be still linked into libopie. This makes it more easy to find all files which belong to the OFileSelector an OLister is able to list for example files and dirs ( OLocalLister ) a ftp lister a bluetooth lister whcich would show available devices a DocLnkSet lister for the Documents Tab a CrossReference lister a View is responsible for showing files to the user... and I renamed *.cc to *.cpp
Diffstat (limited to 'libopie/ofileselector/ofileselector.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/ofileselector.h474
1 files changed, 474 insertions, 0 deletions
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h
new file mode 100644
index 0000000..937569d
--- a/dev/null
+++ b/libopie/ofileselector/ofileselector.h
@@ -0,0 +1,474 @@
1/*
2 This is based on code and ideas of
3 L. J. Potter ljp@llornkcor.com
4 Thanks a lot
5
6
7               =. This file is part of the OPIE Project
8             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
9           .>+-=
10 _;:,     .>    :=|. This library is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This library is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
33
34#ifndef opiefileselector_h
35#define opiefileselector_h
36
37#include <qpe/fileselector.h>
38
39#include <qdir.h>
40#include <qwidget.h>
41#include <qstring.h>
42#include <qpixmap.h>
43#include <qstringlist.h>
44#include <qmap.h>
45#include <qvaluelist.h>
46
47#include <qpe/applnk.h>
48#include <qlistview.h>
49
50/** This is OPIEs FileDialog Widget. You can use it
51 * as a dropin replacement of the fileselector and
52 * or use any of the new features.
53 * This is also a complete FileSave and FileLoad widget
54 * If you look for a Dialog check OFileDialog
55 *
56 */
57class DocLnk;
58class QCheckBox;
59class QComboBox;
60class QPushButton;
61class QGridLayout;
62class QLineEdit;
63class QLabel;
64class QWidgetStack;
65class QHBoxLayout;
66class QVBoxLayout;
67class QPopupMenu;
68class QFileInfo;
69class QHBox;
70class OFileView;
71//
72
73/* the mimetypes one name and a list of mimetypes */
74typedef QMap< QString, QStringList> MimeTypes;
75
76/**
77 * FIXME later
78 */
79struct OPopupMenuFactory {
80 OPopupMenuFactory() {}
81
82};
83
84
85/**
86 * Opie the default OFileSelector
87 * It features multiple views.
88 */
89class OFileSelector : public QWidget {
90 Q_OBJECT
91
92 /* friends are evil but I don't want to make the
93 * methods public
94 */
95 friend class OLister;
96 friend class OFileView;
97 public:
98 /**
99 * The mode of the file selector
100 * Either open, save, fileselector or dir browsing mode
101 *
102 */
103 enum Mode {Open = 1, Save = 2, Fileselector = 4, Dir = 8 };
104
105 /**
106 * Selector. Either Normal for the one shipped with
107 * libqpe or Extended. for the Extended
108 * ExtendedAll also shows 'hidden' files
109 */
110 enum Selector{Normal=0, Extended = 1, ExtendedAll =2 };
111
112 /**
113 * This is reserved for futrue views
114 */
115 enum View { Dirs = 1, Files = 2, Tree = 4, Icon = 8 };
116
117 /**
118 * A c'tor which should be used for advanced mode
119 * @param wid the parent
120 * @param mode the Mode of the Selector
121 * @param selector the current View of the Selector
122 * @param dirName in which dir to start
123 * @param fileName a proposed filename
124 * @param mimetypes A list of mimetypes \
125 * QString is for a identifier name like "Text files"
126 * the coresponding QStringList is used for the mimetypes
127 * if empty it'll fill the list of mimetypes depending
128 * on the content of the current directory
129 */
130
131 OFileSelector(QWidget *wid, int mode, int selector,
132 const QString &dirName,
133 const QString &fileName = QString::null,
134 const MimeTypes &mimetypes = MimeTypes() );
135
136
137 /**
138 * This is a QPE compatible c'tor
139 */
140 OFileSelector(const QString &mimeFilter, QWidget *parent,
141 const char *name, bool newVisible = TRUE,
142 bool closeVisible = FALSE );
143
144 ~OFileSelector();
145
146 // currently only for the FileSelector Mode
147 /* compability mode but only work
148 * with FileSelector
149 */
150 void setNewVisible( bool /*b*/ );
151 void setCloseVisible(bool /*b*/ );
152
153 // end file selector mode
154 // deprecated
155 void reread();
156 // make sure not to leak please
157 const DocLnk *selected();
158 // end deprecated
159
160 /**
161 * @return if the toolbar is visible
162 */
163 bool isToolbarVisible() const { return m_shTool; };
164
165 /**
166 * @return if the permissionBas is visible
167 */
168 bool isPermissionBarVisible() const { return m_shPerm; };
169
170 /**
171 * @return if the lineEdit is visible
172 */
173 bool isLineEditVisible()const { return m_shLne; };
174
175 /**
176 * if the chooser is visible
177 */
178 bool isChooserVisible( )const { return m_shChooser; };
179
180 /**
181 * @return if the yesCancel Bar is visible
182 */
183 bool isYesCancelVisible()const { return m_shYesNo; };
184
185 /**
186 * set Yes/Cancel visible
187 */
188 void setYesCancelVisible( bool show );
189
190 /**
191 * set the toolbar visible
192 */
193 void setToolbarVisible( bool show );
194
195 /**
196 * set the permissionBar to be visible
197 */
198 void setPermissionBarVisible( bool show );
199
200 /**
201 * set the lineedit for file entering visible
202 */
203 void setLineEditVisible(bool show) ;
204
205 /**
206 * set the chooser is visible
207 */
208 void setChooserVisible( bool chooser );
209
210 /**
211 * The permissionCheckbox
212 *
213 */
214 QCheckBox* permissionCheckbox();
215
216 /**
217 * setPermission
218 */
219 bool setPermission() const;
220
221 /**
222 * set ther permission to bool
223 */
224 void setPermissionChecked( bool check );
225
226 /**
227 * set the Selector Mode
228 */
229 void setMode( int );
230
231 /**
232 * whether or not to show dirs
233 */
234 bool showDirs()const { return m_dir; }
235
236 /**
237 * setShowDirs
238 */
239 void setShowDirs(bool );
240
241 /**
242 * set CaseSensetive
243 */
244 bool isCaseSensetive()const { return m_case; }
245
246 /**
247 * set if to be case sensetive
248 */
249 void setCaseSensetive(bool caSe );
250
251 /**
252 * @return if to show files
253 */
254 bool showFiles()const { return m_files; };
255
256 /**
257 * set if files should be shown
258 */
259 void setShowFiles(bool );
260
261 /**
262 * change dir to path
263 */
264 bool cd(const QString &path );
265
266
267 /**
268 * return the mode of the fileselector
269 */
270 int mode()const { return m_mode; };
271
272 /**
273 * return the selector
274 */
275 int selector()const { return m_selector; };
276
277 /**
278 * set the Selector
279 */
280 void setSelector( int );
281
282 /**
283 * wether or not to show popups
284 */
285 bool showPopup()const { return m_showPopup; };
286
287 /**
288 * set show popups
289 */
290 void setShowPopup( bool pop ) { m_showPopup = pop; }
291
292 /**
293 * set the popup factory
294 */
295 void setPopupFactory( OPopupMenuFactory * );
296
297 /**
298 * reparse the current directory and updates
299 * the views + mimetypes
300 */
301 void reparse(); // re reads the dir
302
303 /**
304 * return the selected name
305 */
306 QString selectedName( )const;
307
308 /**
309 * for multiple selections return multiple
310 * filenames
311 */
312 QStringList selectedNames()const;
313
314 /**
315 * return the complete to the file
316 */
317 QString selectedPath() const;
318
319 /**
320 * return the completed paths
321 */
322 QStringList selectedPaths() const;
323
324 /**
325 * the current directory
326 */
327 QString directory()const;
328
329 /**
330 * fileCount
331 */
332 int fileCount();
333
334 DocLnk selectedDocument()const;
335
336 QValueList<DocLnk> selectedDocuments()const;
337
338 OFileView* currentView();
339 int filter();
340 int sorting();
341
342 signals:
343 void fileSelected( const DocLnk & );
344 void fileSelected( const QString & );
345 void dirSelected(const QString &dir );
346 void dirSelected( const QDir& );
347 void closeMe();
348 void ok();
349 void cancel();
350 void contextMenu();
351
352 private slots:
353 void slotOk();
354 void slotCancel();
355 void slotViewCheck(const QString & );
356 void slotMimeCheck(const QString & );
357 void slotLocationActivated(const QString & );
358 void slotInsertLocationPath(const QString &, int);
359 void locationComboChanged();
360
361 private:
362 void init();
363 void updateMimes();
364
365
366 private:
367
368 FileSelector* m_select;
369 int m_mode, m_selector;
370 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
371 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
372 QPushButton *m_reread, *m_up, *m_new, *m_close;
373 QListView *m_View;
374 QCheckBox *m_checkPerm;
375 QWidget *m_pseudo;
376 QVBoxLayout *m_pseudoLayout;
377
378 QString m_currentDir;
379 QString m_name;
380// QStringList m_mimetypes;
381 QMap<QString, QStringList> m_mimetypes;
382
383
384 QWidgetStack *m_stack;
385 QVBoxLayout *m_lay;
386 QGridLayout *m_Oselector;
387
388 QHBox *m_boxToolbar;
389 QHBox *m_boxOk; // (no layout anymore) wait
390 QHBox *m_boxName; // (no Layout anymore) wait
391 QHBox *m_boxView;
392
393 QPopupMenu *m_custom;
394
395 QLineEdit *m_edit;
396 QLabel *m_fnLabel;
397
398 bool m_shClose : 1;
399 bool m_shNew : 1;
400 bool m_shTool : 1;
401 bool m_shPerm : 1;
402 bool m_shLne : 1;
403 bool m_shChooser : 1;
404 bool m_shYesNo : 1;
405 bool m_boCheckPerm : 1;
406 bool m_autoMime : 1;
407 bool m_case : 1;
408 bool m_dir : 1;
409 bool m_files : 1;
410 bool m_showPopup : 1;
411
412 void initVars();
413 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE );
414 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE );
415 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){};
416 void delItems();
417 void initializeName();
418 void initializeYes();
419 void initializeChooser();
420 void initializeListView();
421 void initializePerm();
422 void initPics();
423 bool compliesMime(const QString &path,
424 const QString &mime);
425 bool compliesMime(const QString& mime );
426 /**
427 * Updates the QComboBox with the current mimetypes
428 */
429 void updateMimeCheck();
430
431 /**
432 * Returns the current mimetype
433 */
434 QString currentMimeType()const;
435 class OFileSelectorPrivate;
436 OFileSelectorPrivate *d;
437 static QMap<QString,QPixmap> *m_pixmaps;
438
439private slots:
440 void slotFileSelected(const QString & ); // not really meant to be a slot
441 void slotFileBridgeSelected( const DocLnk & );
442 virtual void slotSelectionChanged();
443 virtual void slotCurrentChanged(QListViewItem* );
444 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int);
445 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int );
446 virtual void slotContextMenu( QListViewItem *item);
447 // listview above
448 // popup below
449 virtual void slotChangedDir();
450 virtual void slotOpen();
451 virtual void slotRescan();
452 virtual void slotRename();
453 virtual void slotDelete();
454 virtual void cdUP();
455 virtual void slotHome();
456 virtual void slotDoc();
457 virtual void slotNavigate( );
458
459 /* for OLister */
460private:
461
462 /* for OFileView */
463private:
464 void internFileSelected( const QString& );
465 void internFileSelected( const DocLnk& );
466 void internContextMenu();
467 void internChangedDir( const QString& );
468 void internChangedDir( const QDir& ) ;
469
470};
471
472
473#endif
474