-rw-r--r-- | libopie/ofileselector.h | 100 |
1 files changed, 78 insertions, 22 deletions
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index a90219f..73674e2 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -17,172 +17,228 @@ | |||
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. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef opiefileselector_h | 34 | #ifndef opiefileselector_h |
35 | #define opiefileselector_h | 35 | #define opiefileselector_h |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
41 | #include <qmap.h> | ||
42 | #include <qvaluelist.h> | ||
41 | 43 | ||
44 | #include <qpe/applnk.h> | ||
42 | #include <qlistview.h> | 45 | #include <qlistview.h> |
43 | /** This is OPIEs FileDialog Widget. You can use it | 46 | /** This is OPIEs FileDialog Widget. You can use it |
44 | * as a dropin replacement of the fileselector and | 47 | * as a dropin replacement of the fileselector and |
45 | * or use any of the new features. | 48 | * or use any of the new features. |
46 | * This is also a complete FileSave and FileLoad widget | 49 | * This is also a complete FileSave and FileLoad widget |
47 | * If you look for a Dialog check OFileDialog | 50 | * If you look for a Dialog check OFileDialog |
48 | * | 51 | * |
49 | */ | 52 | */ |
50 | class DocLnk; | 53 | class DocLnk; |
51 | class QCheckBox; | 54 | class QCheckBox; |
52 | class QComboBox; | 55 | class QComboBox; |
53 | class QPushButton; | 56 | class QPushButton; |
54 | class FileSelector; | 57 | class FileSelector; |
55 | class QGridLayout; | 58 | class QGridLayout; |
56 | class QLineEdit; | 59 | class QLineEdit; |
57 | class QLabel; | 60 | class QLabel; |
58 | class QWidgetStack; | 61 | class QWidgetStack; |
59 | class QHBoxLayout; | 62 | class QHBoxLayout; |
60 | class QVBoxLayout; | 63 | class QVBoxLayout; |
61 | class QPopupMenu; | 64 | class QPopupMenu; |
62 | 65 | class QFileInfo; | |
63 | 66 | // | |
64 | class OFileSelectorItem : public QListViewItem { | 67 | class OFileSelectorItem : public QListViewItem { |
65 | public: | 68 | public: |
66 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
67 | const QString &date, const QString &size, | 70 | const QString &date, const QString &size, const QString &mDir, |
68 | bool isDir=false ): QListViewItem(view) { | 71 | bool isDir=false ): QListViewItem(view) { |
69 | setPixmap(0, pixmap ); | 72 | setPixmap(0, pixmap ); |
70 | setText(1, path ); | 73 | setText(1, path ); |
71 | setText(2, size ); | 74 | setText(2, size ); |
72 | setText(3, date ); | 75 | setText(3, date ); |
76 | //setText(4, mDir ); | ||
77 | m_dir = mDir; | ||
73 | dir = isDir; | 78 | dir = isDir; |
74 | } | 79 | } |
80 | QString directory()const{ | ||
81 | return m_dir; | ||
82 | } | ||
75 | bool isDir()const{ | 83 | bool isDir()const{ |
76 | return dir; | 84 | return dir; |
77 | } | 85 | } |
78 | QString path()const{ | 86 | QString path()const{ |
79 | return text(1 ); | 87 | return text(1 ); |
80 | } | 88 | } |
89 | QString key(int id, bool )const { | ||
90 | QString ke; | ||
91 | if( id == 0 || id == 1 ){ // name | ||
92 | if( dir ){ | ||
93 | ke.append("0" ); | ||
94 | ke.append( text(1) ); | ||
95 | }else{ | ||
96 | ke.append("1" ); | ||
97 | ke.append( text(1) ); | ||
98 | } | ||
99 | }else if( id == 2 ){ // size | ||
100 | return text(2); | ||
101 | }else if( id == 3 ){ // date | ||
102 | return text(3); | ||
103 | } | ||
104 | return ke; | ||
105 | }; | ||
81 | private: | 106 | private: |
82 | bool dir:1; | 107 | bool dir:1; |
108 | QString m_dir; | ||
83 | }; | 109 | }; |
84 | 110 | ||
85 | class OFileSelector : public QWidget { | 111 | class OFileSelector : public QWidget { |
86 | Q_OBJECT | 112 | Q_OBJECT |
87 | public: | 113 | public: |
88 | enum Mode {OPEN=1, SAVE, FILESELECTOR }; | 114 | enum Mode {OPEN=1, SAVE, FILESELECTOR }; |
89 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; | 115 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; |
90 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; | 116 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; |
91 | OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() ); | 117 | OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() ); |
92 | 118 | ||
93 | bool showToolbar() const { return m_shTool; }; | 119 | bool isToolbarVisible() const { return m_shTool; }; |
94 | bool showPermissionBar() const { return m_shPerm; }; | 120 | bool isPermissionBarVisible() const { return m_shPerm; }; |
95 | bool showLineEdit()const { return m_shLne; }; | 121 | bool isLineEditVisible()const { return m_shLne; }; |
96 | bool showChooser( )const { return m_shChooser; }; | 122 | bool isChooserVisible( )const { return m_shChooser; }; |
97 | bool showYesCancel()const { return m_shYesNo; }; | 123 | bool isYesCancelVisible()const { return m_shYesNo; }; |
98 | void setShowYesCancel( bool show ); | 124 | void setYesCancelVisible( bool show ); |
99 | void setShowToolbar( bool show ); | 125 | void setToolbarVisible( bool show ); |
100 | void setShowPermissionBar( bool show ); | 126 | void setPermissionBarVisible( bool show ); |
101 | void setShowLineEdit(bool show) ; | 127 | void setLineEditVisible(bool show) ; |
102 | void setShowChooser( bool chooser ); | 128 | void setChooserVisible( bool chooser ); |
129 | |||
103 | QCheckBox* permissionCheckbox(); | 130 | QCheckBox* permissionCheckbox(); |
104 | bool setPermission() const; | 131 | bool setPermission() const; |
105 | void setPermissionChecked( bool check ); | 132 | void setPermissionChecked( bool check ); |
133 | |||
106 | void setMode( int ); | 134 | void setMode( int ); |
107 | void setShowDirs(bool dir ) { }; | 135 | |
108 | bool showDirs() {bool turn; return turn; } | 136 | bool showDirs()const { return m_dir; } |
137 | void setShowDirs(bool ); | ||
138 | |||
139 | const QListView* listview() { return m_View; }; | ||
140 | |||
141 | bool isCaseSensetive()const { return m_case; } | ||
142 | void setCaseSensetive(bool caSe ); | ||
143 | |||
144 | bool showFiles()const { return m_files; }; | ||
145 | void setShowFiles(bool ); | ||
146 | |||
147 | |||
148 | |||
109 | int mode()const { return m_mode; }; | 149 | int mode()const { return m_mode; }; |
110 | int selector()const { return m_selector; }; | 150 | int selector()const { return m_selector; }; |
111 | void setSelector( int ); | 151 | void setSelector( int ); |
112 | QString selectedName( ); | 152 | |
153 | |||
113 | void setPopupMenu( const QPopupMenu * ); | 154 | void setPopupMenu( const QPopupMenu * ); |
114 | 155 | ||
115 | const DocLnk* selectedDocument()const; | ||
116 | void updateLay(); | 156 | void updateLay(); |
117 | 157 | ||
118 | void reparse(); // re reads the dir | 158 | void reparse(); // re reads the dir |
119 | QString directory(); | 159 | |
160 | QString selectedName( )const; | ||
161 | QStringList selectedNames()const; | ||
162 | |||
163 | QString selectedPath() const; | ||
164 | QStringList selectedPaths() const; | ||
165 | |||
166 | QString directory()const; | ||
120 | int fileCount(); | 167 | int fileCount(); |
121 | 168 | ||
169 | /* the user needs to delete it */ | ||
170 | DocLnk selectedDocument()const; | ||
171 | /* the user needs to delete it */ | ||
172 | QValueList<DocLnk> selectedDocuments(); | ||
173 | |||
122 | signals: | 174 | signals: |
123 | void fileSelected( const DocLnk & ); | 175 | void fileSelected( const DocLnk & ); |
124 | void fileSelected( const QString & ); | 176 | void fileSelected( const QString & ); |
125 | void closeMe(); | 177 | void closeMe(); |
126 | void ok(); | 178 | void ok(); |
127 | void cancel(); | 179 | void cancel(); |
128 | 180 | ||
129 | protected slots: | 181 | protected slots: |
130 | void slotOk(); | 182 | void slotOk(); |
131 | void slotCancel(); | 183 | void slotCancel(); |
132 | void slotViewCheck(const QString & ); | 184 | void slotViewCheck(const QString & ); |
133 | void slotMimeCheck(const QString & ); | 185 | void slotMimeCheck(const QString & ); |
134 | protected: | 186 | protected: |
135 | void init(); | 187 | void init(); |
136 | void updateMimes(); | 188 | void updateMimes(); |
137 | int m_mode, m_selector; | 189 | int m_mode, m_selector; |
138 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | 190 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; |
139 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | 191 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; |
140 | QPushButton *m_reread, *m_up; | 192 | QPushButton *m_reread, *m_up; |
141 | QListView *m_View; | 193 | QListView *m_View; |
142 | QCheckBox *m_checkPerm; | 194 | QCheckBox *m_checkPerm; |
143 | 195 | ||
144 | QString m_currentDir; | 196 | QString m_currentDir; |
145 | QString m_name; | 197 | QString m_name; |
146 | QStringList m_mimetypes; | 198 | QStringList m_mimetypes; |
147 | 199 | ||
148 | FileSelector *m_select; | 200 | FileSelector *m_select; |
149 | QWidgetStack *m_stack; | 201 | QWidgetStack *m_stack; |
150 | QVBoxLayout *m_lay; | 202 | QVBoxLayout *m_lay; |
151 | QGridLayout *m_Oselector; | 203 | QGridLayout *m_Oselector; |
152 | 204 | ||
153 | QHBoxLayout *m_boxToolbar; | 205 | QHBoxLayout *m_boxToolbar; |
154 | QHBoxLayout *m_boxOk; | 206 | QHBoxLayout *m_boxOk; |
155 | QHBoxLayout *m_boxName; | 207 | QHBoxLayout *m_boxName; |
156 | QHBoxLayout *m_boxView; | 208 | QHBoxLayout *m_boxView; |
157 | 209 | ||
158 | QLineEdit *m_edit; | 210 | QLineEdit *m_edit; |
159 | QLabel *m_fnLabel; | 211 | QLabel *m_fnLabel; |
160 | bool m_shTool:1; | 212 | bool m_shTool:1; |
161 | bool m_shPerm:1; | 213 | bool m_shPerm:1; |
162 | bool m_shLne:1; | 214 | bool m_shLne:1; |
163 | bool m_shChooser:1; | 215 | bool m_shChooser:1; |
164 | bool m_shYesNo:1; | 216 | bool m_shYesNo:1; |
165 | bool m_boCheckPerm:1; | 217 | bool m_boCheckPerm:1; |
166 | bool m_autoMime:1; | 218 | bool m_autoMime:1; |
219 | bool m_case:1; | ||
220 | bool m_dir:1; | ||
221 | bool m_files:1; | ||
167 | 222 | ||
168 | protected: | 223 | protected: |
169 | 224 | ||
170 | private: | 225 | private: |
171 | // implementation todo | 226 | // implementation todo |
172 | virtual void addFile(const QString &path, const QString &name, bool symlink = FALSE ) {}; | 227 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); |
173 | virtual void addDir( const QString &path, const QString &dir , bool symlink = FALSE ){}; | 228 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); |
174 | virtual void addSymlink(const QString &path, const QString &name, bool broken = FALSE ){}; | 229 | virtual void addSymlink(const QString &mime, QFileInfo *info, bool broken = FALSE ){}; |
175 | void delItems(); | 230 | void delItems(); |
176 | void initializeName(); | 231 | void initializeName(); |
177 | void initializeYes(); | 232 | void initializeYes(); |
178 | void initializeChooser(); | 233 | void initializeChooser(); |
179 | void initializeListView(); | 234 | void initializeListView(); |
235 | void initPics(); | ||
180 | bool compliesMime(const QString &path, const QString &mime); | 236 | bool compliesMime(const QString &path, const QString &mime); |
181 | 237 | ||
182 | class OFileSelectorPrivate; | 238 | class OFileSelectorPrivate; |
183 | OFileSelectorPrivate *d; | 239 | OFileSelectorPrivate *d; |
184 | 240 | static QMap<QString,QPixmap> *m_pixmaps; | |
185 | }; | 241 | }; |
186 | 242 | ||
187 | 243 | ||
188 | #endif | 244 | #endif |