summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc1699
-rw-r--r--libopie/ofileselector.h39
2 files changed, 841 insertions, 897 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 9cf3f36..d780da9 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -1,80 +1,51 @@
1/* 1
2               =. This file is part of the OPIE Project 2
3             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 3#include <qcheckbox.h>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include <qnamespace.h>
30#include <qpushbutton.h>
31#include <qcombobox.h> 4#include <qcombobox.h>
32#include <qhbox.h> 5#include <qheader.h>
33#include <qvbox.h> 6#include <qlabel.h>
7#include <qabstractlayout.h>
34#include <qlayout.h> 8#include <qlayout.h>
35#include <qwidgetstack.h>
36#include <qlineedit.h> 9#include <qlineedit.h>
37#include <qcheckbox.h> 10#include <qlistview.h>
38#include <qlabel.h>
39#include <qheader.h>
40#include <qdir.h>
41#include <qpainter.h>
42#include <qaction.h>
43#include <qpopupmenu.h>
44#include <qcursor.h>
45#include <qstringlist.h>
46#include <qmessagebox.h> 11#include <qmessagebox.h>
12#include <qpushbutton.h>
13#include <qwidgetstack.h>
14#include <qpopupmenu.h>
15#include <qdir.h>
16#include <qfile.h>
17#include <qfileinfo.h>
18#include <qtimer.h>
47 19
48#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
49#include <qpe/fileselector.h>
50#include <qpe/applnk.h> 21#include <qpe/applnk.h>
22#include <qpe/fileselector.h>
51#include <qpe/global.h> 23#include <qpe/global.h>
52#include <qpe/mimetype.h> 24#include <qpe/mimetype.h>
53#include <qpe/resource.h> 25#include <qpe/resource.h>
54#include <qpe/storage.h> 26#include <qpe/storage.h>
55 27
56#include <unistd.h> 28#include <unistd.h>
57#include <stdlib.h> 29#include <stdlib.h>
58#include <sys/stat.h> 30#include <sys/stat.h>
59 31
60#include "ofileselector.h" 32#include "ofileselector.h"
61//#include "ofileview.h" 33
62 34
63QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; 35QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
64 36
65namespace { 37namespace {
66
67 int indexByString( const QComboBox *box, const QString &str ){ 38 int indexByString( const QComboBox *box, const QString &str ){
68 int index= -1; 39 int index= 0;
69 for(int i= 0; i < box->count(); i++ ){ 40 for(int i= 0; i < box->count(); i++ ){
70 if( str == box->text(i ) ){ 41 if( str == box->text(i ) ){
71 index= i; 42 index= i;
72 break; 43 break;
73 } 44 }
74 } 45 }
75 return index; 46 return index;
76 } 47 }
77 class OFileSelectorItem : public QListViewItem { 48 class OFileSelectorItem : public QListViewItem {
78 public: 49 public:
79 OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, 50 OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path,
80 const QString &date, const QString &size, const QString &mDir, 51 const QString &date, const QString &size, const QString &mDir,
@@ -120,1075 +91,1043 @@ namespace {
120 private: 91 private:
121 bool mLocked:1; 92 bool mLocked:1;
122 bool dir:1; 93 bool dir:1;
123 QString m_dir; 94 QString m_dir;
124 }; 95 };
125}; 96};
126 97
127 98
128OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 99OFileSelector::OFileSelector( QWidget *wid, int mode, int selector,
129 const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) 100 const QString &dirName,
101 const QString &fileName,
102 const QStringList &mimeTypes )
103 : QWidget( wid, "OFileSelector")
130{ 104{
131 if(wid!=0) 105 m_mimetypes = mimeTypes;
132 resize(wid->width(),wid->height()); 106 initVars();
133 m_selector = selector;
134 m_currentDir = dirName;
135 m_name = fileName;
136 m_mimetypes = mimetypes;
137
138 if( mimetypes.isEmpty() )
139 m_autoMime = true;
140
141 qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() );
142 m_mode = mode; 107 m_mode = mode;
143 m_shTool = true; 108 m_selector = selector;
144 m_shPerm = true; 109 m_currentDir = dirName;
145 m_shLne = true;
146 m_shChooser = true;
147 m_shYesNo = true;
148
149 // for FILESELECTOR only view is interesting
150 m_location = 0;
151 m_homeButton = 0;
152 m_docButton = 0;
153 m_hideButton = 0;
154 m_ok = 0;
155 m_cancel = 0;
156 m_reread = 0;
157 m_up = 0;
158 m_View = 0;
159 m_select = 0;
160 m_stack = 0;
161
162 m_select = 0;
163 m_stack = 0;
164 m_lay = 0;
165 m_boxToolbar = 0;
166 m_boxOk = 0;
167 m_edit = 0;
168
169 m_fnLabel = 0;
170 m_checkPerm = 0;
171 m_mimeCheck = 0;
172 m_viewCheck = 0;
173
174 m_pseudo = 0;
175 m_pseudoLayout = 0;
176
177 m_dir = true;
178 m_files = true;
179 m_custom = 0;
180 m_showPopup = true;
181
182 if(m_pixmaps == 0 ) // init the pixmaps
183 initPics();
184
185 m_lay = new QVBoxLayout(this);
186 init(); 110 init();
187 m_edit->setText( fileName ); 111QTimer::singleShot(6*1000, this, SLOT( slotTest() ) );
188} 112}
189 113
190void OFileSelector::initPics() 114OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent,
115 const char *name, bool newVisible = TRUE,
116 bool closeVisible = FALSE )
117 : QWidget( parent, name )
191{ 118{
192 qWarning("init pics" ); 119 m_mimetypes = QStringList::split(";", mimeFilter );
193 m_pixmaps = new QMap<QString,QPixmap>; 120 initVars();
194 QPixmap pm = Resource::loadPixmap( "folder" ); 121 m_currentDir = QPEApplication::documentDir();
195 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 122 m_mode = OPEN;
196 QPainter painter( &pm ); 123 m_selector = NORMAL;
197 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 124 m_shClose = closeVisible;
198 pm.setMask( pm.createHeuristicMask( FALSE ) ); 125 m_shNew = newVisible;
199 m_pixmaps->insert("dirsymlink", pm ); 126 m_shLne = false;
200 127 m_shPerm = false;
201 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 128 m_shYesNo = false;
202 QPainter pen(&pm2 ); 129 init();
203 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
204 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
205 m_pixmaps->insert("symlinkedlocked", pm2 );
206 130
131
207} 132}
208 133
209// let's initialize the gui 134OFileSelector::~OFileSelector()
210/**
211 --------------------
212 | cmbBox Button |
213 --------------------
214 | FileSlector |
215 | or |
216 | OSelector |
217 | |
218 | |
219 ____________________
220 | LineEdit |
221 ____________________
222 | Permission Bar |
223 ____________________
224 | ViewChoose |
225 ____________________
226 | Save Cancel|
227 ____________________
228 */
229void OFileSelector::delItems()
230{ 135{
231 QLayoutIterator it = m_lay->iterator(); 136
232 while ( it.current() != 0 ){
233 it.deleteCurrent();
234 }
235} 137}
236 138
237void OFileSelector::init() 139void OFileSelector::setNewVisible( bool visible )
238{ 140{
239// qDebug("init"); 141 m_shNew = visible;
240 m_stack = new QWidgetStack(this, "wstack" );
241 if( m_selector == NORMAL ){ 142 if( m_selector == NORMAL ){
242 QString currMime; 143 delete m_select;
243 if( m_mimeCheck != 0 ) 144 // we need to initialize but keep the selected mimetype
244 currMime = m_mimeCheck->currentText(); 145 QString mime = m_mimeCheck == 0 ? QString::null : m_mimeCheck->currentText() ;
245 updateMimes(); 146 m_select = new FileSelector( m_autoMime ? mime : m_mimetypes.join(";") ,
246 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , 147 m_stack, "fileselector",
247 m_stack, "fileselector", FALSE, FALSE ); 148 m_shNew, m_shClose);
248 m_stack->addWidget(m_select, NORMAL ); 149 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
249 m_lay->addWidget(m_stack ); 150 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
250 m_stack->raiseWidget(NORMAL ); 151 //connect to close me and other signals as well
251 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), 152 m_stack->addWidget( m_select, NORMAL );
252 this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 153 }else{
253 m_pseudoLayout = 0l; 154 m_new->show();
254
255 } else {
256 initializeListView();
257 } 155 }
258 if(m_shLne ){ 156}
259 initializeName(); 157void OFileSelector::setCloseVisible( bool visible )
158{
159 m_shClose = visible;
160 if( m_selector == NORMAL ){
161 setNewVisible( m_shNew ); // yeah baby
162 }else{
163 m_close->show();
260 } 164 }
261 if(m_shPerm ){ 165}
262 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); 166void OFileSelector::reread()
263 m_checkPerm->setChecked( false ); 167{
264 m_lay->addWidget(m_checkPerm ); 168 if( m_selector == NORMAL ){
169 setNewVisible( m_shNew ); // make it a initializeSelector
170 }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
171 reparse();
172 //}else{
173 //;
265 } 174 }
266 if( m_shChooser ) 175}
267 initializeChooser();
268 if(m_shYesNo )
269 initializeYes();
270 176
271 // m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) ); 177const DocLnk *OFileSelector::selected()
272 // reparse(); 178{
273 179 if( m_selector == NORMAL ){
180 return m_select->selected();
181 }else{
182 DocLnk *lnk = new DocLnk(selectedDocument() );
183 return lnk;
184 }
274} 185}
275 186
276void OFileSelector::setYesCancelVisible( bool show ) 187void OFileSelector::setYesCancelVisible( bool show )
277{ 188{
278 if ( show == m_shYesNo ) 189 initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :(
279 return;
280 m_shYesNo = show; 190 m_shYesNo = show;
281 if( !show ){ 191 if( m_shYesNo )
282 delete m_ok; 192 m_boxOk->show();
283 delete m_cancel; 193 else
284 m_ok = 0; 194 m_boxOk->hide();
285 m_cancel = 0;
286 // delete m_boxOk; all ready deleted in delItems
287 }
288 updateLay(); // recreate it and save the other states
289}
290 195
196}
291void OFileSelector::setToolbarVisible( bool show ) 197void OFileSelector::setToolbarVisible( bool show )
292{ 198{
293 if ( m_shTool == show ) 199 m_shTool = show;
294 return; 200 initializeListView(); // FIXME see above waste of memory
295 if(!m_shTool ){ 201 if(!m_shTool ){
296 delete m_boxToolbar; 202 m_location->hide();
297 delete m_homeButton; 203 m_up->hide();
298 delete m_docButton; 204 m_homeButton->hide();
299 delete m_location; 205 m_docButton->hide();
300 delete m_up; 206 }else{
301 m_boxToolbar = 0; 207 m_location->show();
302 m_homeButton = 0; 208 m_up->show();
303 m_docButton = 0; 209 m_homeButton->show();
304 m_location = 0; 210 m_docButton->show();
305 m_up = 0; 211 }
306 };
307 updateLay();// overkill fix it
308} 212}
309
310void OFileSelector::setPermissionBarVisible( bool show ) 213void OFileSelector::setPermissionBarVisible( bool show )
311{ 214{
312 if( show == m_shPerm )
313 return;
314
315 m_shPerm = show; 215 m_shPerm = show;
316 216 initializePerm();
317 updateLay(); 217 if( m_shPerm )
218 m_checkPerm->show();
219 else
220 m_checkPerm->hide();
318} 221}
319
320void OFileSelector::setLineEditVisible( bool show ) 222void OFileSelector::setLineEditVisible( bool show )
321{ 223{
322 if( show == m_shLne ) 224 if( show ){
323 return; 225 initializeName();
324 226 m_boxName->show();
325 m_shLne = show; 227 }else{
326 if( !show ){ 228 if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go
327 delete m_edit; 229 m_boxName->hide();
328 delete m_fnLabel; 230 }
329 m_edit = 0;
330 m_fnLabel = 0;
331 //delete m_boxName; will be deleted
332 } 231 }
333 updateLay(); 232 m_shLne = show;
334} 233}
335 234
336void OFileSelector::setChooserVisible( bool show ) 235void OFileSelector::setChooserVisible( bool show )
337{ 236{
338 if( show = m_shChooser )
339 return;
340 m_shChooser = show; 237 m_shChooser = show;
341 if( !show ){ 238 initializeChooser();
342 delete m_mimeCheck; 239 if( m_shChooser ){
343 delete m_viewCheck; 240 m_boxView->hide();
344 m_mimeCheck = 0; 241 }else{
345 m_viewCheck = 0; 242 m_boxView->show();
346 } 243 }
347 updateLay();
348} 244}
349 245
350QCheckBox* OFileSelector::permissionCheckbox( ) 246QCheckBox* OFileSelector::permissionCheckbox()
247{
248 if( m_selector == NORMAL )
249 return 0l;
250 else
251 return m_checkPerm;
252}
253bool OFileSelector::setPermission()const
351{ 254{
352 return m_checkPerm; 255 return m_checkPerm == 0 ? false : m_checkPerm->isChecked();
256}
257void OFileSelector::setPermissionChecked( bool check )
258{
259 if( m_checkPerm )
260 m_checkPerm->setChecked( check );
353} 261}
354 262
355void OFileSelector::setCaseSensetive( bool caSe ) 263void OFileSelector::setMode(int mode) // FIXME do direct raising
264{
265 m_mode = mode;
266 if( m_selector == NORMAL )
267 return;
268}
269void OFileSelector::setShowDirs(bool )
270{
271 m_dir = true;
272 reparse();
273}
274void OFileSelector::setCaseSensetive(bool caSe )
356{ 275{
357 m_case = caSe; 276 m_case = caSe;
358 reparse(); 277 reparse();
359} 278}
360 279void OFileSelector::setShowFiles(bool show )
361void OFileSelector::setShowFiles(bool files ){ 280{
362 m_files = files; 281 m_files = show;
363 reparse(); 282 reparse();
364} 283}
365 284///
366void OFileSelector::setPopupMenu(QPopupMenu *pop ) 285bool OFileSelector::cd(const QString &path )
367{ 286{
368 //delete oldpopup; 287 m_currentDir = path;
369 m_custom = pop; 288 reparse();
289 return true;
370} 290}
371 291void OFileSelector::setSelector(int mode )
372bool OFileSelector::setPermission( ) const
373{ 292{
374 if( m_checkPerm == 0 ) 293QString text;
375 return false; 294 switch( mode ){
376 else 295 case NORMAL:
377 return m_checkPerm->isChecked(); 296 text = tr("Documents");
297 break;
298 case EXTENDED:
299 text = tr("Files");
300 break;
301 case EXTENDED_ALL:
302 text = tr("All Files");
303 break;
304 }
305 slotViewCheck( text );
378} 306}
379 307
380void OFileSelector::setPermissionChecked( bool check ) 308void OFileSelector::setPopupMenu(QPopupMenu *popup )
381{ 309{
382 if( m_checkPerm == 0 ) 310 m_custom = popup;
383 return; 311 m_showPopup = true;
384 m_checkPerm->setChecked( check );
385} 312}
386 313
387QString OFileSelector::selectedName( )const 314//void OFileSelector::updateL
315
316QString OFileSelector::selectedName() const
388{ 317{
389 QString string; 318 QString name;
390 if( m_selector == NORMAL ){ 319 if( m_selector == NORMAL ){
391 const DocLnk *lnk = m_select->selected(); 320 const DocLnk *lnk = m_select->selected();
392 string = lnk->file(); 321 name = lnk->file();
393 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 322 delete lnk;
394 QListViewItem *item = m_View->currentItem(); 323 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
395 if(item != 0 ){ 324 QListViewItem *item = m_View->currentItem();
396 string = m_currentDir + "/" + item->text( 1 ); 325 if( item != 0 )
397 } 326 name = m_currentDir + "/" + item->text( 1 );
327 }else { // installed view
328 ;
398 } 329 }
399 return string; 330 return name;
400} 331}
401
402QStringList OFileSelector::selectedNames()const 332QStringList OFileSelector::selectedNames()const
403{ 333{
404 QStringList list; 334 QStringList list;
335 if( m_selector == NORMAL ){
336 list << selectedName();
337 }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
338 list << selectedName(); // FIXME implement multiple Selections
339 }
405 return list; 340 return list;
406} 341}
407 342/** If mode is set to the Dir selection this will return the selected path.
408DocLnk OFileSelector::selectedDocument( )const 343 *
344 *
345 */
346QString OFileSelector::selectedPath()const
409{ 347{
410 DocLnk lnk; 348 QString path;
411 return lnk; 349 if( m_selector == NORMAL ){
350 path = QPEApplication::documentDir();
351 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
352 ;
353 }
354 return path;
412} 355}
413void OFileSelector::updateLay() 356QStringList OFileSelector::selectedPaths() const
414{ 357{
415 /* if( m_shTool ) 358 QStringList list;
416 // 359 list << selectedPath();
417 else 360 return list;
418 // hide
419 */
420 // save the state
421 bool check = false;
422 if( m_checkPerm != 0 )
423 check = m_checkPerm->isChecked();
424 QString text;
425
426 if( m_edit != 0 )
427 text = m_edit->text();
428 // save current mimetype
429
430 delItems();
431 delete m_checkPerm;
432 m_checkPerm = 0;
433 delete m_edit;
434 m_edit = 0;
435 delete m_fnLabel;
436 m_fnLabel = 0;
437 delete m_ok;
438 m_ok = 0;
439 delete m_cancel;
440 m_cancel = 0;
441 delete m_mimeCheck;
442 m_mimeCheck = 0;
443 delete m_viewCheck;
444 m_viewCheck = 0;
445 delete m_select; // test
446 delete m_stack;
447 //delete m_list;
448 init();
449 if( m_shLne )
450 m_edit->setText(text );
451 if( m_shPerm )
452 m_checkPerm->setChecked(check );
453} 361}
454 362QString OFileSelector::directory()const
455// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve
456// insert QListViewItems with the right options
457bool OFileSelector::compliesMime(const QString &path, const QString &mime )
458{ 363{
459 if( mime == "All" ) 364 if( m_selector == NORMAL )
460 return true; 365 return QPEApplication::documentDir();
461 MimeType type( path ); 366
462 if( type.id() == mime ) 367 return QDir(m_currentDir).absPath();
463 return true;
464 return false;
465} 368}
466 369
467void OFileSelector::reparse() 370int OFileSelector::fileCount()
468{ 371{
469 qDebug("reparse"); 372 int count;
470 if(m_View== 0 || m_selector == NORMAL) 373 switch( m_selector ){
471 return; 374 case NORMAL:
472 m_View->clear(); 375 count = m_select->fileCount();
473 QString currMime =m_mimeCheck->currentText();
474 // update the mimetype now
475 if( m_autoMime ) {
476 QDir dir( m_currentDir );
477 m_mimetypes.clear();
478 m_mimeCheck->clear();
479 dir.setFilter( QDir::Files | QDir::Readable );
480 dir.setSorting(QDir::Size );
481 const QFileInfoList *list = dir.entryInfoList();
482 QFileInfoListIterator it( *list );
483 QFileInfo *fi;
484 while( (fi=it.current()) ){
485 if(fi->extension() == QString::fromLatin1("desktop") ){
486 ++it;
487 continue;
488 }
489 MimeType type(fi->filePath() );
490 if( !m_mimetypes.contains( type.id() ) )
491 m_mimetypes.append( type.id() );
492
493 ++it;
494 }
495 m_mimetypes.prepend("All" );
496 m_mimeCheck->insertStringList(m_mimetypes );
497 // set it to the current mimetype
498 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
499 }else{
500 m_mimeCheck->clear();
501 m_mimeCheck->insertItem( m_mimetypes.join(";") );
502 }
503
504 QDir dir( m_currentDir );
505 //dir.setFilter(-1 );
506 int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed;
507 if( m_case )
508 sort = QDir::IgnoreCase;
509 dir.setSorting( sort );
510
511 int filter;
512 /* if( m_dir && !m_files)
513 filter |= QDir::Dirs;
514 else if( !m_dir && m_files )
515 filter |= QDir::Files;
516 else
517 filter |= QDir::All;
518 */
519 if( m_selector == EXTENDED_ALL )
520 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
521 else
522 filter = QDir::Files | QDir::Dirs | QDir::All;
523 dir.setFilter( filter );
524 qDebug("infoList");
525 const QFileInfoList *list = dir.entryInfoList();
526 QFileInfoListIterator it( *list );
527 QFileInfo *fi;
528 while( (fi=it.current()) ){
529 if(fi->fileName() == ".." || fi->fileName() == "." ){
530 ++it;
531 continue;
532 }
533// qWarning("Test: %s", fi->fileName().latin1() );
534 if(fi->isSymLink() ){
535// qWarning("Symlink %s", fi->fileName().latin1() );
536 QString file = fi->dirPath(true)+"/"+ fi->readLink();
537// qWarning("File ->%s", file.latin1() );
538 for(int i=0; i<=4; i++ ){ // prepend from dos
539 QFileInfo info( file );
540 if( !info.exists() ){
541// qWarning("does not exist" );
542 addSymlink(currMime, fi, TRUE );
543 break; 376 break;
544 }else if( info.isDir() ){ 377 //case CUSTOM:
545// qWarning("isDir" ); 378 case EXTENDED:
546 addDir(currMime, fi, TRUE ); 379 case EXTENDED_ALL:
380 default:
381 count = m_View->childCount();
547 break; 382 break;
548 }else if( info.isFile() ){ 383 }
549// qWarning("isFile" ); 384 return count;
550 addFile(currMime, fi, TRUE ); 385}
386DocLnk OFileSelector::selectedDocument() const
387{
388 DocLnk lnk;
389 switch( m_selector ){
390 case NORMAL:{
391 const DocLnk *lnk2 = m_select->selected();
392 lnk = DocLnk(*lnk2 ); // copy
393 delete lnk2;
551 break; 394 break;
552 }else if( info.isSymLink() ){
553 file = info.dirPath(true)+ "/"+ info.readLink();
554// qWarning("isSymlink again %s", file.latin1() );
555 }else if( i == 4 ){ // just insert it and have the symlink symbol
556 addSymlink(currMime, fi );
557// qWarning("level too deep" );
558 } 395 }
559 } 396 case EXTENDED:
560 }else if( fi->isDir() ){ 397 case EXTENDED_ALL:
561 addDir(currMime, fi ); 398 default:
562 }else if( fi->isFile() ) { // file ? 399 lnk = DocLnk( selectedName() ); // new DocLnk
563 addFile(currMime, fi ); 400 break;
564 }
565 ++it;
566 } 401 }
567 m_View->sort(); 402 return lnk;
568// m_View->ensureItemVisible();
569} 403}
570 404QValueList<DocLnk> OFileSelector::selectedDocuments() const
571QString OFileSelector::directory()const
572{ 405{
573 QDir d( m_currentDir); 406 QValueList<DocLnk> docs;
574 return d.absPath(); 407 docs.append( selectedDocument() );
408 return docs;
575} 409}
576 410
577int OFileSelector::fileCount()
578{
579 return 0;
580}
581 411
582void OFileSelector::slotOk( ) 412// slots internal
413
414void OFileSelector::slotOk()
583{ 415{
584 emit ok(); 416 emit ok();
585} 417}
586 418void OFileSelector::slotCancel()
587void OFileSelector::slotCancel( )
588{ 419{
589 emit cancel(); 420 emit cancel();
590} 421}
591 422void OFileSelector::slotViewCheck(const QString &sel)
592void OFileSelector::initializeName()
593{ 423{
594 m_boxName = new QHBoxLayout(this ); 424 if( sel == tr("Documents" ) ){
595 m_edit = new QLineEdit(this ); 425 if( m_select == 0 ){
596 m_fnLabel = new QLabel(this ); 426 // autMime? fix cause now we use All and not the current
597 m_fnLabel->setText(tr("Name:") ); 427 m_select = new FileSelector(m_autoMime ? QString::null : m_mimetypes.join(";"),
598 m_boxName->addWidget(m_fnLabel ); 428 m_stack, "fileselector",
599 m_boxName->insertSpacing(1, 8 ); 429 FALSE, FALSE);
600 m_boxName->addWidget(m_edit, 100 ); 430 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
601 431 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
602 m_lay->addLayout(m_boxName); 432 //connect to close me and other signals as well
433
434 m_stack->addWidget( m_select, NORMAL );
435 }
436 m_stack->raiseWidget( NORMAL );
437 m_selector = NORMAL;
438 }else if( sel == tr("Files") ){
439 m_selector = EXTENDED;
440 initializeListView();
441 reparse();
442 m_stack->raiseWidget( EXTENDED );
443 }else if( sel == tr("All Files") ){
444 m_selector = EXTENDED_ALL;
445 initializeListView();
446 reparse();
447 m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter
448 }
603} 449}
604 450void OFileSelector::slotMimeCheck(const QString &mime)
605void OFileSelector::initializeYes()
606{ 451{
607 m_ok = new QPushButton("&Save", this, "save" ); 452 if( m_selector == NORMAL ){
608 m_cancel = new QPushButton("C&ancel", this, "cancel" ); 453 if( m_autoMime ){
609 m_boxOk = new QHBoxLayout(this ); 454 delete m_select;
610 m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); 455 m_select = new FileSelector( mime == tr("All") ? QString::null : mime,
611 m_boxOk->insertSpacing(1, 8 ); 456 m_stack, "fileselector",
612 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); 457 FALSE, FALSE);
613 m_lay->addLayout(m_boxOk ); 458
614 connect(m_ok, SIGNAL(clicked() ), 459 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
615 this, SLOT(slotOk() ) ); 460 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
616 connect(m_cancel, SIGNAL(clicked() ), 461 //connect to close me and other signals as well
617 this, SLOT(slotCancel() ) ); 462 m_stack->addWidget( m_select, NORMAL );
463 m_stack->raiseWidget( NORMAL );
464 updateMimes();
465 m_mimeCheck->clear();
466 m_mimeCheck->insertStringList(m_mimetypes );
467 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
468 }
469 }else{ // others
470 qWarning("Mime %s", mime.latin1() );
471 if(m_shChooser ){
472 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
473 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
474 }
475 reparse();
476 }
618 477
619} 478}
620 479void OFileSelector::slotLocationActivated(const QString &file)
621void OFileSelector::initializeChooser()
622{ 480{
623 m_boxView = new QHBoxLayout(this ); 481 cd(file.left(file.find("<-",0,TRUE)));
624 482 reparse();
625 m_mimeCheck = new QComboBox(this, "mime check");
626 m_viewCheck = new QComboBox(this, "view check");
627 m_boxView->addWidget(m_viewCheck, 0 );
628 m_boxView->insertSpacing(2, 8 );
629 m_boxView->addWidget(m_mimeCheck, 0 );
630 m_lay->addLayout(m_boxView );
631 m_lay->insertSpacing( 4, 8);
632
633 m_viewCheck->insertItem(tr("Documents") );
634 m_viewCheck->insertItem(tr("Files") );
635 m_viewCheck->insertItem(tr("All Files") );
636
637 if(!m_autoMime )
638 m_mimeCheck->insertItem(m_mimetypes.join("," ) );
639 else{ // check
640 updateMimes();
641 m_mimeCheck->insertStringList( m_mimetypes );
642 }
643
644 connect( m_viewCheck, SIGNAL(activated(const QString &) ),
645 this, SLOT(slotViewCheck(const QString & ) ) );
646
647 connect( m_mimeCheck, SIGNAL(activated(const QString &) ),
648 this, SLOT(slotMimeCheck(const QString & ) ) );
649} 483}
650 484void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
651void OFileSelector::slotMimeCheck(const QString &view ){ 485{
652 if(m_selector == NORMAL ){ 486 QStringList pathList;
653 delete m_select; 487 bool underDog = FALSE;
654 m_select = new FileSelector(view == "All" ? QString::null : view 488 for(int i=0;i<count;i++) {
655 , m_stack, "fileselector", FALSE, FALSE ); 489 pathList << m_location->text(i);
656 m_stack->addWidget( m_select, NORMAL ); 490 if( m_location->text(i) == currentPath)
657 m_stack->raiseWidget( NORMAL ); 491 underDog = TRUE;
658 }else{ 492 }
659 reparse(); 493 if( !underDog) {
494 m_location->clear();
495 if( currentPath.left(2)=="//")
496 pathList.append( currentPath.right(currentPath.length()-1) );
497 else
498 pathList.append( currentPath );
499 m_location->insertStringList( pathList,-1);
660 } 500 }
661} 501}
502void OFileSelector::locationComboChanged()
503{
504 cd( m_location->lineEdit()->text());
505 reparse();
506}
507void OFileSelector::init()
508{
509 m_lay = new QVBoxLayout( this );
510 m_lay->setSpacing(0 );
662 511
663void OFileSelector::slotViewCheck(const QString &view ){ 512 m_stack = new QWidgetStack( this );
664 qWarning("changed: show %s", view.latin1() ); 513 if( m_selector == NORMAL ){
665 // if the current view is the one 514 m_select = new FileSelector(m_autoMime ? QString::null : m_mimetypes.join(";"),
666 QString currMime = m_mimeCheck->currentText(); 515 m_stack, "fileselector",
667 if( view == QString::fromLatin1("Documents") ){ 516 FALSE, FALSE);
668 // get the mimetype now 517
669 // check if we're the current widget and return 518 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
670 if( m_View != 0) { // delete 0 shouldn't crash but it did :( 519 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
671 delete m_View; 520 //connect to close me and other signals as well
672 delete m_boxToolbar;
673 delete m_homeButton;
674 delete m_docButton;
675 delete m_location;
676 delete m_up;
677 delete m_pseudo;
678 //if(m_pseudoLayout!=0 )
679// delete m_pseudoLayout;
680 }
681 m_View = 0;
682 m_boxToolbar = 0;
683 m_homeButton = 0;
684 m_docButton = 0;
685 m_location = 0;
686 m_up = 0;
687 m_pseudo = 0;
688 m_pseudoLayout = 0;
689 521
690 delete m_select;
691 m_select = new FileSelector( currMime == "All" ? QString::null : currMime,
692 m_stack,"fileselector", FALSE, FALSE );
693 m_stack->addWidget( m_select, NORMAL ); 522 m_stack->addWidget( m_select, NORMAL );
694 m_mimeCheck->clear();
695 m_selector = NORMAL;
696 updateMimes();
697 m_mimeCheck->insertStringList( m_mimetypes );
698 m_stack->raiseWidget( NORMAL ); 523 m_stack->raiseWidget( NORMAL );
699 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 524 }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL
525 // and initializeListview will take care of those
526 // toolbar get's generade in initializeListView
527 initializeListView( ); // will raise the widget as well
528 }
529 m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch
700 530
701 } else if(view == QString::fromLatin1("Files") ){ 531 if( m_shLne ) // the LineEdit with the current FileName
702 // remove from the stack 532 initializeName();
703 delete m_select;
704 m_select = 0;
705 delete m_View;
706 m_View = 0;
707 533
708 m_selector = EXTENDED; 534 if( m_shPerm ) // the Permission QCheckBox
709 initializeListView(); 535 initializePerm();
710 reparse();
711 } else if(view == QString::fromLatin1("All Files") ) {
712 // remove from the stack
713 delete m_select;
714 m_select = 0;
715 delete m_View;
716 m_View = 0;
717
718 m_selector = EXTENDED_ALL;
719 initializeListView();
720 reparse();
721 }
722}
723 536
537 if( m_shChooser ) // the Chooser for the view and Mimetypes
538 initializeChooser();
724 539
725void OFileSelector::updateMimes() // lets check which mode is active 540 if( m_shYesNo ) // the Yes No button row
726 // check the current dir for items then 541 initializeYes( );
542}
543void OFileSelector::updateMimes()
727{ 544{
728 if( m_autoMime ){ 545 if( m_autoMime ){
729 m_mimetypes.clear(); 546 m_mimetypes.clear();
730 m_mimetypes.append("All" ); 547 m_mimetypes.append( tr("All") );
731 if( m_selector == NORMAL ){ 548 if( m_selector == NORMAL ){
732 DocLnkSet set; 549 DocLnkSet set;
733 Global::findDocuments(&set, QString::null ); 550 Global::findDocuments(&set, QString::null );
734 QListIterator<DocLnk> dit( set.children() ); 551 QListIterator<DocLnk> dit( set.children() );
735 for ( ; dit.current(); ++dit ) { 552 for( ; dit.current(); ++dit ){
736 if( !m_mimetypes.contains((*dit)->type() ) ) 553 if( !m_mimetypes.contains( (*dit)->type() ) )
737 m_mimetypes.append( (*dit)->type() ); 554 m_mimetypes.append( (*dit)->type() );
738 } 555 }
739 }else{ 556 }// else done in reparse
740 // should be allreday updatet 557 }
741 ;
742 }
743 }
744} 558}
745 559void OFileSelector::initVars()
746void OFileSelector::initializeListView()
747{ 560{
748 // in the instance that a developer selected the view to be Files or Entended, 561 if( m_mimetypes.isEmpty() )
749 // in the initial initialization, you are deleting objects here 562 m_autoMime = true;
750 // that aren't even existing yet. 563 else
751 564 m_autoMime = false;
752 // just to make sure but clean it up better FIXME 565 m_shClose = false;
753 delete m_View; 566 m_shNew = false;
754 m_View = 0; 567 m_shTool = true;
755 delete m_boxToolbar; 568 m_shPerm = false;
756 delete m_homeButton; 569 m_shLne = true;
757 delete m_docButton; 570 m_shChooser = true;
758 delete m_location; 571 m_shYesNo = true;
759 delete m_up; 572 m_case = false;
760 delete m_pseudo; 573 m_dir = true;
574 m_files = true;
575 m_showPopup = false;
576 if(m_pixmaps == 0 ) // init the pixmaps
577 initPics();
761 578
762 m_boxToolbar = 0; 579 // pointers
580 m_location = 0;
581 m_mimeCheck = 0;
582 m_viewCheck = 0;
763 m_homeButton = 0; 583 m_homeButton = 0;
764 m_docButton = 0; 584 m_docButton = 0;
765 m_location = 0; 585 m_hideButton = 0;
586 m_ok = 0;
587 m_cancel = 0;
588 m_reread = 0;
766 m_up = 0; 589 m_up = 0;
590 m_View = 0;
591 m_checkPerm = 0;
767 m_pseudo = 0; 592 m_pseudo = 0;
768 m_pseudoLayout = 0; 593 m_pseudoLayout = 0;
769 qDebug(" time for the toolbar "); 594 m_select = 0;
770 m_pseudo = new QWidget(m_stack, "Pseudo Widget"); 595 m_stack = 0;
771 m_pseudoLayout = new QVBoxLayout(m_pseudo ); 596 m_lay = 0;
772 if(m_shTool ){ 597 m_Oselector = 0;
773 m_boxToolbar = new QHBoxLayout( ); 598 m_boxToolbar = 0;
774 m_boxToolbar->setAutoAdd( true ); 599 m_boxOk = 0;
775 m_location = new QComboBox(m_pseudo ); 600 m_boxName = 0;
776 m_location ->setEditable(TRUE); 601 m_boxView = 0;
777 connect( m_location, SIGNAL(activated(const QString &) ), this, SLOT( locationComboActivated(const QString & ) ) ); 602 m_custom = 0;
778 connect( m_location->lineEdit(),SIGNAL(returnPressed()), this,SLOT( locationComboChanged())); 603 m_edit = 0;
779 604 m_fnLabel = 0;
780 m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); 605 m_new = 0;
781 m_up->setFixedSize( QSize( 20, 20 ) ); 606 m_close = 0;
782 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); 607}
783 m_up->setFlat(TRUE); 608void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink)
784 609{
785 m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); 610 if(!m_files)
786 m_homeButton->setFixedSize( QSize( 20, 20 ) );
787 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
788 m_homeButton->setFlat(TRUE);
789
790 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton");
791 m_docButton->setFixedSize( QSize( 20, 20 ) );
792 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
793 m_docButton->setFlat(TRUE);
794
795 m_boxToolbar->addWidget(m_location );
796 m_boxToolbar->addWidget(m_up );
797 m_boxToolbar->addWidget(m_homeButton );
798 m_boxToolbar->addWidget(m_docButton );
799 m_pseudoLayout->addLayout(m_boxToolbar );
800 qDebug("lets fill the combobox");
801 StorageInfo storage;
802 const QList<FileSystem> &fs = storage.fileSystems();
803 QListIterator<FileSystem> it ( fs );
804 for( ; it.current(); ++it ){
805 const QString disk = (*it)->name();
806 const QString path = (*it)->path();
807 m_location->insertItem(path+ "<-"+disk );
808 }
809 int count = m_location->count();
810 m_location->insertItem(m_currentDir );
811 m_location->setCurrentItem( count );
812 };
813
814 m_View = new QListView(m_pseudo, "Extended view" );
815 m_stack->addWidget( m_pseudo, EXTENDED );
816 m_stack->raiseWidget( EXTENDED );
817 m_pseudoLayout->addWidget(m_View );
818 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold);
819 // set up the stuff
820 // Pixmap Name Date Size mime
821 //(m_View->header() )->hide();
822 //m_View->setRootIsDecorated(false);
823 m_View->addColumn(" ");
824 m_View->addColumn(tr("Name"),135 );
825 m_View->addColumn(tr("Size"),-1 );
826 m_View->addColumn(tr("Date"), 60 );
827 m_View->addColumn(tr("Mime Type"),-1 );
828 QHeader *header = m_View->header();
829 header->hide();
830 m_View->setSorting(1 );
831 m_View->setAllColumnsShowFocus( TRUE);
832 // connect now
833 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) );
834 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
835 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
836 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
837 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
838 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
839
840
841};
842
843/* If a item is locked depends on the mode
844 if we're in OPEN !isReadable is locked
845 if we're in SAVE !isWriteable is locked
846
847
848 */
849
850
851void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){
852// qWarning("Add Files" );
853 if( !m_files ){
854// qWarning("not mfiles" );
855 return; 611 return;
856 } 612 // if( !compliesMime(info->absFilePath(), mime ) )
857 613 // return;
858 MimeType type( info->filePath() ); 614 MimeType type( info->absFilePath() );
859 QString name; 615 if( mime != tr("All") && type.id() != mime )
860 QString dir;
861 bool locked= false;
862 if(mime == "All" ){
863 ;
864 }else if( type.id() != mime ) {
865 return; 616 return;
866 } 617 QPixmap pix = type.pixmap();
867 QPixmap pix = type.pixmap(); 618 QString dir;
868 if(pix.isNull() ) 619 QString name;
869 pix = Resource::loadPixmap( "UnknownDocument-14" ); 620 bool locked;
621 if( pix.isNull() )
622 pix = Resource::loadPixmap( "UnknownDocument-14");
870 dir = info->dirPath( true ); 623 dir = info->dirPath( true );
871 if( symlink ) { // check if the readLink is readable 624 if( symlink )
872 // do it right later 625 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
873 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 626 else {
874 }else{ // keep track of the icons
875 name = info->fileName(); 627 name = info->fileName();
876 if( m_mode == OPEN ){ 628 if( ( m_mode == OPEN && !info->isReadable() )||
877 if( !info->isReadable() ){ 629 ( m_mode == SAVE && !info->isWritable() ) ){
878 locked = true; 630
879 pix = Resource::loadPixmap("locked" ); 631 locked = true; pix = Resource::loadPixmap("locked");
880 } 632 }
881 }else if( m_mode == SAVE ){
882 if( !info->isWritable() ){
883 locked = true;
884 pix = Resource::loadPixmap("locked" );
885 }
886 }
887 } 633 }
888 new OFileSelectorItem( m_View, pix, name, 634 new OFileSelectorItem( m_View, pix, name,
889 info->lastModified().toString(), 635 info->lastModified().toString(),
890 QString::number( info->size() ), 636 QString::number( info->size() ),
891 dir, locked ); 637 dir, locked );
892} 638}
893 639void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
894void OFileSelector::addDir(const QString &/*mime*/, QFileInfo *info, bool symlink )
895{ 640{
896 if(!m_dir ) 641 if(!m_dir)
897 return; 642 return;
898 //if( showDirs ) 643 if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){
899 { 644 bool locked = false;
900 bool locked=false;
901 QString name; 645 QString name;
902 QPixmap pix; 646 QPixmap pix;
903 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ 647 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
904 locked = true; 648 locked = true;
905 if( symlink ){ 649 if( symlink )
906 pix = (*m_pixmaps)["symlinkedlocked"]; 650 pix = (*m_pixmaps)["symlinkedlocked"];
907 }else{ 651 else
908 pix = Resource::loadPixmap("lockedfolder" ); 652 pix = Resource::loadPixmap("lockedfolder");
909 } 653 }else { // readable
910 }else{ 654 pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ;
911 if( symlink ){
912 pix = (*m_pixmaps)["dirsymlink" ];
913 }else{
914 pix = Resource::loadPixmap("folder" );
915 }
916 } 655 }
917 if( symlink){ 656 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ;
918 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); 657 new OFileSelectorItem( m_View, pix, name,
658 info->lastModified().toString(),
659 QString::number( info->size() ),
660 info->dirPath( true ), locked,
661 true );
662
663 }// else CUSTOM View
664}
665void OFileSelector::delItems()
666{
919 667
920 }else{ 668}
921 //if(info->isReadable() ) 669void OFileSelector::initializeName()
922 name = info->fileName(); 670{
671 /** Name Layout Line
672 * This is the Layout line arranged in
673 * horizontal way each components
674 * are next to each other
675 * but we will only do this if
676 * we didn't initialize a while ago.
677 */
678 if( m_boxName == 0 ){
679 m_boxName = new QHBox( this ); // remove this this? or use a QHBox
680 m_fnLabel = new QLabel( m_boxName );
681 m_fnLabel->setText( tr("Name:") );
682 m_edit = new QLineEdit( m_boxName );
683 //m_boxName->addWidget( m_fnLabel );
684 m_boxName->setMargin( 5 );
685 m_boxName->setSpacing( 8 );
686 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor
687
688 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout
689 }// else we already initialized
690 // maybe show the components?
691 //
692}
693void OFileSelector::initializeYes()
694{
695 /** The Save Cancel bar
696 *
697 */
698 if( m_boxOk == 0 ){
699 m_boxOk = new QHBox( this );
700 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" );
701 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" );
702
703 //m_boxOk->addWidget( m_ok );
704 //m_boxOk->addWidget( m_cancel );
705 m_boxOk->setMargin( 5 );
706 m_boxOk->setSpacing( 10 );
707 m_lay->addWidget( m_boxOk, 0 );
708
709 connect( m_ok, SIGNAL( clicked() ),
710 this, SLOT(slotOk() ) );
711 connect( m_cancel, SIGNAL( clicked() ),
712 this, SLOT( slotCancel() ) );
713 }
714}
715void OFileSelector::initializeChooser()
716{
717 if( m_boxView == 0 ){
718 m_boxView = new QHBox( this );
719 m_viewCheck = new QComboBox( m_boxView, "view check");
720 m_mimeCheck = new QComboBox( m_boxView, "mime check");
721 m_boxView->setSpacing( 8 );
722 m_lay->addWidget(m_boxView, 0 );
723
724 m_viewCheck->insertItem( tr("Documents") );
725 m_viewCheck->insertItem( tr("Files") );
726 m_viewCheck->insertItem( tr("All Files") );
727 if(!m_autoMime )
728 m_mimeCheck->insertItem(m_mimetypes.join(",") );
729 else{
730 updateMimes();
731 m_mimeCheck->insertStringList( m_mimetypes );
923 } 732 }
924 733 connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
925 new OFileSelectorItem(m_View, pix, 734 this, SLOT( slotViewCheck(const QString & ) ) );
926 name, info->lastModified().toString(), 735 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
927 QString::number(info->size() ),info->dirPath(true), locked, true ); 736 this, SLOT( slotMimeCheck( const QString & ) ) );
737 }
738}
739void OFileSelector::initializeListView()
740{
741 if( m_pseudo == 0 ){
742 m_pseudo = new QWidget( m_stack, "Pseudo Widget");
743 m_pseudoLayout = new QVBoxLayout( m_pseudo );
744 // toolbar
745 m_boxToolbar = new QHBox( m_pseudo );
746 m_boxToolbar->setSpacing(0 ); // next to each other please
747
748 // toolbar members
749 {
750 // location QComboBox
751 m_location = new QComboBox( m_boxToolbar );
752 m_location->setEditable( TRUE );
753 m_location->setDuplicatesEnabled( FALSE );
754 connect( m_location, SIGNAL(activated(const QString &) ),
755 this, SLOT( slotLocationActivated(const QString &) ) );
756 connect( m_location->lineEdit(), SIGNAL(returnPressed() ),
757 this, SLOT(locationComboChanged() ) );
758 // UP Button
759 m_up = new QPushButton(Resource::loadIconSet("up"),"",
760 m_boxToolbar,"cdUpButton");
761 m_up->setFixedSize( QSize( 20, 20 ) );
762 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
763 m_up->setFlat(TRUE);
764
765 // Home Button
766 m_homeButton = new QPushButton(Resource::loadIconSet("home") ,
767 "", m_boxToolbar);
768 m_homeButton->setFixedSize( QSize( 20, 20 ) );
769 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
770 m_homeButton->setFlat(TRUE);
771 // Documents Button
772 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",
773 m_boxToolbar,"docsButton");
774 m_docButton->setFixedSize( QSize( 20, 20 ) );
775 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
776 m_docButton->setFlat(TRUE);
777
778 // Close button
779 m_close = new QPushButton( Resource::loadIconSet( "close"), "",
780 m_boxToolbar );
781 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
782 m_close->setFixedSize( 20, 20 );
783
784 m_boxToolbar->setFixedHeight( 20 );
785 m_pseudoLayout->addWidget(m_boxToolbar );
786
787 // let;s fill the Location ComboBox
788 StorageInfo storage;
789 const QList<FileSystem> &fs = storage.fileSystems();
790 QListIterator<FileSystem> it ( fs );
791 for( ; it.current(); ++it ){
792 const QString disk = (*it)->name();
793 const QString path = (*it)->path();
794 m_location->insertItem(path+ "<-"+disk );
795 }
796 int count = m_location->count();
797 m_location->insertItem( m_currentDir );
798 m_location->setCurrentItem( count );
799 // due to the New and Close button we can not simply hide m_boxToolBar to not show it
800 if( !m_shTool ){
801 m_location->hide( );
802 m_up->hide( );
803 m_homeButton->hide( );
804 m_docButton->hide( );
805 }
806 if(!m_shClose )
807 m_close->hide();
808 if(!m_shNew)
809 m_close->hide();
810
811 } // off toolbar
812 // the Main ListView
813 // make a QWidgetStack first so Views can share the Toolbar
814 m_View = new QListView( m_pseudo, "Extended view");
815 QPEApplication::setStylusOperation( m_View->viewport(),
816 QPEApplication::RightOnHold);
817 m_View->addColumn(" " );
818 m_View->addColumn(tr("Name"), 135 );
819 m_View->addColumn(tr("Size"), -1 );
820 m_View->addColumn(tr("Date"), 60 );
821 m_View->addColumn(tr("Mime Type"), -1 );
822 QHeader *header = m_View->header();
823 header->hide();
824 m_View->setSorting( 1 );
825 m_View->setAllColumnsShowFocus( TRUE );
826
827 connect(m_View, SIGNAL(selectionChanged() ),
828 this, SLOT(slotSelectionChanged() ) );
829
830 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ),
831 this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
832
833 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
834 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
835
836 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
837 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
838
839 m_pseudoLayout->addWidget( m_View, 288 );
840 m_stack->addWidget( m_pseudo, EXTENDED );
841 }
842}
843void OFileSelector::initializePerm()
844{
845 if( m_checkPerm == 0 ){
846 m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm");
847 m_checkPerm->setChecked( false );
848 m_lay->addWidget( m_checkPerm );
928 849
929 } 850 }
930} 851}
852void OFileSelector::initPics()
853{
854 m_pixmaps = new QMap<QString,QPixmap>;
855 QPixmap pm = Resource::loadPixmap( "folder" );
856 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
857 QPainter painter( &pm );
858 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
859 pm.setMask( pm.createHeuristicMask( FALSE ) );
860 m_pixmaps->insert("dirsymlink", pm );
931 861
932void OFileSelector::setShowDirs(bool dir ) 862 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
863 QPainter pen(&pm2 );
864 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
865 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
866 m_pixmaps->insert("symlinkedlocked", pm2 );
867}
868// if a mime complies with the m_mimeCheck->currentItem
869bool OFileSelector::compliesMime( const QString &path, const QString &mime )
933{ 870{
934 m_dir = dir; 871 if( mime == "All" )
935 reparse(); 872 return true;
873 MimeType type( path );
874 if( type.id() == mime )
875 return true;
876 return false;
936} 877}
937 878
938void OFileSelector::slotFileSelected(const QString &string ) 879void OFileSelector::slotFileSelected( const QString &string )
939{ 880{
940 if(m_shLne ) 881 if( m_shLne )
941 m_edit->setText( string ); 882 m_edit->setText( string );
942
943 emit fileSelected( string ); 883 emit fileSelected( string );
944 // do AppLnk stuff 884}
945}
946
947void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 885void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
948{ 886{
949 slotFileSelected(lnk.name() ); 887 slotFileSelected( lnk.name() );
950 emit fileSelected( lnk ); 888 // emit fileSelected( lnk );
951} 889}
952 890void OFileSelector::slotSelectionChanged()
953void OFileSelector::slotSelectionChanged() // get the current items
954 // fixme
955{ 891{
956 qWarning("selection changed" );
957}
958 892
959void OFileSelector::slotCurrentChanged(QListViewItem *item ) 893}
894void OFileSelector::slotCurrentChanged(QListViewItem* item )
960{ 895{
961// qWarning("current changed" );
962 if( item == 0 ) 896 if( item == 0 )
963 return; 897 return;
964 898 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
965 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 899 OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;)
966 OFileSelectorItem *sel = (OFileSelectorItem*)item;
967 if(!sel->isDir() ){ 900 if(!sel->isDir() ){
968// qWarning("is not dir" ); 901 if( m_shLne )
969 if(m_shLne ){ 902 m_edit->setText( sel->text(1) );
970 m_edit->setText(sel->text(1) );
971// qWarning("setTexy" );
972 }
973 } 903 }
974 }else {
975 qWarning("mode not extended" );
976 } 904 }
977} 905}
978 906void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int)
979// either select or change dir
980void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &/*point*/, int )
981{ 907{
982 if( item == 0 ) 908 if ( item == 0 )
983 return; 909 return;
984 910
985 if( button != Qt::LeftButton ) 911 if( button != Qt::LeftButton )
986 return; 912 return;
987 913
988// qWarning("clicked" ); 914 switch( m_selector ){
989 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 915 default:
990// qWarning("inside" ); 916 break;
917 case EXTENDED: // fall through
918 case EXTENDED_ALL:{
991 OFileSelectorItem *sel = (OFileSelectorItem*)item; 919 OFileSelectorItem *sel = (OFileSelectorItem*)item;
992 if(!sel->isLocked() ){ // not locked either changedir or open 920 if(!sel->isLocked() ){
993 QStringList str = QStringList::split("->", sel->text(1) ); 921 QStringList str = QStringList::split("->", sel->text(1) );
994 if(sel->isDir() ){ 922 if( sel->isDir() ){
995 cd( sel->directory() + "/" + str[0] ); 923 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
996 } else { 924 // if MODE Dir m_shLne set the Text
997// qWarning("file" ); 925 }else{
998 if(m_shLne ) 926 if( m_shLne )
999 m_edit->setText(str[0] ); 927 m_edit->setText( str[0].stripWhiteSpace() );
1000 emit fileSelected(str[0] ); 928 emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() );
1001 // emit DocLnk need to do it
1002 } 929 }
1003 } else {
1004 qWarning( "locked" );
1005 } 930 }
1006 }; 931 break;
932 }
933 }
1007} 934}
1008
1009void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 935void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
1010{ 936{
1011 if (item == 0 ) 937 if( item == 0 )
1012 return; 938 return;
1013 939
1014 if( button != Qt::RightButton ) 940 if( button != Qt::RightButton )
1015 return;
1016// qWarning("right button" );
1017 slotContextMenu(item);
1018}
1019
1020void OFileSelector::slotContextMenu(QListViewItem *item)
1021{
1022// qWarning("context menu" );
1023 if( item ==0 || !m_showPopup )
1024 return; 941 return;
1025 942 slotContextMenu( item );
1026 if( m_custom !=0){
1027 m_custom->exec();
1028 }else{
1029 QPopupMenu menu;
1030 QAction up;
1031 up.setText("cd up");
1032 up.addTo( &menu );
1033 connect(&up, SIGNAL(activated() ),
1034 this, SLOT(cdUP() ) );
1035
1036 QAction act;
1037 OFileSelectorItem *sel = (OFileSelectorItem*)item;
1038 if(sel->isDir() ){
1039 act.setText( tr("Change Directory") );
1040 act.addTo(&menu );
1041 connect(&act, SIGNAL(activated() ),
1042 this, SLOT(slotChangedDir() ) );
1043 }else{
1044 act.setText( tr("Open file" ) );
1045 act.addTo( &menu );
1046 connect(&act, SIGNAL(activated() ),
1047 this, SLOT(slotOpen() ) );
1048 }
1049 QAction rescan;
1050 rescan.setText( tr("Rescan") );
1051 rescan.addTo( &menu );
1052 connect(&rescan, SIGNAL(activated() ),
1053 this, SLOT(slotRescan() ) );
1054
1055 QAction rename;
1056 rename.setText( tr("Rename") );
1057 rename.addTo( &menu );
1058 connect(&rename, SIGNAL(activated() ),
1059 this, SLOT(slotRename() ) );
1060
1061 menu.insertSeparator();
1062 QAction delItem;
1063 delItem.setText( tr("Delete") );
1064 delItem.addTo(&menu );
1065 connect(&delItem, SIGNAL(activated() ),
1066 this, SLOT(slotDelete() ) );
1067
1068 menu.exec(QCursor::pos() );
1069 }
1070} 943}
1071 944void OFileSelector::slotContextMenu( QListViewItem *item)
1072bool OFileSelector::cd(const QString &str )
1073{ 945{
1074// qWarning(" dir %s", str.latin1() );
1075 QDir dir( str);
1076 if(dir.exists() ){
1077 m_currentDir = dir.absPath();
1078 reparse();
1079 if(m_shTool ){
1080 int count = m_location->count();
1081 insertLocationPath( str ,count );
1082 m_location->setCurrentItem( count );
1083 }
1084 return true;
1085 }
1086 return false;
1087}
1088 946
1089void OFileSelector::insertLocationPath(const QString &currentPath, int count) {
1090 QStringList pathList;
1091 bool underDog = FALSE;
1092 for(int i=0;i<count;i++) {
1093 pathList << m_location->text(i);
1094 if( m_location->text(i) == currentPath)
1095 underDog = TRUE;
1096 }
1097 if( !underDog) {
1098 m_location->clear();
1099 if( currentPath.left(2)=="//")
1100 pathList.append( currentPath.right(currentPath.length()-1) );
1101 else
1102 pathList.append( currentPath );
1103 m_location->insertStringList( pathList,-1);
1104 }
1105} 947}
1106
1107void OFileSelector::slotChangedDir() 948void OFileSelector::slotChangedDir()
1108{ 949{
1109 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 950 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1110 if(sel->isDir() ){ 951 if(sel->isDir() ){
1111 QStringList str = QStringList::split("->", sel->text(1) ); 952 QStringList str = QStringList::split("->", sel->text(1) );
1112 cd( sel->directory() + "/" + str[0] ); 953 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
1113
1114 } 954 }
1115} 955}
1116
1117void OFileSelector::slotOpen() 956void OFileSelector::slotOpen()
1118{ 957{
1119 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 958 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1120 if(!sel->isDir() ){ 959 if(!sel->isDir() ){
1121 QStringList str = QStringList::split("->", sel->text(1) ); 960 QStringList str = QStringList::split("->", sel->text(1) );
1122 slotFileSelected( str[0] ); 961 slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() );
1123 } 962 }
1124} 963}
1125
1126void OFileSelector::slotRescan() 964void OFileSelector::slotRescan()
1127{ 965{
1128 reparse();
1129}
1130 966
967}
1131void OFileSelector::slotRename() 968void OFileSelector::slotRename()
1132{ 969{
1133 // rename inline 970 reparse();
1134} 971}
1135
1136void OFileSelector::slotDelete() 972void OFileSelector::slotDelete()
1137{ 973{
1138// qWarning("delete slot" );
1139 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 974 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1140 QStringList list = QStringList::split("->", sel->text(1) ); 975 QStringList list = QStringList::split("->", sel->text(1) );
1141 if( sel->isDir() ){ 976 if( sel->isDir() ){
1142 QString str = QString::fromLatin1("rm -rf ") + list[0]; //better safe than sorry 977 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
1143 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], 978 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
1144 tr("Yes"),tr("No"),0,1,1) ) { 979 tr("Yes"),tr("No"),0,1,1) ) {
1145 case 0: 980 case 0:
1146 ::system(str.utf8().data() ); 981 ::system(str.utf8().data() );
1147 break; 982 break;
1148 } 983 }
1149 } else { 984 } else {
1150 QFile::remove( list[0] ); 985 QFile::remove( list[0] );
1151 } 986 }
1152 m_View->takeItem( sel ); 987 m_View->takeItem( sel );
1153 delete sel; 988 delete sel;
1154} 989}
1155
1156void OFileSelector::cdUP() 990void OFileSelector::cdUP()
1157{ 991{
1158 QDir dir( m_currentDir ); 992 QDir dir( m_currentDir );
1159 dir.cdUp(); 993 dir.cdUp();
1160 if(dir.exists() ){ 994 if(dir.exists() ){
1161 m_currentDir = dir.absPath(); 995 m_currentDir = dir.absPath();
1162 reparse(); 996 reparse();
1163 int count = m_location->count(); 997 int count = m_location->count();
1164 insertLocationPath( m_currentDir, count); 998 slotInsertLocationPath( m_currentDir, count);
1165 m_location->setCurrentItem( indexByString( m_location, m_currentDir)); 999 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
1166//this wont work in all instances 1000 //this wont work in all instances
1167 // FIXME 1001 // FIXME
1168 } 1002 }
1169} 1003}
1170
1171void OFileSelector::slotHome() 1004void OFileSelector::slotHome()
1172{ 1005{
1173 cd(QDir::homeDirPath() ); 1006 cd(QDir::homeDirPath() );
1174} 1007}
1175
1176void OFileSelector::slotDoc() 1008void OFileSelector::slotDoc()
1177{ 1009{
1178 cd(QDir::homeDirPath() + "/Documents" ); 1010 cd(QPEApplication::documentDir() );
1179} 1011}
1180 1012void OFileSelector::slotNavigate( )
1181void OFileSelector::slotNavigate()
1182{ 1013{
1183 1014
1184} 1015}
1016// fill the View with life
1017void OFileSelector::reparse()
1018{
1019 if( m_selector == NORMAL )
1020 return;
1021 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL )
1022 m_View->clear();
1023 else // custom view
1024 ; // currentView()->clear();
1025 if( m_shChooser)
1026 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
1027
1028 QString currentMimeType;
1029 // let's update the mimetype
1030 if( m_autoMime ){
1031 m_mimetypes.clear();
1032 // ok we can change mimetype so we need to be able to give a selection
1033 if( m_shChooser ) {
1034 currentMimeType = m_mimeCheck->currentText();
1035 m_mimeCheck->clear();
1036
1037 // let's find possible mimetypes
1038 QDir dir( m_currentDir );
1039 dir.setFilter( QDir::Files | QDir::Readable );
1040 dir.setSorting( QDir::Size );
1041 const QFileInfoList *list = dir.entryInfoList();
1042 QFileInfoListIterator it( *list );
1043 QFileInfo *fi;
1044 while( (fi=it.current() ) ) {
1045 if( fi->extension() == QString::fromLatin1("desktop") ){
1046 ++it;
1047 continue;
1048 }
1049 MimeType type( fi->absFilePath() );
1050 if( !m_mimetypes.contains( type.id() ) ){
1051 //qWarning("Type %s", type.id().latin1() );
1052 m_mimetypes.append( type.id() );
1053 }
1185 1054
1186void OFileSelector::locationComboActivated(const QString & file ) { 1055 ++it;
1187 cd(file.left(file.find("<-",0,TRUE))); 1056 }
1188 reparse(); 1057 // add them to the chooser
1189} 1058 m_mimeCheck->insertItem( tr("All") );
1059 m_mimeCheck->insertStringList( m_mimetypes );
1060 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
1061 currentMimeType = m_mimeCheck->currentText();
1062 }
1063 }else { // no autoMime
1064 currentMimeType = m_mimetypes.join(";");
1065 if( m_shChooser ){
1066 m_mimeCheck->clear();
1067 m_mimeCheck->insertItem(m_mimetypes.join(",") );
1068 }
1069 }
1070 // now we got our mimetypes we can add the files
1190 1071
1191void OFileSelector::locationComboChanged() { 1072 QDir dir( m_currentDir );
1192 cd( m_location->lineEdit()->text()); 1073
1193 reparse(); 1074 int sort;
1075 if ( m_case )
1076 sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed);
1077 else
1078 sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed);
1079 dir.setSorting( sort );
1080
1081 int filter;
1082 if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){
1083 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
1084 }else
1085 filter = QDir::Files | QDir::Dirs | QDir::All;
1086 dir.setFilter( filter );
1087
1088 // now go through all files
1089 const QFileInfoList *list = dir.entryInfoList();
1090 QFileInfoListIterator it( *list );
1091 QFileInfo *fi;
1092 while( (fi=it.current() ) ){
1093 //qWarning("True and only" );
1094 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){
1095 //qWarning(".. or ." );
1096 ++it;
1097 continue;
1098 }
1099 if( fi->isSymLink() ){
1100 QString file = fi->dirPath( true ) + "/" + fi->readLink();
1101 for( int i = 0; i<=4; i++) { // 5 tries to prevent dos
1102 QFileInfo info( file );
1103 if( !info.exists() ){
1104 addSymlink( currentMimeType, fi, TRUE );
1105 break;
1106 }else if( info.isDir() ){
1107 addDir( currentMimeType, fi, TRUE );
1108 break;
1109 }else if( info.isFile() ){
1110 addFile( currentMimeType, fi, TRUE );
1111 break;
1112 }else if( info.isSymLink() ){
1113 file = info.dirPath(true ) + "/" + info.readLink() ;
1114 break;
1115 }else if( i == 4){
1116 addSymlink( currentMimeType, fi );
1117 }
1118 } // off for loop
1119 }else if( fi->isDir() ){
1120 addDir( currentMimeType, fi );
1121 }else if( fi->isFile() ){
1122 addFile( currentMimeType, fi );
1123 }
1124 //qWarning( "%s", fi->fileName().latin1() );
1125 ++it;
1126 } // of while loop
1127 m_View->sort();
1128 if( m_shTool ){
1129 m_location->insertItem( m_currentDir );
1130
1131 }
1132 // reenable painting and updates
1194} 1133}
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 5c38ac4..47697b9 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -58,16 +58,17 @@ class FileSelector;
58class QGridLayout; 58class QGridLayout;
59class QLineEdit; 59class QLineEdit;
60class QLabel; 60class QLabel;
61class QWidgetStack; 61class QWidgetStack;
62class QHBoxLayout; 62class QHBoxLayout;
63class QVBoxLayout; 63class QVBoxLayout;
64class QPopupMenu; 64class QPopupMenu;
65class QFileInfo; 65class QFileInfo;
66class QHBox;
66// 67//
67 68
68 69
69class OFileSelector : public QWidget { 70class OFileSelector : public QWidget {
70 Q_OBJECT 71 Q_OBJECT
71 public: 72 public:
72 enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; 73 enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 };
73 enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 }; 74 enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 };
@@ -76,27 +77,27 @@ class OFileSelector : public QWidget {
76 OFileSelector(QWidget *wid, int mode, int selector, 77 OFileSelector(QWidget *wid, int mode, int selector,
77 const QString &dirName, 78 const QString &dirName,
78 const QString &fileName = QString::null, 79 const QString &fileName = QString::null,
79 const QStringList &mimetypes = QStringList() ); 80 const QStringList &mimetypes = QStringList() );
80 81
81 82
82 OFileSelector(const QString &mimeFilter, QWidget *parent, 83 OFileSelector(const QString &mimeFilter, QWidget *parent,
83 const char *name, bool newVisible = TRUE, 84 const char *name, bool newVisible = TRUE,
84 bool closeVisible = FALSE ) { }; 85 bool closeVisible = FALSE );
85 86
86 ~OFileSelector() {}; 87 ~OFileSelector();
87 88
88 // currently only for the FILESELECTOR Mode 89 // currently only for the FILESELECTOR Mode
89 void setNewVisible( bool /*b*/ ) { }; 90 void setNewVisible( bool /*b*/ );
90 void setCloseVisible(bool /*b*/ ) { }; 91 void setCloseVisible(bool /*b*/ );
91 92
92 // end file selector mode 93 // end file selector mode
93 // deprecated 94 // deprecated
94 void reread() { reparse(); }; 95 void reread();
95 // make sure not to leak please 96 // make sure not to leak please
96 const DocLnk *selected(); 97 const DocLnk *selected();
97 // end deprecated 98 // end deprecated
98 99
99 bool isToolbarVisible() const { return m_shTool; }; 100 bool isToolbarVisible() const { return m_shTool; };
100 bool isPermissionBarVisible() const { return m_shPerm; }; 101 bool isPermissionBarVisible() const { return m_shPerm; };
101 bool isLineEditVisible()const { return m_shLne; }; 102 bool isLineEditVisible()const { return m_shLne; };
102 bool isChooserVisible( )const { return m_shChooser; }; 103 bool isChooserVisible( )const { return m_shChooser; };
@@ -129,17 +130,17 @@ class OFileSelector : public QWidget {
129 int mode()const { return m_mode; }; 130 int mode()const { return m_mode; };
130 int selector()const { return m_selector; }; 131 int selector()const { return m_selector; };
131 void setSelector( int ); 132 void setSelector( int );
132 133
133 bool showPopup()const { return m_showPopup; }; 134 bool showPopup()const { return m_showPopup; };
134 void setShowPopup( bool pop ) { m_showPopup = pop; }; 135 void setShowPopup( bool pop ) { m_showPopup = pop; };
135 void setPopupMenu( QPopupMenu * ); 136 void setPopupMenu( QPopupMenu * );
136 137
137 void updateLay(); 138 // void updateLay();
138 139
139 void reparse(); // re reads the dir 140 void reparse(); // re reads the dir
140 141
141 QString selectedName( )const; 142 QString selectedName( )const;
142 QStringList selectedNames()const; 143 QStringList selectedNames()const;
143 144
144 QString selectedPath() const; 145 QString selectedPath() const;
145 QStringList selectedPaths() const; 146 QStringList selectedPaths() const;
@@ -154,54 +155,57 @@ class OFileSelector : public QWidget {
154 155
155 signals: 156 signals:
156 void fileSelected( const DocLnk & ); 157 void fileSelected( const DocLnk & );
157 void fileSelected( const QString & ); 158 void fileSelected( const QString & );
158 void dirSelected(const QString &dir ); 159 void dirSelected(const QString &dir );
159 void closeMe(); 160 void closeMe();
160 void ok(); 161 void ok();
161 void cancel(); 162 void cancel();
163 void contextMenu();
162 164
163 protected slots: 165 private slots:
166 void slotTest() { qWarning("slotTest" ); setLineEditVisible(false ); };
164 void slotOk(); 167 void slotOk();
165 void slotCancel(); 168 void slotCancel();
166 void slotViewCheck(const QString & ); 169 void slotViewCheck(const QString & );
167 void slotMimeCheck(const QString & ); 170 void slotMimeCheck(const QString & );
168 void locationComboActivated(const QString & ); 171 void slotLocationActivated(const QString & );
169 void insertLocationPath(const QString &, int); 172 void slotInsertLocationPath(const QString &, int);
170 void locationComboChanged(); 173 void locationComboChanged();
171 protected: 174
175 private:
172 void init(); 176 void init();
173 void updateMimes(); 177 void updateMimes();
174 178
175 protected: 179 protected:
176 180
177 private: 181 private:
178 int m_mode, m_selector; 182 int m_mode, m_selector;
179 QComboBox *m_location, *m_mimeCheck, *m_viewCheck; 183 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
180 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; 184 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
181 QPushButton *m_reread, *m_up; 185 QPushButton *m_reread, *m_up, *m_new, *m_close;
182 QListView *m_View; 186 QListView *m_View;
183 QCheckBox *m_checkPerm; 187 QCheckBox *m_checkPerm;
184 QWidget *m_pseudo; 188 QWidget *m_pseudo;
185 QVBoxLayout *m_pseudoLayout; 189 QVBoxLayout *m_pseudoLayout;
186 190
187 QString m_currentDir; 191 QString m_currentDir;
188 QString m_name; 192 QString m_name;
189 QStringList m_mimetypes, requestedMimeTypesList; 193 QStringList m_mimetypes;
190 194
191 FileSelector *m_select; 195 FileSelector *m_select;
192 QWidgetStack *m_stack; 196 QWidgetStack *m_stack;
193 QVBoxLayout *m_lay; 197 QVBoxLayout *m_lay;
194 QGridLayout *m_Oselector; 198 QGridLayout *m_Oselector;
195 199
196 QHBoxLayout *m_boxToolbar; 200 QHBox *m_boxToolbar;
197 QHBoxLayout *m_boxOk; 201 QHBox *m_boxOk; // (no layout anymore) wait
198 QHBoxLayout *m_boxName; 202 QHBox *m_boxName; // (no Layout anymore) wait
199 QHBoxLayout *m_boxView; 203 QHBox *m_boxView;
200 204
201 QPopupMenu *m_custom; 205 QPopupMenu *m_custom;
202 206
203 QLineEdit *m_edit; 207 QLineEdit *m_edit;
204 QLabel *m_fnLabel; 208 QLabel *m_fnLabel;
205 209
206 bool m_shClose : 1; 210 bool m_shClose : 1;
207 bool m_shNew : 1; 211 bool m_shNew : 1;
@@ -212,25 +216,26 @@ class OFileSelector : public QWidget {
212 bool m_shYesNo : 1; 216 bool m_shYesNo : 1;
213 bool m_boCheckPerm : 1; 217 bool m_boCheckPerm : 1;
214 bool m_autoMime : 1; 218 bool m_autoMime : 1;
215 bool m_case : 1; 219 bool m_case : 1;
216 bool m_dir : 1; 220 bool m_dir : 1;
217 bool m_files : 1; 221 bool m_files : 1;
218 bool m_showPopup : 1; 222 bool m_showPopup : 1;
219 223
220 // implementation todo 224 void initVars();
221 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); 225 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE );
222 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); 226 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE );
223 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; 227 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){};
224 void delItems(); 228 void delItems();
225 void initializeName(); 229 void initializeName();
226 void initializeYes(); 230 void initializeYes();
227 void initializeChooser(); 231 void initializeChooser();
228 void initializeListView(); 232 void initializeListView();
233 void initializePerm();
229 void initPics(); 234 void initPics();
230 bool compliesMime(const QString &path, const QString &mime); 235 bool compliesMime(const QString &path, const QString &mime);
231 236
232 class OFileSelectorPrivate; 237 class OFileSelectorPrivate;
233 OFileSelectorPrivate *d; 238 OFileSelectorPrivate *d;
234 static QMap<QString,QPixmap> *m_pixmaps; 239 static QMap<QString,QPixmap> *m_pixmaps;
235 240
236private slots: 241private slots: