author | zecke <zecke> | 2002-06-26 18:01:53 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-26 18:01:53 (UTC) |
commit | 76f87a51800511fe108edbcd14d4dd40ead6f391 (patch) (unidiff) | |
tree | 1d1b3cf7c3bbd98d294cac738b3bfa277964b32d /libopie/ofileselector.h | |
parent | 125dc1fe52d7a3c8be1b955c79d729cc935c8b6d (diff) | |
download | opie-76f87a51800511fe108edbcd14d4dd40ead6f391.zip opie-76f87a51800511fe108edbcd14d4dd40ead6f391.tar.gz opie-76f87a51800511fe108edbcd14d4dd40ead6f391.tar.bz2 |
Improve mimetype handling
API is now fixed
2 Bugs outstanding though
-rw-r--r-- | libopie/ofileselector.h | 77 |
1 files changed, 61 insertions, 16 deletions
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index 47697b9..f2d5f84 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | This is based on code and idea of | 2 | This is based on code and ideas of |
3 | L. J. Potter ljp@llornkcor.com | 3 | L. J. Potter ljp@llornkcor.com |
4 | Thanks a lot | 4 | Thanks a lot |
5 | 5 | ||
@@ -7,24 +7,24 @@ | |||
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 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 |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This library is distributed in the hope that | 17 | .i_,=:_. -<s. This library is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
@@ -43,11 +43,12 @@ | |||
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qlistview.h> | 45 | #include <qlistview.h> |
46 | |||
46 | /** This is OPIEs FileDialog Widget. You can use it | 47 | /** This is OPIEs FileDialog Widget. You can use it |
47 | * as a dropin replacement of the fileselector and | 48 | * as a dropin replacement of the fileselector and |
48 | * or use any of the new features. | 49 | * or use any of the new features. |
49 | * This is also a complete FileSave and FileLoad widget | 50 | * This is also a complete FileSave and FileLoad widget |
50 | * If you look for a Dialog check OFileDialog | 51 | * If you look for a Dialog check OFileDialog |
51 | * | 52 | * |
52 | */ | 53 | */ |
53 | class DocLnk; | 54 | class DocLnk; |
@@ -64,22 +65,55 @@ class QVBoxLayout; | |||
64 | class QPopupMenu; | 65 | class QPopupMenu; |
65 | class QFileInfo; | 66 | class QFileInfo; |
66 | class QHBox; | 67 | class QHBox; |
67 | // | 68 | // |
68 | 69 | ||
70 | typedef QMap< QString, QStringList> MimeTypes; | ||
69 | 71 | ||
70 | class OFileSelector : public QWidget { | 72 | class OFileSelector : public QWidget { |
71 | Q_OBJECT | 73 | Q_OBJECT |
72 | public: | 74 | public: |
75 | /** | ||
76 | * The mode of the file selector | ||
77 | * Either open, save, fileselector or dir browsing mode | ||
78 | * | ||
79 | */ | ||
73 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; | 80 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; |
81 | |||
82 | /** | ||
83 | * Selector. Either NORMAL for the one shipped with | ||
84 | * libqpe or EXTENDED. for the EXTENDED | ||
85 | * EXTENDED_ALL also shows 'hidden' files | ||
86 | */ | ||
74 | enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 }; | 87 | enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 }; |
88 | |||
89 | /** | ||
90 | * This is reserved for futrue views | ||
91 | */ | ||
75 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; | 92 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; |
76 | 93 | ||
77 | OFileSelector(QWidget *wid, int mode, int selector, | 94 | /** |
95 | * A c'tor which should be used for advanced mode | ||
96 | * @param wid the parent | ||
97 | * @param mode the Mode of the Selector | ||
98 | * @param selector the current View of the Selector | ||
99 | * @param dirName in which dir to start | ||
100 | * @param fileName a proposed filename | ||
101 | * @param mimetypes A list of mimetypes \ | ||
102 | * QString is for a identifier name like "Text files" | ||
103 | * the coresponding QStringList is used for the mimetypes | ||
104 | * if empty it'll fill the list of mimetypes depending | ||
105 | * on the content of the current directory | ||
106 | */ | ||
107 | |||
108 | OFileSelector(QWidget *wid, int mode, int selector, | ||
78 | const QString &dirName, | 109 | const QString &dirName, |
79 | const QString &fileName = QString::null, | 110 | const QString &fileName = QString::null, |
80 | const QStringList &mimetypes = QStringList() ); | 111 | const MimeTypes &mimetypes = MimeTypes() ); |
81 | 112 | ||
82 | 113 | ||
114 | /** | ||
115 | * This is a QPE compatible c'tor | ||
116 | */ | ||
83 | OFileSelector(const QString &mimeFilter, QWidget *parent, | 117 | OFileSelector(const QString &mimeFilter, QWidget *parent, |
84 | const char *name, bool newVisible = TRUE, | 118 | const char *name, bool newVisible = TRUE, |
85 | bool closeVisible = FALSE ); | 119 | bool closeVisible = FALSE ); |
@@ -130,7 +164,7 @@ class OFileSelector : public QWidget { | |||
130 | int mode()const { return m_mode; }; | 164 | int mode()const { return m_mode; }; |
131 | int selector()const { return m_selector; }; | 165 | int selector()const { return m_selector; }; |
132 | void setSelector( int ); | 166 | void setSelector( int ); |
133 | 167 | ||
134 | bool showPopup()const { return m_showPopup; }; | 168 | bool showPopup()const { return m_showPopup; }; |
135 | void setShowPopup( bool pop ) { m_showPopup = pop; }; | 169 | void setShowPopup( bool pop ) { m_showPopup = pop; }; |
136 | void setPopupMenu( QPopupMenu * ); | 170 | void setPopupMenu( QPopupMenu * ); |
@@ -175,7 +209,7 @@ class OFileSelector : public QWidget { | |||
175 | private: | 209 | private: |
176 | void init(); | 210 | void init(); |
177 | void updateMimes(); | 211 | void updateMimes(); |
178 | 212 | ||
179 | protected: | 213 | protected: |
180 | 214 | ||
181 | private: | 215 | private: |
@@ -190,7 +224,8 @@ class OFileSelector : public QWidget { | |||
190 | 224 | ||
191 | QString m_currentDir; | 225 | QString m_currentDir; |
192 | QString m_name; | 226 | QString m_name; |
193 | QStringList m_mimetypes; | 227 | // QStringList m_mimetypes; |
228 | QMap<QString, QStringList> m_mimetypes; | ||
194 | 229 | ||
195 | FileSelector *m_select; | 230 | FileSelector *m_select; |
196 | QWidgetStack *m_stack; | 231 | QWidgetStack *m_stack; |
@@ -232,12 +267,22 @@ class OFileSelector : public QWidget { | |||
232 | void initializeListView(); | 267 | void initializeListView(); |
233 | void initializePerm(); | 268 | void initializePerm(); |
234 | void initPics(); | 269 | void initPics(); |
235 | bool compliesMime(const QString &path, const QString &mime); | 270 | bool compliesMime(const QString &path, |
236 | 271 | const QString &mime); | |
272 | bool compliesMime(const QString& mime ); | ||
273 | /** | ||
274 | * Updates the QComboBox with the current mimetypes | ||
275 | */ | ||
276 | void updateMimeCheck(); | ||
277 | |||
278 | /** | ||
279 | * Returns the current mimetype | ||
280 | */ | ||
281 | QString currentMimeType()const; | ||
237 | class OFileSelectorPrivate; | 282 | class OFileSelectorPrivate; |
238 | OFileSelectorPrivate *d; | 283 | OFileSelectorPrivate *d; |
239 | static QMap<QString,QPixmap> *m_pixmaps; | 284 | static QMap<QString,QPixmap> *m_pixmaps; |
240 | 285 | ||
241 | private slots: | 286 | private slots: |
242 | void slotFileSelected(const QString & ); // not really meant to be a slot | 287 | void slotFileSelected(const QString & ); // not really meant to be a slot |
243 | void slotFileBridgeSelected( const DocLnk & ); | 288 | void slotFileBridgeSelected( const DocLnk & ); |