summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/ofileselector.cpp102
-rw-r--r--libopie/ofileselector/ofileselector.h8
2 files changed, 95 insertions, 15 deletions
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
index 91a510f..7f38f5b 100644
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -1,1024 +1,1100 @@
1 1
2 2
3#include <qcheckbox.h> 3#include <qcheckbox.h>
4#include <qcombobox.h> 4#include <qcombobox.h>
5#include <qheader.h> 5#include <qheader.h>
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qabstractlayout.h> 7#include <qabstractlayout.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qlistview.h> 10#include <qlistview.h>
11#include <qmessagebox.h> 11#include <qmessagebox.h>
12#include <qpainter.h> 12#include <qpainter.h>
13#include <qpushbutton.h> 13#include <qpushbutton.h>
14#include <qwidgetstack.h> 14#include <qwidgetstack.h>
15#include <qpopupmenu.h> 15#include <qpopupmenu.h>
16#include <qdir.h> 16#include <qdir.h>
17#include <qfile.h> 17#include <qfile.h>
18#include <qfileinfo.h> 18#include <qfileinfo.h>
19#include <qtimer.h> 19#include <qtimer.h>
20 20
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/applnk.h> 22#include <qpe/applnk.h>
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/mimetype.h> 24#include <qpe/mimetype.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/storage.h> 26#include <qpe/storage.h>
27 27
28#include <unistd.h> 28#include <unistd.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#include <sys/stat.h> 30#include <sys/stat.h>
31 31
32#include "ofileview.h" 32#include "ofileview.h"
33#include "ofileselectormain.h" 33#include "ofileselectormain.h"
34#include "ofileselector.h" 34#include "ofileselector.h"
35#include "olocallister.h" 35#include "olocallister.h"
36#include "olister.h" 36#include "olister.h"
37#include "odefaultfactories.h" 37#include "odefaultfactories.h"
38 38
39QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; 39QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
40 40
41namespace { 41namespace {
42 /* let's find the index for a specified string */ 42 /* let's find the index for a specified string */
43 int indexByString( const QComboBox *box, const QString &str ){ 43 int indexByString( const QComboBox *box, const QString &str ){
44 int index= 0; 44 int index= 0;
45 for(int i= 0; i < box->count(); i++ ){ 45 for(int i= 0; i < box->count(); i++ ){
46 /* found */ 46 /* found */
47 if( str == box->text(i ) ){ 47 if( str == box->text(i ) ){
48 index= i; 48 index= i;
49 break; 49 break;
50 } 50 }
51 } 51 }
52 return index; 52 return index;
53 } 53 }
54} 54}
55 55
56OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, 56OFileSelector::OFileSelector( QWidget *wid, int mode, int selector,
57 const QString &dirName, 57 const QString &dirName,
58 const QString &fileName, 58 const QString &fileName,
59 const QMap<QString,QStringList>& mimeTypes) 59 const QMap<QString,QStringList>& mimeTypes)
60 : QWidget( wid, "OFileSelector") 60 : QWidget( wid, "OFileSelector")
61{ 61{
62 m_mimetypes = mimeTypes; 62 m_mimetypes = mimeTypes;
63 if (mode == Save ) 63 if (mode == Save )
64 m_name = fileName; 64 m_name = fileName;
65 65
66 initVars(); 66 initVars();
67 67
68 m_mode = mode; 68 m_mode = mode;
69 m_selector = selector; 69 m_selector = selector;
70 m_currentDir = dirName; 70 m_currentDir = dirName;
71 init(); 71 init();
72} 72}
73 73
74OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, 74OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent,
75 const char *name, bool newVisible, 75 const char *name, bool newVisible,
76 bool closeVisible ) 76 bool closeVisible )
77 : QWidget( parent, name ) 77 : QWidget( parent, name )
78{ 78{
79 /* update the mimefilter */ 79 /* update the mimefilter */
80 if (!mimeFilter.isEmpty() ) { 80 if (!mimeFilter.isEmpty() ) {
81 QStringList list = QStringList::split(";", mimeFilter ); 81 QStringList list = QStringList::split(";", mimeFilter );
82 m_mimetypes.insert(mimeFilter, list ); 82 m_mimetypes.insert(mimeFilter, list );
83 } 83 }
84 initVars(); 84 initVars();
85 m_currentDir = QPEApplication::documentDir(); 85 m_currentDir = QPEApplication::documentDir();
86 m_mode = Fileselector; 86 m_mode = Fileselector;
87 m_selector = Normal; 87 m_selector = Normal;
88 m_shClose = closeVisible; 88 m_shClose = closeVisible;
89 m_shNew = newVisible; 89 m_shNew = newVisible;
90 m_shLne = false; 90 m_shLne = false;
91 m_shPerm = false; 91 m_shPerm = false;
92 m_shYesNo = false; 92 m_shYesNo = false;
93 init(); 93 init();
94 94
95 95
96} 96}
97 97
98OFileSelector::~OFileSelector() 98OFileSelector::~OFileSelector()
99{ 99{
100 100
101 101
102} 102}
103 103
104void OFileSelector::setNewVisible( bool visible ) 104void OFileSelector::setNewVisible( bool visible )
105{ 105{
106 m_shNew = visible; 106 m_shNew = visible;
107 if (m_new ) 107 if (m_new )
108 m_new->show(); 108 m_new->show();
109} 109}
110void OFileSelector::setCloseVisible( bool visible ) 110void OFileSelector::setCloseVisible( bool visible )
111{ 111{
112 m_shClose = visible; 112 m_shClose = visible;
113 113
114 if( m_close ) 114 if( m_close )
115 m_close->show(); 115 m_close->show();
116} 116}
117void OFileSelector::reread() 117void OFileSelector::reread()
118{ 118{
119 if( m_selector == Normal ) 119 if( m_selector == Normal )
120 initializeOldSelector(); 120 initializeOldSelector();
121 else 121 else
122 reparse(); 122 reparse();
123} 123}
124 124
125const DocLnk *OFileSelector::selected() 125const DocLnk *OFileSelector::selected()
126{ 126{
127 DocLnk *lnk = new DocLnk(selectedDocument() ); 127 DocLnk *lnk = new DocLnk(selectedDocument() );
128 return lnk; 128 return lnk;
129} 129}
130 130
131void OFileSelector::setYesCancelVisible( bool show ) 131void OFileSelector::setYesCancelVisible( bool show )
132{ 132{
133 initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( 133 initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :(
134 m_shYesNo = show; 134 m_shYesNo = show;
135 135
136 if( m_shYesNo ) 136 if( m_shYesNo )
137 m_boxOk->show(); 137 m_boxOk->show();
138 else 138 else
139 m_boxOk->hide(); 139 m_boxOk->hide();
140 140
141} 141}
142void OFileSelector::setToolbarVisible( bool show ) 142void OFileSelector::setToolbarVisible( bool show )
143{ 143{
144 m_shTool = show; 144 m_shTool = show;
145 145
146 if(!m_shTool ){ 146 if(!m_shTool ){
147 m_location->hide(); 147 m_location->hide();
148 m_up->hide(); 148 m_up->hide();
149 m_homeButton->hide(); 149 m_homeButton->hide();
150 m_docButton->hide(); 150 m_docButton->hide();
151 }else{ 151 }else{
152 m_location->show(); 152 m_location->show();
153 m_up->show(); 153 m_up->show();
154 m_homeButton->show(); 154 m_homeButton->show();
155 m_docButton->show(); 155 m_docButton->show();
156 } 156 }
157} 157}
158void OFileSelector::setPermissionBarVisible( bool show ) 158void OFileSelector::setPermissionBarVisible( bool show )
159{ 159{
160 m_shPerm = show; 160 m_shPerm = show;
161 initializePerm(); 161 initializePerm();
162 162
163 if( m_shPerm ) 163 if( m_shPerm )
164 m_checkPerm->show(); 164 m_checkPerm->show();
165 else 165 else
166 m_checkPerm->hide(); 166 m_checkPerm->hide();
167} 167}
168void OFileSelector::setLineEditVisible( bool show ) 168void OFileSelector::setLineEditVisible( bool show )
169{ 169{
170 if( show ){ 170 if( show ){
171 initializeName(); 171 initializeName();
172 m_boxName->show(); 172 m_boxName->show();
173 }else{ 173 }else{
174 // check if we showed before this is the way to go 174 // check if we showed before this is the way to go
175 if( m_shLne && m_boxName != 0 ) 175 if( m_shLne && m_boxName != 0 )
176 m_boxName->hide(); 176 m_boxName->hide();
177 } 177 }
178 m_shLne = show; 178 m_shLne = show;
179} 179}
180 180
181void OFileSelector::setChooserVisible( bool show ) 181void OFileSelector::setChooserVisible( bool show )
182{ 182{
183 m_shChooser = show; 183 m_shChooser = show;
184 initializeChooser(); 184 initializeChooser();
185 185
186 if( m_shChooser ) 186 if( m_shChooser )
187 m_boxView->hide(); 187 m_boxView->hide();
188 else 188 else
189 m_boxView->show(); 189 m_boxView->show();
190 190
191} 191}
192 192
193QCheckBox* OFileSelector::permissionCheckbox() 193QCheckBox* OFileSelector::permissionCheckbox()
194{ 194{
195 if( m_selector == Normal ) 195 if( m_selector == Normal )
196 return 0l; 196 return 0l;
197 else 197 else
198 return m_checkPerm; 198 return m_checkPerm;
199} 199}
200bool OFileSelector::setPermission()const 200bool OFileSelector::setPermission()const
201{ 201{
202 return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); 202 return m_checkPerm == 0 ? false : m_checkPerm->isChecked();
203} 203}
204void OFileSelector::setPermissionChecked( bool check ) 204void OFileSelector::setPermissionChecked( bool check )
205{ 205{
206 if( m_checkPerm ) 206 if( m_checkPerm )
207 m_checkPerm->setChecked( check ); 207 m_checkPerm->setChecked( check );
208} 208}
209 209
210void OFileSelector::setMode(int mode) // FIXME do direct raising 210void OFileSelector::setMode(int mode) // FIXME do direct raising
211{ 211{
212 m_mode = mode; 212 m_mode = mode;
213 if( m_selector == Normal ) 213 if( m_selector == Normal )
214 return; 214 return;
215} 215}
216void OFileSelector::setShowDirs(bool dir) 216void OFileSelector::setShowDirs(bool dir)
217{ 217{
218 m_dir = dir; 218 m_dir = dir;
219 if ( m_selector != Fileselector ) 219 if ( m_selector != Fileselector )
220 reparse(); 220 reparse();
221} 221}
222void OFileSelector::setCaseSensetive(bool caSe ) 222void OFileSelector::setCaseSensetive(bool caSe )
223{ 223{
224 m_case = caSe; 224 m_case = caSe;
225 225
226 if ( m_selector != Fileselector ) 226 if ( m_selector != Fileselector )
227 reparse(); 227 reparse();
228} 228}
229void OFileSelector::setShowFiles(bool show ) 229void OFileSelector::setShowFiles(bool show )
230{ 230{
231 m_files = show; 231 m_files = show;
232 reparse(); 232 reparse();
233} 233}
234/// 234///
235bool OFileSelector::cd(const QString &path ) 235bool OFileSelector::cd(const QString &path )
236{ 236{
237 m_currentDir = path; 237 m_currentDir = path;
238 reparse(); 238 reparse();
239 return true; 239 return true;
240} 240}
241void OFileSelector::setSelector(int mode ) 241void OFileSelector::setSelector(int mode )
242{ 242{
243 QString text; 243 QString text;
244 switch( mode ){ 244 switch( mode ){
245 case Normal: 245 case Normal:
246 text = tr("Documents"); 246 text = tr("Documents");
247 break; 247 break;
248 case Extended: 248 case Extended:
249 text = tr("Files"); 249 text = tr("Files");
250 break; 250 break;
251 case ExtendedAll: 251 case ExtendedAll:
252 text = tr("All Files"); 252 text = tr("All Files");
253 break; 253 break;
254 } 254 }
255 slotViewCheck( text ); 255 slotViewCheck( text );
256} 256}
257 257
258void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) 258void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ )
259{ 259{
260/* m_custom = popup; 260/* m_custom = popup;
261 m_showPopup = true; 261 m_showPopup = true;
262*/ 262*/
263} 263}
264 264
265//void OFileSelector::updateL 265//void OFileSelector::updateL
266 266
267QString OFileSelector::selectedName() const 267QString OFileSelector::selectedName() const
268{ 268{
269 QString name; 269 QString name;
270 if( m_selector == Normal ){ 270 if( m_selector == Normal ){
271 DocLnk lnk = m_select->selectedDocument(); 271 DocLnk lnk = m_select->selectedDocument();
272 name = lnk.file(); 272 name = lnk.file();
273 }else { 273 }else {
274 if ( m_shLne ) { 274 if ( m_shLne ) {
275 name = m_currentDir + "/" +m_edit->text(); 275 name = m_currentDir + "/" +m_edit->text();
276 }else{ 276 }else{
277 name = m_currentDir + "/" + currentView()->selectedName(); 277 name = m_currentDir + "/" + currentView()->selectedName();
278 } 278 }
279 } 279 }
280 return name; 280 return name;
281} 281}
282QStringList OFileSelector::selectedNames()const 282QStringList OFileSelector::selectedNames()const
283{ 283{
284 QStringList list; 284 QStringList list;
285 if( m_selector == Normal ){ 285 if( m_selector == Normal ){
286 list << selectedName(); 286 list << selectedName();
287 }else { 287 }else {
288 list << selectedName(); // FIXME implement multiple Selections 288 list << selectedName(); // FIXME implement multiple Selections
289 } 289 }
290 return list; 290 return list;
291} 291}
292/** If mode is set to the Dir selection this will return the selected path. 292/** If mode is set to the Dir selection this will return the selected path.
293 * 293 *
294 * 294 *
295 */ 295 */
296QString OFileSelector::selectedPath()const 296QString OFileSelector::selectedPath()const
297{ 297{
298 QString path; 298 QString path;
299 if( m_selector == Normal ){ 299 if( m_selector == Normal ){
300 path = QPEApplication::documentDir(); 300 path = QPEApplication::documentDir();
301 } /* normal case to do */ 301 } /* normal case to do */
302 return path; 302 return path;
303} 303}
304QStringList OFileSelector::selectedPaths() const 304QStringList OFileSelector::selectedPaths() const
305{ 305{
306 QStringList list; 306 QStringList list;
307 list << selectedPath(); 307 list << selectedPath();
308 return list; 308 return list;
309} 309}
310QString OFileSelector::directory()const 310QString OFileSelector::directory()const
311{ 311{
312 if( m_selector == Normal ) 312 if( m_selector == Normal )
313 return QPEApplication::documentDir(); 313 return QPEApplication::documentDir();
314 314
315 return QDir(m_currentDir).absPath(); 315 return QDir(m_currentDir).absPath();
316} 316}
317 317
318int OFileSelector::fileCount() 318int OFileSelector::fileCount()
319{ 319{
320 int count; 320 int count;
321 switch( m_selector ){ 321 switch( m_selector ){
322 case Normal: 322 case Normal:
323 count = m_select->fileCount(); 323 count = m_select->fileCount();
324 break; 324 break;
325 case Extended: 325 case Extended:
326 case ExtendedAll: 326 case ExtendedAll:
327 default: 327 default:
328 count = currentView()->fileCount(); 328 count = currentView()->fileCount();
329 break; 329 break;
330 } 330 }
331 return count; 331 return count;
332} 332}
333DocLnk OFileSelector::selectedDocument() const 333DocLnk OFileSelector::selectedDocument() const
334{ 334{
335 DocLnk lnk; 335 DocLnk lnk;
336 switch( m_selector ){ 336 switch( m_selector ){
337 case Normal:{ 337 case Normal:{
338 lnk = m_select->selectedDocument(); 338 lnk = m_select->selectedDocument();
339 break; 339 break;
340 } 340 }
341 case Extended: 341 case Extended:
342 case ExtendedAll: 342 case ExtendedAll:
343 default: 343 default:
344 lnk = DocLnk( selectedName() ); 344 lnk = DocLnk( selectedName() );
345 break; 345 break;
346 } 346 }
347 return lnk; 347 return lnk;
348} 348}
349QValueList<DocLnk> OFileSelector::selectedDocuments() const 349QValueList<DocLnk> OFileSelector::selectedDocuments() const
350{ 350{
351 QValueList<DocLnk> docs; 351 QValueList<DocLnk> docs;
352 docs.append( selectedDocument() ); 352 docs.append( selectedDocument() );
353 return docs; 353 return docs;
354} 354}
355 355
356 356
357// slots internal 357// slots internal
358 358
359void OFileSelector::slotOk() 359void OFileSelector::slotOk()
360{ 360{
361 emit ok(); 361 emit ok();
362} 362}
363void OFileSelector::slotCancel() 363void OFileSelector::slotCancel()
364{ 364{
365 emit cancel(); 365 emit cancel();
366} 366}
367/* switch the views */ 367/* switch the views */
368void OFileSelector::slotViewCheck(const QString &sel) 368void OFileSelector::slotViewCheck(const QString &sel)
369{ 369{
370 if( sel == tr("Documents" ) ){ 370 setView( sel );
371 initializeOldSelector();
372 m_selector = Normal;
373
374 }else {
375;
376 }
377} 371}
378 372
379QString OFileSelector::currentMimeType() const{ 373QString OFileSelector::currentMimeType() const{
380 QString mime; 374 QString mime;
381 QString currentText; 375 QString currentText;
382 if (m_shChooser && m_mimeCheck ) 376 if (m_shChooser && m_mimeCheck )
383 currentText = m_mimeCheck->currentText(); 377 currentText = m_mimeCheck->currentText();
384 378
385 qWarning("CurrentText" + currentText ); 379 qWarning("CurrentText" + currentText );
386 if (tr("All") == currentText ) return QString::null; 380 if (tr("All") == currentText ) return QString::null;
387 else if (currentText.isEmpty() ) { 381 else if (currentText.isEmpty() ) {
388 ; 382 ;
389 }else { 383 }else {
390 QMap<QString, QStringList>::ConstIterator it; 384 QMap<QString, QStringList>::ConstIterator it;
391 it = m_mimetypes.find( currentText ); 385 it = m_mimetypes.find( currentText );
392 if ( it != m_mimetypes.end() ) { 386 if ( it != m_mimetypes.end() ) {
393 mime = it.data().join(";"); 387 mime = it.data().join(";");
394 }else{ 388 }else{
395 mime = currentText; 389 mime = currentText;
396 } 390 }
397 } 391 }
398 return mime; 392 return mime;
399} 393}
400void OFileSelector::slotMimeCheck(const QString &mime) 394void OFileSelector::slotMimeCheck(const QString &mime)
401{ 395{
402 if( m_selector == Normal ){ 396 if( m_selector == Normal ){
403 initializeOldSelector(); 397 initializeOldSelector();
404 398
405 updateMimes(); 399 updateMimes();
406 updateMimeCheck(); 400 updateMimeCheck();
407 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 401 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
408 }else{ // others 402 }else{ // others
409 qWarning("Mime %s", mime.latin1() ); 403 qWarning("Mime %s", mime.latin1() );
410 if(m_shChooser ){ 404 if(m_shChooser ){
411 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); 405 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
412 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 406 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
413 } 407 }
414 reparse(); 408 reparse();
415 } 409 }
416 410
417} 411}
418/* 412/*
419 * Ok if a non dir gets inserted into this combobox 413 * Ok if a non dir gets inserted into this combobox
420 * we need to change it 414 * we need to change it
421 * QFileInfo and dirPath will give us the right Dir 415 * QFileInfo and dirPath will give us the right Dir
422 */ 416 */
423void OFileSelector::slotLocationActivated(const QString &file) 417void OFileSelector::slotLocationActivated(const QString &file)
424{ 418{
425 qWarning("slotLocationActivated"); 419 qWarning("slotLocationActivated");
426 QString name = file.left( file.find("<-", 0, TRUE ) ); 420 QString name = file.left( file.find("<-", 0, TRUE ) );
427 QFileInfo info( name ); 421 QFileInfo info( name );
428 if ( info.isFile() ) 422 if ( info.isFile() )
429 cd(info.dirPath( TRUE ) ); //absolute 423 cd(info.dirPath( TRUE ) ); //absolute
430 else 424 else
431 cd(name ); 425 cd(name );
432 reparse(); 426 reparse();
433} 427}
434void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count) 428void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
435{ 429{
436 QStringList pathList; 430 QStringList pathList;
437 bool underDog = FALSE; 431 bool underDog = FALSE;
438 for(int i=0;i<count;i++) { 432 for(int i=0;i<count;i++) {
439 pathList << m_location->text(i); 433 pathList << m_location->text(i);
440 if( m_location->text(i) == currentPath) 434 if( m_location->text(i) == currentPath)
441 underDog = TRUE; 435 underDog = TRUE;
442 } 436 }
443 if( !underDog) { 437 if( !underDog) {
444 m_location->clear(); 438 m_location->clear();
445 if( currentPath.left(2)=="//") 439 if( currentPath.left(2)=="//")
446 pathList.append( currentPath.right(currentPath.length()-1) ); 440 pathList.append( currentPath.right(currentPath.length()-1) );
447 else 441 else
448 pathList.append( currentPath ); 442 pathList.append( currentPath );
449 m_location->insertStringList( pathList,-1); 443 m_location->insertStringList( pathList,-1);
450 } 444 }
451} 445}
452/* 446/*
453 * Do not crash anymore 447 * Do not crash anymore
454 * don't try to change dir to a file 448 * don't try to change dir to a file
455 */ 449 */
456void OFileSelector::locationComboChanged() 450void OFileSelector::locationComboChanged()
457{ 451{
458 QFileInfo info( m_location->lineEdit()->text() ); 452 QFileInfo info( m_location->lineEdit()->text() );
459 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); 453 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() );
460 if (info.isFile() ) 454 if (info.isFile() )
461 cd(info.dirPath(TRUE) ); //absolute path 455 cd(info.dirPath(TRUE) ); //absolute path
462 else 456 else
463 cd( m_location->lineEdit()->text() ); 457 cd( m_location->lineEdit()->text() );
464 458
465 reparse(); 459 reparse();
466} 460}
467void OFileSelector::init() 461void OFileSelector::init()
468{ 462{
469 initFactory(); 463 initFactory();
470 m_lay = new QVBoxLayout( this ); 464 m_lay = new QVBoxLayout( this );
471 m_lay->setSpacing(0 ); 465 m_lay->setSpacing(0 );
472 466
473 /* take care of the main view... */ 467 /* take care of the main view... */
474 initToolbar(); 468 initToolbar();
475 469
476 /* initialize the file lister */ 470 /* initialize the file lister */
477 initLister();
478 if( m_selector == Normal ){ 471 if( m_selector == Normal ){
479 QString mime; 472 QString mime;
480 if (!m_autoMime) { 473 if (!m_autoMime) {
481 if (!m_mimetypes.isEmpty() ) { 474 if (!m_mimetypes.isEmpty() ) {
482 QMap<QString, QStringList>::Iterator it; 475 QMap<QString, QStringList>::Iterator it;
483 it = m_mimetypes.begin(); // cause we're in the init 476 it = m_mimetypes.begin(); // cause we're in the init
484 mime = it.data().join(";"); 477 mime = it.data().join(";");
485 } 478 }
486 } 479 }
487 initializeOldSelector(); 480 initializeOldSelector();
488 }else{ 481 }else{
489 initializeView(); 482 initializeView();
490 } 483 }
491 484
492 if( m_shLne ) // the LineEdit with the current FileName 485 if( m_shLne ) // the LineEdit with the current FileName
493 initializeName(); 486 initializeName();
494 487
495 if( m_shPerm ) // the Permission QCheckBox 488 if( m_shPerm ) // the Permission QCheckBox
496 initializePerm(); 489 initializePerm();
497 490
498 if( m_shChooser ) // the Chooser for the view and Mimetypes 491 if( m_shChooser ) // the Chooser for the view and Mimetypes
499 initializeChooser(); 492 initializeChooser();
500 493
501 if( m_shYesNo ) // the Yes No button row 494 if( m_shYesNo ) // the Yes No button row
502 initializeYes( ); 495 initializeYes( );
503 496
504 if (m_selector != Normal ) 497 if (m_selector != Normal )
505 reparse(); 498 reparse();
506} 499}
507void OFileSelector::updateMimes() 500void OFileSelector::updateMimes()
508{ 501{
509 if( m_autoMime ){ 502 if( m_autoMime ){
510 m_mimetypes.clear(); 503 m_mimetypes.clear();
511 m_mimetypes.insert( tr("All"), QString::null ); 504 m_mimetypes.insert( tr("All"), QString::null );
512 if( m_selector == Normal ){ 505 if( m_selector == Normal ){
513 DocLnkSet set; 506 DocLnkSet set;
514 Global::findDocuments(&set, QString::null ); 507 Global::findDocuments(&set, QString::null );
515 QListIterator<DocLnk> dit( set.children() ); 508 QListIterator<DocLnk> dit( set.children() );
516 for( ; dit.current(); ++dit ){ 509 for( ; dit.current(); ++dit ){
517 if( !m_mimetypes.contains( (*dit)->type() ) ) 510 if( !m_mimetypes.contains( (*dit)->type() ) )
518 m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); 511 m_mimetypes.insert( (*dit)->type(), (*dit)->type() );
519 } 512 }
520 }// else done in reparse 513 }// else done in reparse
521 } 514 }
522} 515}
523void OFileSelector::initVars() 516void OFileSelector::initVars()
524{ 517{
525 if( m_mimetypes.isEmpty() ) 518 if( m_mimetypes.isEmpty() )
526 m_autoMime = true; 519 m_autoMime = true;
527 else 520 else
528 m_autoMime = false; 521 m_autoMime = false;
529 522
530 m_shClose = false; 523 m_shClose = false;
531 m_shNew = false; 524 m_shNew = false;
532 m_shTool = true; 525 m_shTool = true;
533 m_shPerm = false; 526 m_shPerm = false;
534 m_shLne = true; 527 m_shLne = true;
535 m_shChooser = true; 528 m_shChooser = true;
536 m_shYesNo = true; 529 m_shYesNo = true;
537 m_case = false; 530 m_case = false;
538 m_dir = true; 531 m_dir = true;
539 m_files = true; 532 m_files = true;
540 m_showPopup = false; 533 m_showPopup = false;
541 m_mainView = 0l; 534 m_mainView = 0l;
542 m_fileView = 0l; 535 m_fileView = 0l;
543 m_lister = 0l; 536 m_lister = 0l;
544 537
545 if(m_pixmaps == 0 ) // init the pixmaps 538 if(m_pixmaps == 0 ) // init the pixmaps
546 initPics(); 539 initPics();
547 540
548 // pointers 541 // pointers
549 m_location = 0; 542 m_location = 0;
550 m_mimeCheck = 0; 543 m_mimeCheck = 0;
551 m_viewCheck = 0; 544 m_viewCheck = 0;
552 m_homeButton = 0; 545 m_homeButton = 0;
553 m_docButton = 0; 546 m_docButton = 0;
554 m_hideButton = 0; 547 m_hideButton = 0;
555 m_ok = 0; 548 m_ok = 0;
556 m_cancel = 0; 549 m_cancel = 0;
557 m_reread = 0; 550 m_reread = 0;
558 m_up = 0; 551 m_up = 0;
559 m_View = 0; 552 m_View = 0;
560 m_checkPerm = 0; 553 m_checkPerm = 0;
561 m_pseudo = 0; 554 m_pseudo = 0;
562 m_pseudoLayout = 0; 555 m_pseudoLayout = 0;
563 m_select = 0; 556 m_select = 0;
564 m_lay = 0; 557 m_lay = 0;
565 m_Oselector = 0; 558 m_Oselector = 0;
566 m_boxToolbar = 0; 559 m_boxToolbar = 0;
567 m_boxOk = 0; 560 m_boxOk = 0;
568 m_boxName = 0; 561 m_boxName = 0;
569 m_boxView = 0; 562 m_boxView = 0;
570 m_edit = 0; 563 m_edit = 0;
571 m_fnLabel = 0; 564 m_fnLabel = 0;
572 m_new = 0; 565 m_new = 0;
573 m_close = 0; 566 m_close = 0;
574} 567}
575void OFileSelector::initializeName() 568void OFileSelector::initializeName()
576{ 569{
577 /** Name Layout Line 570 /** Name Layout Line
578 * This is the Layout line arranged in 571 * This is the Layout line arranged in
579 * horizontal way each components 572 * horizontal way each components
580 * are next to each other 573 * are next to each other
581 * but we will only do this if 574 * but we will only do this if
582 * we didn't initialize a while ago. 575 * we didn't initialize a while ago.
583 */ 576 */
584 if( m_boxName == 0 ){ 577 if( m_boxName == 0 ){
585 m_boxName = new QHBox( this ); // remove this this? or use a QHBox 578 m_boxName = new QHBox( this ); // remove this this? or use a QHBox
586 m_fnLabel = new QLabel( m_boxName ); 579 m_fnLabel = new QLabel( m_boxName );
587 m_fnLabel->setText( tr("Name:") ); 580 m_fnLabel->setText( tr("Name:") );
588 m_edit = new QLineEdit( m_boxName ); 581 m_edit = new QLineEdit( m_boxName );
589 m_edit->setText( m_name ); 582 m_edit->setText( m_name );
590 //m_boxName->addWidget( m_fnLabel ); 583 //m_boxName->addWidget( m_fnLabel );
591 m_boxName->setMargin( 5 ); 584 m_boxName->setMargin( 5 );
592 m_boxName->setSpacing( 8 ); 585 m_boxName->setSpacing( 8 );
593 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor 586 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor
594 587
595 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout 588 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout
596 }// else we already initialized 589 }// else we already initialized
597 // maybe show the components? 590 // maybe show the components?
598 // 591 //
599} 592}
600void OFileSelector::initializeYes() 593void OFileSelector::initializeYes()
601{ 594{
602 /** The Save Cancel bar 595 /** The Save Cancel bar
603 * 596 *
604 */ 597 */
605 if( m_boxOk == 0 ){ 598 if( m_boxOk == 0 ){
606 m_boxOk = new QHBox( this ); 599 m_boxOk = new QHBox( this );
607 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); 600 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" );
608 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); 601 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" );
609 602
610 //m_boxOk->addWidget( m_ok ); 603 //m_boxOk->addWidget( m_ok );
611 //m_boxOk->addWidget( m_cancel ); 604 //m_boxOk->addWidget( m_cancel );
612 m_boxOk->setMargin( 5 ); 605 m_boxOk->setMargin( 5 );
613 m_boxOk->setSpacing( 10 ); 606 m_boxOk->setSpacing( 10 );
614 m_lay->addWidget( m_boxOk, 0 ); 607 m_lay->addWidget( m_boxOk, 0 );
615 608
616 connect( m_ok, SIGNAL( clicked() ), 609 connect( m_ok, SIGNAL( clicked() ),
617 this, SLOT(slotOk() ) ); 610 this, SLOT(slotOk() ) );
618 connect( m_cancel, SIGNAL( clicked() ), 611 connect( m_cancel, SIGNAL( clicked() ),
619 this, SLOT( slotCancel() ) ); 612 this, SLOT( slotCancel() ) );
620 } 613 }
621} 614}
622/* 615/*
623 * OK m_mimeCheck is a QComboBox we now want to fill 616 * OK m_mimeCheck is a QComboBox we now want to fill
624 * out that combobox 617 * out that combobox
625 * if automime we need to update the mimetypes 618 * if automime we need to update the mimetypes
626 */ 619 */
627void OFileSelector::updateMimeCheck() { 620void OFileSelector::updateMimeCheck() {
628 m_mimeCheck->clear(); 621 m_mimeCheck->clear();
629 if (m_autoMime ) { 622 if (m_autoMime ) {
630 //m_mimeCheck->insertItem( tr("All") ); 623 //m_mimeCheck->insertItem( tr("All") );
631 updateMimes(); 624 updateMimes();
632 } 625 }
633 626
634 QMap<QString, QStringList>::Iterator it; 627 QMap<QString, QStringList>::Iterator it;
635 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { 628 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) {
636 m_mimeCheck->insertItem( it.key() ); 629 m_mimeCheck->insertItem( it.key() );
637 } 630 }
638} 631}
639 632
640void OFileSelector::initializeChooser() 633void OFileSelector::initializeChooser()
641{ 634{
642 if( m_boxView == 0 ){ 635 if( m_boxView == 0 ){
643 m_boxView = new QHBox( this ); 636 m_boxView = new QHBox( this );
644 m_viewCheck = new QComboBox( m_boxView, "view check"); 637 m_viewCheck = new QComboBox( m_boxView, "view check");
645 m_mimeCheck = new QComboBox( m_boxView, "mime check"); 638 m_mimeCheck = new QComboBox( m_boxView, "mime check");
646 m_boxView->setSpacing( 8 ); 639 m_boxView->setSpacing( 8 );
647 m_lay->addWidget(m_boxView, 0 ); 640 m_lay->addWidget(m_boxView, 0 );
648 641
649 642
650 updateMimeCheck(); 643 updateMimeCheck();
644 fillList();
651 645
652 connect( m_viewCheck, SIGNAL( activated(const QString & ) ), 646 connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
653 this, SLOT( slotViewCheck(const QString & ) ) ); 647 this, SLOT( slotViewCheck(const QString & ) ) );
654 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), 648 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
655 this, SLOT( slotMimeCheck( const QString & ) ) ); 649 this, SLOT( slotMimeCheck( const QString & ) ) );
656 } 650 }
657} 651}
658/* generate the buttons for the toolbar */ 652/* generate the buttons for the toolbar */
659void OFileSelector::initToolbar() { 653void OFileSelector::initToolbar() {
660 m_mainView = new OFileSelectorMain( this ); 654 m_mainView = new OFileSelectorMain( this );
661 655
662 /* now generate the tool bar */ 656 /* now generate the tool bar */
663 qWarning( "toolbar" ); 657 qWarning( "toolbar" );
664 m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); 658 m_pseudo = new QWidget( m_mainView, "Pseudo Widget" );
665 m_pseudoLayout = new QVBoxLayout( m_pseudo ); 659 m_pseudoLayout = new QVBoxLayout( m_pseudo );
666 660
667 m_boxToolbar = new QHBox( m_pseudo ); 661 m_boxToolbar = new QHBox( m_pseudo );
668 m_boxToolbar->setSpacing( 0 ); 662 m_boxToolbar->setSpacing( 0 );
669 663
670 // tool bar members now 664 // tool bar members now
671 m_location = new QComboBox( m_boxToolbar ); 665 m_location = new QComboBox( m_boxToolbar );
672 m_location->setEditable( TRUE ); 666 m_location->setEditable( TRUE );
673 m_location->setDuplicatesEnabled( FALSE ); 667 m_location->setDuplicatesEnabled( FALSE );
674 connect( m_location, SIGNAL(activated(const QString& ) ), 668 connect( m_location, SIGNAL(activated(const QString& ) ),
675 this, SLOT(slotLocationActivated(const QString& )) ); 669 this, SLOT(slotLocationActivated(const QString& )) );
676 connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , 670 connect( m_location->lineEdit(), SIGNAL(returnPressed() ) ,
677 this, SLOT(locationComboChanged() ) ); 671 this, SLOT(locationComboChanged() ) );
678 672
679 // UP Button 673 // UP Button
680 m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, 674 m_up = new QPushButton( Resource::loadIconSet("up"), QString::null,
681 m_boxToolbar, "cdUpButton" ); 675 m_boxToolbar, "cdUpButton" );
682 m_up->setFixedSize( QSize(20, 20 ) ); 676 m_up->setFixedSize( QSize(20, 20 ) );
683 connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); 677 connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) );
684 m_up->setFlat( TRUE ); 678 m_up->setFlat( TRUE );
685 679
686 // Home Button 680 // Home Button
687 m_homeButton = new QPushButton(Resource::loadIconSet("home"), 681 m_homeButton = new QPushButton(Resource::loadIconSet("home"),
688 QString::null, m_boxToolbar ); 682 QString::null, m_boxToolbar );
689 m_homeButton->setFixedSize( QSize(20, 20 ) ); 683 m_homeButton->setFixedSize( QSize(20, 20 ) );
690 connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); 684 connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) );
691 m_homeButton->setFlat( TRUE ); 685 m_homeButton->setFlat( TRUE );
692 686
693 // Documents Button 687 // Documents Button
694 m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), 688 m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"),
695 QString::null, m_boxToolbar, 689 QString::null, m_boxToolbar,
696 "docsButton" ); 690 "docsButton" );
697 m_docButton->setFixedSize( QSize(20, 20 ) ); 691 m_docButton->setFixedSize( QSize(20, 20 ) );
698 m_docButton->setFlat( true ); 692 m_docButton->setFlat( true );
699 connect( m_docButton, SIGNAL(clicked() ), 693 connect( m_docButton, SIGNAL(clicked() ),
700 this, SLOT(slotDoc() ) ); 694 this, SLOT(slotDoc() ) );
701 695
702 // close button 696 // close button
703 m_close = new QPushButton( Resource::loadIconSet( "close"), "", 697 m_close = new QPushButton( Resource::loadIconSet( "close"), "",
704 m_boxToolbar ); 698 m_boxToolbar );
705 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); 699 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
706 m_close->setFixedSize( 20, 20 ); 700 m_close->setFixedSize( 20, 20 );
707 701
708 m_boxToolbar->setFixedHeight( 20 ); 702 m_boxToolbar->setFixedHeight( 20 );
709 m_pseudoLayout->addWidget(m_boxToolbar ); 703 m_pseudoLayout->addWidget(m_boxToolbar );
710 704
711 /* init the locations */ 705 /* init the locations */
712 initLocations(); 706 initLocations();
713 707
714 if( !m_shTool ){ 708 if( !m_shTool ){
715 m_location->hide( ); 709 m_location->hide( );
716 m_up->hide( ); 710 m_up->hide( );
717 m_homeButton->hide( ); 711 m_homeButton->hide( );
718 m_docButton->hide( ); 712 m_docButton->hide( );
719 } 713 }
720 if(!m_shClose ) 714 if(!m_shClose )
721 m_close->hide(); 715 m_close->hide();
722 716
723 m_mainView->setToolbar( m_pseudo ); 717 m_mainView->setToolbar( m_pseudo );
724 m_lay->addWidget( m_mainView, 100 ); 718 m_lay->addWidget( m_mainView, 100 );
725} 719}
726/* initialize the OLocalLister */
727void OFileSelector::initLister() {
728 m_lister = new OLocalLister(this);
729}
730/* put default locations into the bar */ 720/* put default locations into the bar */
731void OFileSelector::initLocations () { 721void OFileSelector::initLocations () {
732 722
733 // let;s fill the Location ComboBox 723 // let;s fill the Location ComboBox
734 StorageInfo storage; 724 StorageInfo storage;
735 const QList<FileSystem> &fs = storage.fileSystems(); 725 const QList<FileSystem> &fs = storage.fileSystems();
736 QListIterator<FileSystem> it ( fs ); 726 QListIterator<FileSystem> it ( fs );
737 for( ; it.current(); ++it ){ 727 for( ; it.current(); ++it ){
738 const QString disk = (*it)->name(); 728 const QString disk = (*it)->name();
739 const QString path = (*it)->path(); 729 const QString path = (*it)->path();
740 m_location->insertItem(path+ "<-"+disk ); 730 m_location->insertItem(path+ "<-"+disk );
741 } 731 }
742 int count = m_location->count(); 732 int count = m_location->count();
743 m_location->insertItem( m_currentDir ); 733 m_location->insertItem( m_currentDir );
744 m_location->setCurrentItem( count ); 734 m_location->setCurrentItem( count );
745 735
746} 736}
747void OFileSelector::initializePerm() 737void OFileSelector::initializePerm()
748{ 738{
749 if( m_checkPerm == 0 ){ 739 if( m_checkPerm == 0 ){
750 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); 740 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm");
751 m_checkPerm->setChecked( false ); 741 m_checkPerm->setChecked( false );
752 m_lay->addWidget( m_checkPerm ); 742 m_lay->addWidget( m_checkPerm );
753 } 743 }
754} 744}
755void OFileSelector::initPics() 745void OFileSelector::initPics()
756{ 746{
757 m_pixmaps = new QMap<QString,QPixmap>; 747 m_pixmaps = new QMap<QString,QPixmap>;
758 QPixmap pm = Resource::loadPixmap( "folder" ); 748 QPixmap pm = Resource::loadPixmap( "folder" );
759 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 749 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
760 750
761 QPainter painter( &pm ); 751 QPainter painter( &pm );
762 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 752 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
763 pm.setMask( pm.createHeuristicMask( FALSE ) ); 753 pm.setMask( pm.createHeuristicMask( FALSE ) );
764 m_pixmaps->insert("dirsymlink", pm ); 754 m_pixmaps->insert("dirsymlink", pm );
765 755
766 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 756 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
767 QPainter pen(&pm2 ); 757 QPainter pen(&pm2 );
768 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 758 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
769 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 759 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
770 m_pixmaps->insert("symlinkedlocked", pm2 ); 760 m_pixmaps->insert("symlinkedlocked", pm2 );
771} 761}
772// if a mime complies with the m_mimeCheck->currentItem 762// if a mime complies with the m_mimeCheck->currentItem
773bool OFileSelector::compliesMime( const QString &path, const QString &mime ) 763bool OFileSelector::compliesMime( const QString &path, const QString &mime )
774{ 764{
775 if( mime == "All" ) 765 if( mime == "All" )
776 return true; 766 return true;
777 MimeType type( path ); 767 MimeType type( path );
778 if( type.id() == mime ) 768 if( type.id() == mime )
779 return true; 769 return true;
780 return false; 770 return false;
781} 771}
782/* check if the mimetype in mime 772/* check if the mimetype in mime
783 * complies with the one which is current 773 * complies with the one which is current
784 */ 774 */
785/* 775/*
786 * We've the mimetype of the file 776 * We've the mimetype of the file
787 * We need to get the stringlist of the current mimetype 777 * We need to get the stringlist of the current mimetype
788 * 778 *
789 * mime = image/jpeg 779 * mime = image/jpeg
790 * QStringList = 'image/*' 780 * QStringList = 'image/*'
791 * or QStringList = image/jpeg;image/png;application/x-ogg 781 * or QStringList = image/jpeg;image/png;application/x-ogg
792 * or QStringList = application/x-ogg;image/*; 782 * or QStringList = application/x-ogg;image/*;
793 * with all these mime filters it should get acceptes 783 * with all these mime filters it should get acceptes
794 * to do so we need to look if mime is contained inside 784 * to do so we need to look if mime is contained inside
795 * the stringlist 785 * the stringlist
796 * if it's contained return true 786 * if it's contained return true
797 * if not ( I'm no RegExp expert at all ) we'll look if a '/*' 787 * if not ( I'm no RegExp expert at all ) we'll look if a '/*'
798 * is contained in the mimefilter and then we will 788 * is contained in the mimefilter and then we will
799 * look if both are equal until the '/' 789 * look if both are equal until the '/'
800 */ 790 */
801bool OFileSelector::compliesMime( const QString& mime ) { 791bool OFileSelector::compliesMime( const QString& mime ) {
802 qWarning("mimetype is %s", mime.latin1() ); 792 qWarning("mimetype is %s", mime.latin1() );
803 QString currentText; 793 QString currentText;
804 if (m_shChooser ) 794 if (m_shChooser )
805 currentText = m_mimeCheck->currentText(); 795 currentText = m_mimeCheck->currentText();
806 796
807 qWarning("current text is %s", currentText.latin1() ); 797 qWarning("current text is %s", currentText.latin1() );
808 QMap<QString, QStringList>::Iterator it; 798 QMap<QString, QStringList>::Iterator it;
809 QStringList list; 799 QStringList list;
810 if ( currentText == tr("All") ) return true; 800 if ( currentText == tr("All") ) return true;
811 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { 801 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) {
812 it = m_mimetypes.begin(); 802 it = m_mimetypes.begin();
813 list = it.data(); 803 list = it.data();
814 }else if ( currentText.isEmpty() ) return true; 804 }else if ( currentText.isEmpty() ) return true;
815 else{ 805 else{
816 it = m_mimetypes.find(currentText ); 806 it = m_mimetypes.find(currentText );
817 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; 807 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText;
818 else qWarning("found"), list = it.data(); 808 else qWarning("found"), list = it.data();
819 } 809 }
820 810
821 811
822 if ( list.contains(mime) ) return true; 812 if ( list.contains(mime) ) return true;
823 qWarning("list doesn't contain it "); 813 qWarning("list doesn't contain it ");
824 QStringList::Iterator it2; 814 QStringList::Iterator it2;
825 int pos; 815 int pos;
826 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { 816 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) {
827 pos = (*it2).findRev("/*"); 817 pos = (*it2).findRev("/*");
828 if ( pos >= 0 ) { 818 if ( pos >= 0 ) {
829 if ( mime.contains( (*it2).left(pos) ) ) return true; 819 if ( mime.contains( (*it2).left(pos) ) ) return true;
830 } 820 }
831 } 821 }
832 return false; 822 return false;
833} 823}
834void OFileSelector::slotFileSelected( const QString &string ) 824void OFileSelector::slotFileSelected( const QString &string )
835{ 825{
836 if( m_shLne ) 826 if( m_shLne )
837 m_edit->setText( string ); 827 m_edit->setText( string );
838 emit fileSelected( string ); 828 emit fileSelected( string );
839} 829}
840void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 830void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
841{ 831{
842 slotFileSelected( lnk.name() ); 832 slotFileSelected( lnk.name() );
843 // emit fileSelected( lnk ); 833 // emit fileSelected( lnk );
844} 834}
845 835
846 836
847void OFileSelector::slotDelete() 837void OFileSelector::slotDelete()
848{ 838{
849 /* 839 /*
850 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 840 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
851 QStringList list = QStringList::split("->", sel->text(1) ); 841 QStringList list = QStringList::split("->", sel->text(1) );
852 if( sel->isDir() ){ 842 if( sel->isDir() ){
853 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry 843 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
854 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], 844 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
855 tr("Yes"),tr("No"),0,1,1) ) { 845 tr("Yes"),tr("No"),0,1,1) ) {
856 case 0: 846 case 0:
857 ::system(str.utf8().data() ); 847 ::system(str.utf8().data() );
858 break; 848 break;
859 } 849 }
860 } else { 850 } else {
861 QFile::remove( list[0] ); 851 QFile::remove( list[0] );
862 } 852 }
863 m_View->takeItem( sel ); 853 m_View->takeItem( sel );
864 delete sel; 854 delete sel;
865 */ 855 */
866} 856}
867void OFileSelector::cdUP() 857void OFileSelector::cdUP()
868{ 858{
869 QDir dir( m_currentDir ); 859 QDir dir( m_currentDir );
870 dir.cdUp(); 860 dir.cdUp();
871 if(dir.exists() ){ 861 if(dir.exists() ){
872 m_currentDir = dir.absPath(); 862 m_currentDir = dir.absPath();
873 reparse(); 863 reparse();
874 int count = m_location->count(); 864 int count = m_location->count();
875 slotInsertLocationPath( m_currentDir, count); 865 slotInsertLocationPath( m_currentDir, count);
876 m_location->setCurrentItem( indexByString( m_location, m_currentDir)); 866 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
877 //this wont work in all instances 867 //this wont work in all instances
878 // FIXME 868 // FIXME
879 } 869 }
880} 870}
881void OFileSelector::slotHome() 871void OFileSelector::slotHome()
882{ 872{
883 cd(QDir::homeDirPath() ); 873 cd(QDir::homeDirPath() );
884} 874}
885void OFileSelector::slotDoc() 875void OFileSelector::slotDoc()
886{ 876{
887 cd(QPEApplication::documentDir() ); 877 cd(QPEApplication::documentDir() );
888} 878}
889void OFileSelector::slotNavigate( ) 879void OFileSelector::slotNavigate( )
890{ 880{
891 881
892} 882}
893// fill the View with life 883// fill the View with life
894void OFileSelector::reparse() 884void OFileSelector::reparse()
895{ 885{
896 if( m_selector == Normal ) 886 if( m_selector == Normal )
897 return; 887 return;
898 888
899 currentView()->clear(); 889 currentView()->clear();
900 890
901 if( m_shChooser) 891 if( m_shChooser)
902 qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); 892 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
903 893
904 QString currentMimeType; 894 QString currentMimeType;
905 895
906 // let's update the mimetype 896 // let's update the mimetype
907 if( m_autoMime ){ 897 if( m_autoMime ){
908 m_mimetypes.clear(); 898 m_mimetypes.clear();
909 // ok we can change mimetype so we need to be able to give a selection 899 // ok we can change mimetype so we need to be able to give a selection
910 if( m_shChooser ) { 900 if( m_shChooser ) {
911 currentMimeType = m_mimeCheck->currentText(); 901 currentMimeType = m_mimeCheck->currentText();
912 m_mimeCheck->clear(); 902 m_mimeCheck->clear();
913 903
914 // let's find possible mimetypes 904 // let's find possible mimetypes
915 m_mimetypes = currentLister()->mimeTypes( m_currentDir ); 905 m_mimetypes = currentLister()->mimeTypes( m_currentDir );
916 906
917 // add them to the chooser 907 // add them to the chooser
918 updateMimeCheck(); 908 updateMimeCheck();
919 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); 909 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
920 currentMimeType = m_mimeCheck->currentText(); 910 currentMimeType = m_mimeCheck->currentText();
921 } 911 }
922 }else { // no autoMime 912 }else { // no autoMime
923 // let the mimetype be set from out side the m_mimeCheck FEATURE 913 // let the mimetype be set from out side the m_mimeCheck FEATURE
924 914
925 if( m_shChooser ) 915 if( m_shChooser )
926 currentMimeType = m_mimeCheck->currentText(); 916 currentMimeType = m_mimeCheck->currentText();
927 917
928 } 918 }
929 // now we got our mimetypes we can add the files 919 // now we got our mimetypes we can add the files
930 920
931 currentLister()->reparse( m_currentDir ); 921 currentLister()->reparse( m_currentDir );
932 /* we're done with adding let's sort */ 922 /* we're done with adding let's sort */
933 currentView()->sort(); 923 currentView()->sort();
934 924
935 925
936 if( m_shTool ){ 926 if( m_shTool ){
937 m_location->insertItem( m_currentDir ); 927 m_location->insertItem( m_currentDir );
938 928
939 } 929 }
940 // reenable painting and updates 930 // reenable painting and updates
941} 931}
942 932/* switch lister to @param lister */
933void OFileSelector::setLister(const QString& lister) {
934 QStringList listerList = factory()->lister();
935
936 if (listerList.contains(lister) ) {
937 delete (OLister*) m_lister;
938 m_lister = factory()->lister( lister, this );
939 }else if (!m_lister ) {
940 /*
941 * if we do not have a lister
942 * we need to take the default one
943 */
944 m_lister = new OLocalLister(this);
945 }
946 m_listerName = lister;
947}
948void OFileSelector::setView( const QString& lis ) {
949 qWarning("setView ");
950 fillList();
951 if ( lis == tr("Documents") ) {
952 m_selector = Normal;
953 delete m_lister;
954 delete m_fileView;
955 m_lister = 0l;
956 m_fileView = 0l;
957 initializeOldSelector();
958 }else {
959 QString list;
960
961 delete m_lister;
962 delete m_fileView;
963 delete m_select;
964 m_lister =0l;
965 m_fileView = 0l;
966 m_select = 0l;
967 if ( lis.startsWith("All") ) {
968 m_selector = ExtendedAll;
969 list = lis.mid(4 ).stripWhiteSpace();
970 } else{
971 list = lis;
972 m_selector = Extended;
973 }
974 setLister(m_listerName);
975 m_fileView = factory()->view( list, this, m_mainView );
976 m_mainView->setWidget( m_fileView->widget() );
977 reparse();
978 }
979}
943/* 980/*
944 * the factory 981 * the factory
945 */ 982 */
946void OFileSelector::initFactory() { 983void OFileSelector::initFactory() {
947 m_fileFactory = new OFileFactory(); 984 m_fileFactory = new OFileFactory();
948 m_fileFactory->addLister(tr("Files"), newLocalLister ); 985 m_fileFactory->addLister(tr("Files"), newLocalLister );
949 m_fileFactory->addView(tr("List View"), newFileListView ); 986 m_fileFactory->addView(tr("List View"), newFileListView );
950 /* the factory is just a dummy */ 987 /* the factory is just a dummy */
951 m_fileFactory->addView(tr("Documents"), newFileListView ); 988 m_fileFactory->addView(tr("Documents"), newFileListView );
952} 989}
990void OFileSelector::fillList() {
991 qWarning("fill list");
992 if (!m_viewCheck )
993 return;
994
995 m_viewCheck->clear();
996 QStringList list = factory()->views();
997 qWarning("views: " + list.join(";") );
998 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
999 qWarning( (*it) );
1000 if ( (*it) == tr("Documents") ) {
1001 m_viewCheck->insertItem( (*it) );
1002 }else{
1003 m_viewCheck->insertItem( (*it) );
1004 m_viewCheck->insertItem( tr("All ") + (*it) );
1005 }
1006 }
1007}
1008OFileFactory* OFileSelector::factory() {
1009 return m_fileFactory;
1010}
953 1011
954 1012
955OFileView* OFileSelector::currentView() { 1013OFileView* OFileSelector::currentView() {
956 return m_fileView; 1014 return m_fileView;
957} 1015}
958OFileView* OFileSelector::currentView() const{ 1016OFileView* OFileSelector::currentView() const{
959 return m_fileView; 1017 return m_fileView;
960} 1018}
961int OFileSelector::filter() { 1019int OFileSelector::filter() {
962 int filter; 1020 int filter;
963 if ( m_selector == ExtendedAll ) 1021 if ( m_selector == ExtendedAll )
964 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 1022 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
965 else 1023 else
966 filter = QDir::Files | QDir::Dirs | QDir::All ; 1024 filter = QDir::Files | QDir::Dirs | QDir::All ;
967 1025
968 return filter; 1026 return filter;
969} 1027}
970int OFileSelector::sorting() { 1028int OFileSelector::sorting() {
971 int sort; 1029 int sort;
972 1030
973 if (m_case ) 1031 if (m_case )
974 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); 1032 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed );
975 else 1033 else
976 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 1034 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed );
977 1035
978 return sort; 1036 return sort;
979} 1037}
980void OFileSelector::internFileSelected( const QString& s) { 1038void OFileSelector::internFileSelected( const QString& s) {
981 emit fileSelected( s ); 1039 emit fileSelected( s );
982} 1040}
983void OFileSelector::internFileSelected( const DocLnk& d ) { 1041void OFileSelector::internFileSelected( const DocLnk& d ) {
984 emit fileSelected( d ); 1042 emit fileSelected( d );
985} 1043}
986void OFileSelector::internContextMenu() { 1044void OFileSelector::internContextMenu() {
987 emit contextMenu(); 1045 emit contextMenu();
988} 1046}
989void OFileSelector::internChangedDir( const QString& s) { 1047void OFileSelector::internChangedDir( const QString& s) {
990 emit dirSelected( s ); 1048 emit dirSelected( s );
991 cd(s ); 1049 cd(s );
992} 1050}
993void OFileSelector::internChangedDir( const QDir& s) { 1051void OFileSelector::internChangedDir( const QDir& s) {
994 emit dirSelected( s ); 1052 emit dirSelected( s );
995} 1053}
996QPixmap OFileSelector::pixmap( const QString& s ) { 1054QPixmap OFileSelector::pixmap( const QString& s ) {
997 1055
998 return (*m_pixmaps)[s]; 1056 return (*m_pixmaps)[s];
999} 1057}
1000OLister* OFileSelector::currentLister()const { 1058OLister* OFileSelector::currentLister()const {
1001 return m_lister; 1059 return m_lister;
1002} 1060}
1003void OFileSelector::initializeOldSelector() { 1061void OFileSelector::initializeOldSelector() {
1004 qWarning("initializeOldSelector"); 1062 qWarning("initializeOldSelector");
1005 1063
1006 delete m_select; 1064 delete m_select;
1007 1065
1008 // we need to initialize but keep the selected mimetype 1066 // we need to initialize but keep the selected mimetype
1009 /* we default not to show close and new buttons */ 1067 /* we default not to show close and new buttons */
1010 QString mime = currentMimeType(); 1068 QString mime = currentMimeType();
1011 qWarning("MimeType " + mime ); 1069 qWarning("MimeType " + mime );
1012 m_select = new FileSelector( mime , 1070 m_select = new FileSelector( mime ,
1013 m_mainView, "fileselector", 1071 m_mainView, "fileselector",
1014 FALSE, FALSE); 1072 FALSE, FALSE);
1015 m_select->setCategorySelectVisible( FALSE ); 1073 m_select->setCategorySelectVisible( FALSE );
1016 m_select->setTypeComboVisible( FALSE ); 1074 m_select->setTypeComboVisible( FALSE );
1017 1075
1018 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 1076 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
1019 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 1077 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
1020 connect(m_select, SIGNAL(closeMe() ), 1078 connect(m_select, SIGNAL(closeMe() ),
1021 this, SIGNAL(closeMe() ) ); 1079 this, SIGNAL(closeMe() ) );
1022 //connect to close me and other signals as well 1080 //connect to close me and other signals as well
1023 m_mainView->setWidget( m_select ); 1081 m_mainView->setWidget( m_select );
1024} 1082}
1083/*
1084 * initialize the listview
1085 * we will call fillList
1086 * setLister
1087 * with QString::null to get the default
1088 * setView with either Files or All Files
1089 * depending on Extended
1090 */
1091void OFileSelector::initializeView() {
1092 setLister(QString::null);
1093 fillList();
1094 if (m_selector == Extended ) {
1095 setView( tr("Files") );
1096 }else{
1097 setView( tr("All Files") );
1098 }
1099}
1100
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h
index 3e834fb..76c3ced 100644
--- a/libopie/ofileselector/ofileselector.h
+++ b/libopie/ofileselector/ofileselector.h
@@ -1,488 +1,492 @@
1/* 1/*
2 This is based on code and ideas of 2 This is based on code and ideas of
3 L. J. Potter ljp@llornkcor.com 3 L. J. Potter ljp@llornkcor.com
4 Thanks a lot 4 Thanks a lot
5 5
6 6
7               =. This file is part of the OPIE Project 7               =. This file is part of the OPIE Project
8             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 8             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This library is free software; you can 10 _;:,     .>    :=|. This library is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This library is distributed in the hope that 17    .i_,=:_.      -<s. This library is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef opiefileselector_h 34#ifndef opiefileselector_h
35#define opiefileselector_h 35#define opiefileselector_h
36 36
37#include <qpe/fileselector.h> 37#include <qpe/fileselector.h>
38 38
39#include <qdir.h> 39#include <qdir.h>
40#include <qguardedptr.h>
40#include <qwidget.h> 41#include <qwidget.h>
41#include <qstring.h> 42#include <qstring.h>
42#include <qpixmap.h> 43#include <qpixmap.h>
43#include <qstringlist.h> 44#include <qstringlist.h>
44#include <qmap.h> 45#include <qmap.h>
45#include <qvaluelist.h> 46#include <qvaluelist.h>
46 47
47#include <qpe/applnk.h> 48#include <qpe/applnk.h>
48#include <qlistview.h> 49#include <qlistview.h>
49 50
50/** This is OPIEs FileDialog Widget. You can use it 51/** This is OPIEs FileDialog Widget. You can use it
51 * as a dropin replacement of the fileselector and 52 * as a dropin replacement of the fileselector and
52 * or use any of the new features. 53 * or use any of the new features.
53 * This is also a complete FileSave and FileLoad widget 54 * This is also a complete FileSave and FileLoad widget
54 * If you look for a Dialog check OFileDialog 55 * If you look for a Dialog check OFileDialog
55 * 56 *
56 */ 57 */
57class DocLnk; 58class DocLnk;
58class QCheckBox; 59class QCheckBox;
59class QComboBox; 60class QComboBox;
60class QPushButton; 61class QPushButton;
61class QGridLayout; 62class QGridLayout;
62class QLineEdit; 63class QLineEdit;
63class QLabel; 64class QLabel;
64class QWidgetStack; 65class QWidgetStack;
65class QHBoxLayout; 66class QHBoxLayout;
66class QVBoxLayout; 67class QVBoxLayout;
67class QPopupMenu; 68class QPopupMenu;
68class QFileInfo; 69class QFileInfo;
69class QHBox; 70class QHBox;
70class OFileView; 71class OFileView;
71class OLister; 72class OLister;
72class OFileSelectorMain; 73class OFileSelectorMain;
73class OFileFactory; 74class OFileFactory;
74// 75//
75 76
76/* the mimetypes one name and a list of mimetypes */ 77/* the mimetypes one name and a list of mimetypes */
77typedef QMap< QString, QStringList> MimeTypes; 78typedef QMap< QString, QStringList> MimeTypes;
78 79
79/** 80/**
80 * FIXME later 81 * FIXME later
81 */ 82 */
82struct OPopupMenuFactory { 83struct OPopupMenuFactory {
83 OPopupMenuFactory() {} 84 OPopupMenuFactory() {}
84 85
85}; 86};
86 87
87 88
88/** 89/**
89 * Opie the default OFileSelector 90 * Opie the default OFileSelector
90 * It features multiple views. 91 * It features multiple views.
91 */ 92 */
92class OFileSelector : public QWidget { 93class OFileSelector : public QWidget {
93 Q_OBJECT 94 Q_OBJECT
94 95
95 /* friends are evil but I don't want to make the 96 /* friends are evil but I don't want to make the
96 * methods public 97 * methods public
97 */ 98 */
98 friend class OLister; 99 friend class OLister;
99 friend class OFileView; 100 friend class OFileView;
100 public: 101 public:
101 /** 102 /**
102 * The mode of the file selector 103 * The mode of the file selector
103 * Either open, save, fileselector or dir browsing mode 104 * Either open, save, fileselector or dir browsing mode
104 * 105 *
105 */ 106 */
106 enum Mode {Open = 1, Save = 2, Fileselector = 4, Dir = 8 }; 107 enum Mode {Open = 1, Save = 2, Fileselector = 4, Dir = 8 };
107 108
108 /** 109 /**
109 * Selector. Either Normal for the one shipped with 110 * Selector. Either Normal for the one shipped with
110 * libqpe or Extended. for the Extended 111 * libqpe or Extended. for the Extended
111 * ExtendedAll also shows 'hidden' files 112 * ExtendedAll also shows 'hidden' files
112 */ 113 */
113 enum Selector{Normal=0, Extended = 1, ExtendedAll = 2}; 114 enum Selector{Normal=0, Extended = 1, ExtendedAll = 2};
114 115
115 /** 116 /**
116 * This is reserved for futrue views 117 * This is reserved for futrue views
117 */ 118 */
118 enum View { Dirs = 1, Files = 2, Tree = 4, Icon = 8 }; 119 enum View { Dirs = 1, Files = 2, Tree = 4, Icon = 8 };
119 120
120 /** 121 /**
121 * A c'tor which should be used for advanced mode 122 * A c'tor which should be used for advanced mode
122 * @param wid the parent 123 * @param wid the parent
123 * @param mode the Mode of the Selector 124 * @param mode the Mode of the Selector
124 * @param selector the current View of the Selector 125 * @param selector the current View of the Selector
125 * @param dirName in which dir to start 126 * @param dirName in which dir to start
126 * @param fileName a proposed filename 127 * @param fileName a proposed filename
127 * @param mimetypes A list of mimetypes \ 128 * @param mimetypes A list of mimetypes \
128 * QString is for a identifier name like "Text files" 129 * QString is for a identifier name like "Text files"
129 * the coresponding QStringList is used for the mimetypes 130 * the coresponding QStringList is used for the mimetypes
130 * if empty it'll fill the list of mimetypes depending 131 * if empty it'll fill the list of mimetypes depending
131 * on the content of the current directory 132 * on the content of the current directory
132 */ 133 */
133 134
134 OFileSelector(QWidget *wid, int mode, int selector, 135 OFileSelector(QWidget *wid, int mode, int selector,
135 const QString &dirName, 136 const QString &dirName,
136 const QString &fileName = QString::null, 137 const QString &fileName = QString::null,
137 const MimeTypes &mimetypes = MimeTypes() ); 138 const MimeTypes &mimetypes = MimeTypes() );
138 139
139 140
140 /** 141 /**
141 * This is a QPE compatible c'tor 142 * This is a QPE compatible c'tor
142 */ 143 */
143 OFileSelector(const QString &mimeFilter, QWidget *parent, 144 OFileSelector(const QString &mimeFilter, QWidget *parent,
144 const char *name, bool newVisible = TRUE, 145 const char *name, bool newVisible = TRUE,
145 bool closeVisible = FALSE ); 146 bool closeVisible = FALSE );
146 147
147 ~OFileSelector(); 148 ~OFileSelector();
148 149
149 // currently only for the FileSelector Mode 150 // currently only for the FileSelector Mode
150 /* compability mode but only work 151 /* compability mode but only work
151 * with FileSelector 152 * with FileSelector
152 */ 153 */
153 void setNewVisible( bool /*b*/ ); 154 void setNewVisible( bool /*b*/ );
154 void setCloseVisible(bool /*b*/ ); 155 void setCloseVisible(bool /*b*/ );
155 156
156 // end file selector mode 157 // end file selector mode
157 // deprecated 158 // deprecated
158 void reread(); 159 void reread();
159 // make sure not to leak please 160 // make sure not to leak please
160 const DocLnk *selected(); 161 const DocLnk *selected();
161 // end deprecated 162 // end deprecated
162 163
163 /** 164 /**
164 * @return if the toolbar is visible 165 * @return if the toolbar is visible
165 */ 166 */
166 bool isToolbarVisible() const { return m_shTool; }; 167 bool isToolbarVisible() const { return m_shTool; };
167 168
168 /** 169 /**
169 * @return if the permissionBas is visible 170 * @return if the permissionBas is visible
170 */ 171 */
171 bool isPermissionBarVisible() const { return m_shPerm; }; 172 bool isPermissionBarVisible() const { return m_shPerm; };
172 173
173 /** 174 /**
174 * @return if the lineEdit is visible 175 * @return if the lineEdit is visible
175 */ 176 */
176 bool isLineEditVisible()const { return m_shLne; }; 177 bool isLineEditVisible()const { return m_shLne; };
177 178
178 /** 179 /**
179 * if the chooser is visible 180 * if the chooser is visible
180 */ 181 */
181 bool isChooserVisible( )const { return m_shChooser; }; 182 bool isChooserVisible( )const { return m_shChooser; };
182 183
183 /** 184 /**
184 * @return if the yesCancel Bar is visible 185 * @return if the yesCancel Bar is visible
185 */ 186 */
186 bool isYesCancelVisible()const { return m_shYesNo; }; 187 bool isYesCancelVisible()const { return m_shYesNo; };
187 188
188 /** 189 /**
189 * set Yes/Cancel visible 190 * set Yes/Cancel visible
190 */ 191 */
191 void setYesCancelVisible( bool show ); 192 void setYesCancelVisible( bool show );
192 193
193 /** 194 /**
194 * set the toolbar visible 195 * set the toolbar visible
195 */ 196 */
196 void setToolbarVisible( bool show ); 197 void setToolbarVisible( bool show );
197 198
198 /** 199 /**
199 * set the permissionBar to be visible 200 * set the permissionBar to be visible
200 */ 201 */
201 void setPermissionBarVisible( bool show ); 202 void setPermissionBarVisible( bool show );
202 203
203 /** 204 /**
204 * set the lineedit for file entering visible 205 * set the lineedit for file entering visible
205 */ 206 */
206 void setLineEditVisible(bool show) ; 207 void setLineEditVisible(bool show) ;
207 208
208 /** 209 /**
209 * set the chooser is visible 210 * set the chooser is visible
210 */ 211 */
211 void setChooserVisible( bool chooser ); 212 void setChooserVisible( bool chooser );
212 213
213 /** 214 /**
214 * The permissionCheckbox 215 * The permissionCheckbox
215 * 216 *
216 */ 217 */
217 QCheckBox* permissionCheckbox(); 218 QCheckBox* permissionCheckbox();
218 219
219 /** 220 /**
220 * setPermission 221 * setPermission
221 */ 222 */
222 bool setPermission() const; 223 bool setPermission() const;
223 224
224 /** 225 /**
225 * set ther permission to bool 226 * set ther permission to bool
226 */ 227 */
227 void setPermissionChecked( bool check ); 228 void setPermissionChecked( bool check );
228 229
229 /** 230 /**
230 * set the Selector Mode 231 * set the Selector Mode
231 */ 232 */
232 void setMode( int ); 233 void setMode( int );
233 234
235 void setLister( const QString& name );
236 void setView( const QString& all );
234 /** 237 /**
235 * whether or not to show dirs 238 * whether or not to show dirs
236 */ 239 */
237 bool showDirs()const { return m_dir; } 240 bool showDirs()const { return m_dir; }
238 241
239 /** 242 /**
240 * setShowDirs 243 * setShowDirs
241 */ 244 */
242 void setShowDirs(bool ); 245 void setShowDirs(bool );
243 246
244 /** 247 /**
245 * set CaseSensetive 248 * set CaseSensetive
246 */ 249 */
247 bool isCaseSensetive()const { return m_case; } 250 bool isCaseSensetive()const { return m_case; }
248 251
249 /** 252 /**
250 * set if to be case sensetive 253 * set if to be case sensetive
251 */ 254 */
252 void setCaseSensetive(bool caSe ); 255 void setCaseSensetive(bool caSe );
253 256
254 /** 257 /**
255 * @return if to show files 258 * @return if to show files
256 */ 259 */
257 bool showFiles()const { return m_files; }; 260 bool showFiles()const { return m_files; };
258 261
259 /** 262 /**
260 * set if files should be shown 263 * set if files should be shown
261 */ 264 */
262 void setShowFiles(bool ); 265 void setShowFiles(bool );
263 266
264 /** 267 /**
265 * change dir to path 268 * change dir to path
266 */ 269 */
267 bool cd(const QString &path ); 270 bool cd(const QString &path );
268 271
269 272
270 /** 273 /**
271 * return the mode of the fileselector 274 * return the mode of the fileselector
272 */ 275 */
273 int mode()const { return m_mode; }; 276 int mode()const { return m_mode; };
274 277
275 /** 278 /**
276 * return the selector 279 * return the selector
277 */ 280 */
278 int selector()const { return m_selector; }; 281 int selector()const { return m_selector; };
279 282
280 /** 283 /**
281 * set the Selector 284 * set the Selector
282 */ 285 */
283 void setSelector( int ); 286 void setSelector( int );
284 287
285 /** 288 /**
286 * wether or not to show popups 289 * wether or not to show popups
287 */ 290 */
288 bool showPopup()const { return m_showPopup; }; 291 bool showPopup()const { return m_showPopup; };
289 292
290 /** 293 /**
291 * set show popups 294 * set show popups
292 */ 295 */
293 void setShowPopup( bool pop ) { m_showPopup = pop; } 296 void setShowPopup( bool pop ) { m_showPopup = pop; }
294 297
295 /** 298 /**
296 * set the popup factory 299 * set the popup factory
297 */ 300 */
298 void setPopupFactory( OPopupMenuFactory * ); 301 void setPopupFactory( OPopupMenuFactory * );
299 302
300 /** 303 /**
301 * reparse the current directory and updates 304 * reparse the current directory and updates
302 * the views + mimetypes 305 * the views + mimetypes
303 */ 306 */
304 void reparse(); // re reads the dir 307 void reparse(); // re reads the dir
305 308
306 /** 309 /**
307 * return the selected name 310 * return the selected name
308 */ 311 */
309 QString selectedName( )const; 312 QString selectedName( )const;
310 313
311 /** 314 /**
312 * for multiple selections return multiple 315 * for multiple selections return multiple
313 * filenames 316 * filenames
314 */ 317 */
315 QStringList selectedNames()const; 318 QStringList selectedNames()const;
316 319
317 /** 320 /**
318 * return the complete to the file 321 * return the complete to the file
319 */ 322 */
320 QString selectedPath() const; 323 QString selectedPath() const;
321 324
322 /** 325 /**
323 * return the completed paths 326 * return the completed paths
324 */ 327 */
325 QStringList selectedPaths() const; 328 QStringList selectedPaths() const;
326 329
327 /** 330 /**
328 * the current directory 331 * the current directory
329 */ 332 */
330 QString directory()const; 333 QString directory()const;
331 334
332 /** 335 /**
333 * fileCount 336 * fileCount
334 */ 337 */
335 int fileCount(); 338 int fileCount();
336 339
337 DocLnk selectedDocument()const; 340 DocLnk selectedDocument()const;
338 341
339 QValueList<DocLnk> selectedDocuments()const; 342 QValueList<DocLnk> selectedDocuments()const;
340 343
341 OFileView* currentView(); 344 OFileView* currentView();
342 OFileView* currentView()const; 345 OFileView* currentView()const;
343 OLister* currentLister()const; 346 OLister* currentLister()const;
344 OFileFactory* factory(); 347 OFileFactory* factory();
345 int filter(); 348 int filter();
346 int sorting(); 349 int sorting();
347 QPixmap pixmap( const QString& ); 350 QPixmap pixmap( const QString& );
348 /* our tool bar */ 351 /* our tool bar */
349 QWidget* toolBar(); 352 QWidget* toolBar();
350 353
351 signals: 354 signals:
352 void fileSelected( const DocLnk & ); 355 void fileSelected( const DocLnk & );
353 void fileSelected( const QString & ); 356 void fileSelected( const QString & );
354 void dirSelected(const QString &dir ); 357 void dirSelected(const QString &dir );
355 void dirSelected( const QDir& ); 358 void dirSelected( const QDir& );
356 void closeMe(); 359 void closeMe();
357 void ok(); 360 void ok();
358 void cancel(); 361 void cancel();
359 void contextMenu(); 362 void contextMenu();
360 363
361 private slots: 364 private slots:
362 void slotOk(); 365 void slotOk();
363 void slotCancel(); 366 void slotCancel();
364 void slotViewCheck(const QString & ); 367 void slotViewCheck(const QString & );
365 void slotMimeCheck(const QString & ); 368 void slotMimeCheck(const QString & );
366 void slotLocationActivated(const QString & ); 369 void slotLocationActivated(const QString & );
367 void slotInsertLocationPath(const QString &, int); 370 void slotInsertLocationPath(const QString &, int);
368 void locationComboChanged(); 371 void locationComboChanged();
369 372
370 private: 373 private:
371 void init(); 374 void init();
372 void updateMimes(); 375 void updateMimes();
373 376
374 377
375 private: 378 private:
376 379
377 OFileFactory* m_fileFactory; 380 OFileFactory* m_fileFactory;
378 OFileSelectorMain* m_mainView; 381 OFileSelectorMain* m_mainView;
379 OLister* m_lister; 382 OLister* m_lister;
383 QString m_listerName;
380 OFileView* m_fileView; 384 OFileView* m_fileView;
381 FileSelector* m_select; 385 FileSelector* m_select;
382 int m_mode, m_selector; 386 int m_mode, m_selector;
383 QComboBox *m_location, 387 QComboBox *m_location,
384 *m_mimeCheck, 388 *m_mimeCheck,
385 *m_viewCheck; 389 *m_viewCheck;
386 390
387 QPushButton *m_homeButton, 391 QPushButton *m_homeButton,
388 *m_docButton, 392 *m_docButton,
389 *m_hideButton, 393 *m_hideButton,
390 *m_ok, *m_cancel; 394 *m_ok, *m_cancel;
391 QPushButton *m_reread, 395 QPushButton *m_reread,
392 *m_up, 396 *m_up,
393 *m_new, 397 *m_new,
394 *m_close; 398 *m_close;
395 QListView *m_View; 399 QListView *m_View;
396 QCheckBox *m_checkPerm; 400 QCheckBox *m_checkPerm;
397 QWidget *m_pseudo; 401 QWidget *m_pseudo;
398 QVBoxLayout *m_pseudoLayout; 402 QVBoxLayout *m_pseudoLayout;
399 403
400 QString m_currentDir; 404 QString m_currentDir;
401 QString m_name; 405 QString m_name;
402 406
403 QMap<QString, QStringList> m_mimetypes; 407 QMap<QString, QStringList> m_mimetypes;
404 408
405 QVBoxLayout *m_lay; 409 QVBoxLayout *m_lay;
406 QGridLayout *m_Oselector; 410 QGridLayout *m_Oselector;
407 411
408 QHBox *m_boxToolbar; 412 QHBox *m_boxToolbar;
409 QHBox *m_boxOk; 413 QHBox *m_boxOk;
410 QHBox *m_boxName; 414 QHBox *m_boxName;
411 QHBox *m_boxView; 415 QHBox *m_boxView;
412 416
413 417
414 QLineEdit *m_edit; 418 QLineEdit *m_edit;
415 QLabel *m_fnLabel; 419 QLabel *m_fnLabel;
416 420
417 bool m_shClose : 1; 421 bool m_shClose : 1;
418 bool m_shNew : 1; 422 bool m_shNew : 1;
419 bool m_shTool : 1; 423 bool m_shTool : 1;
420 bool m_shPerm : 1; 424 bool m_shPerm : 1;
421 bool m_shLne : 1; 425 bool m_shLne : 1;
422 bool m_shChooser : 1; 426 bool m_shChooser : 1;
423 bool m_shYesNo : 1; 427 bool m_shYesNo : 1;
424 bool m_boCheckPerm : 1; 428 bool m_boCheckPerm : 1;
425 bool m_autoMime : 1; 429 bool m_autoMime : 1;
426 bool m_case : 1; 430 bool m_case : 1;
427 bool m_dir : 1; 431 bool m_dir : 1;
428 bool m_files : 1; 432 bool m_files : 1;
429 bool m_showPopup : 1; 433 bool m_showPopup : 1;
430 bool m_showHidden : 1; 434 bool m_showHidden : 1;
431 435
432 void initVars(); 436 void initVars();
433 437
434 void delItems(); 438 void delItems();
435 void initializeName(); 439 void initializeName();
436 void initializeYes(); 440 void initializeYes();
437 void initializeChooser(); 441 void initializeChooser();
438 void initializePerm(); 442 void initializePerm();
439 void initPics(); 443 void initPics();
440 bool compliesMime(const QString &path, 444 bool compliesMime(const QString &path,
441 const QString &mime); 445 const QString &mime);
442 bool compliesMime(const QString& mime ); 446 bool compliesMime(const QString& mime );
443 /** 447 /**
444 * Updates the QComboBox with the current mimetypes 448 * Updates the QComboBox with the current mimetypes
445 */ 449 */
446 void updateMimeCheck(); 450 void updateMimeCheck();
447 451
448 void initializeOldSelector(); 452 void initializeOldSelector();
449 void initLister();
450 void initToolbar(); 453 void initToolbar();
451 void initLocations(); 454 void initLocations();
452 void initializeView() {}; // FIXME 455 void initializeView(); // FIXME
456 void fillList();
453 void initFactory(); 457 void initFactory();
454 /** 458 /**
455 * Returns the current mimetype 459 * Returns the current mimetype
456 */ 460 */
457 QString currentMimeType()const; 461 QString currentMimeType()const;
458 class OFileSelectorPrivate; 462 class OFileSelectorPrivate;
459 OFileSelectorPrivate *d; 463 OFileSelectorPrivate *d;
460 static QMap<QString,QPixmap> *m_pixmaps; 464 static QMap<QString,QPixmap> *m_pixmaps;
461 465
462private slots: 466private slots:
463 void slotFileSelected(const QString & ); // not really meant to be a slot 467 void slotFileSelected(const QString & ); // not really meant to be a slot
464 void slotFileBridgeSelected( const DocLnk & ); 468 void slotFileBridgeSelected( const DocLnk & );
465 // listview above 469 // listview above
466 // popup below 470 // popup below
467 virtual void slotDelete(); 471 virtual void slotDelete();
468 virtual void cdUP(); 472 virtual void cdUP();
469 virtual void slotHome(); 473 virtual void slotHome();
470 virtual void slotDoc(); 474 virtual void slotDoc();
471 virtual void slotNavigate( ); 475 virtual void slotNavigate( );
472 476
473 /* for OLister */ 477 /* for OLister */
474private: 478private:
475 479
476 /* for OFileView */ 480 /* for OFileView */
477private: 481private:
478 void internFileSelected( const QString& ); 482 void internFileSelected( const QString& );
479 void internFileSelected( const DocLnk& ); 483 void internFileSelected( const DocLnk& );
480 void internContextMenu(); 484 void internContextMenu();
481 void internChangedDir( const QString& ); 485 void internChangedDir( const QString& );
482 void internChangedDir( const QDir& ) ; 486 void internChangedDir( const QDir& ) ;
483 487
484}; 488};
485 489
486 490
487#endif 491#endif
488 492