author | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
commit | ea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (unidiff) | |
tree | f2ea22cc50e9aa8aa73ee7dea148f41c563c9666 /noncore/unsupported/libopie/ofileselector.h | |
parent | 1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff) | |
download | opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2 |
libopie1 goes into unsupported
Diffstat (limited to 'noncore/unsupported/libopie/ofileselector.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/libopie/ofileselector.h | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/noncore/unsupported/libopie/ofileselector.h b/noncore/unsupported/libopie/ofileselector.h new file mode 100644 index 0000000..767455c --- a/dev/null +++ b/noncore/unsupported/libopie/ofileselector.h | |||
@@ -0,0 +1,210 @@ | |||
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,2003 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 | |||
35 | #ifndef OPIE_OFILESELECTOR_FOO_H | ||
36 | #define OPIE_OFILESELECTOR_FOO_H | ||
37 | |||
38 | #include <qlist.h> | ||
39 | #include <qwidget.h> | ||
40 | #include <qmap.h> | ||
41 | #include <qvaluelist.h> | ||
42 | #include <qstringlist.h> | ||
43 | |||
44 | #include <qpe/applnk.h> | ||
45 | |||
46 | typedef QMap<QString, QStringList> MimeTypes; | ||
47 | |||
48 | class OFileViewInterface; | ||
49 | class OFileViewFileListView; | ||
50 | class QLineEdit; | ||
51 | class QComboBox; | ||
52 | class QWidgetStack; | ||
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 | */ | ||
67 | class OFileSelector : public QWidget { | ||
68 | Q_OBJECT | ||
69 | friend class OFileViewInterface; | ||
70 | friend class OFileViewFileListView; | ||
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 | */ | ||
78 | enum Mode { Open=1, Save=2, FileSelector=4, 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 | */ | ||
86 | enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; | ||
87 | // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; | ||
88 | |||
89 | |||
90 | OFileSelector(QWidget* parent, int mode, int selector, | ||
91 | const QString& dirName, | ||
92 | const QString& fileName, | ||
93 | const MimeTypes& mimetypes = MimeTypes(), | ||
94 | bool newVisible = FALSE, bool closeVisible = FALSE ); | ||
95 | |||
96 | OFileSelector(const QString& mimeFilter, QWidget* parent, | ||
97 | const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); | ||
98 | ~OFileSelector(); | ||
99 | |||
100 | const DocLnk* selected(); | ||
101 | |||
102 | QString selectedName()const; | ||
103 | QString selectedPath()const; | ||
104 | QString directory()const; | ||
105 | |||
106 | DocLnk selectedDocument()const; | ||
107 | |||
108 | int fileCount()const; | ||
109 | void reread(); | ||
110 | |||
111 | int mode()const; | ||
112 | int selector()const; | ||
113 | |||
114 | /** | ||
115 | * Set the Icon visible | ||
116 | * @param b Show or Hide the New Button | ||
117 | */ | ||
118 | void setNewVisible( bool b ); | ||
119 | |||
120 | /** | ||
121 | * Set the Icon visible | ||
122 | */ | ||
123 | void setCloseVisible( bool b ); | ||
124 | |||
125 | /** | ||
126 | * Set the Name Line visible | ||
127 | */ | ||
128 | void setNameVisible( bool b ); | ||
129 | |||
130 | signals: | ||
131 | /** | ||
132 | * dirSelected is emitted whenever changed into a different dir | ||
133 | */ | ||
134 | void dirSelected( const QString& ); | ||
135 | |||
136 | /** | ||
137 | * fileSelected is emitted when a file is selected | ||
138 | * it uses a DocLnk as parameter | ||
139 | */ | ||
140 | void fileSelected( const DocLnk& ); | ||
141 | |||
142 | /** | ||
143 | * fileSelected is emitted when a file is selected | ||
144 | * the complete path is a parameter | ||
145 | */ | ||
146 | void fileSelected( const QString& ); | ||
147 | |||
148 | /** | ||
149 | * Create a new File with a DocLnk | ||
150 | */ | ||
151 | void newSelected( const DocLnk& ); | ||
152 | |||
153 | void closeMe(); | ||
154 | |||
155 | /** | ||
156 | * Ok is emitted on a Qt::Key_Return or Q::Key_Enter | ||
157 | * in the line edit | ||
158 | */ | ||
159 | void ok(); | ||
160 | void cancel(); | ||
161 | |||
162 | /* used by the ViewInterface */ | ||
163 | private: | ||
164 | bool showNew()const; | ||
165 | bool showClose()const; | ||
166 | MimeTypes mimeTypes()const; | ||
167 | QStringList currentMimeType()const; | ||
168 | |||
169 | private: | ||
170 | /* inits the Widgets */ | ||
171 | void initUI(); | ||
172 | /* inits the MimeType ComboBox content + connects signals and slots */ | ||
173 | void initMime(); | ||
174 | /* init the Views :) */ | ||
175 | void initViews(); | ||
176 | |||
177 | private: | ||
178 | QLineEdit* m_lneEdit; // the LineEdit for the Name | ||
179 | QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType | ||
180 | QWidgetStack* m_stack; // our widget stack which will contain the views | ||
181 | OFileViewInterface* currentView()const; // returns the currentView | ||
182 | OFileViewInterface* m_current; // here is the view saved | ||
183 | bool m_shNew : 1; // should we show New? | ||
184 | bool m_shClose : 1; // should we show Close? | ||
185 | MimeTypes m_mimeType; // list of mimetypes | ||
186 | |||
187 | QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr | ||
188 | QHBox* m_nameBox; // the LineEdit + Label is hold here | ||
189 | QHBox* m_cmbBox; // this holds the two combo boxes | ||
190 | |||
191 | QString m_startDir; | ||
192 | int m_mode; | ||
193 | int m_selector; | ||
194 | |||
195 | struct Data; // used for future versions | ||
196 | Data *d; | ||
197 | |||
198 | private slots: | ||
199 | void slotMimeTypeChanged(); | ||
200 | |||
201 | /* will set the text of the lineedit and emit a fileChanged signal */ | ||
202 | void slotDocLnkBridge( const DocLnk& ); | ||
203 | void slotFileBridge( const QString& ); | ||
204 | void slotViewChange( const QString& ); | ||
205 | |||
206 | bool eventFilter (QObject *o, QEvent *e); | ||
207 | |||
208 | }; | ||
209 | |||
210 | #endif | ||