summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-26 19:15:17 (UTC)
committer zecke <zecke>2002-06-26 19:15:17 (UTC)
commit7b3b485aff7fc5f5cdef40a7d4989295d5c8ab4a (patch) (unidiff)
tree661027703c822da5a109247b9ce54862af38932c
parentf6800ca0bed431aac90f09ec98e481fb424c7b31 (diff)
downloadopie-7b3b485aff7fc5f5cdef40a7d4989295d5c8ab4a.zip
opie-7b3b485aff7fc5f5cdef40a7d4989295d5c8ab4a.tar.gz
opie-7b3b485aff7fc5f5cdef40a7d4989295d5c8ab4a.tar.bz2
done for now
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 74b308e..98290e0 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -191,998 +191,1004 @@ const DocLnk *OFileSelector::selected()
191 } 191 }
192} 192}
193 193
194void OFileSelector::setYesCancelVisible( bool show ) 194void OFileSelector::setYesCancelVisible( bool show )
195{ 195{
196 initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( 196 initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :(
197 m_shYesNo = show; 197 m_shYesNo = show;
198 if( m_shYesNo ) 198 if( m_shYesNo )
199 m_boxOk->show(); 199 m_boxOk->show();
200 else 200 else
201 m_boxOk->hide(); 201 m_boxOk->hide();
202 202
203} 203}
204void OFileSelector::setToolbarVisible( bool show ) 204void OFileSelector::setToolbarVisible( bool show )
205{ 205{
206 m_shTool = show; 206 m_shTool = show;
207 initializeListView(); // FIXME see above waste of memory 207 initializeListView(); // FIXME see above waste of memory
208 if(!m_shTool ){ 208 if(!m_shTool ){
209 m_location->hide(); 209 m_location->hide();
210 m_up->hide(); 210 m_up->hide();
211 m_homeButton->hide(); 211 m_homeButton->hide();
212 m_docButton->hide(); 212 m_docButton->hide();
213 }else{ 213 }else{
214 m_location->show(); 214 m_location->show();
215 m_up->show(); 215 m_up->show();
216 m_homeButton->show(); 216 m_homeButton->show();
217 m_docButton->show(); 217 m_docButton->show();
218 } 218 }
219} 219}
220void OFileSelector::setPermissionBarVisible( bool show ) 220void OFileSelector::setPermissionBarVisible( bool show )
221{ 221{
222 m_shPerm = show; 222 m_shPerm = show;
223 initializePerm(); 223 initializePerm();
224 if( m_shPerm ) 224 if( m_shPerm )
225 m_checkPerm->show(); 225 m_checkPerm->show();
226 else 226 else
227 m_checkPerm->hide(); 227 m_checkPerm->hide();
228} 228}
229void OFileSelector::setLineEditVisible( bool show ) 229void OFileSelector::setLineEditVisible( bool show )
230{ 230{
231 if( show ){ 231 if( show ){
232 initializeName(); 232 initializeName();
233 m_boxName->show(); 233 m_boxName->show();
234 }else{ 234 }else{
235 if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go 235 if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go
236 m_boxName->hide(); 236 m_boxName->hide();
237 } 237 }
238 } 238 }
239 m_shLne = show; 239 m_shLne = show;
240} 240}
241 241
242void OFileSelector::setChooserVisible( bool show ) 242void OFileSelector::setChooserVisible( bool show )
243{ 243{
244 m_shChooser = show; 244 m_shChooser = show;
245 initializeChooser(); 245 initializeChooser();
246 if( m_shChooser ){ 246 if( m_shChooser ){
247 m_boxView->hide(); 247 m_boxView->hide();
248 }else{ 248 }else{
249 m_boxView->show(); 249 m_boxView->show();
250 } 250 }
251} 251}
252 252
253QCheckBox* OFileSelector::permissionCheckbox() 253QCheckBox* OFileSelector::permissionCheckbox()
254{ 254{
255 if( m_selector == NORMAL ) 255 if( m_selector == NORMAL )
256 return 0l; 256 return 0l;
257 else 257 else
258 return m_checkPerm; 258 return m_checkPerm;
259} 259}
260bool OFileSelector::setPermission()const 260bool OFileSelector::setPermission()const
261{ 261{
262 return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); 262 return m_checkPerm == 0 ? false : m_checkPerm->isChecked();
263} 263}
264void OFileSelector::setPermissionChecked( bool check ) 264void OFileSelector::setPermissionChecked( bool check )
265{ 265{
266 if( m_checkPerm ) 266 if( m_checkPerm )
267 m_checkPerm->setChecked( check ); 267 m_checkPerm->setChecked( check );
268} 268}
269 269
270void OFileSelector::setMode(int mode) // FIXME do direct raising 270void OFileSelector::setMode(int mode) // FIXME do direct raising
271{ 271{
272 m_mode = mode; 272 m_mode = mode;
273 if( m_selector == NORMAL ) 273 if( m_selector == NORMAL )
274 return; 274 return;
275} 275}
276void OFileSelector::setShowDirs(bool ) 276void OFileSelector::setShowDirs(bool )
277{ 277{
278 m_dir = true; 278 m_dir = true;
279 reparse(); 279 reparse();
280} 280}
281void OFileSelector::setCaseSensetive(bool caSe ) 281void OFileSelector::setCaseSensetive(bool caSe )
282{ 282{
283 m_case = caSe; 283 m_case = caSe;
284 reparse(); 284 reparse();
285} 285}
286void OFileSelector::setShowFiles(bool show ) 286void OFileSelector::setShowFiles(bool show )
287{ 287{
288 m_files = show; 288 m_files = show;
289 reparse(); 289 reparse();
290} 290}
291/// 291///
292bool OFileSelector::cd(const QString &path ) 292bool OFileSelector::cd(const QString &path )
293{ 293{
294 m_currentDir = path; 294 m_currentDir = path;
295 reparse(); 295 reparse();
296 return true; 296 return true;
297} 297}
298void OFileSelector::setSelector(int mode ) 298void OFileSelector::setSelector(int mode )
299{ 299{
300QString text; 300QString text;
301 switch( mode ){ 301 switch( mode ){
302 case NORMAL: 302 case NORMAL:
303 text = tr("Documents"); 303 text = tr("Documents");
304 break; 304 break;
305 case EXTENDED: 305 case EXTENDED:
306 text = tr("Files"); 306 text = tr("Files");
307 break; 307 break;
308 case EXTENDED_ALL: 308 case EXTENDED_ALL:
309 text = tr("All Files"); 309 text = tr("All Files");
310 break; 310 break;
311 } 311 }
312 slotViewCheck( text ); 312 slotViewCheck( text );
313} 313}
314 314
315void OFileSelector::setPopupMenu(QPopupMenu *popup ) 315void OFileSelector::setPopupMenu(QPopupMenu *popup )
316{ 316{
317 m_custom = popup; 317 m_custom = popup;
318 m_showPopup = true; 318 m_showPopup = true;
319} 319}
320 320
321//void OFileSelector::updateL 321//void OFileSelector::updateL
322 322
323QString OFileSelector::selectedName() const 323QString OFileSelector::selectedName() const
324{ 324{
325 QString name; 325 QString name;
326 if( m_selector == NORMAL ){ 326 if( m_selector == NORMAL ){
327 const DocLnk *lnk = m_select->selected(); 327 const DocLnk *lnk = m_select->selected();
328 name = lnk->file(); 328 name = lnk->file();
329 delete lnk; 329 delete lnk;
330 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 330 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
331 QListViewItem *item = m_View->currentItem(); 331 QListViewItem *item = m_View->currentItem();
332 if( item != 0 ) 332 if( item != 0 )
333 name = m_currentDir + "/" + item->text( 1 ); 333 name = m_currentDir + "/" + item->text( 1 );
334 }else { // installed view 334 }else { // installed view
335 ; 335 ;
336 } 336 }
337 return name; 337 return name;
338} 338}
339QStringList OFileSelector::selectedNames()const 339QStringList OFileSelector::selectedNames()const
340{ 340{
341 QStringList list; 341 QStringList list;
342 if( m_selector == NORMAL ){ 342 if( m_selector == NORMAL ){
343 list << selectedName(); 343 list << selectedName();
344 }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 344 }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
345 list << selectedName(); // FIXME implement multiple Selections 345 list << selectedName(); // FIXME implement multiple Selections
346 } 346 }
347 return list; 347 return list;
348} 348}
349/** If mode is set to the Dir selection this will return the selected path. 349/** If mode is set to the Dir selection this will return the selected path.
350 * 350 *
351 * 351 *
352 */ 352 */
353QString OFileSelector::selectedPath()const 353QString OFileSelector::selectedPath()const
354{ 354{
355 QString path; 355 QString path;
356 if( m_selector == NORMAL ){ 356 if( m_selector == NORMAL ){
357 path = QPEApplication::documentDir(); 357 path = QPEApplication::documentDir();
358 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 358 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
359 ; 359 ;
360 } 360 }
361 return path; 361 return path;
362} 362}
363QStringList OFileSelector::selectedPaths() const 363QStringList OFileSelector::selectedPaths() const
364{ 364{
365 QStringList list; 365 QStringList list;
366 list << selectedPath(); 366 list << selectedPath();
367 return list; 367 return list;
368} 368}
369QString OFileSelector::directory()const 369QString OFileSelector::directory()const
370{ 370{
371 if( m_selector == NORMAL ) 371 if( m_selector == NORMAL )
372 return QPEApplication::documentDir(); 372 return QPEApplication::documentDir();
373 373
374 return QDir(m_currentDir).absPath(); 374 return QDir(m_currentDir).absPath();
375} 375}
376 376
377int OFileSelector::fileCount() 377int OFileSelector::fileCount()
378{ 378{
379 int count; 379 int count;
380 switch( m_selector ){ 380 switch( m_selector ){
381 case NORMAL: 381 case NORMAL:
382 count = m_select->fileCount(); 382 count = m_select->fileCount();
383 break; 383 break;
384 //case CUSTOM: 384 //case CUSTOM:
385 case EXTENDED: 385 case EXTENDED:
386 case EXTENDED_ALL: 386 case EXTENDED_ALL:
387 default: 387 default:
388 count = m_View->childCount(); 388 count = m_View->childCount();
389 break; 389 break;
390 } 390 }
391 return count; 391 return count;
392} 392}
393DocLnk OFileSelector::selectedDocument() const 393DocLnk OFileSelector::selectedDocument() const
394{ 394{
395 DocLnk lnk; 395 DocLnk lnk;
396 switch( m_selector ){ 396 switch( m_selector ){
397 case NORMAL:{ 397 case NORMAL:{
398 const DocLnk *lnk2 = m_select->selected(); 398 const DocLnk *lnk2 = m_select->selected();
399 lnk = DocLnk(*lnk2 ); // copy 399 lnk = DocLnk(*lnk2 ); // copy
400 delete lnk2; 400 delete lnk2;
401 break; 401 break;
402 } 402 }
403 case EXTENDED: 403 case EXTENDED:
404 case EXTENDED_ALL: 404 case EXTENDED_ALL:
405 default: 405 default:
406 lnk = DocLnk( selectedName() ); // new DocLnk 406 lnk = DocLnk( selectedName() ); // new DocLnk
407 break; 407 break;
408 } 408 }
409 return lnk; 409 return lnk;
410} 410}
411QValueList<DocLnk> OFileSelector::selectedDocuments() const 411QValueList<DocLnk> OFileSelector::selectedDocuments() const
412{ 412{
413 QValueList<DocLnk> docs; 413 QValueList<DocLnk> docs;
414 docs.append( selectedDocument() ); 414 docs.append( selectedDocument() );
415 return docs; 415 return docs;
416} 416}
417 417
418 418
419// slots internal 419// slots internal
420 420
421void OFileSelector::slotOk() 421void OFileSelector::slotOk()
422{ 422{
423 emit ok(); 423 emit ok();
424} 424}
425void OFileSelector::slotCancel() 425void OFileSelector::slotCancel()
426{ 426{
427 emit cancel(); 427 emit cancel();
428} 428}
429void OFileSelector::slotViewCheck(const QString &sel) 429void OFileSelector::slotViewCheck(const QString &sel)
430{ 430{
431 if( sel == tr("Documents" ) ){ 431 if( sel == tr("Documents" ) ){
432 if( m_select == 0 ){ 432 if( m_select == 0 ){
433 // autMime? fix cause now we use All and not the current 433 // autMime? fix cause now we use All and not the current
434 // yes currentMime fixes that for us 434 // yes currentMime fixes that for us
435 QString mime = currentMimeType(); 435 QString mime = currentMimeType();
436 m_select = new FileSelector(mime, 436 m_select = new FileSelector(mime,
437 m_stack, "fileselector", 437 m_stack, "fileselector",
438 FALSE, FALSE); 438 FALSE, FALSE);
439 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 439 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
440 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 440 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
441 //connect to close me and other signals as well 441 //connect to close me and other signals as well
442 442
443 m_stack->addWidget( m_select, NORMAL ); 443 m_stack->addWidget( m_select, NORMAL );
444 } 444 }
445 m_stack->raiseWidget( NORMAL ); 445 m_stack->raiseWidget( NORMAL );
446 m_selector = NORMAL; 446 m_selector = NORMAL;
447 }else if( sel == tr("Files") ){ 447 }else if( sel == tr("Files") ){
448 m_selector = EXTENDED; 448 m_selector = EXTENDED;
449 initializeListView(); 449 initializeListView();
450 reparse(); 450 reparse();
451 m_stack->raiseWidget( EXTENDED ); 451 m_stack->raiseWidget( EXTENDED );
452 }else if( sel == tr("All Files") ){ 452 }else if( sel == tr("All Files") ){
453 m_selector = EXTENDED_ALL; 453 m_selector = EXTENDED_ALL;
454 initializeListView(); 454 initializeListView();
455 reparse(); 455 reparse();
456 m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter 456 m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter
457 } 457 }
458} 458}
459// not yet finished..... 459// not yet finished.....
460QString OFileSelector::currentMimeType() const{ 460QString OFileSelector::currentMimeType() const{
461 QString mime; 461 QString mime;
462 QString currentText; 462 QString currentText;
463 if (m_shChooser ) 463 if (m_shChooser )
464 currentText = m_mimeCheck->currentText(); 464 currentText = m_mimeCheck->currentText();
465 465
466 if (tr("All") == currentText ) return QString::null; 466 if (tr("All") == currentText ) return QString::null;
467 else if (currentText.isEmpty() ) { 467 else if (currentText.isEmpty() ) {
468 ; 468 ;
469 }else { 469 }else {
470 QMap<QString, QStringList>::ConstIterator it; 470 QMap<QString, QStringList>::ConstIterator it;
471 it = m_mimetypes.find( currentText ); 471 it = m_mimetypes.find( currentText );
472 if ( it == m_mimetypes.end() ) { 472 if ( it == m_mimetypes.end() ) {
473 mime = it.data().join(";"); 473 mime = it.data().join(";");
474 }else{ 474 }else{
475 mime = currentText; 475 mime = currentText;
476 } 476 }
477 } 477 }
478 return mime; 478 return mime;
479} 479}
480void OFileSelector::slotMimeCheck(const QString &mime) 480void OFileSelector::slotMimeCheck(const QString &mime)
481{ 481{
482 if( m_selector == NORMAL ){ 482 if( m_selector == NORMAL ){
483 //if( m_autoMime ){ 483 //if( m_autoMime ){
484 QString newMimeType; 484 QString newMimeType;
485 if (mime != tr("All") ) { 485 if (mime != tr("All") ) {
486 QMap<QString, QStringList>::Iterator it; 486 QMap<QString, QStringList>::Iterator it;
487 it = m_mimetypes.find(mime); 487 it = m_mimetypes.find(mime);
488 if ( it != m_mimetypes.end() ) { 488 if ( it != m_mimetypes.end() ) {
489 newMimeType = it.data().join(";"); 489 newMimeType = it.data().join(";");
490 }else{ 490 }else{
491 newMimeType = mime; 491 newMimeType = mime;
492 } 492 }
493 } 493 }
494 delete m_select; 494 delete m_select;
495 m_select = new FileSelector( newMimeType, 495 m_select = new FileSelector( newMimeType,
496 m_stack, "fileselector", 496 m_stack, "fileselector",
497 FALSE, FALSE); 497 FALSE, FALSE);
498 498
499 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 499 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
500 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 500 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
501 //connect to close me and other signals as well 501 //connect to close me and other signals as well
502 m_stack->addWidget( m_select, NORMAL ); 502 m_stack->addWidget( m_select, NORMAL );
503 m_stack->raiseWidget( NORMAL ); 503 m_stack->raiseWidget( NORMAL );
504 updateMimes(); 504 updateMimes();
505 updateMimeCheck(); 505 updateMimeCheck();
506 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 506 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
507 //} 507 //}
508 }else{ // others 508 }else{ // others
509 qWarning("Mime %s", mime.latin1() ); 509 qWarning("Mime %s", mime.latin1() );
510 if(m_shChooser ){ 510 if(m_shChooser ){
511 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); 511 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
512 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 512 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
513 } 513 }
514 reparse(); 514 reparse();
515 } 515 }
516 516
517} 517}
518void OFileSelector::slotLocationActivated(const QString &file) 518void OFileSelector::slotLocationActivated(const QString &file)
519{ 519{
520 cd(file.left(file.find("<-",0,TRUE))); 520 cd(file.left(file.find("<-",0,TRUE)));
521 reparse(); 521 reparse();
522} 522}
523void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count) 523void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
524{ 524{
525 QStringList pathList; 525 QStringList pathList;
526 bool underDog = FALSE; 526 bool underDog = FALSE;
527 for(int i=0;i<count;i++) { 527 for(int i=0;i<count;i++) {
528 pathList << m_location->text(i); 528 pathList << m_location->text(i);
529 if( m_location->text(i) == currentPath) 529 if( m_location->text(i) == currentPath)
530 underDog = TRUE; 530 underDog = TRUE;
531 } 531 }
532 if( !underDog) { 532 if( !underDog) {
533 m_location->clear(); 533 m_location->clear();
534 if( currentPath.left(2)=="//") 534 if( currentPath.left(2)=="//")
535 pathList.append( currentPath.right(currentPath.length()-1) ); 535 pathList.append( currentPath.right(currentPath.length()-1) );
536 else 536 else
537 pathList.append( currentPath ); 537 pathList.append( currentPath );
538 m_location->insertStringList( pathList,-1); 538 m_location->insertStringList( pathList,-1);
539 } 539 }
540} 540}
541void OFileSelector::locationComboChanged() 541void OFileSelector::locationComboChanged()
542{ 542{
543 cd( m_location->lineEdit()->text()); 543 cd( m_location->lineEdit()->text());
544 reparse(); 544 reparse();
545} 545}
546void OFileSelector::init() 546void OFileSelector::init()
547{ 547{
548 m_lay = new QVBoxLayout( this ); 548 m_lay = new QVBoxLayout( this );
549 m_lay->setSpacing(0 ); 549 m_lay->setSpacing(0 );
550 550
551 m_stack = new QWidgetStack( this ); 551 m_stack = new QWidgetStack( this );
552 if( m_selector == NORMAL ){ 552 if( m_selector == NORMAL ){
553 QString mime; 553 QString mime;
554 if (!m_autoMime) { 554 if (!m_autoMime) {
555 if (!m_mimetypes.isEmpty() ) { 555 if (!m_mimetypes.isEmpty() ) {
556 QMap<QString, QStringList>::Iterator it; 556 QMap<QString, QStringList>::Iterator it;
557 it = m_mimetypes.begin(); // cause we're in the init 557 it = m_mimetypes.begin(); // cause we're in the init
558 mime = it.data().join(";"); 558 mime = it.data().join(";");
559 } 559 }
560 } 560 }
561 m_select = new FileSelector(mime, 561 m_select = new FileSelector(mime,
562 m_stack, "fileselector", 562 m_stack, "fileselector",
563 FALSE, FALSE); 563 FALSE, FALSE);
564 564
565 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 565 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
566 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 566 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
567 //connect to close me and other signals as well 567 //connect to close me and other signals as well
568 568
569 m_stack->addWidget( m_select, NORMAL ); 569 m_stack->addWidget( m_select, NORMAL );
570 m_stack->raiseWidget( NORMAL ); 570 m_stack->raiseWidget( NORMAL );
571 }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL 571 }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL
572 // and initializeListview will take care of those 572 // and initializeListview will take care of those
573 // toolbar get's generade in initializeListView 573 // toolbar get's generade in initializeListView
574 initializeListView( ); // will raise the widget as well 574 initializeListView( ); // will raise the widget as well
575 m_stack->raiseWidget( EXTENDED );
575 } 576 }
576 m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch 577 m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch
577 578
578 if( m_shLne ) // the LineEdit with the current FileName 579 if( m_shLne ) // the LineEdit with the current FileName
579 initializeName(); 580 initializeName();
580 581
581 if( m_shPerm ) // the Permission QCheckBox 582 if( m_shPerm ) // the Permission QCheckBox
582 initializePerm(); 583 initializePerm();
583 584
584 if( m_shChooser ) // the Chooser for the view and Mimetypes 585 if( m_shChooser ) // the Chooser for the view and Mimetypes
585 initializeChooser(); 586 initializeChooser();
586 587
587 if( m_shYesNo ) // the Yes No button row 588 if( m_shYesNo ) // the Yes No button row
588 initializeYes( ); 589 initializeYes( );
590
591 if (m_selector != NORMAL )
592 reparse();
589} 593}
590void OFileSelector::updateMimes() 594void OFileSelector::updateMimes()
591{ 595{
592 if( m_autoMime ){ 596 if( m_autoMime ){
593 m_mimetypes.clear(); 597 m_mimetypes.clear();
594 m_mimetypes.insert( tr("All"), QString::null ); 598 m_mimetypes.insert( tr("All"), QString::null );
595 if( m_selector == NORMAL ){ 599 if( m_selector == NORMAL ){
596 DocLnkSet set; 600 DocLnkSet set;
597 Global::findDocuments(&set, QString::null ); 601 Global::findDocuments(&set, QString::null );
598 QListIterator<DocLnk> dit( set.children() ); 602 QListIterator<DocLnk> dit( set.children() );
599 for( ; dit.current(); ++dit ){ 603 for( ; dit.current(); ++dit ){
600 if( !m_mimetypes.contains( (*dit)->type() ) ) 604 if( !m_mimetypes.contains( (*dit)->type() ) )
601 m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); 605 m_mimetypes.insert( (*dit)->type(), (*dit)->type() );
602 } 606 }
603 }// else done in reparse 607 }// else done in reparse
604 } 608 }
605} 609}
606void OFileSelector::initVars() 610void OFileSelector::initVars()
607{ 611{
608 if( m_mimetypes.isEmpty() ) 612 if( m_mimetypes.isEmpty() )
609 m_autoMime = true; 613 m_autoMime = true;
610 else 614 else
611 m_autoMime = false; 615 m_autoMime = false;
612 m_shClose = false; 616 m_shClose = false;
613 m_shNew = false; 617 m_shNew = false;
614 m_shTool = true; 618 m_shTool = true;
615 m_shPerm = false; 619 m_shPerm = false;
616 m_shLne = true; 620 m_shLne = true;
617 m_shChooser = true; 621 m_shChooser = true;
618 m_shYesNo = true; 622 m_shYesNo = true;
619 m_case = false; 623 m_case = false;
620 m_dir = true; 624 m_dir = true;
621 m_files = true; 625 m_files = true;
622 m_showPopup = false; 626 m_showPopup = false;
623 if(m_pixmaps == 0 ) // init the pixmaps 627 if(m_pixmaps == 0 ) // init the pixmaps
624 initPics(); 628 initPics();
625 629
626 // pointers 630 // pointers
627 m_location = 0; 631 m_location = 0;
628 m_mimeCheck = 0; 632 m_mimeCheck = 0;
629 m_viewCheck = 0; 633 m_viewCheck = 0;
630 m_homeButton = 0; 634 m_homeButton = 0;
631 m_docButton = 0; 635 m_docButton = 0;
632 m_hideButton = 0; 636 m_hideButton = 0;
633 m_ok = 0; 637 m_ok = 0;
634 m_cancel = 0; 638 m_cancel = 0;
635 m_reread = 0; 639 m_reread = 0;
636 m_up = 0; 640 m_up = 0;
637 m_View = 0; 641 m_View = 0;
638 m_checkPerm = 0; 642 m_checkPerm = 0;
639 m_pseudo = 0; 643 m_pseudo = 0;
640 m_pseudoLayout = 0; 644 m_pseudoLayout = 0;
641 m_select = 0; 645 m_select = 0;
642 m_stack = 0; 646 m_stack = 0;
643 m_lay = 0; 647 m_lay = 0;
644 m_Oselector = 0; 648 m_Oselector = 0;
645 m_boxToolbar = 0; 649 m_boxToolbar = 0;
646 m_boxOk = 0; 650 m_boxOk = 0;
647 m_boxName = 0; 651 m_boxName = 0;
648 m_boxView = 0; 652 m_boxView = 0;
649 m_custom = 0; 653 m_custom = 0;
650 m_edit = 0; 654 m_edit = 0;
651 m_fnLabel = 0; 655 m_fnLabel = 0;
652 m_new = 0; 656 m_new = 0;
653 m_close = 0; 657 m_close = 0;
654} 658}
655void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) 659void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink)
656{ 660{
657 if(!m_files) 661 if(!m_files)
658 return; 662 return;
659 // if( !compliesMime(info->absFilePath(), mime ) ) 663 // if( !compliesMime(info->absFilePath(), mime ) )
660 // return; 664 // return;
661 MimeType type( info->absFilePath() ); 665 MimeType type( info->absFilePath() );
662 if (!compliesMime( type.id() ) ) 666 if (!compliesMime( type.id() ) )
663 return; 667 return;
664 668
665 QPixmap pix = type.pixmap(); 669 QPixmap pix = type.pixmap();
666 QString dir; 670 QString dir;
667 QString name; 671 QString name;
668 bool locked; 672 bool locked;
669 if( pix.isNull() ) 673 if( pix.isNull() )
670 pix = Resource::loadPixmap( "UnknownDocument-14"); 674 pix = Resource::loadPixmap( "UnknownDocument-14");
671 dir = info->dirPath( true ); 675 dir = info->dirPath( true );
672 if( symlink ) 676 if( symlink )
673 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); 677 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
674 else { 678 else {
675 name = info->fileName(); 679 name = info->fileName();
676 if( ( m_mode == OPEN && !info->isReadable() )|| 680 if( ( m_mode == OPEN && !info->isReadable() )||
677 ( m_mode == SAVE && !info->isWritable() ) ){ 681 ( m_mode == SAVE && !info->isWritable() ) ){
678 682
679 locked = true; pix = Resource::loadPixmap("locked"); 683 locked = true; pix = Resource::loadPixmap("locked");
680 } 684 }
681 } 685 }
682 new OFileSelectorItem( m_View, pix, name, 686 new OFileSelectorItem( m_View, pix, name,
683 info->lastModified().toString(), 687 info->lastModified().toString(),
684 QString::number( info->size() ), 688 QString::number( info->size() ),
685 dir, locked ); 689 dir, locked );
686} 690}
687void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) 691void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
688{ 692{
689 if(!m_dir) 693 if(!m_dir)
690 return; 694 return;
691 if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ 695 if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){
692 bool locked = false; 696 bool locked = false;
693 QString name; 697 QString name;
694 QPixmap pix; 698 QPixmap pix;
695 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ 699 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
696 locked = true; 700 locked = true;
697 if( symlink ) 701 if( symlink )
698 pix = (*m_pixmaps)["symlinkedlocked"]; 702 pix = (*m_pixmaps)["symlinkedlocked"];
699 else 703 else
700 pix = Resource::loadPixmap("lockedfolder"); 704 pix = Resource::loadPixmap("lockedfolder");
701 }else { // readable 705 }else { // readable
702 pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; 706 pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ;
703 } 707 }
704 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; 708 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ;
705 new OFileSelectorItem( m_View, pix, name, 709 new OFileSelectorItem( m_View, pix, name,
706 info->lastModified().toString(), 710 info->lastModified().toString(),
707 QString::number( info->size() ), 711 QString::number( info->size() ),
708 info->dirPath( true ), locked, 712 info->dirPath( true ), locked,
709 true ); 713 true );
710 714
711 }// else CUSTOM View 715 }// else CUSTOM View
712} 716}
713void OFileSelector::delItems() 717void OFileSelector::delItems()
714{ 718{
715 719
716} 720}
717void OFileSelector::initializeName() 721void OFileSelector::initializeName()
718{ 722{
719 /** Name Layout Line 723 /** Name Layout Line
720 * This is the Layout line arranged in 724 * This is the Layout line arranged in
721 * horizontal way each components 725 * horizontal way each components
722 * are next to each other 726 * are next to each other
723 * but we will only do this if 727 * but we will only do this if
724 * we didn't initialize a while ago. 728 * we didn't initialize a while ago.
725 */ 729 */
726 if( m_boxName == 0 ){ 730 if( m_boxName == 0 ){
727 m_boxName = new QHBox( this ); // remove this this? or use a QHBox 731 m_boxName = new QHBox( this ); // remove this this? or use a QHBox
728 m_fnLabel = new QLabel( m_boxName ); 732 m_fnLabel = new QLabel( m_boxName );
729 m_fnLabel->setText( tr("Name:") ); 733 m_fnLabel->setText( tr("Name:") );
730 m_edit = new QLineEdit( m_boxName ); 734 m_edit = new QLineEdit( m_boxName );
731 m_edit->setText( m_name ); 735 m_edit->setText( m_name );
732 //m_boxName->addWidget( m_fnLabel ); 736 //m_boxName->addWidget( m_fnLabel );
733 m_boxName->setMargin( 5 ); 737 m_boxName->setMargin( 5 );
734 m_boxName->setSpacing( 8 ); 738 m_boxName->setSpacing( 8 );
735 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor 739 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor
736 740
737 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout 741 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout
738 }// else we already initialized 742 }// else we already initialized
739 // maybe show the components? 743 // maybe show the components?
740 // 744 //
741} 745}
742void OFileSelector::initializeYes() 746void OFileSelector::initializeYes()
743{ 747{
744 /** The Save Cancel bar 748 /** The Save Cancel bar
745 * 749 *
746 */ 750 */
747 if( m_boxOk == 0 ){ 751 if( m_boxOk == 0 ){
748 m_boxOk = new QHBox( this ); 752 m_boxOk = new QHBox( this );
749 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); 753 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" );
750 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); 754 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" );
751 755
752 //m_boxOk->addWidget( m_ok ); 756 //m_boxOk->addWidget( m_ok );
753 //m_boxOk->addWidget( m_cancel ); 757 //m_boxOk->addWidget( m_cancel );
754 m_boxOk->setMargin( 5 ); 758 m_boxOk->setMargin( 5 );
755 m_boxOk->setSpacing( 10 ); 759 m_boxOk->setSpacing( 10 );
756 m_lay->addWidget( m_boxOk, 0 ); 760 m_lay->addWidget( m_boxOk, 0 );
757 761
758 connect( m_ok, SIGNAL( clicked() ), 762 connect( m_ok, SIGNAL( clicked() ),
759 this, SLOT(slotOk() ) ); 763 this, SLOT(slotOk() ) );
760 connect( m_cancel, SIGNAL( clicked() ), 764 connect( m_cancel, SIGNAL( clicked() ),
761 this, SLOT( slotCancel() ) ); 765 this, SLOT( slotCancel() ) );
762 } 766 }
763} 767}
764/* 768/*
765 * OK m_mimeCheck is a QComboBox we now want to fill 769 * OK m_mimeCheck is a QComboBox we now want to fill
766 * out that combobox 770 * out that combobox
767 * if automime we need to update the mimetypes 771 * if automime we need to update the mimetypes
768 */ 772 */
769void OFileSelector::updateMimeCheck() { 773void OFileSelector::updateMimeCheck() {
770 m_mimeCheck->clear(); 774 m_mimeCheck->clear();
771 if (m_autoMime ) { 775 if (m_autoMime ) {
772 //m_mimeCheck->insertItem( tr("All") ); 776 //m_mimeCheck->insertItem( tr("All") );
773 updateMimes(); 777 updateMimes();
774 } 778 }
775 779
776 QMap<QString, QStringList>::Iterator it; 780 QMap<QString, QStringList>::Iterator it;
777 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { 781 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) {
778 m_mimeCheck->insertItem( it.key() ); 782 m_mimeCheck->insertItem( it.key() );
779 } 783 }
780} 784}
781 785
782void OFileSelector::initializeChooser() 786void OFileSelector::initializeChooser()
783{ 787{
784 if( m_boxView == 0 ){ 788 if( m_boxView == 0 ){
785 m_boxView = new QHBox( this ); 789 m_boxView = new QHBox( this );
786 m_viewCheck = new QComboBox( m_boxView, "view check"); 790 m_viewCheck = new QComboBox( m_boxView, "view check");
787 m_mimeCheck = new QComboBox( m_boxView, "mime check"); 791 m_mimeCheck = new QComboBox( m_boxView, "mime check");
788 m_boxView->setSpacing( 8 ); 792 m_boxView->setSpacing( 8 );
789 m_lay->addWidget(m_boxView, 0 ); 793 m_lay->addWidget(m_boxView, 0 );
790 794
791 m_viewCheck->insertItem( tr("Documents") ); 795 m_viewCheck->insertItem( tr("Documents") );
792 m_viewCheck->insertItem( tr("Files") ); 796 m_viewCheck->insertItem( tr("Files") );
793 m_viewCheck->insertItem( tr("All Files") ); 797 m_viewCheck->insertItem( tr("All Files") );
794 updateMimeCheck(); 798 updateMimeCheck();
795 799
796 connect( m_viewCheck, SIGNAL( activated(const QString & ) ), 800 connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
797 this, SLOT( slotViewCheck(const QString & ) ) ); 801 this, SLOT( slotViewCheck(const QString & ) ) );
798 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), 802 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
799 this, SLOT( slotMimeCheck( const QString & ) ) ); 803 this, SLOT( slotMimeCheck( const QString & ) ) );
800 } 804 }
801} 805}
802void OFileSelector::initializeListView() 806void OFileSelector::initializeListView()
803{ 807{
808 qWarning("initializeListView");
804 if( m_pseudo == 0 ){ 809 if( m_pseudo == 0 ){
810 qWarning("init");
805 m_pseudo = new QWidget( m_stack, "Pseudo Widget"); 811 m_pseudo = new QWidget( m_stack, "Pseudo Widget");
806 m_pseudoLayout = new QVBoxLayout( m_pseudo ); 812 m_pseudoLayout = new QVBoxLayout( m_pseudo );
807 // toolbar 813 // toolbar
808 m_boxToolbar = new QHBox( m_pseudo ); 814 m_boxToolbar = new QHBox( m_pseudo );
809 m_boxToolbar->setSpacing(0 ); // next to each other please 815 m_boxToolbar->setSpacing(0 ); // next to each other please
810 816
811 // toolbar members 817 // toolbar members
812 { 818 {
813 // location QComboBox 819 // location QComboBox
814 m_location = new QComboBox( m_boxToolbar ); 820 m_location = new QComboBox( m_boxToolbar );
815 m_location->setEditable( TRUE ); 821 m_location->setEditable( TRUE );
816 m_location->setDuplicatesEnabled( FALSE ); 822 m_location->setDuplicatesEnabled( FALSE );
817 connect( m_location, SIGNAL(activated(const QString &) ), 823 connect( m_location, SIGNAL(activated(const QString &) ),
818 this, SLOT( slotLocationActivated(const QString &) ) ); 824 this, SLOT( slotLocationActivated(const QString &) ) );
819 connect( m_location->lineEdit(), SIGNAL(returnPressed() ), 825 connect( m_location->lineEdit(), SIGNAL(returnPressed() ),
820 this, SLOT(locationComboChanged() ) ); 826 this, SLOT(locationComboChanged() ) );
821 // UP Button 827 // UP Button
822 m_up = new QPushButton(Resource::loadIconSet("up"),"", 828 m_up = new QPushButton(Resource::loadIconSet("up"),"",
823 m_boxToolbar,"cdUpButton"); 829 m_boxToolbar,"cdUpButton");
824 m_up->setFixedSize( QSize( 20, 20 ) ); 830 m_up->setFixedSize( QSize( 20, 20 ) );
825 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); 831 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
826 m_up->setFlat(TRUE); 832 m_up->setFlat(TRUE);
827 833
828 // Home Button 834 // Home Button
829 m_homeButton = new QPushButton(Resource::loadIconSet("home") , 835 m_homeButton = new QPushButton(Resource::loadIconSet("home") ,
830 "", m_boxToolbar); 836 "", m_boxToolbar);
831 m_homeButton->setFixedSize( QSize( 20, 20 ) ); 837 m_homeButton->setFixedSize( QSize( 20, 20 ) );
832 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); 838 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
833 m_homeButton->setFlat(TRUE); 839 m_homeButton->setFlat(TRUE);
834 // Documents Button 840 // Documents Button
835 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", 841 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",
836 m_boxToolbar,"docsButton"); 842 m_boxToolbar,"docsButton");
837 m_docButton->setFixedSize( QSize( 20, 20 ) ); 843 m_docButton->setFixedSize( QSize( 20, 20 ) );
838 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); 844 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
839 m_docButton->setFlat(TRUE); 845 m_docButton->setFlat(TRUE);
840 846
841 // Close button 847 // Close button
842 m_close = new QPushButton( Resource::loadIconSet( "close"), "", 848 m_close = new QPushButton( Resource::loadIconSet( "close"), "",
843 m_boxToolbar ); 849 m_boxToolbar );
844 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); 850 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
845 m_close->setFixedSize( 20, 20 ); 851 m_close->setFixedSize( 20, 20 );
846 852
847 m_boxToolbar->setFixedHeight( 20 ); 853 m_boxToolbar->setFixedHeight( 20 );
848 m_pseudoLayout->addWidget(m_boxToolbar ); 854 m_pseudoLayout->addWidget(m_boxToolbar );
849 855
850 // let;s fill the Location ComboBox 856 // let;s fill the Location ComboBox
851 StorageInfo storage; 857 StorageInfo storage;
852 const QList<FileSystem> &fs = storage.fileSystems(); 858 const QList<FileSystem> &fs = storage.fileSystems();
853 QListIterator<FileSystem> it ( fs ); 859 QListIterator<FileSystem> it ( fs );
854 for( ; it.current(); ++it ){ 860 for( ; it.current(); ++it ){
855 const QString disk = (*it)->name(); 861 const QString disk = (*it)->name();
856 const QString path = (*it)->path(); 862 const QString path = (*it)->path();
857 m_location->insertItem(path+ "<-"+disk ); 863 m_location->insertItem(path+ "<-"+disk );
858 } 864 }
859 int count = m_location->count(); 865 int count = m_location->count();
860 m_location->insertItem( m_currentDir ); 866 m_location->insertItem( m_currentDir );
861 m_location->setCurrentItem( count ); 867 m_location->setCurrentItem( count );
862 // due to the New and Close button we can not simply hide m_boxToolBar to not show it 868 // due to the New and Close button we can not simply hide m_boxToolBar to not show it
863 if( !m_shTool ){ 869 if( !m_shTool ){
864 m_location->hide( ); 870 m_location->hide( );
865 m_up->hide( ); 871 m_up->hide( );
866 m_homeButton->hide( ); 872 m_homeButton->hide( );
867 m_docButton->hide( ); 873 m_docButton->hide( );
868 } 874 }
869 if(!m_shClose ) 875 if(!m_shClose )
870 m_close->hide(); 876 m_close->hide();
871 if(!m_shNew) 877 if(!m_shNew)
872 m_close->hide(); 878 m_close->hide();
873 879
874 } // off toolbar 880 } // off toolbar
875 // the Main ListView 881 // the Main ListView
876 // make a QWidgetStack first so Views can share the Toolbar 882 // make a QWidgetStack first so Views can share the Toolbar
877 m_View = new QListView( m_pseudo, "Extended view"); 883 m_View = new QListView( m_pseudo, "Extended view");
878 QPEApplication::setStylusOperation( m_View->viewport(), 884 QPEApplication::setStylusOperation( m_View->viewport(),
879 QPEApplication::RightOnHold); 885 QPEApplication::RightOnHold);
880 m_View->addColumn(" " ); 886 m_View->addColumn(" " );
881 m_View->addColumn(tr("Name"), 135 ); 887 m_View->addColumn(tr("Name"), 135 );
882 m_View->addColumn(tr("Size"), -1 ); 888 m_View->addColumn(tr("Size"), -1 );
883 m_View->addColumn(tr("Date"), 60 ); 889 m_View->addColumn(tr("Date"), 60 );
884 m_View->addColumn(tr("Mime Type"), -1 ); 890 m_View->addColumn(tr("Mime Type"), -1 );
885 QHeader *header = m_View->header(); 891 QHeader *header = m_View->header();
886 header->hide(); 892 header->hide();
887 m_View->setSorting( 1 ); 893 m_View->setSorting( 1 );
888 m_View->setAllColumnsShowFocus( TRUE ); 894 m_View->setAllColumnsShowFocus( TRUE );
889 895
890 connect(m_View, SIGNAL(selectionChanged() ), 896 connect(m_View, SIGNAL(selectionChanged() ),
891 this, SLOT(slotSelectionChanged() ) ); 897 this, SLOT(slotSelectionChanged() ) );
892 898
893 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), 899 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ),
894 this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); 900 this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
895 901
896 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), 902 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
897 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); 903 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
898 904
899 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), 905 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
900 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); 906 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
901 907
902 m_pseudoLayout->addWidget( m_View, 288 ); 908 m_pseudoLayout->addWidget( m_View, 288 );
903 m_stack->addWidget( m_pseudo, EXTENDED ); 909 m_stack->addWidget( m_pseudo, EXTENDED );
904 } 910 }
905} 911}
906void OFileSelector::initializePerm() 912void OFileSelector::initializePerm()
907{ 913{
908 if( m_checkPerm == 0 ){ 914 if( m_checkPerm == 0 ){
909 m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); 915 m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm");
910 m_checkPerm->setChecked( false ); 916 m_checkPerm->setChecked( false );
911 m_lay->addWidget( m_checkPerm ); 917 m_lay->addWidget( m_checkPerm );
912 918
913 } 919 }
914} 920}
915void OFileSelector::initPics() 921void OFileSelector::initPics()
916{ 922{
917 m_pixmaps = new QMap<QString,QPixmap>; 923 m_pixmaps = new QMap<QString,QPixmap>;
918 QPixmap pm = Resource::loadPixmap( "folder" ); 924 QPixmap pm = Resource::loadPixmap( "folder" );
919 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 925 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
920 QPainter painter( &pm ); 926 QPainter painter( &pm );
921 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 927 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
922 pm.setMask( pm.createHeuristicMask( FALSE ) ); 928 pm.setMask( pm.createHeuristicMask( FALSE ) );
923 m_pixmaps->insert("dirsymlink", pm ); 929 m_pixmaps->insert("dirsymlink", pm );
924 930
925 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 931 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
926 QPainter pen(&pm2 ); 932 QPainter pen(&pm2 );
927 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 933 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
928 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 934 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
929 m_pixmaps->insert("symlinkedlocked", pm2 ); 935 m_pixmaps->insert("symlinkedlocked", pm2 );
930} 936}
931// if a mime complies with the m_mimeCheck->currentItem 937// if a mime complies with the m_mimeCheck->currentItem
932bool OFileSelector::compliesMime( const QString &path, const QString &mime ) 938bool OFileSelector::compliesMime( const QString &path, const QString &mime )
933{ 939{
934 if( mime == "All" ) 940 if( mime == "All" )
935 return true; 941 return true;
936 MimeType type( path ); 942 MimeType type( path );
937 if( type.id() == mime ) 943 if( type.id() == mime )
938 return true; 944 return true;
939 return false; 945 return false;
940} 946}
941/* check if the mimetype in mime 947/* check if the mimetype in mime
942 * complies with the one which is current 948 * complies with the one which is current
943 */ 949 */
944/* 950/*
945 * We've the mimetype of the file 951 * We've the mimetype of the file
946 * We need to get the stringlist of the current mimetype 952 * We need to get the stringlist of the current mimetype
947 * 953 *
948 * mime = image/jpeg 954 * mime = image/jpeg
949 * QStringList = 'image/*' 955 * QStringList = 'image/*'
950 * or QStringList = image/jpeg;image/png;application/x-ogg 956 * or QStringList = image/jpeg;image/png;application/x-ogg
951 * or QStringList = application/x-ogg;image/*; 957 * or QStringList = application/x-ogg;image/*;
952 * with all these mime filters it should get acceptes 958 * with all these mime filters it should get acceptes
953 * to do so we need to look if mime is contained inside 959 * to do so we need to look if mime is contained inside
954 * the stringlist 960 * the stringlist
955 * if it's contained return true 961 * if it's contained return true
956 * if not ( I'm no RegExp expert at all ) we'll look if a '/*' 962 * if not ( I'm no RegExp expert at all ) we'll look if a '/*'
957 * is contained in the mimefilter and then we will 963 * is contained in the mimefilter and then we will
958 * look if both are equal until the '/' 964 * look if both are equal until the '/'
959 */ 965 */
960bool OFileSelector::compliesMime( const QString& mime ) { 966bool OFileSelector::compliesMime( const QString& mime ) {
961 qWarning("mimetype is %s", mime.latin1() ); 967 qWarning("mimetype is %s", mime.latin1() );
962 QString currentText; 968 QString currentText;
963 if (m_shChooser ) 969 if (m_shChooser )
964 currentText = m_mimeCheck->currentText(); 970 currentText = m_mimeCheck->currentText();
965 971
966 qWarning("current text is %s", currentText.latin1() ); 972 qWarning("current text is %s", currentText.latin1() );
967 QMap<QString, QStringList>::Iterator it; 973 QMap<QString, QStringList>::Iterator it;
968 QStringList list; 974 QStringList list;
969 if ( currentText == tr("All") ) return true; 975 if ( currentText == tr("All") ) return true;
970 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { 976 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) {
971 it = m_mimetypes.begin(); 977 it = m_mimetypes.begin();
972 list = it.data(); 978 list = it.data();
973 }else if ( currentText.isEmpty() ) return true; 979 }else if ( currentText.isEmpty() ) return true;
974 else{ 980 else{
975 it = m_mimetypes.find(currentText ); 981 it = m_mimetypes.find(currentText );
976 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; 982 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText;
977 else qWarning("found"), list = it.data(); 983 else qWarning("found"), list = it.data();
978 } 984 }
979 // dump it now 985 // dump it now
980 //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 986 //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
981 // qWarning( "%s", (*it).latin1() ); 987 // qWarning( "%s", (*it).latin1() );
982 //} 988 //}
983 989
984 990
985 if ( list.contains(mime) ) return true; 991 if ( list.contains(mime) ) return true;
986 qWarning("list doesn't contain it "); 992 qWarning("list doesn't contain it ");
987 QStringList::Iterator it2; 993 QStringList::Iterator it2;
988 int pos; 994 int pos;
989 int pos2; 995 int pos2;
990 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { 996 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) {
991 pos = (*it2).findRev("/*"); 997 pos = (*it2).findRev("/*");
992 if ( pos >= 0 ) { 998 if ( pos >= 0 ) {
993 if ( mime.contains( (*it2).left(pos) ) ) return true; 999 if ( mime.contains( (*it2).left(pos) ) ) return true;
994 } 1000 }
995 } 1001 }
996 return false; 1002 return false;
997} 1003}
998void OFileSelector::slotFileSelected( const QString &string ) 1004void OFileSelector::slotFileSelected( const QString &string )
999{ 1005{
1000 if( m_shLne ) 1006 if( m_shLne )
1001 m_edit->setText( string ); 1007 m_edit->setText( string );
1002 emit fileSelected( string ); 1008 emit fileSelected( string );
1003} 1009}
1004void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 1010void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
1005{ 1011{
1006 slotFileSelected( lnk.name() ); 1012 slotFileSelected( lnk.name() );
1007 // emit fileSelected( lnk ); 1013 // emit fileSelected( lnk );
1008} 1014}
1009void OFileSelector::slotSelectionChanged() 1015void OFileSelector::slotSelectionChanged()
1010{ 1016{
1011 1017
1012} 1018}
1013void OFileSelector::slotCurrentChanged(QListViewItem* item ) 1019void OFileSelector::slotCurrentChanged(QListViewItem* item )
1014{ 1020{
1015 if( item == 0 ) 1021 if( item == 0 )
1016 return; 1022 return;
1017 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 1023 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
1018 OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) 1024 OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;)
1019 if(!sel->isDir() ){ 1025 if(!sel->isDir() ){
1020 if( m_shLne ) 1026 if( m_shLne )
1021 m_edit->setText( sel->text(1) ); 1027 m_edit->setText( sel->text(1) );
1022 } 1028 }
1023 } 1029 }
1024} 1030}
1025void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) 1031void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int)
1026{ 1032{
1027 if ( item == 0 ) 1033 if ( item == 0 )
1028 return; 1034 return;
1029 1035
1030 if( button != Qt::LeftButton ) 1036 if( button != Qt::LeftButton )
1031 return; 1037 return;
1032 1038
1033 switch( m_selector ){ 1039 switch( m_selector ){
1034 default: 1040 default:
1035 break; 1041 break;
1036 case EXTENDED: // fall through 1042 case EXTENDED: // fall through
1037 case EXTENDED_ALL:{ 1043 case EXTENDED_ALL:{
1038 OFileSelectorItem *sel = (OFileSelectorItem*)item; 1044 OFileSelectorItem *sel = (OFileSelectorItem*)item;
1039 if(!sel->isLocked() ){ 1045 if(!sel->isLocked() ){
1040 QStringList str = QStringList::split("->", sel->text(1) ); 1046 QStringList str = QStringList::split("->", sel->text(1) );
1041 if( sel->isDir() ){ 1047 if( sel->isDir() ){
1042 cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1048 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
1043 // if MODE Dir m_shLne set the Text 1049 // if MODE Dir m_shLne set the Text
1044 }else{ 1050 }else{
1045 if( m_shLne ) 1051 if( m_shLne )
1046 m_edit->setText( str[0].stripWhiteSpace() ); 1052 m_edit->setText( str[0].stripWhiteSpace() );
1047 emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1053 emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() );
1048 } 1054 }
1049 } 1055 }
1050 break; 1056 break;
1051 } 1057 }
1052 } 1058 }
1053} 1059}
1054void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 1060void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
1055{ 1061{
1056 if( item == 0 ) 1062 if( item == 0 )
1057 return; 1063 return;
1058 1064
1059 if( button != Qt::RightButton ) 1065 if( button != Qt::RightButton )
1060 return; 1066 return;
1061 slotContextMenu( item ); 1067 slotContextMenu( item );
1062} 1068}
1063void OFileSelector::slotContextMenu( QListViewItem *item) 1069void OFileSelector::slotContextMenu( QListViewItem *item)
1064{ 1070{
1065 1071
1066} 1072}
1067void OFileSelector::slotChangedDir() 1073void OFileSelector::slotChangedDir()
1068{ 1074{
1069 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1075 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1070 if(sel->isDir() ){ 1076 if(sel->isDir() ){
1071 QStringList str = QStringList::split("->", sel->text(1) ); 1077 QStringList str = QStringList::split("->", sel->text(1) );
1072 cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1078 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
1073 } 1079 }
1074} 1080}
1075void OFileSelector::slotOpen() 1081void OFileSelector::slotOpen()
1076{ 1082{
1077 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1083 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1078 if(!sel->isDir() ){ 1084 if(!sel->isDir() ){
1079 QStringList str = QStringList::split("->", sel->text(1) ); 1085 QStringList str = QStringList::split("->", sel->text(1) );
1080 slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); 1086 slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() );
1081 } 1087 }
1082} 1088}
1083void OFileSelector::slotRescan() 1089void OFileSelector::slotRescan()
1084{ 1090{
1085 1091
1086} 1092}
1087void OFileSelector::slotRename() 1093void OFileSelector::slotRename()
1088{ 1094{
1089 reparse(); 1095 reparse();
1090} 1096}
1091void OFileSelector::slotDelete() 1097void OFileSelector::slotDelete()
1092{ 1098{
1093 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1099 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1094 QStringList list = QStringList::split("->", sel->text(1) ); 1100 QStringList list = QStringList::split("->", sel->text(1) );
1095 if( sel->isDir() ){ 1101 if( sel->isDir() ){
1096 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry 1102 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
1097 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], 1103 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
1098 tr("Yes"),tr("No"),0,1,1) ) { 1104 tr("Yes"),tr("No"),0,1,1) ) {
1099 case 0: 1105 case 0:
1100 ::system(str.utf8().data() ); 1106 ::system(str.utf8().data() );
1101 break; 1107 break;
1102 } 1108 }
1103 } else { 1109 } else {
1104 QFile::remove( list[0] ); 1110 QFile::remove( list[0] );
1105 } 1111 }
1106 m_View->takeItem( sel ); 1112 m_View->takeItem( sel );
1107 delete sel; 1113 delete sel;
1108} 1114}
1109void OFileSelector::cdUP() 1115void OFileSelector::cdUP()
1110{ 1116{
1111 QDir dir( m_currentDir ); 1117 QDir dir( m_currentDir );
1112 dir.cdUp(); 1118 dir.cdUp();
1113 if(dir.exists() ){ 1119 if(dir.exists() ){
1114 m_currentDir = dir.absPath(); 1120 m_currentDir = dir.absPath();
1115 reparse(); 1121 reparse();
1116 int count = m_location->count(); 1122 int count = m_location->count();
1117 slotInsertLocationPath( m_currentDir, count); 1123 slotInsertLocationPath( m_currentDir, count);
1118 m_location->setCurrentItem( indexByString( m_location, m_currentDir)); 1124 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
1119 //this wont work in all instances 1125 //this wont work in all instances
1120 // FIXME 1126 // FIXME
1121 } 1127 }
1122} 1128}
1123void OFileSelector::slotHome() 1129void OFileSelector::slotHome()
1124{ 1130{
1125 cd(QDir::homeDirPath() ); 1131 cd(QDir::homeDirPath() );
1126} 1132}
1127void OFileSelector::slotDoc() 1133void OFileSelector::slotDoc()
1128{ 1134{
1129 cd(QPEApplication::documentDir() ); 1135 cd(QPEApplication::documentDir() );
1130} 1136}
1131void OFileSelector::slotNavigate( ) 1137void OFileSelector::slotNavigate( )
1132{ 1138{
1133 1139
1134} 1140}
1135// fill the View with life 1141// fill the View with life
1136void OFileSelector::reparse() 1142void OFileSelector::reparse()
1137{ 1143{
1138 if( m_selector == NORMAL ) 1144 if( m_selector == NORMAL )
1139 return; 1145 return;
1140 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) 1146 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL )
1141 m_View->clear(); 1147 m_View->clear();
1142 else // custom view 1148 else // custom view
1143 ; // currentView()->clear(); 1149 ; // currentView()->clear();
1144 if( m_shChooser) 1150 if( m_shChooser)
1145 qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); 1151 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
1146 1152
1147 QString currentMimeType; 1153 QString currentMimeType;
1148 // let's update the mimetype 1154 // let's update the mimetype
1149 if( m_autoMime ){ 1155 if( m_autoMime ){
1150 m_mimetypes.clear(); 1156 m_mimetypes.clear();
1151 // ok we can change mimetype so we need to be able to give a selection 1157 // ok we can change mimetype so we need to be able to give a selection
1152 if( m_shChooser ) { 1158 if( m_shChooser ) {
1153 currentMimeType = m_mimeCheck->currentText(); 1159 currentMimeType = m_mimeCheck->currentText();
1154 m_mimeCheck->clear(); 1160 m_mimeCheck->clear();
1155 1161
1156 // let's find possible mimetypes 1162 // let's find possible mimetypes
1157 QDir dir( m_currentDir ); 1163 QDir dir( m_currentDir );
1158 dir.setFilter( QDir::Files | QDir::Readable ); 1164 dir.setFilter( QDir::Files | QDir::Readable );
1159 dir.setSorting( QDir::Size ); 1165 dir.setSorting( QDir::Size );
1160 const QFileInfoList *list = dir.entryInfoList(); 1166 const QFileInfoList *list = dir.entryInfoList();
1161 QFileInfoListIterator it( *list ); 1167 QFileInfoListIterator it( *list );
1162 QFileInfo *fi; 1168 QFileInfo *fi;
1163 while( (fi=it.current() ) ) { 1169 while( (fi=it.current() ) ) {
1164 if( fi->extension() == QString::fromLatin1("desktop") ){ 1170 if( fi->extension() == QString::fromLatin1("desktop") ){
1165 ++it; 1171 ++it;
1166 continue; 1172 continue;
1167 } 1173 }
1168 MimeType type( fi->absFilePath() ); 1174 MimeType type( fi->absFilePath() );
1169 if( !m_mimetypes.contains( type.id() ) ){ 1175 if( !m_mimetypes.contains( type.id() ) ){
1170 //qWarning("Type %s", type.id().latin1() ); 1176 //qWarning("Type %s", type.id().latin1() );
1171 m_mimetypes.insert( type.id(), type.id() ); 1177 m_mimetypes.insert( type.id(), type.id() );
1172 } 1178 }
1173 1179
1174 ++it; 1180 ++it;
1175 } 1181 }
1176 // add them to the chooser 1182 // add them to the chooser
1177 updateMimeCheck(); 1183 updateMimeCheck();
1178 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); 1184 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
1179 currentMimeType = m_mimeCheck->currentText(); 1185 currentMimeType = m_mimeCheck->currentText();
1180 } 1186 }
1181 }else { // no autoMime 1187 }else { // no autoMime
1182 // let the mimetype be set from out side the m_mimeCheck FEATURE 1188 // let the mimetype be set from out side the m_mimeCheck FEATURE
1183 1189
1184 if( m_shChooser ){ 1190 if( m_shChooser ){
1185 currentMimeType = m_mimeCheck->currentText(); 1191 currentMimeType = m_mimeCheck->currentText();
1186// updateMimeCheck(); 1192// updateMimeCheck();
1187 } 1193 }
1188 } 1194 }