-rw-r--r-- | libopie/ofileselector.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index bc7c6c2..c3a3514 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,593 +1,595 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qnamespace.h> | 29 | #include <qnamespace.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qhbox.h> | 32 | #include <qhbox.h> |
33 | #include <qvbox.h> | 33 | #include <qvbox.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qwidgetstack.h> | 35 | #include <qwidgetstack.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qheader.h> | 39 | #include <qheader.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qaction.h> | 42 | #include <qaction.h> |
43 | #include <qpopupmenu.h> | 43 | #include <qpopupmenu.h> |
44 | #include <qcursor.h> | 44 | #include <qcursor.h> |
45 | 45 | ||
46 | #include <qpe/qpeapplication.h> | 46 | #include <qpe/qpeapplication.h> |
47 | #include <qpe/fileselector.h> | 47 | #include <qpe/fileselector.h> |
48 | #include <qpe/applnk.h> | 48 | #include <qpe/applnk.h> |
49 | #include <qpe/global.h> | 49 | #include <qpe/global.h> |
50 | #include <qpe/mimetype.h> | 50 | #include <qpe/mimetype.h> |
51 | #include <qpe/resource.h> | 51 | #include <qpe/resource.h> |
52 | #include <qpe/storage.h> | 52 | #include <qpe/storage.h> |
53 | 53 | ||
54 | #include <unistd.h> | 54 | #include <unistd.h> |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | #include <sys/stat.h> | 56 | #include <sys/stat.h> |
57 | 57 | ||
58 | #include "ofileselector.h" | 58 | #include "ofileselector.h" |
59 | 59 | ||
60 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 60 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
61 | 61 | ||
62 | namespace { | 62 | namespace { |
63 | 63 | ||
64 | int indexByString( const QComboBox *box, const QString &str ){ | 64 | int indexByString( const QComboBox *box, const QString &str ){ |
65 | int index= -1; | 65 | int index= -1; |
66 | for(int i= 0; i < box->count(); i++ ){ | 66 | for(int i= 0; i < box->count(); i++ ){ |
67 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); | 67 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); |
68 | if( str == box->text(i ) ){ | 68 | if( str == box->text(i ) ){ |
69 | index= i; | 69 | index= i; |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | return index; | 73 | return index; |
74 | } | 74 | } |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, | 79 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, |
80 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) | 80 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) |
81 | { | 81 | { |
82 | |||
83 | resize(wid->width(),wid->height()); | ||
82 | m_selector = selector; | 84 | m_selector = selector; |
83 | m_currentDir = dirName; | 85 | m_currentDir = dirName; |
84 | m_name = fileName; | 86 | m_name = fileName; |
85 | m_mimetypes = mimetypes; | 87 | m_mimetypes = mimetypes; |
86 | if( mimetypes.isEmpty() ) | 88 | if( mimetypes.isEmpty() ) |
87 | m_autoMime = true; | 89 | m_autoMime = true; |
88 | 90 | ||
89 | m_mode = mode; | 91 | m_mode = mode; |
90 | m_shTool = true; | 92 | m_shTool = true; |
91 | m_shPerm = true; | 93 | m_shPerm = true; |
92 | m_shLne = true; | 94 | m_shLne = true; |
93 | m_shChooser = true; | 95 | m_shChooser = true; |
94 | m_shYesNo = true; | 96 | m_shYesNo = true; |
95 | // for FILESELECTOR only view is interesting | 97 | // for FILESELECTOR only view is interesting |
96 | m_location = 0; | 98 | m_location = 0; |
97 | m_homeButton = 0; | 99 | m_homeButton = 0; |
98 | m_docButton = 0; | 100 | m_docButton = 0; |
99 | m_hideButton = 0; | 101 | m_hideButton = 0; |
100 | m_ok = 0; | 102 | m_ok = 0; |
101 | m_cancel = 0; | 103 | m_cancel = 0; |
102 | m_reread = 0; | 104 | m_reread = 0; |
103 | m_up = 0; | 105 | m_up = 0; |
104 | m_View = 0; | 106 | m_View = 0; |
105 | m_select = 0; | 107 | m_select = 0; |
106 | m_stack = 0; | 108 | m_stack = 0; |
107 | 109 | ||
108 | m_select = 0; | 110 | m_select = 0; |
109 | m_stack = 0; | 111 | m_stack = 0; |
110 | m_lay = 0; | 112 | m_lay = 0; |
111 | m_boxToolbar = 0; | 113 | m_boxToolbar = 0; |
112 | m_boxOk = 0; | 114 | m_boxOk = 0; |
113 | m_edit = 0; | 115 | m_edit = 0; |
114 | 116 | ||
115 | m_fnLabel = 0; | 117 | m_fnLabel = 0; |
116 | m_checkPerm = 0; | 118 | m_checkPerm = 0; |
117 | m_mimeCheck = 0; | 119 | m_mimeCheck = 0; |
118 | m_viewCheck = 0; | 120 | m_viewCheck = 0; |
119 | 121 | ||
120 | m_pseudo = 0; | 122 | m_pseudo = 0; |
121 | m_pseudoLayout = 0; | 123 | m_pseudoLayout = 0; |
122 | 124 | ||
123 | m_dir = true; | 125 | m_dir = true; |
124 | m_files = true; | 126 | m_files = true; |
125 | m_custom = 0; | 127 | m_custom = 0; |
126 | m_showPopup = true; | 128 | m_showPopup = true; |
127 | 129 | ||
128 | if(m_pixmaps == 0 ) // init the pixmaps | 130 | if(m_pixmaps == 0 ) // init the pixmaps |
129 | initPics(); | 131 | initPics(); |
130 | 132 | ||
131 | m_lay = new QVBoxLayout(this); | 133 | m_lay = new QVBoxLayout(this); |
132 | init(); | 134 | init(); |
133 | m_edit->setText( fileName ); | 135 | m_edit->setText( fileName ); |
134 | } | 136 | } |
135 | void OFileSelector::initPics() | 137 | void OFileSelector::initPics() |
136 | { | 138 | { |
137 | qWarning("init pics" ); | 139 | qWarning("init pics" ); |
138 | m_pixmaps = new QMap<QString,QPixmap>; | 140 | m_pixmaps = new QMap<QString,QPixmap>; |
139 | QPixmap pm = Resource::loadPixmap( "folder" ); | 141 | QPixmap pm = Resource::loadPixmap( "folder" ); |
140 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 142 | QPixmap lnk = Resource::loadPixmap( "symlink" ); |
141 | QPainter painter( &pm ); | 143 | QPainter painter( &pm ); |
142 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 144 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
143 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 145 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
144 | m_pixmaps->insert("dirsymlink", pm ); | 146 | m_pixmaps->insert("dirsymlink", pm ); |
145 | 147 | ||
146 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 148 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
147 | QPainter pen(&pm2 ); | 149 | QPainter pen(&pm2 ); |
148 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 150 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
149 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 151 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
150 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 152 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
151 | 153 | ||
152 | }; | 154 | }; |
153 | // let's initialize the gui | 155 | // let's initialize the gui |
154 | /** | 156 | /** |
155 | -------------------- | 157 | -------------------- |
156 | | cmbBox Button | | 158 | | cmbBox Button | |
157 | -------------------- | 159 | -------------------- |
158 | | FileSlector | | 160 | | FileSlector | |
159 | | or | | 161 | | or | |
160 | | OSelector | | 162 | | OSelector | |
161 | | | | 163 | | | |
162 | | | | 164 | | | |
163 | ____________________ | 165 | ____________________ |
164 | | LineEdit | | 166 | | LineEdit | |
165 | ____________________ | 167 | ____________________ |
166 | | Permission Bar | | 168 | | Permission Bar | |
167 | ____________________ | 169 | ____________________ |
168 | | ViewChoose | | 170 | | ViewChoose | |
169 | ____________________ | 171 | ____________________ |
170 | | Save Cancel| | 172 | | Save Cancel| |
171 | ____________________ | 173 | ____________________ |
172 | */ | 174 | */ |
173 | void OFileSelector::delItems() | 175 | void OFileSelector::delItems() |
174 | { | 176 | { |
175 | QLayoutIterator it = m_lay->iterator(); | 177 | QLayoutIterator it = m_lay->iterator(); |
176 | while ( it.current() != 0 ){ | 178 | while ( it.current() != 0 ){ |
177 | it.deleteCurrent(); | 179 | it.deleteCurrent(); |
178 | } | 180 | } |
179 | } | 181 | } |
180 | void OFileSelector::init() | 182 | void OFileSelector::init() |
181 | { | 183 | { |
182 | 184 | ||
183 | m_stack = new QWidgetStack(this, "wstack" ); | 185 | m_stack = new QWidgetStack(this, "wstack" ); |
184 | if( m_selector == NORMAL ){ | 186 | if( m_selector == NORMAL ){ |
185 | QString currMime; | 187 | QString currMime; |
186 | if( m_mimeCheck != 0 ) | 188 | if( m_mimeCheck != 0 ) |
187 | currMime = m_mimeCheck->currentText(); | 189 | currMime = m_mimeCheck->currentText(); |
188 | 190 | ||
189 | updateMimes(); | 191 | updateMimes(); |
190 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); | 192 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); |
191 | m_stack->addWidget(m_select, NORMAL ); | 193 | m_stack->addWidget(m_select, NORMAL ); |
192 | m_lay->addWidget(m_stack ); | 194 | m_lay->addWidget(m_stack ); |
193 | m_stack->raiseWidget(NORMAL ); | 195 | m_stack->raiseWidget(NORMAL ); |
194 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 196 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
195 | }else { | 197 | }else { |
196 | initializeListView(); | 198 | initializeListView(); |
197 | } | 199 | } |
198 | 200 | ||
199 | if(m_shLne ){ | 201 | if(m_shLne ){ |
200 | initializeName(); | 202 | initializeName(); |
201 | } | 203 | } |
202 | 204 | ||
203 | if(m_shPerm ){ | 205 | if(m_shPerm ){ |
204 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); | 206 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); |
205 | m_checkPerm->setChecked( false ); | 207 | m_checkPerm->setChecked( false ); |
206 | m_lay->addWidget(m_checkPerm ); | 208 | m_lay->addWidget(m_checkPerm ); |
207 | } | 209 | } |
208 | 210 | ||
209 | if( m_shChooser ) | 211 | if( m_shChooser ) |
210 | initializeChooser(); | 212 | initializeChooser(); |
211 | 213 | ||
212 | if(m_shYesNo ) | 214 | if(m_shYesNo ) |
213 | initializeYes(); | 215 | initializeYes(); |
214 | 216 | ||
215 | 217 | ||
216 | }; | 218 | }; |
217 | 219 | ||
218 | void OFileSelector::setYesCancelVisible( bool show ) | 220 | void OFileSelector::setYesCancelVisible( bool show ) |
219 | { | 221 | { |
220 | if ( show == m_shYesNo ) | 222 | if ( show == m_shYesNo ) |
221 | return; | 223 | return; |
222 | m_shYesNo = show; | 224 | m_shYesNo = show; |
223 | if( !show ){ | 225 | if( !show ){ |
224 | delete m_ok; | 226 | delete m_ok; |
225 | delete m_cancel; | 227 | delete m_cancel; |
226 | m_ok = 0; | 228 | m_ok = 0; |
227 | m_cancel = 0; | 229 | m_cancel = 0; |
228 | // delete m_boxOk; all ready deleted in delItems | 230 | // delete m_boxOk; all ready deleted in delItems |
229 | } | 231 | } |
230 | updateLay(); // recreate it and save the other states | 232 | updateLay(); // recreate it and save the other states |
231 | } | 233 | } |
232 | 234 | ||
233 | void OFileSelector::setToolbarVisible( bool show ) | 235 | void OFileSelector::setToolbarVisible( bool show ) |
234 | { | 236 | { |
235 | if ( m_shTool == show ) | 237 | if ( m_shTool == show ) |
236 | return; | 238 | return; |
237 | if(!m_shTool ){ | 239 | if(!m_shTool ){ |
238 | delete m_boxToolbar; | 240 | delete m_boxToolbar; |
239 | delete m_homeButton; | 241 | delete m_homeButton; |
240 | delete m_docButton; | 242 | delete m_docButton; |
241 | delete m_location; | 243 | delete m_location; |
242 | delete m_up; | 244 | delete m_up; |
243 | m_boxToolbar = 0; | 245 | m_boxToolbar = 0; |
244 | m_homeButton = 0; | 246 | m_homeButton = 0; |
245 | m_docButton = 0; | 247 | m_docButton = 0; |
246 | m_location = 0; | 248 | m_location = 0; |
247 | m_up = 0; | 249 | m_up = 0; |
248 | }; | 250 | }; |
249 | updateLay();// overkill fix it | 251 | updateLay();// overkill fix it |
250 | } | 252 | } |
251 | 253 | ||
252 | void OFileSelector::setPermissionBarVisible( bool show ) | 254 | void OFileSelector::setPermissionBarVisible( bool show ) |
253 | { | 255 | { |
254 | if( show == m_shPerm ) | 256 | if( show == m_shPerm ) |
255 | return; | 257 | return; |
256 | 258 | ||
257 | m_shPerm = show; | 259 | m_shPerm = show; |
258 | 260 | ||
259 | updateLay(); | 261 | updateLay(); |
260 | } | 262 | } |
261 | void OFileSelector::setLineEditVisible( bool show ) | 263 | void OFileSelector::setLineEditVisible( bool show ) |
262 | { | 264 | { |
263 | if( show == m_shLne ) | 265 | if( show == m_shLne ) |
264 | return; | 266 | return; |
265 | 267 | ||
266 | m_shLne = show; | 268 | m_shLne = show; |
267 | if( !show ){ | 269 | if( !show ){ |
268 | delete m_edit; | 270 | delete m_edit; |
269 | delete m_fnLabel; | 271 | delete m_fnLabel; |
270 | m_edit = 0; | 272 | m_edit = 0; |
271 | m_fnLabel = 0; | 273 | m_fnLabel = 0; |
272 | //delete m_boxName; will be deleted | 274 | //delete m_boxName; will be deleted |
273 | } | 275 | } |
274 | updateLay(); | 276 | updateLay(); |
275 | } | 277 | } |
276 | void OFileSelector::setChooserVisible( bool show ) | 278 | void OFileSelector::setChooserVisible( bool show ) |
277 | { | 279 | { |
278 | if( show = m_shChooser ) | 280 | if( show = m_shChooser ) |
279 | return; | 281 | return; |
280 | m_shChooser = show; | 282 | m_shChooser = show; |
281 | if( !show ){ | 283 | if( !show ){ |
282 | delete m_mimeCheck; | 284 | delete m_mimeCheck; |
283 | delete m_viewCheck; | 285 | delete m_viewCheck; |
284 | m_mimeCheck = 0; | 286 | m_mimeCheck = 0; |
285 | m_viewCheck = 0; | 287 | m_viewCheck = 0; |
286 | } | 288 | } |
287 | updateLay(); | 289 | updateLay(); |
288 | } | 290 | } |
289 | QCheckBox* OFileSelector::permissionCheckbox( ) | 291 | QCheckBox* OFileSelector::permissionCheckbox( ) |
290 | { | 292 | { |
291 | return m_checkPerm; | 293 | return m_checkPerm; |
292 | } | 294 | } |
293 | void OFileSelector::setCaseSensetive( bool caSe ) | 295 | void OFileSelector::setCaseSensetive( bool caSe ) |
294 | { | 296 | { |
295 | m_case = caSe; | 297 | m_case = caSe; |
296 | reparse(); | 298 | reparse(); |
297 | } | 299 | } |
298 | void OFileSelector::setShowFiles(bool files ){ | 300 | void OFileSelector::setShowFiles(bool files ){ |
299 | m_files = files; | 301 | m_files = files; |
300 | reparse(); | 302 | reparse(); |
301 | } | 303 | } |
302 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) | 304 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
303 | { | 305 | { |
304 | //delete oldpopup; | 306 | //delete oldpopup; |
305 | m_custom = pop; | 307 | m_custom = pop; |
306 | } | 308 | } |
307 | bool OFileSelector::setPermission( ) const | 309 | bool OFileSelector::setPermission( ) const |
308 | { | 310 | { |
309 | if( m_checkPerm == 0 ) | 311 | if( m_checkPerm == 0 ) |
310 | return false; | 312 | return false; |
311 | else | 313 | else |
312 | return m_checkPerm->isChecked(); | 314 | return m_checkPerm->isChecked(); |
313 | } | 315 | } |
314 | void OFileSelector::setPermissionChecked( bool check ) | 316 | void OFileSelector::setPermissionChecked( bool check ) |
315 | { | 317 | { |
316 | if( m_checkPerm == 0 ) | 318 | if( m_checkPerm == 0 ) |
317 | return; | 319 | return; |
318 | m_checkPerm->setChecked( check ); | 320 | m_checkPerm->setChecked( check ); |
319 | } | 321 | } |
320 | QString OFileSelector::selectedName( )const | 322 | QString OFileSelector::selectedName( )const |
321 | { | 323 | { |
322 | QString string; | 324 | QString string; |
323 | if( m_selector == NORMAL ){ | 325 | if( m_selector == NORMAL ){ |
324 | const DocLnk *lnk = m_select->selected(); | 326 | const DocLnk *lnk = m_select->selected(); |
325 | string = lnk->file(); | 327 | string = lnk->file(); |
326 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 328 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
327 | QListViewItem *item = m_View->currentItem(); | 329 | QListViewItem *item = m_View->currentItem(); |
328 | if(item != 0 ){ | 330 | if(item != 0 ){ |
329 | string = item->text( 1 ); | 331 | string = item->text( 1 ); |
330 | } | 332 | } |
331 | } | 333 | } |
332 | return string; | 334 | return string; |
333 | } | 335 | } |
334 | QStringList OFileSelector::selectedNames()const | 336 | QStringList OFileSelector::selectedNames()const |
335 | { | 337 | { |
336 | QStringList list; | 338 | QStringList list; |
337 | return list; | 339 | return list; |
338 | } | 340 | } |
339 | DocLnk OFileSelector::selectedDocument( )const | 341 | DocLnk OFileSelector::selectedDocument( )const |
340 | { | 342 | { |
341 | DocLnk lnk; | 343 | DocLnk lnk; |
342 | return lnk; | 344 | return lnk; |
343 | } | 345 | } |
344 | void OFileSelector::updateLay() | 346 | void OFileSelector::updateLay() |
345 | { | 347 | { |
346 | /* if( m_shTool ) | 348 | /* if( m_shTool ) |
347 | // | 349 | // |
348 | else | 350 | else |
349 | // hide | 351 | // hide |
350 | */ | 352 | */ |
351 | // save the state | 353 | // save the state |
352 | bool check = false; | 354 | bool check = false; |
353 | if( m_checkPerm != 0 ) | 355 | if( m_checkPerm != 0 ) |
354 | check = m_checkPerm->isChecked(); | 356 | check = m_checkPerm->isChecked(); |
355 | QString text; | 357 | QString text; |
356 | 358 | ||
357 | if( m_edit != 0 ) | 359 | if( m_edit != 0 ) |
358 | text = m_edit->text(); | 360 | text = m_edit->text(); |
359 | // save current mimetype | 361 | // save current mimetype |
360 | 362 | ||
361 | delItems(); | 363 | delItems(); |
362 | delete m_checkPerm; | 364 | delete m_checkPerm; |
363 | m_checkPerm = 0; | 365 | m_checkPerm = 0; |
364 | delete m_edit; | 366 | delete m_edit; |
365 | m_edit = 0; | 367 | m_edit = 0; |
366 | delete m_fnLabel; | 368 | delete m_fnLabel; |
367 | m_fnLabel = 0; | 369 | m_fnLabel = 0; |
368 | delete m_ok; | 370 | delete m_ok; |
369 | m_ok = 0; | 371 | m_ok = 0; |
370 | delete m_cancel; | 372 | delete m_cancel; |
371 | m_cancel = 0; | 373 | m_cancel = 0; |
372 | delete m_mimeCheck; | 374 | delete m_mimeCheck; |
373 | m_mimeCheck = 0; | 375 | m_mimeCheck = 0; |
374 | delete m_viewCheck; | 376 | delete m_viewCheck; |
375 | m_viewCheck = 0; | 377 | m_viewCheck = 0; |
376 | delete m_select; // test | 378 | delete m_select; // test |
377 | delete m_stack; | 379 | delete m_stack; |
378 | //delete m_list; | 380 | //delete m_list; |
379 | init(); | 381 | init(); |
380 | if( m_shLne ) | 382 | if( m_shLne ) |
381 | m_edit->setText(text ); | 383 | m_edit->setText(text ); |
382 | if( m_shPerm ) | 384 | if( m_shPerm ) |
383 | m_checkPerm->setChecked(check ); | 385 | m_checkPerm->setChecked(check ); |
384 | } | 386 | } |
385 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | 387 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve |
386 | // insert QListViewItems with the right options | 388 | // insert QListViewItems with the right options |
387 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | 389 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) |
388 | { | 390 | { |
389 | if( mime == "All" ) | 391 | if( mime == "All" ) |
390 | return true; | 392 | return true; |
391 | MimeType type( path ); | 393 | MimeType type( path ); |
392 | if( type.id() == mime ) | 394 | if( type.id() == mime ) |
393 | return true; | 395 | return true; |
394 | return false; | 396 | return false; |
395 | } | 397 | } |
396 | 398 | ||
397 | void OFileSelector::reparse() | 399 | void OFileSelector::reparse() |
398 | { | 400 | { |
399 | if(m_View== 0 || m_selector == NORMAL) | 401 | if(m_View== 0 || m_selector == NORMAL) |
400 | return; | 402 | return; |
401 | 403 | ||
402 | m_View->clear(); | 404 | m_View->clear(); |
403 | 405 | ||
404 | 406 | ||
405 | QString currMime =m_mimeCheck->currentText(); | 407 | QString currMime =m_mimeCheck->currentText(); |
406 | // update the mimetype now | 408 | // update the mimetype now |
407 | if( m_autoMime ) { | 409 | if( m_autoMime ) { |
408 | QDir dir( m_currentDir ); | 410 | QDir dir( m_currentDir ); |
409 | m_mimetypes.clear(); | 411 | m_mimetypes.clear(); |
410 | m_mimeCheck->clear(); | 412 | m_mimeCheck->clear(); |
411 | dir.setFilter( QDir::Files | QDir::Readable ); | 413 | dir.setFilter( QDir::Files | QDir::Readable ); |
412 | dir.setSorting(QDir::Size ); | 414 | dir.setSorting(QDir::Size ); |
413 | const QFileInfoList *list = dir.entryInfoList(); | 415 | const QFileInfoList *list = dir.entryInfoList(); |
414 | QFileInfoListIterator it( *list ); | 416 | QFileInfoListIterator it( *list ); |
415 | QFileInfo *fi; | 417 | QFileInfo *fi; |
416 | while( (fi=it.current()) ){ | 418 | while( (fi=it.current()) ){ |
417 | if(fi->extension() == QString::fromLatin1("desktop") ){ | 419 | if(fi->extension() == QString::fromLatin1("desktop") ){ |
418 | ++it; | 420 | ++it; |
419 | continue; | 421 | continue; |
420 | } | 422 | } |
421 | MimeType type(fi->filePath() ); | 423 | MimeType type(fi->filePath() ); |
422 | if( !m_mimetypes.contains( type.id() ) ) | 424 | if( !m_mimetypes.contains( type.id() ) ) |
423 | m_mimetypes.append( type.id() ); | 425 | m_mimetypes.append( type.id() ); |
424 | 426 | ||
425 | ++it; | 427 | ++it; |
426 | } | 428 | } |
427 | m_mimetypes.prepend("All" ); | 429 | m_mimetypes.prepend("All" ); |
428 | m_mimeCheck->insertStringList(m_mimetypes ); | 430 | m_mimeCheck->insertStringList(m_mimetypes ); |
429 | // set it to the current mimetype | 431 | // set it to the current mimetype |
430 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 432 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
431 | }; | 433 | }; |
432 | QDir dir( m_currentDir ); | 434 | QDir dir( m_currentDir ); |
433 | //dir.setFilter(-1 ); | 435 | //dir.setFilter(-1 ); |
434 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; | 436 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; |
435 | if( m_case ) | 437 | if( m_case ) |
436 | sort = QDir::IgnoreCase; | 438 | sort = QDir::IgnoreCase; |
437 | dir.setSorting( sort ); | 439 | dir.setSorting( sort ); |
438 | 440 | ||
439 | int filter; | 441 | int filter; |
440 | /* if( m_dir && !m_files) | 442 | /* if( m_dir && !m_files) |
441 | filter |= QDir::Dirs; | 443 | filter |= QDir::Dirs; |
442 | else if( !m_dir && m_files ) | 444 | else if( !m_dir && m_files ) |
443 | filter |= QDir::Files; | 445 | filter |= QDir::Files; |
444 | else | 446 | else |
445 | filter |= QDir::All; | 447 | filter |= QDir::All; |
446 | */ | 448 | */ |
447 | if( m_selector == EXTENDED_ALL ) | 449 | if( m_selector == EXTENDED_ALL ) |
448 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 450 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
449 | else | 451 | else |
450 | filter = QDir::Files | QDir::Dirs | QDir::All; | 452 | filter = QDir::Files | QDir::Dirs | QDir::All; |
451 | dir.setFilter( filter ); | 453 | dir.setFilter( filter ); |
452 | 454 | ||
453 | const QFileInfoList *list = dir.entryInfoList(); | 455 | const QFileInfoList *list = dir.entryInfoList(); |
454 | QFileInfoListIterator it( *list ); | 456 | QFileInfoListIterator it( *list ); |
455 | QFileInfo *fi; | 457 | QFileInfo *fi; |
456 | while( (fi=it.current()) ){ | 458 | while( (fi=it.current()) ){ |
457 | if(fi->fileName() == ".." || fi->fileName() == "." ){ | 459 | if(fi->fileName() == ".." || fi->fileName() == "." ){ |
458 | ++it; | 460 | ++it; |
459 | continue; | 461 | continue; |
460 | } | 462 | } |
461 | qWarning("Test: %s", fi->fileName().latin1() ); | 463 | qWarning("Test: %s", fi->fileName().latin1() ); |
462 | if(fi->isSymLink() ){ | 464 | if(fi->isSymLink() ){ |
463 | qWarning("Symlink %s", fi->fileName().latin1() ); | 465 | qWarning("Symlink %s", fi->fileName().latin1() ); |
464 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); | 466 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); |
465 | qWarning("File ->%s", file.latin1() ); | 467 | qWarning("File ->%s", file.latin1() ); |
466 | for(int i=0; i<=4; i++ ){ // prepend from dos | 468 | for(int i=0; i<=4; i++ ){ // prepend from dos |
467 | QFileInfo info( file ); | 469 | QFileInfo info( file ); |
468 | if( !info.exists() ){ | 470 | if( !info.exists() ){ |
469 | qWarning("does not exist" ); | 471 | qWarning("does not exist" ); |
470 | addSymlink(currMime, fi, TRUE ); | 472 | addSymlink(currMime, fi, TRUE ); |
471 | break; | 473 | break; |
472 | }else if( info.isDir() ){ | 474 | }else if( info.isDir() ){ |
473 | qWarning("isDir" ); | 475 | qWarning("isDir" ); |
474 | addDir(currMime, fi, TRUE ); | 476 | addDir(currMime, fi, TRUE ); |
475 | break; | 477 | break; |
476 | }else if( info.isFile() ){ | 478 | }else if( info.isFile() ){ |
477 | qWarning("isFile" ); | 479 | qWarning("isFile" ); |
478 | addFile(currMime, fi, TRUE ); | 480 | addFile(currMime, fi, TRUE ); |
479 | break; | 481 | break; |
480 | }else if( info.isSymLink() ){ | 482 | }else if( info.isSymLink() ){ |
481 | file = info.dirPath(true)+ "/"+ info.readLink(); | 483 | file = info.dirPath(true)+ "/"+ info.readLink(); |
482 | qWarning("isSymlink again %s", file.latin1() ); | 484 | qWarning("isSymlink again %s", file.latin1() ); |
483 | }else if( i == 4 ){ // just insert it and have the symlink symbol | 485 | }else if( i == 4 ){ // just insert it and have the symlink symbol |
484 | addSymlink(currMime, fi ); | 486 | addSymlink(currMime, fi ); |
485 | qWarning("level too deep" ); | 487 | qWarning("level too deep" ); |
486 | } | 488 | } |
487 | } | 489 | } |
488 | }else if( fi->isDir() ){ | 490 | }else if( fi->isDir() ){ |
489 | addDir(currMime, fi ); | 491 | addDir(currMime, fi ); |
490 | }else if( fi->isFile() ) { // file ? | 492 | }else if( fi->isFile() ) { // file ? |
491 | addFile(currMime, fi ); | 493 | addFile(currMime, fi ); |
492 | } | 494 | } |
493 | ++it; | 495 | ++it; |
494 | } | 496 | } |
495 | m_View->sort(); | 497 | m_View->sort(); |
496 | } | 498 | } |
497 | QString OFileSelector::directory()const | 499 | QString OFileSelector::directory()const |
498 | { | 500 | { |
499 | return m_currentDir; | 501 | return m_currentDir; |
500 | } | 502 | } |
501 | int OFileSelector::fileCount() | 503 | int OFileSelector::fileCount() |
502 | { | 504 | { |
503 | return 0; | 505 | return 0; |
504 | } | 506 | } |
505 | void OFileSelector::slotOk( ) | 507 | void OFileSelector::slotOk( ) |
506 | { | 508 | { |
507 | emit ok(); | 509 | emit ok(); |
508 | } | 510 | } |
509 | void OFileSelector::slotCancel( ) | 511 | void OFileSelector::slotCancel( ) |
510 | { | 512 | { |
511 | emit cancel(); | 513 | emit cancel(); |
512 | } | 514 | } |
513 | 515 | ||
514 | void OFileSelector::initializeName() | 516 | void OFileSelector::initializeName() |
515 | { | 517 | { |
516 | m_boxName = new QHBoxLayout(this ); | 518 | m_boxName = new QHBoxLayout(this ); |
517 | m_edit = new QLineEdit(this ); | 519 | m_edit = new QLineEdit(this ); |
518 | m_fnLabel = new QLabel(this ); | 520 | m_fnLabel = new QLabel(this ); |
519 | m_fnLabel->setText(tr("Name:") ); | 521 | m_fnLabel->setText(tr("Name:") ); |
520 | m_boxName->addWidget(m_fnLabel ); | 522 | m_boxName->addWidget(m_fnLabel ); |
521 | m_boxName->insertSpacing(1, 8 ); | 523 | m_boxName->insertSpacing(1, 8 ); |
522 | m_boxName->addWidget(m_edit, 100 ); | 524 | m_boxName->addWidget(m_edit, 100 ); |
523 | 525 | ||
524 | m_lay->addLayout(m_boxName); | 526 | m_lay->addLayout(m_boxName); |
525 | } | 527 | } |
526 | void OFileSelector::initializeYes() | 528 | void OFileSelector::initializeYes() |
527 | { | 529 | { |
528 | m_ok = new QPushButton("&Save", this, "save" ); | 530 | m_ok = new QPushButton("&Save", this, "save" ); |
529 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); | 531 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); |
530 | m_boxOk = new QHBoxLayout(this ); | 532 | m_boxOk = new QHBoxLayout(this ); |
531 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); | 533 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); |
532 | m_boxOk->insertSpacing(1, 8 ); | 534 | m_boxOk->insertSpacing(1, 8 ); |
533 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); | 535 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); |
534 | m_lay->addLayout(m_boxOk ); | 536 | m_lay->addLayout(m_boxOk ); |
535 | connect(m_ok, SIGNAL(clicked() ), | 537 | connect(m_ok, SIGNAL(clicked() ), |
536 | this, SLOT(slotOk() ) ); | 538 | this, SLOT(slotOk() ) ); |
537 | connect(m_cancel, SIGNAL(clicked() ), | 539 | connect(m_cancel, SIGNAL(clicked() ), |
538 | this, SLOT(slotCancel() ) ); | 540 | this, SLOT(slotCancel() ) ); |
539 | 541 | ||
540 | } | 542 | } |
541 | void OFileSelector::initializeChooser() | 543 | void OFileSelector::initializeChooser() |
542 | { | 544 | { |
543 | m_boxView = new QHBoxLayout(this ); | 545 | m_boxView = new QHBoxLayout(this ); |
544 | 546 | ||
545 | m_mimeCheck = new QComboBox(this, "mime check"); | 547 | m_mimeCheck = new QComboBox(this, "mime check"); |
546 | m_viewCheck = new QComboBox(this, "view check"); | 548 | m_viewCheck = new QComboBox(this, "view check"); |
547 | m_boxView->addWidget(m_viewCheck, 0 ); | 549 | m_boxView->addWidget(m_viewCheck, 0 ); |
548 | m_boxView->insertSpacing(1, 8 ); | 550 | m_boxView->insertSpacing(1, 8 ); |
549 | m_boxView->addWidget(m_mimeCheck, 0 ); | 551 | m_boxView->addWidget(m_mimeCheck, 0 ); |
550 | m_lay->addLayout(m_boxView ); | 552 | m_lay->addLayout(m_boxView ); |
551 | 553 | ||
552 | m_viewCheck->insertItem(tr("Documents") ); | 554 | m_viewCheck->insertItem(tr("Documents") ); |
553 | m_viewCheck->insertItem(tr("Files") ); | 555 | m_viewCheck->insertItem(tr("Files") ); |
554 | m_viewCheck->insertItem(tr("All Files") ); | 556 | m_viewCheck->insertItem(tr("All Files") ); |
555 | 557 | ||
556 | if(!m_autoMime ) | 558 | if(!m_autoMime ) |
557 | m_mimeCheck->insertItem(m_mimetypes.join("," ) ); | 559 | m_mimeCheck->insertItem(m_mimetypes.join("," ) ); |
558 | else{ // check | 560 | else{ // check |
559 | updateMimes(); | 561 | updateMimes(); |
560 | m_mimeCheck->insertStringList( m_mimetypes ); | 562 | m_mimeCheck->insertStringList( m_mimetypes ); |
561 | } | 563 | } |
562 | 564 | ||
563 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), | 565 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), |
564 | this, SLOT(slotViewCheck(const QString & ) ) ); | 566 | this, SLOT(slotViewCheck(const QString & ) ) ); |
565 | 567 | ||
566 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), | 568 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), |
567 | this, SLOT(slotMimeCheck(const QString & ) ) ); | 569 | this, SLOT(slotMimeCheck(const QString & ) ) ); |
568 | } | 570 | } |
569 | void OFileSelector::slotMimeCheck(const QString &view ){ | 571 | void OFileSelector::slotMimeCheck(const QString &view ){ |
570 | if(m_selector == NORMAL ){ | 572 | if(m_selector == NORMAL ){ |
571 | delete m_select; | 573 | delete m_select; |
572 | m_select = new FileSelector(view == "All" ? QString::null : view | 574 | m_select = new FileSelector(view == "All" ? QString::null : view |
573 | , m_stack, "fileselector", FALSE, FALSE ); | 575 | , m_stack, "fileselector", FALSE, FALSE ); |
574 | m_stack->addWidget( m_select, NORMAL ); | 576 | m_stack->addWidget( m_select, NORMAL ); |
575 | m_stack->raiseWidget( NORMAL ); | 577 | m_stack->raiseWidget( NORMAL ); |
576 | }else{ | 578 | }else{ |
577 | reparse(); | 579 | reparse(); |
578 | } | 580 | } |
579 | } | 581 | } |
580 | 582 | ||
581 | void OFileSelector::slotViewCheck(const QString &view ){ | 583 | void OFileSelector::slotViewCheck(const QString &view ){ |
582 | qWarning("changed: show %s", view.latin1() ); | 584 | qWarning("changed: show %s", view.latin1() ); |
583 | // if the current view is the one | 585 | // if the current view is the one |
584 | QString currMime = m_mimeCheck->currentText(); | 586 | QString currMime = m_mimeCheck->currentText(); |
585 | if( view == QString::fromLatin1("Documents") ){ | 587 | if( view == QString::fromLatin1("Documents") ){ |
586 | // get the mimetype now | 588 | // get the mimetype now |
587 | // check if we're the current widget and return | 589 | // check if we're the current widget and return |
588 | if( m_View != 0) { // delete 0 shouldn't crash but it did :( | 590 | if( m_View != 0) { // delete 0 shouldn't crash but it did :( |
589 | delete m_View; | 591 | delete m_View; |
590 | delete m_boxToolbar; | 592 | delete m_boxToolbar; |
591 | delete m_homeButton; | 593 | delete m_homeButton; |
592 | delete m_docButton; | 594 | delete m_docButton; |
593 | delete m_location; | 595 | delete m_location; |