summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 1807575..128292f 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -1,709 +1,717 @@
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 42
43#include <qpe/qpeapplication.h> 43#include <qpe/qpeapplication.h>
44#include <qpe/fileselector.h> 44#include <qpe/fileselector.h>
45#include <qpe/applnk.h> 45#include <qpe/applnk.h>
46#include <qpe/global.h> 46#include <qpe/global.h>
47#include <qpe/mimetype.h> 47#include <qpe/mimetype.h>
48#include <qpe/resource.h> 48#include <qpe/resource.h>
49 49
50#include "ofileselector.h" 50#include "ofileselector.h"
51 51
52QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; 52QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
53 53
54namespace { 54namespace {
55 55
56 int indexByString( const QComboBox *box, const QString &str ){ 56 int indexByString( const QComboBox *box, const QString &str ){
57 int index= -1; 57 int index= -1;
58 for(int i= 0; i < box->count(); i++ ){ 58 for(int i= 0; i < box->count(); i++ ){
59 qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); 59 qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() );
60 if( str == box->text(i ) ){ 60 if( str == box->text(i ) ){
61 index= i; 61 index= i;
62 break; 62 break;
63 } 63 }
64 } 64 }
65 return index; 65 return index;
66 } 66 }
67 67
68}; 68};
69 69
70 70
71OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 71OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
72 const QString &fileName, const QStringList mimetypes ) : QWidget( wid ) 72 const QString &fileName, const QStringList mimetypes ) : QWidget( wid )
73{ 73{
74 m_selector = selector; 74 m_selector = selector;
75 m_currentDir = dirName; 75 m_currentDir = dirName;
76 m_name = fileName; 76 m_name = fileName;
77 m_mimetypes = mimetypes; 77 m_mimetypes = mimetypes;
78 if( mimetypes.isEmpty() ) 78 if( mimetypes.isEmpty() )
79 m_autoMime = true; 79 m_autoMime = true;
80 80
81 m_mode = mode; 81 m_mode = mode;
82 m_shTool = true; 82 m_shTool = true;
83 m_shPerm = true; 83 m_shPerm = true;
84 m_shLne = true; 84 m_shLne = true;
85 m_shChooser = true; 85 m_shChooser = true;
86 m_shYesNo = true; 86 m_shYesNo = true;
87 // for FILESELECTOR only view is interesting 87 // for FILESELECTOR only view is interesting
88 m_location = 0; 88 m_location = 0;
89 m_homeButton = 0; 89 m_homeButton = 0;
90 m_docButton = 0; 90 m_docButton = 0;
91 m_hideButton = 0; 91 m_hideButton = 0;
92 m_ok = 0; 92 m_ok = 0;
93 m_cancel = 0; 93 m_cancel = 0;
94 m_reread = 0; 94 m_reread = 0;
95 m_up = 0; 95 m_up = 0;
96 m_View = 0; 96 m_View = 0;
97 m_select = 0; 97 m_select = 0;
98 m_stack = 0; 98 m_stack = 0;
99 99
100 m_select = 0; 100 m_select = 0;
101 m_stack = 0; 101 m_stack = 0;
102 m_lay = 0; 102 m_lay = 0;
103 m_boxToolbar = 0; 103 m_boxToolbar = 0;
104 m_boxOk = 0; 104 m_boxOk = 0;
105 m_edit = 0; 105 m_edit = 0;
106 106
107 m_fnLabel = 0; 107 m_fnLabel = 0;
108 m_checkPerm = 0; 108 m_checkPerm = 0;
109 m_mimeCheck = 0; 109 m_mimeCheck = 0;
110 m_viewCheck = 0; 110 m_viewCheck = 0;
111 111
112 m_dir = true; 112 m_dir = true;
113 m_files = true; 113 m_files = true;
114 114
115 if(m_pixmaps == 0 ) // init the pixmaps 115 if(m_pixmaps == 0 ) // init the pixmaps
116 initPics(); 116 initPics();
117 117
118 m_lay = new QVBoxLayout(this); 118 m_lay = new QVBoxLayout(this);
119 init(); 119 init();
120 m_edit->setText( fileName ); 120 m_edit->setText( fileName );
121} 121}
122void OFileSelector::initPics() 122void OFileSelector::initPics()
123{ 123{
124 qWarning("init pics" ); 124 qWarning("init pics" );
125 m_pixmaps = new QMap<QString,QPixmap>; 125 m_pixmaps = new QMap<QString,QPixmap>;
126 QPixmap pm = Resource::loadPixmap( "folder" ); 126 QPixmap pm = Resource::loadPixmap( "folder" );
127 QPixmap lnk = Resource::loadPixmap( "symlink" ); 127 QPixmap lnk = Resource::loadPixmap( "symlink" );
128 QPainter painter( &pm ); 128 QPainter painter( &pm );
129 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 129 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
130 pm.setMask( pm.createHeuristicMask( FALSE ) ); 130 pm.setMask( pm.createHeuristicMask( FALSE ) );
131 m_pixmaps->insert("dirsymlink", pm ); 131 m_pixmaps->insert("dirsymlink", pm );
132 132
133 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 133 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
134 QPainter pen(&pm2 ); 134 QPainter pen(&pm2 );
135 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 135 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
136 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 136 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
137 m_pixmaps->insert("symlinkedlocked", pm2 ); 137 m_pixmaps->insert("symlinkedlocked", pm2 );
138 138
139}; 139};
140// let's initialize the gui 140// let's initialize the gui
141/** 141/**
142 -------------------- 142 --------------------
143 | cmbBox Button | 143 | cmbBox Button |
144 -------------------- 144 --------------------
145 | FileSlector | 145 | FileSlector |
146 | or | 146 | or |
147 | OSelector | 147 | OSelector |
148 | | 148 | |
149 | | 149 | |
150 ____________________ 150 ____________________
151 | LineEdit | 151 | LineEdit |
152 ____________________ 152 ____________________
153 | Permission Bar | 153 | Permission Bar |
154 ____________________ 154 ____________________
155 | ViewChoose | 155 | ViewChoose |
156 ____________________ 156 ____________________
157 | Save Cancel| 157 | Save Cancel|
158 ____________________ 158 ____________________
159 */ 159 */
160void OFileSelector::delItems() 160void OFileSelector::delItems()
161{ 161{
162 QLayoutIterator it = m_lay->iterator(); 162 QLayoutIterator it = m_lay->iterator();
163 while ( it.current() != 0 ){ 163 while ( it.current() != 0 ){
164 it.deleteCurrent(); 164 it.deleteCurrent();
165 } 165 }
166} 166}
167void OFileSelector::init() 167void OFileSelector::init()
168{ 168{
169 169
170 m_stack = new QWidgetStack(this, "wstack" ); 170 m_stack = new QWidgetStack(this, "wstack" );
171 if( m_selector == NORMAL ){ 171 if( m_selector == NORMAL ){
172 QString currMime; 172 QString currMime;
173 if( m_mimeCheck != 0 ) 173 if( m_mimeCheck != 0 )
174 currMime = m_mimeCheck->currentText(); 174 currMime = m_mimeCheck->currentText();
175
175 updateMimes(); 176 updateMimes();
176 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); 177 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE );
177 m_stack->addWidget(m_select, NORMAL ); 178 m_stack->addWidget(m_select, NORMAL );
178 m_lay->addWidget(m_stack ); 179 m_lay->addWidget(m_stack );
179 m_stack->raiseWidget(NORMAL ); 180 m_stack->raiseWidget(NORMAL );
180 }else { 181 }else {
181 initializeListView(); 182 initializeListView();
182 } 183 }
183 184
184 if(m_shLne ){ 185 if(m_shLne ){
185 initializeName(); 186 initializeName();
186 } 187 }
187 188
188 if(m_shPerm ){ 189 if(m_shPerm ){
189 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); 190 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" );
190 m_checkPerm->setChecked( false ); 191 m_checkPerm->setChecked( false );
191 m_lay->addWidget(m_checkPerm ); 192 m_lay->addWidget(m_checkPerm );
192 } 193 }
193 194
194 if( m_shChooser ) 195 if( m_shChooser )
195 initializeChooser(); 196 initializeChooser();
196 197
197 if(m_shYesNo ) 198 if(m_shYesNo )
198 initializeYes(); 199 initializeYes();
199 200
200 201
201}; 202};
202 203
203void OFileSelector::setYesCancelVisible( bool show ) 204void OFileSelector::setYesCancelVisible( bool show )
204{ 205{
205 if ( show == m_shYesNo ) 206 if ( show == m_shYesNo )
206 return; 207 return;
207 m_shYesNo = show; 208 m_shYesNo = show;
208 if( !show ){ 209 if( !show ){
209 delete m_ok; 210 delete m_ok;
210 delete m_cancel; 211 delete m_cancel;
211 m_ok = 0; 212 m_ok = 0;
212 m_cancel = 0; 213 m_cancel = 0;
213 // delete m_boxOk; all ready deleted in delItems 214 // delete m_boxOk; all ready deleted in delItems
214 } 215 }
215 updateLay(); // recreate it and save the other states 216 updateLay(); // recreate it and save the other states
216} 217}
217 218
218void OFileSelector::setToolbarVisible( bool show ) 219void OFileSelector::setToolbarVisible( bool show )
219{ 220{
220 if ( m_shTool == show ) 221 if ( m_shTool == show )
221 return; 222 return;
222 /* if( show ){ 223 /* if( show ){
223 224
224 }else { 225 }else {
225 226
226 }*/ 227 }*/
227} 228}
228 229
229void OFileSelector::setPermissionBarVisible( bool show ) 230void OFileSelector::setPermissionBarVisible( bool show )
230{ 231{
231 if( show == m_shPerm ) 232 if( show == m_shPerm )
232 return; 233 return;
233 234
234 m_shPerm = show; 235 m_shPerm = show;
235 236
236 updateLay(); 237 updateLay();
237} 238}
238void OFileSelector::setLineEditVisible( bool show ) 239void OFileSelector::setLineEditVisible( bool show )
239{ 240{
240 if( show == m_shLne ) 241 if( show == m_shLne )
241 return; 242 return;
242 243
243 m_shLne = show; 244 m_shLne = show;
244 if( !show ){ 245 if( !show ){
245 delete m_edit; 246 delete m_edit;
246 delete m_fnLabel; 247 delete m_fnLabel;
247 m_edit = 0; 248 m_edit = 0;
248 m_fnLabel = 0; 249 m_fnLabel = 0;
249 //delete m_boxName; will be deleted 250 //delete m_boxName; will be deleted
250 } 251 }
251 updateLay(); 252 updateLay();
252} 253}
253void OFileSelector::setChooserVisible( bool show ) 254void OFileSelector::setChooserVisible( bool show )
254{ 255{
255 if( show = m_shChooser ) 256 if( show = m_shChooser )
256 return; 257 return;
257 m_shChooser = show; 258 m_shChooser = show;
258 if( !show ){ 259 if( !show ){
259 delete m_mimeCheck; 260 delete m_mimeCheck;
260 delete m_viewCheck; 261 delete m_viewCheck;
261 m_mimeCheck = 0; 262 m_mimeCheck = 0;
262 m_viewCheck = 0; 263 m_viewCheck = 0;
263 } 264 }
264 updateLay(); 265 updateLay();
265} 266}
266QCheckBox* OFileSelector::permissionCheckbox( ) 267QCheckBox* OFileSelector::permissionCheckbox( )
267{ 268{
268 return m_checkPerm; 269 return m_checkPerm;
269} 270}
270void OFileSelector::setCaseSensetive( bool caSe ) 271void OFileSelector::setCaseSensetive( bool caSe )
271{ 272{
272 m_case = caSe; 273 m_case = caSe;
273 reparse(); 274 reparse();
274} 275}
275void OFileSelector::setShowFiles(bool files ){ 276void OFileSelector::setShowFiles(bool files ){
276 m_files = files; 277 m_files = files;
277 reparse(); 278 reparse();
278} 279}
279void OFileSelector::setPopupMenu(const QPopupMenu * ) 280void OFileSelector::setPopupMenu(const QPopupMenu * )
280{ 281{
281 //delete oldpopup; 282 //delete oldpopup;
282 283
283} 284}
284bool OFileSelector::setPermission( ) const 285bool OFileSelector::setPermission( ) const
285{ 286{
286 if( m_checkPerm == 0 ) 287 if( m_checkPerm == 0 )
287 return false; 288 return false;
288 else 289 else
289 return m_checkPerm->isChecked(); 290 return m_checkPerm->isChecked();
290} 291}
291void OFileSelector::setPermissionChecked( bool check ) 292void OFileSelector::setPermissionChecked( bool check )
292{ 293{
293 if( m_checkPerm == 0 ) 294 if( m_checkPerm == 0 )
294 return; 295 return;
295 m_checkPerm->setChecked( check ); 296 m_checkPerm->setChecked( check );
296} 297}
297QString OFileSelector::selectedName( )const 298QString OFileSelector::selectedName( )const
298{ 299{
299 QString string; 300 QString string;
300 if( m_selector == NORMAL ){ 301 if( m_selector == NORMAL ){
301 const DocLnk *lnk = m_select->selected(); 302 const DocLnk *lnk = m_select->selected();
302 string = lnk->file(); 303 string = lnk->file();
303 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 304 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
304 QListViewItem *item = m_View->currentItem(); 305 QListViewItem *item = m_View->currentItem();
305 if(item != 0 ){ 306 if(item != 0 ){
306 string = item->text( 1 ); 307 string = item->text( 1 );
307 } 308 }
308 } 309 }
309 return string; 310 return string;
310} 311}
311QStringList OFileSelector::selectedNames()const 312QStringList OFileSelector::selectedNames()const
312{ 313{
313 QStringList list; 314 QStringList list;
314 return list; 315 return list;
315} 316}
316DocLnk OFileSelector::selectedDocument( )const 317DocLnk OFileSelector::selectedDocument( )const
317{ 318{
318 DocLnk lnk; 319 DocLnk lnk;
319 return lnk; 320 return lnk;
320} 321}
321void OFileSelector::updateLay() 322void OFileSelector::updateLay()
322{ 323{
323 /* if( m_shTool ) 324 /* if( m_shTool )
324 // 325 //
325 else 326 else
326 // hide 327 // hide
327 */ 328 */
328 // save the state 329 // save the state
329 bool check = false; 330 bool check = false;
330 if( m_checkPerm != 0 ) 331 if( m_checkPerm != 0 )
331 check = m_checkPerm->isChecked(); 332 check = m_checkPerm->isChecked();
332 QString text; 333 QString text;
333 334
334 if( m_edit != 0 ) 335 if( m_edit != 0 )
335 text = m_edit->text(); 336 text = m_edit->text();
336 // save current mimetype 337 // save current mimetype
337 338
338 delItems(); 339 delItems();
339 delete m_checkPerm; 340 delete m_checkPerm;
341 m_checkPerm = 0;
340 delete m_edit; 342 delete m_edit;
343 m_edit = 0;
341 delete m_fnLabel; 344 delete m_fnLabel;
345 m_fnLabel = 0;
342 delete m_ok; 346 delete m_ok;
347 m_ok = 0;
343 delete m_cancel; 348 delete m_cancel;
349 m_cancel = 0;
344 delete m_mimeCheck; 350 delete m_mimeCheck;
351 m_mimeCheck = 0;
345 delete m_viewCheck; 352 delete m_viewCheck;
353 m_viewCheck = 0;
346 delete m_select; // test 354 delete m_select; // test
347 delete m_stack; 355 delete m_stack;
348 //delete m_list; 356 //delete m_list;
349 init(); 357 init();
350 if( m_shLne ) 358 if( m_shLne )
351 m_edit->setText(text ); 359 m_edit->setText(text );
352 if( m_shPerm ) 360 if( m_shPerm )
353 m_checkPerm->setChecked(check ); 361 m_checkPerm->setChecked(check );
354} 362}
355// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve 363// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve
356// insert QListViewItems with the right options 364// insert QListViewItems with the right options
357bool OFileSelector::compliesMime(const QString &path, const QString &mime ) 365bool OFileSelector::compliesMime(const QString &path, const QString &mime )
358{ 366{
359 if( mime == "All" ) 367 if( mime == "All" )
360 return true; 368 return true;
361 MimeType type( path ); 369 MimeType type( path );
362 if( type.id() == mime ) 370 if( type.id() == mime )
363 return true; 371 return true;
364 return false; 372 return false;
365} 373}
366 374
367void OFileSelector::reparse() 375void OFileSelector::reparse()
368{ 376{
369 if(m_View== 0 || m_selector == NORMAL) 377 if(m_View== 0 || m_selector == NORMAL)
370 return; 378 return;
371 379
372 m_View->clear(); 380 m_View->clear();
373 381
374 382
375 QString currMime =m_mimeCheck->currentText(); 383 QString currMime =m_mimeCheck->currentText();
376 // update the mimetype now 384 // update the mimetype now
377 if( m_autoMime ) { 385 if( m_autoMime ) {
378 QDir dir( m_currentDir ); 386 QDir dir( m_currentDir );
379 m_mimetypes.clear(); 387 m_mimetypes.clear();
380 m_mimeCheck->clear(); 388 m_mimeCheck->clear();
381 dir.setFilter( QDir::Files | QDir::Readable ); 389 dir.setFilter( QDir::Files | QDir::Readable );
382 dir.setSorting(QDir::Size ); 390 dir.setSorting(QDir::Size );
383 const QFileInfoList *list = dir.entryInfoList(); 391 const QFileInfoList *list = dir.entryInfoList();
384 QFileInfoListIterator it( *list ); 392 QFileInfoListIterator it( *list );
385 QFileInfo *fi; 393 QFileInfo *fi;
386 while( (fi=it.current()) ){ 394 while( (fi=it.current()) ){
387 if(fi->extension() == QString::fromLatin1("desktop") ){ 395 if(fi->extension() == QString::fromLatin1("desktop") ){
388 ++it; 396 ++it;
389 continue; 397 continue;
390 } 398 }
391 MimeType type(fi->filePath() ); 399 MimeType type(fi->filePath() );
392 if( !m_mimetypes.contains( type.id() ) ) 400 if( !m_mimetypes.contains( type.id() ) )
393 m_mimetypes.append( type.id() ); 401 m_mimetypes.append( type.id() );
394 402
395 ++it; 403 ++it;
396 } 404 }
397 m_mimetypes.prepend("All" ); 405 m_mimetypes.prepend("All" );
398 m_mimeCheck->insertStringList(m_mimetypes ); 406 m_mimeCheck->insertStringList(m_mimetypes );
399 // set it to the current mimetype 407 // set it to the current mimetype
400 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); 408 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
401 }; 409 };
402 QDir dir( m_currentDir ); 410 QDir dir( m_currentDir );
403 //dir.setFilter(-1 ); 411 //dir.setFilter(-1 );
404 dir.setSorting(QDir::Name | QDir::DirsFirst | QDir::Reversed | QDir::IgnoreCase ); 412 dir.setSorting(QDir::Name | QDir::DirsFirst | QDir::Reversed | QDir::IgnoreCase );
405 const QFileInfoList *list = dir.entryInfoList(); 413 const QFileInfoList *list = dir.entryInfoList();
406 QFileInfoListIterator it( *list ); 414 QFileInfoListIterator it( *list );
407 QFileInfo *fi; 415 QFileInfo *fi;
408 while( (fi=it.current()) ){ 416 while( (fi=it.current()) ){
409 if(fi->fileName() == ".." || fi->fileName() == "." ){ 417 if(fi->fileName() == ".." || fi->fileName() == "." ){
410 ++it; 418 ++it;
411 continue; 419 continue;
412 } 420 }
413 qWarning("Test: %s", fi->fileName().latin1() ); 421 qWarning("Test: %s", fi->fileName().latin1() );
414 if(fi->isSymLink() ){ 422 if(fi->isSymLink() ){
415 qWarning("Symlink %s", fi->fileName().latin1() ); 423 qWarning("Symlink %s", fi->fileName().latin1() );
416 QString file = fi->dirPath(true)+"/"+ fi->readLink(); 424 QString file = fi->dirPath(true)+"/"+ fi->readLink();
417 qWarning("File ->%s", file.latin1() ); 425 qWarning("File ->%s", file.latin1() );
418 for(int i=0; i<=4; i++ ){ // prepend from dos 426 for(int i=0; i<=4; i++ ){ // prepend from dos
419 QFileInfo info( file ); 427 QFileInfo info( file );
420 if( !info.exists() ){ 428 if( !info.exists() ){
421 qWarning("does not exist" ); 429 qWarning("does not exist" );
422 addSymlink(currMime, fi, TRUE ); 430 addSymlink(currMime, fi, TRUE );
423 break; 431 break;
424 }else if( info.isDir() ){ 432 }else if( info.isDir() ){
425 qWarning("isDir" ); 433 qWarning("isDir" );
426 addDir(currMime, fi, TRUE ); 434 addDir(currMime, fi, TRUE );
427 break; 435 break;
428 }else if( info.isFile() ){ 436 }else if( info.isFile() ){
429 qWarning("isFile" ); 437 qWarning("isFile" );
430 addFile(currMime, fi, TRUE ); 438 addFile(currMime, fi, TRUE );
431 break; 439 break;
432 }else if( info.isSymLink() ){ 440 }else if( info.isSymLink() ){
433 file = info.dirPath(true)+ "/"+ info.readLink(); 441 file = info.dirPath(true)+ "/"+ info.readLink();
434 qWarning("isSymlink again %s", file.latin1() ); 442 qWarning("isSymlink again %s", file.latin1() );
435 }else if( i == 4 ){ // just insert it and have the symlink symbol 443 }else if( i == 4 ){ // just insert it and have the symlink symbol
436 addSymlink(currMime, fi ); 444 addSymlink(currMime, fi );
437 qWarning("level too deep" ); 445 qWarning("level too deep" );
438 } 446 }
439 } 447 }
440 }else if( fi->isDir() ){ 448 }else if( fi->isDir() ){
441 addDir(currMime, fi ); 449 addDir(currMime, fi );
442 }else if( fi->isFile() ) { // file ? 450 }else if( fi->isFile() ) { // file ?
443 addFile(currMime, fi ); 451 addFile(currMime, fi );
444 } 452 }
445 ++it; 453 ++it;
446 } 454 }
447 m_View->sort(); 455 m_View->sort();
448} 456}
449QString OFileSelector::directory()const 457QString OFileSelector::directory()const
450{ 458{
451 return m_currentDir; 459 return m_currentDir;
452} 460}
453int OFileSelector::fileCount() 461int OFileSelector::fileCount()
454{ 462{
455 return 0; 463 return 0;
456} 464}
457void OFileSelector::slotOk( ) 465void OFileSelector::slotOk( )
458{ 466{
459 emit ok(); 467 emit ok();
460} 468}
461void OFileSelector::slotCancel( ) 469void OFileSelector::slotCancel( )
462{ 470{
463 emit cancel(); 471 emit cancel();
464} 472}
465 473
466void OFileSelector::initializeName() 474void OFileSelector::initializeName()
467{ 475{
468 m_boxName = new QHBoxLayout(this ); 476 m_boxName = new QHBoxLayout(this );
469 m_edit = new QLineEdit(this ); 477 m_edit = new QLineEdit(this );
470 m_fnLabel = new QLabel(this ); 478 m_fnLabel = new QLabel(this );
471 m_fnLabel->setText(tr("Name:") ); 479 m_fnLabel->setText(tr("Name:") );
472 m_boxName->addWidget(m_fnLabel ); 480 m_boxName->addWidget(m_fnLabel );
473 m_boxName->insertSpacing(1, 8 ); 481 m_boxName->insertSpacing(1, 8 );
474 m_boxName->addWidget(m_edit, 100 ); 482 m_boxName->addWidget(m_edit, 100 );
475 483
476 m_lay->addLayout(m_boxName); 484 m_lay->addLayout(m_boxName);
477} 485}
478void OFileSelector::initializeYes() 486void OFileSelector::initializeYes()
479{ 487{
480 m_ok = new QPushButton("&Save", this, "save" ); 488 m_ok = new QPushButton("&Save", this, "save" );
481 m_cancel = new QPushButton("C&ancel", this, "cancel" ); 489 m_cancel = new QPushButton("C&ancel", this, "cancel" );
482 m_boxOk = new QHBoxLayout(this ); 490 m_boxOk = new QHBoxLayout(this );
483 m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); 491 m_boxOk->addWidget( m_ok, Qt::AlignHCenter );
484 m_boxOk->insertSpacing(1, 8 ); 492 m_boxOk->insertSpacing(1, 8 );
485 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); 493 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter);
486 m_lay->addLayout(m_boxOk ); 494 m_lay->addLayout(m_boxOk );
487 connect(m_ok, SIGNAL(clicked() ), 495 connect(m_ok, SIGNAL(clicked() ),
488 this, SLOT(slotOk() ) ); 496 this, SLOT(slotOk() ) );
489 connect(m_cancel, SIGNAL(clicked() ), 497 connect(m_cancel, SIGNAL(clicked() ),
490 this, SLOT(slotCancel() ) ); 498 this, SLOT(slotCancel() ) );
491 499
492} 500}
493void OFileSelector::initializeChooser() 501void OFileSelector::initializeChooser()
494{ 502{
495 m_boxView = new QHBoxLayout(this ); 503 m_boxView = new QHBoxLayout(this );
496 504
497 m_mimeCheck = new QComboBox(this, "mime check"); 505 m_mimeCheck = new QComboBox(this, "mime check");
498 m_viewCheck = new QComboBox(this, "view check"); 506 m_viewCheck = new QComboBox(this, "view check");
499 m_boxView->addWidget(m_viewCheck, 0 ); 507 m_boxView->addWidget(m_viewCheck, 0 );
500 m_boxView->insertSpacing(1, 8 ); 508 m_boxView->insertSpacing(1, 8 );
501 m_boxView->addWidget(m_mimeCheck, 0 ); 509 m_boxView->addWidget(m_mimeCheck, 0 );
502 m_lay->addLayout(m_boxView ); 510 m_lay->addLayout(m_boxView );
503 511
504 m_viewCheck->insertItem(tr("Documents") ); 512 m_viewCheck->insertItem(tr("Documents") );
505 m_viewCheck->insertItem(tr("Files") ); 513 m_viewCheck->insertItem(tr("Files") );
506 m_viewCheck->insertItem(tr("All Files") ); 514 m_viewCheck->insertItem(tr("All Files") );
507 515
508 if(!m_autoMime ) 516 if(!m_autoMime )
509 m_mimeCheck->insertItem(m_mimetypes.join("," ) ); 517 m_mimeCheck->insertItem(m_mimetypes.join("," ) );
510 else{ // check 518 else{ // check
511 updateMimes(); 519 updateMimes();
512 m_mimeCheck->insertStringList( m_mimetypes ); 520 m_mimeCheck->insertStringList( m_mimetypes );
513 } 521 }
514 522
515 connect( m_viewCheck, SIGNAL(activated(const QString &) ), 523 connect( m_viewCheck, SIGNAL(activated(const QString &) ),
516 this, SLOT(slotViewCheck(const QString & ) ) ); 524 this, SLOT(slotViewCheck(const QString & ) ) );
517 525
518 connect( m_mimeCheck, SIGNAL(activated(const QString &) ), 526 connect( m_mimeCheck, SIGNAL(activated(const QString &) ),
519 this, SLOT(slotMimeCheck(const QString & ) ) ); 527 this, SLOT(slotMimeCheck(const QString & ) ) );
520} 528}
521void OFileSelector::slotMimeCheck(const QString &view ){ 529void OFileSelector::slotMimeCheck(const QString &view ){
522 if(m_selector == NORMAL ){ 530 if(m_selector == NORMAL ){
523 delete m_select; 531 delete m_select;
524 m_select = new FileSelector(view == "All" ? QString::null : view 532 m_select = new FileSelector(view == "All" ? QString::null : view
525 , m_stack, "fileselector", FALSE, FALSE ); 533 , m_stack, "fileselector", FALSE, FALSE );
526 m_stack->addWidget( m_select, NORMAL ); 534 m_stack->addWidget( m_select, NORMAL );
527 m_stack->raiseWidget( NORMAL ); 535 m_stack->raiseWidget( NORMAL );
528 }else{ 536 }else{
529 reparse(); 537 reparse();
530 } 538 }
531} 539}
532 540
533void OFileSelector::slotViewCheck(const QString &view ){ 541void OFileSelector::slotViewCheck(const QString &view ){
534 qWarning("changed: show %s", view.latin1() ); 542 qWarning("changed: show %s", view.latin1() );
535 // if the current view is the one 543 // if the current view is the one
536 QString currMime = m_mimeCheck->currentText(); 544 QString currMime = m_mimeCheck->currentText();
537 if( view == QString::fromLatin1("Documents") ){ 545 if( view == QString::fromLatin1("Documents") ){
538 // get the mimetype now 546 // get the mimetype now
539 // check if we're the current widget and return 547 // check if we're the current widget and return
540 if( m_View != 0) // delete 0 shouldn't crash but it did :( 548 if( m_View != 0) // delete 0 shouldn't crash but it did :(
541 delete m_View; 549 delete m_View;
542 m_View = 0; 550 m_View = 0;
543 delete m_select; 551 delete m_select;
544 m_select = new FileSelector( currMime == "All" ? QString::null : currMime, 552 m_select = new FileSelector( currMime == "All" ? QString::null : currMime,
545 m_stack,"fileselector", FALSE, FALSE ); 553 m_stack,"fileselector", FALSE, FALSE );
546 m_stack->addWidget( m_select, NORMAL ); 554 m_stack->addWidget( m_select, NORMAL );
547 m_mimeCheck->clear(); 555 m_mimeCheck->clear();
548 m_selector = NORMAL; 556 m_selector = NORMAL;
549 updateMimes(); 557 updateMimes();
550 m_mimeCheck->insertStringList( m_mimetypes ); 558 m_mimeCheck->insertStringList( m_mimetypes );
551 m_stack->raiseWidget( NORMAL ); 559 m_stack->raiseWidget( NORMAL );
552 560
553 561
554 }else if(view == QString::fromLatin1("Files") ){ 562 }else if(view == QString::fromLatin1("Files") ){
555 // remove from the stack 563 // remove from the stack
556 delete m_select; 564 delete m_select;
557 m_select = 0; 565 m_select = 0;
558 delete m_View; 566 delete m_View;
559 m_View = 0; 567 m_View = 0;
560 m_selector = EXTENDED; 568 m_selector = EXTENDED;
561 // create the ListView or IconView 569 // create the ListView or IconView
562 initializeListView(); 570 initializeListView();
563 571
564 reparse(); 572 reparse();
565 }else if(view == QString::fromLatin1("All Files") ) { 573 }else if(view == QString::fromLatin1("All Files") ) {
566 // remove from the stack 574 // remove from the stack
567 delete m_select; 575 delete m_select;
568 m_select = 0; 576 m_select = 0;
569 delete m_View; 577 delete m_View;
570 m_View = 0; 578 m_View = 0;
571 m_selector = EXTENDED_ALL; 579 m_selector = EXTENDED_ALL;
572 initializeListView(); 580 initializeListView();
573 reparse(); 581 reparse();
574 }; 582 };
575}; 583};
576 584
577 585
578void OFileSelector::updateMimes() // lets check which mode is active 586void OFileSelector::updateMimes() // lets check which mode is active
579 // check the current dir for items then 587 // check the current dir for items then
580{ 588{
581 m_mimetypes.clear(); 589 m_mimetypes.clear();
582 m_mimetypes.append("All" ); 590 m_mimetypes.append("All" );
583 if( m_selector == NORMAL ){ 591 if( m_selector == NORMAL ){
584 DocLnkSet set; 592 DocLnkSet set;
585 Global::findDocuments(&set, QString::null ); 593 Global::findDocuments(&set, QString::null );
586 QListIterator<DocLnk> dit( set.children() ); 594 QListIterator<DocLnk> dit( set.children() );
587 for ( ; dit.current(); ++dit ) { 595 for ( ; dit.current(); ++dit ) {
588 if( !m_mimetypes.contains((*dit)->type() ) ) 596 if( !m_mimetypes.contains((*dit)->type() ) )
589 m_mimetypes.append( (*dit)->type() ); 597 m_mimetypes.append( (*dit)->type() );
590 } 598 }
591 }else{ 599 }else{
592 // should be allreday updatet 600 // should be allreday updatet
593 ; 601 ;
594 } 602 }
595}; 603};
596void OFileSelector::initializeListView() 604void OFileSelector::initializeListView()
597{ 605{
598 m_View = new QListView(m_stack, "Extended view" ); 606 m_View = new QListView(m_stack, "Extended view" );
599 m_stack->addWidget( m_View, EXTENDED ); 607 m_stack->addWidget( m_View, EXTENDED );
600 m_stack->raiseWidget( EXTENDED ); 608 m_stack->raiseWidget( EXTENDED );
601 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); 609 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold);
602 // set up the stuff 610 // set up the stuff
603 // Pixmap Name Date Size mime 611 // Pixmap Name Date Size mime
604 //(m_View->header() )->hide(); 612 //(m_View->header() )->hide();
605 //m_View->setRootIsDecorated(false); 613 //m_View->setRootIsDecorated(false);
606 m_View->addColumn(" "); 614 m_View->addColumn(" ");
607 m_View->addColumn(tr("Name") ); 615 m_View->addColumn(tr("Name") );
608 m_View->addColumn(tr("Size") ); 616 m_View->addColumn(tr("Size") );
609 m_View->addColumn(tr("Date"), 60 ); 617 m_View->addColumn(tr("Date"), 60 );
610 m_View->addColumn(tr("Mime Type") ); 618 m_View->addColumn(tr("Mime Type") );
611 QHeader *header = m_View->header(); 619 QHeader *header = m_View->header();
612 header->hide(); 620 header->hide();
613 m_View->setSorting(1 ); 621 m_View->setSorting(1 );
614}; 622};
615/* If a item is locked depends on the mode 623/* If a item is locked depends on the mode
616 if we're in OPEN !isReadable is locked 624 if we're in OPEN !isReadable is locked
617 if we're in SAVE !isWriteable is locked 625 if we're in SAVE !isWriteable is locked
618 626
619 627
620 */ 628 */
621 629
622 630
623void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ 631void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){
624 qWarning("Add Files" ); 632 qWarning("Add Files" );
625 if( !m_files ){ 633 if( !m_files ){
626 qWarning("not mfiles" ); 634 qWarning("not mfiles" );
627 return; 635 return;
628 } 636 }
629 637
630 MimeType type( info->filePath() ); 638 MimeType type( info->filePath() );
631 QString name; 639 QString name;
632 QString dir; 640 QString dir;
633 bool locked= false; 641 bool locked= false;
634 if(mime == "All" ){ 642 if(mime == "All" ){
635 ; 643 ;
636 }else if( type.id() != mime ) { 644 }else if( type.id() != mime ) {
637 return; 645 return;
638 } 646 }
639 QPixmap pix = type.pixmap(); 647 QPixmap pix = type.pixmap();
640 if(pix.isNull() ) 648 if(pix.isNull() )
641 pix = Resource::loadPixmap( "UnknownDocument-14" ); 649 pix = Resource::loadPixmap( "UnknownDocument-14" );
642 dir = info->dirPath( true ); 650 dir = info->dirPath( true );
643 if( symlink ) { // check if the readLink is readable 651 if( symlink ) { // check if the readLink is readable
644 // do it right later 652 // do it right later
645 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 653 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
646 }else{ // keep track of the icons 654 }else{ // keep track of the icons
647 name = info->fileName(); 655 name = info->fileName();
648 if( m_mode == OPEN ){ 656 if( m_mode == OPEN ){
649 if( !info->isReadable() ){ 657 if( !info->isReadable() ){
650 locked = true; 658 locked = true;
651 pix = Resource::loadPixmap("locked" ); 659 pix = Resource::loadPixmap("locked" );
652 } 660 }
653 }else if( m_mode == SAVE ){ 661 }else if( m_mode == SAVE ){
654 if( !info->isWritable() ){ 662 if( !info->isWritable() ){
655 locked = true; 663 locked = true;
656 pix = Resource::loadPixmap("locked" ); 664 pix = Resource::loadPixmap("locked" );
657 } 665 }
658 } 666 }
659 } 667 }
660 new OFileSelectorItem( m_View, pix, name, 668 new OFileSelectorItem( m_View, pix, name,
661 info->lastModified().toString(), 669 info->lastModified().toString(),
662 QString::number( info->size() ), 670 QString::number( info->size() ),
663 dir, locked ); 671 dir, locked );
664} 672}
665void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) 673void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
666{ 674{
667 if(!m_dir ) 675 if(!m_dir )
668 return; 676 return;
669 //if( showDirs ) 677 //if( showDirs )
670 { 678 {
671 bool locked; 679 bool locked;
672 QString name; 680 QString name;
673 QPixmap pix; 681 QPixmap pix;
674 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ 682 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
675 locked = true; 683 locked = true;
676 if( symlink ){ 684 if( symlink ){
677 pix = (*m_pixmaps)["symlinkedlocked"]; 685 pix = (*m_pixmaps)["symlinkedlocked"];
678 }else{ 686 }else{
679 pix = Resource::loadPixmap("lockedfolder" ); 687 pix = Resource::loadPixmap("lockedfolder" );
680 } 688 }
681 }else{ 689 }else{
682 if( symlink ){ 690 if( symlink ){
683 pix = (*m_pixmaps)["dirsymlink" ]; 691 pix = (*m_pixmaps)["dirsymlink" ];
684 }else{ 692 }else{
685 pix = Resource::loadPixmap("folder" ); 693 pix = Resource::loadPixmap("folder" );
686 } 694 }
687 } 695 }
688 if( symlink){ 696 if( symlink){
689 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); 697 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink();
690 698
691 }else{ 699 }else{
692 //if(info->isReadable() ) 700 //if(info->isReadable() )
693 name = info->fileName(); 701 name = info->fileName();
694 } 702 }
695 703
696 new OFileSelectorItem(m_View, pix, 704 new OFileSelectorItem(m_View, pix,
697 name, info->lastModified().toString(), 705 name, info->lastModified().toString(),
698 QString::number(info->size() ),info->dirPath(true), locked, true ); 706 QString::number(info->size() ),info->dirPath(true), locked, true );
699 707
700 } 708 }
701} 709}
702void OFileSelector::setShowDirs(bool dir ) 710void OFileSelector::setShowDirs(bool dir )
703{ 711{
704 m_dir = dir; 712 m_dir = dir;
705 reparse(); 713 reparse();
706} 714}
707 715
708 716
709 717