-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 1f6ca05..5528aed 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp | |||
@@ -358,413 +358,413 @@ OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& st | |||
358 | pop->insertItem( disk ); | 358 | pop->insertItem( disk ); |
359 | } | 359 | } |
360 | m_fsPop = pop; | 360 | m_fsPop = pop; |
361 | 361 | ||
362 | 362 | ||
363 | btn->setPopup( pop ); | 363 | btn->setPopup( pop ); |
364 | 364 | ||
365 | lay->addWidget( box ); | 365 | lay->addWidget( box ); |
366 | 366 | ||
367 | m_view = new QListView( this ); | 367 | m_view = new QListView( this ); |
368 | 368 | ||
369 | m_view->installEventFilter(this); | 369 | m_view->installEventFilter(this); |
370 | 370 | ||
371 | QPEApplication::setStylusOperation( m_view->viewport(), | 371 | QPEApplication::setStylusOperation( m_view->viewport(), |
372 | QPEApplication::RightOnHold); | 372 | QPEApplication::RightOnHold); |
373 | m_view->addColumn(" " ); | 373 | m_view->addColumn(" " ); |
374 | m_view->addColumn(tr("Name"), 135 ); | 374 | m_view->addColumn(tr("Name"), 135 ); |
375 | m_view->addColumn(tr("Size"), -1 ); | 375 | m_view->addColumn(tr("Size"), -1 ); |
376 | m_view->addColumn(tr("Date"), 60 ); | 376 | m_view->addColumn(tr("Date"), 60 ); |
377 | m_view->addColumn(tr("Mime Type"), -1 ); | 377 | m_view->addColumn(tr("Mime Type"), -1 ); |
378 | 378 | ||
379 | 379 | ||
380 | m_view->setSorting( 1 ); | 380 | m_view->setSorting( 1 ); |
381 | m_view->setAllColumnsShowFocus( TRUE ); | 381 | m_view->setAllColumnsShowFocus( TRUE ); |
382 | 382 | ||
383 | lay->addWidget( m_view, 1000 ); | 383 | lay->addWidget( m_view, 1000 ); |
384 | connectSlots(); | 384 | connectSlots(); |
385 | } | 385 | } |
386 | 386 | ||
387 | OFileViewFileListView::~OFileViewFileListView() | 387 | OFileViewFileListView::~OFileViewFileListView() |
388 | { | 388 | { |
389 | } | 389 | } |
390 | 390 | ||
391 | void OFileViewFileListView::slotNew() | 391 | void OFileViewFileListView::slotNew() |
392 | { | 392 | { |
393 | DocLnk lnk; | 393 | DocLnk lnk; |
394 | emit selector()->newSelected( lnk ); | 394 | emit selector()->newSelected( lnk ); |
395 | } | 395 | } |
396 | 396 | ||
397 | OFileSelectorItem* OFileViewFileListView::currentItem()const | 397 | OFileSelectorItem* OFileViewFileListView::currentItem()const |
398 | { | 398 | { |
399 | QListViewItem* item = m_view->currentItem(); | 399 | QListViewItem* item = m_view->currentItem(); |
400 | if (!item ) | 400 | if (!item ) |
401 | return 0l; | 401 | return 0l; |
402 | 402 | ||
403 | return static_cast<OFileSelectorItem*>(item); | 403 | return static_cast<OFileSelectorItem*>(item); |
404 | } | 404 | } |
405 | 405 | ||
406 | void OFileViewFileListView::reread( bool all ) | 406 | void OFileViewFileListView::reread( bool all ) |
407 | { | 407 | { |
408 | m_view->clear(); | 408 | m_view->clear(); |
409 | 409 | ||
410 | if (selector()->showClose() ) | 410 | if (selector()->showClose() ) |
411 | m_btnClose->show(); | 411 | m_btnClose->show(); |
412 | else | 412 | else |
413 | m_btnClose->hide(); | 413 | m_btnClose->hide(); |
414 | 414 | ||
415 | if (selector()->showNew() ) | 415 | if (selector()->showNew() ) |
416 | m_btnNew->show(); | 416 | m_btnNew->show(); |
417 | else | 417 | else |
418 | m_btnNew->hide(); | 418 | m_btnNew->hide(); |
419 | 419 | ||
420 | m_mimes = selector()->currentMimeType(); | 420 | m_mimes = selector()->currentMimeType(); |
421 | m_all = all; | 421 | m_all = all; |
422 | 422 | ||
423 | QDir dir( m_currentDir ); | 423 | QDir dir( m_currentDir ); |
424 | if (!dir.exists() ) | 424 | if (!dir.exists() ) |
425 | return; | 425 | return; |
426 | 426 | ||
427 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 427 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
428 | int filter; | 428 | int filter; |
429 | if (m_all ) | 429 | if (m_all ) |
430 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 430 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
431 | else | 431 | else |
432 | filter = QDir::Files | QDir::Dirs | QDir::All; | 432 | filter = QDir::Files | QDir::Dirs | QDir::All; |
433 | dir.setFilter( filter ); | 433 | dir.setFilter( filter ); |
434 | 434 | ||
435 | // now go through all files | 435 | // now go through all files |
436 | const QFileInfoList *list = dir.entryInfoList(); | 436 | const QFileInfoList *list = dir.entryInfoList(); |
437 | if (!list) | 437 | if (!list) |
438 | { | 438 | { |
439 | cdUP(); | 439 | cdUP(); |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | 442 | ||
443 | QFileInfoListIterator it( *list ); | 443 | QFileInfoListIterator it( *list ); |
444 | QFileInfo *fi; | 444 | QFileInfo *fi; |
445 | while( (fi=it.current() ) ) | 445 | while( (fi=it.current() ) ) |
446 | { | 446 | { |
447 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) | 447 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) |
448 | { | 448 | { |
449 | ++it; | 449 | ++it; |
450 | continue; | 450 | continue; |
451 | } | 451 | } |
452 | 452 | ||
453 | /* | 453 | /* |
454 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 454 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
455 | * | 455 | * |
456 | */ | 456 | */ |
457 | if( fi->isSymLink() ) | 457 | if( fi->isSymLink() ) |
458 | { | 458 | { |
459 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 459 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
460 | for( int i = 0; i<=4; i++) | 460 | for( int i = 0; i<=4; i++) |
461 | { // 5 tries to prevent dos | 461 | { // 5 tries to prevent dos |
462 | QFileInfo info( file ); | 462 | QFileInfo info( file ); |
463 | if( !info.exists() ) | 463 | if( !info.exists() ) |
464 | { | 464 | { |
465 | addSymlink( fi, TRUE ); | 465 | addSymlink( fi, TRUE ); |
466 | break; | 466 | break; |
467 | } | 467 | } |
468 | else if( info.isDir() ) | 468 | else if( info.isDir() ) |
469 | { | 469 | { |
470 | addDir( fi, TRUE ); | 470 | addDir( fi, TRUE ); |
471 | break; | 471 | break; |
472 | } | 472 | } |
473 | else if( info.isFile() ) | 473 | else if( info.isFile() ) |
474 | { | 474 | { |
475 | addFile( fi, TRUE ); | 475 | addFile( fi, TRUE ); |
476 | break; | 476 | break; |
477 | } | 477 | } |
478 | else if( info.isSymLink() ) | 478 | else if( info.isSymLink() ) |
479 | { | 479 | { |
480 | file = info.dirPath(true ) + "/" + info.readLink() ; | 480 | file = info.dirPath(true ) + "/" + info.readLink() ; |
481 | break; | 481 | break; |
482 | } | 482 | } |
483 | else if( i == 4) | 483 | else if( i == 4) |
484 | { // couldn't resolve symlink add it as symlink | 484 | { // couldn't resolve symlink add it as symlink |
485 | addSymlink( fi ); | 485 | addSymlink( fi ); |
486 | } | 486 | } |
487 | } // off for loop for symlink resolving | 487 | } // off for loop for symlink resolving |
488 | } | 488 | } |
489 | else if( fi->isDir() ) | 489 | else if( fi->isDir() ) |
490 | addDir( fi ); | 490 | addDir( fi ); |
491 | else if( fi->isFile() ) | 491 | else if( fi->isFile() ) |
492 | addFile( fi ); | 492 | addFile( fi ); |
493 | 493 | ||
494 | ++it; | 494 | ++it; |
495 | } // of while loop | 495 | } // of while loop |
496 | m_view->sort(); | 496 | m_view->sort(); |
497 | 497 | ||
498 | } | 498 | } |
499 | int OFileViewFileListView::fileCount()const | 499 | int OFileViewFileListView::fileCount()const |
500 | { | 500 | { |
501 | return m_view->childCount(); | 501 | return m_view->childCount(); |
502 | } | 502 | } |
503 | 503 | ||
504 | QString OFileViewFileListView::currentDir()const | 504 | QString OFileViewFileListView::currentDir()const |
505 | { | 505 | { |
506 | return m_currentDir; | 506 | return m_currentDir; |
507 | } | 507 | } |
508 | 508 | ||
509 | OFileSelector* OFileViewFileListView::selector() | 509 | OFileSelector* OFileViewFileListView::selector() |
510 | { | 510 | { |
511 | return m_sel; | 511 | return m_sel; |
512 | } | 512 | } |
513 | 513 | ||
514 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) | 514 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) |
515 | { | 515 | { |
516 | if ( e->type() == QEvent::KeyPress ) | 516 | if ( e->type() == QEvent::KeyPress ) |
517 | { | 517 | { |
518 | QKeyEvent *k = (QKeyEvent *)e; | 518 | QKeyEvent *k = (QKeyEvent *)e; |
519 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 519 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
520 | { | 520 | { |
521 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 521 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
522 | return true; | 522 | return true; |
523 | } | 523 | } |
524 | } | 524 | } |
525 | return false; | 525 | return false; |
526 | } | 526 | } |
527 | 527 | ||
528 | void OFileViewFileListView::connectSlots() | 528 | void OFileViewFileListView::connectSlots() |
529 | { | 529 | { |
530 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 530 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
531 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 531 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
532 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), | 532 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
533 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); | 533 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); |
534 | } | 534 | } |
535 | 535 | ||
536 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) | 536 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) |
537 | { | 537 | { |
538 | if (!item) | 538 | if (!item) |
539 | return; | 539 | return; |
540 | #if 0 | 540 | #if 0 |
541 | 541 | ||
542 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 542 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
543 | 543 | ||
544 | if (!sel->isDir() ) | 544 | if (!sel->isDir() ) |
545 | { | 545 | { |
546 | selector()->m_lneEdit->setText( sel->text(1) ); | 546 | selector()->m_lneEdit->setText( sel->text(1) ); |
547 | // if in fileselector mode we will emit selected | 547 | // if in fileselector mode we will emit selected |
548 | if ( selector()->mode() == OFileSelector::FileSelector ) | 548 | if ( selector()->mode() == OFileSelector::FileSelector ) |
549 | { | 549 | { |
550 | owarn << "slot Current Changed" << oendl; | 550 | odebug << "slot Current Changed" << oendl; |
551 | QStringList str = QStringList::split("->", sel->text(1) ); | 551 | QStringList str = QStringList::split("->", sel->text(1) ); |
552 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 552 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
553 | emit selector()->fileSelected( path ); | 553 | emit selector()->fileSelected( path ); |
554 | DocLnk lnk( path ); | 554 | DocLnk lnk( path ); |
555 | emit selector()->fileSelected( lnk ); | 555 | emit selector()->fileSelected( lnk ); |
556 | } | 556 | } |
557 | } | 557 | } |
558 | #endif | 558 | #endif |
559 | } | 559 | } |
560 | 560 | ||
561 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) | 561 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) |
562 | { | 562 | { |
563 | if (!item || ( button != Qt::LeftButton) ) | 563 | if (!item || ( button != Qt::LeftButton) ) |
564 | return; | 564 | return; |
565 | 565 | ||
566 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 566 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
567 | if (!sel->isLocked() ) | 567 | if (!sel->isLocked() ) |
568 | { | 568 | { |
569 | QStringList str = QStringList::split("->", sel->text(1) ); | 569 | QStringList str = QStringList::split("->", sel->text(1) ); |
570 | if (sel->isDir() ) | 570 | if (sel->isDir() ) |
571 | { | 571 | { |
572 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 572 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); |
573 | emit selector()->dirSelected( m_currentDir ); | 573 | emit selector()->dirSelected( m_currentDir ); |
574 | reread( m_all ); | 574 | reread( m_all ); |
575 | } | 575 | } |
576 | else | 576 | else |
577 | { // file | 577 | { // file |
578 | owarn << "slot Clicked" << oendl; | 578 | odebug << "slot Clicked" << oendl; |
579 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 579 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
580 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 580 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
581 | emit selector()->fileSelected( path ); | 581 | emit selector()->fileSelected( path ); |
582 | DocLnk lnk( path ); | 582 | DocLnk lnk( path ); |
583 | emit selector()->fileSelected( lnk ); | 583 | emit selector()->fileSelected( lnk ); |
584 | } | 584 | } |
585 | } // not locked | 585 | } // not locked |
586 | } | 586 | } |
587 | 587 | ||
588 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) | 588 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) |
589 | { | 589 | { |
590 | MimeType type( info->absFilePath() ); | 590 | MimeType type( info->absFilePath() ); |
591 | if (!compliesMime( type.id() ) ) | 591 | if (!compliesMime( type.id() ) ) |
592 | return; | 592 | return; |
593 | 593 | ||
594 | QPixmap pix = type.pixmap(); | 594 | QPixmap pix = type.pixmap(); |
595 | QString dir, name; bool locked; | 595 | QString dir, name; bool locked; |
596 | if ( pix.isNull() ) | 596 | if ( pix.isNull() ) |
597 | { | 597 | { |
598 | QWMatrix matrix; | 598 | QWMatrix matrix; |
599 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | 599 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); |
600 | matrix.scale( .4, .4 ); | 600 | matrix.scale( .4, .4 ); |
601 | pix = pixer.xForm( matrix ); | 601 | pix = pixer.xForm( matrix ); |
602 | } | 602 | } |
603 | dir = info->dirPath( true ); | 603 | dir = info->dirPath( true ); |
604 | locked = false; | 604 | locked = false; |
605 | if ( symlink ) | 605 | if ( symlink ) |
606 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | 606 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); |
607 | else | 607 | else |
608 | { | 608 | { |
609 | name = info->fileName(); | 609 | name = info->fileName(); |
610 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 610 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
611 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) | 611 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) |
612 | { | 612 | { |
613 | locked = true; pix = Resource::loadPixmap("locked"); | 613 | locked = true; pix = Resource::loadPixmap("locked"); |
614 | } | 614 | } |
615 | } | 615 | } |
616 | (void)new OFileSelectorItem( m_view, pix, name, | 616 | (void)new OFileSelectorItem( m_view, pix, name, |
617 | info->lastModified().toString(), QString::number( info->size() ), | 617 | info->lastModified().toString(), QString::number( info->size() ), |
618 | dir, locked ); | 618 | dir, locked ); |
619 | } | 619 | } |
620 | 620 | ||
621 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) | 621 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) |
622 | { | 622 | { |
623 | bool locked = false; QString name; QPixmap pix; | 623 | bool locked = false; QString name; QPixmap pix; |
624 | 624 | ||
625 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 625 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
626 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) | 626 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) |
627 | { | 627 | { |
628 | locked = true; | 628 | locked = true; |
629 | if ( symlink ) | 629 | if ( symlink ) |
630 | pix = Resource::loadPixmap( "opie/symlink" ); | 630 | pix = Resource::loadPixmap( "opie/symlink" ); |
631 | else | 631 | else |
632 | pix = Resource::loadPixmap( "lockedfolder" ); | 632 | pix = Resource::loadPixmap( "lockedfolder" ); |
633 | } | 633 | } |
634 | else | 634 | else |
635 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); | 635 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); |
636 | 636 | ||
637 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : | 637 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : |
638 | info->fileName(); | 638 | info->fileName(); |
639 | 639 | ||
640 | (void)new OFileSelectorItem( m_view, pix, name, | 640 | (void)new OFileSelectorItem( m_view, pix, name, |
641 | info->lastModified().toString(), | 641 | info->lastModified().toString(), |
642 | QString::number( info->size() ), | 642 | QString::number( info->size() ), |
643 | info->dirPath( true ), locked, true ); | 643 | info->dirPath( true ), locked, true ); |
644 | 644 | ||
645 | 645 | ||
646 | } | 646 | } |
647 | 647 | ||
648 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) | 648 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) |
649 | { | 649 | { |
650 | } | 650 | } |
651 | 651 | ||
652 | void OFileViewFileListView::cdUP() | 652 | void OFileViewFileListView::cdUP() |
653 | { | 653 | { |
654 | QDir dir( m_currentDir ); | 654 | QDir dir( m_currentDir ); |
655 | dir.cdUp(); | 655 | dir.cdUp(); |
656 | 656 | ||
657 | if (!dir.exists() ) | 657 | if (!dir.exists() ) |
658 | m_currentDir = "/"; | 658 | m_currentDir = "/"; |
659 | else | 659 | else |
660 | m_currentDir = dir.absPath(); | 660 | m_currentDir = dir.absPath(); |
661 | 661 | ||
662 | emit selector()->dirSelected( m_currentDir ); | 662 | emit selector()->dirSelected( m_currentDir ); |
663 | reread( m_all ); | 663 | reread( m_all ); |
664 | } | 664 | } |
665 | 665 | ||
666 | void OFileViewFileListView::cdHome() | 666 | void OFileViewFileListView::cdHome() |
667 | { | 667 | { |
668 | m_currentDir = QDir::homeDirPath(); | 668 | m_currentDir = QDir::homeDirPath(); |
669 | emit selector()->dirSelected( m_currentDir ); | 669 | emit selector()->dirSelected( m_currentDir ); |
670 | reread( m_all ); | 670 | reread( m_all ); |
671 | } | 671 | } |
672 | 672 | ||
673 | void OFileViewFileListView::cdDoc() | 673 | void OFileViewFileListView::cdDoc() |
674 | { | 674 | { |
675 | m_currentDir = QPEApplication::documentDir(); | 675 | m_currentDir = QPEApplication::documentDir(); |
676 | emit selector()->dirSelected( m_currentDir ); | 676 | emit selector()->dirSelected( m_currentDir ); |
677 | reread( m_all ); | 677 | reread( m_all ); |
678 | } | 678 | } |
679 | 679 | ||
680 | void OFileViewFileListView::changeDir( const QString& dir ) | 680 | void OFileViewFileListView::changeDir( const QString& dir ) |
681 | { | 681 | { |
682 | m_currentDir = dir; | 682 | m_currentDir = dir; |
683 | emit selector()->dirSelected( m_currentDir ); | 683 | emit selector()->dirSelected( m_currentDir ); |
684 | reread( m_all ); | 684 | reread( m_all ); |
685 | } | 685 | } |
686 | 686 | ||
687 | void OFileViewFileListView::slotFSActivated( int id ) | 687 | void OFileViewFileListView::slotFSActivated( int id ) |
688 | { | 688 | { |
689 | changeDir ( m_dev[m_fsPop->text(id)] ); | 689 | changeDir ( m_dev[m_fsPop->text(id)] ); |
690 | } | 690 | } |
691 | 691 | ||
692 | /* check if the mimetype in mime | 692 | /* check if the mimetype in mime |
693 | * complies with the one which is current | 693 | * complies with the one which is current |
694 | */ | 694 | */ |
695 | /* | 695 | /* |
696 | * We've the mimetype of the file | 696 | * We've the mimetype of the file |
697 | * We need to get the stringlist of the current mimetype | 697 | * We need to get the stringlist of the current mimetype |
698 | * | 698 | * |
699 | * mime = image@slashjpeg | 699 | * mime = image@slashjpeg |
700 | * QStringList = 'image@slash*' | 700 | * QStringList = 'image@slash*' |
701 | * or QStringList = image/jpeg;image/png;application/x-ogg | 701 | * or QStringList = image/jpeg;image/png;application/x-ogg |
702 | * or QStringList = application/x-ogg;image@slash*; | 702 | * or QStringList = application/x-ogg;image@slash*; |
703 | * with all these mime filters it should get acceptes | 703 | * with all these mime filters it should get acceptes |
704 | * to do so we need to look if mime is contained inside | 704 | * to do so we need to look if mime is contained inside |
705 | * the stringlist | 705 | * the stringlist |
706 | * if it's contained return true | 706 | * if it's contained return true |
707 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 707 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
708 | * is contained in the mimefilter and then we will | 708 | * is contained in the mimefilter and then we will |
709 | * look if both are equal until the '/' | 709 | * look if both are equal until the '/' |
710 | */ | 710 | */ |
711 | 711 | ||
712 | bool OFileViewFileListView::compliesMime( const QString& str) | 712 | bool OFileViewFileListView::compliesMime( const QString& str) |
713 | { | 713 | { |
714 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 714 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
715 | return true; | 715 | return true; |
716 | 716 | ||
717 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) | 717 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) |
718 | { | 718 | { |
719 | QRegExp reg( (*it) ); | 719 | QRegExp reg( (*it) ); |
720 | reg.setWildcard( true ); | 720 | reg.setWildcard( true ); |
721 | if ( str.find( reg ) != -1 ) | 721 | if ( str.find( reg ) != -1 ) |
722 | return true; | 722 | return true; |
723 | 723 | ||
724 | } | 724 | } |
725 | return false; | 725 | return false; |
726 | } | 726 | } |
727 | /* | 727 | /* |
728 | * The listView giving access to the file system! | 728 | * The listView giving access to the file system! |
729 | */ | 729 | */ |
730 | 730 | ||
731 | class OFileViewFileSystem : public OFileViewInterface | 731 | class OFileViewFileSystem : public OFileViewInterface |
732 | { | 732 | { |
733 | public: | 733 | public: |
734 | OFileViewFileSystem( OFileSelector* ); | 734 | OFileViewFileSystem( OFileSelector* ); |
735 | ~OFileViewFileSystem(); | 735 | ~OFileViewFileSystem(); |
736 | 736 | ||
737 | QString selectedName() const; | 737 | QString selectedName() const; |
738 | QString selectedPath() const; | 738 | QString selectedPath() const; |
739 | 739 | ||
740 | QString directory()const; | 740 | QString directory()const; |
741 | void reread(); | 741 | void reread(); |
742 | int fileCount()const; | 742 | int fileCount()const; |
743 | 743 | ||
744 | QWidget* widget( QWidget* parent ); | 744 | QWidget* widget( QWidget* parent ); |
745 | void activate( const QString& ); | 745 | void activate( const QString& ); |
746 | private: | 746 | private: |
747 | OFileViewFileListView* m_view; | 747 | OFileViewFileListView* m_view; |
748 | bool m_all : 1; | 748 | bool m_all : 1; |
749 | }; | 749 | }; |
750 | 750 | ||
751 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 751 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
752 | : OFileViewInterface( sel ) | 752 | : OFileViewInterface( sel ) |
753 | { | 753 | { |
754 | m_view = 0; | 754 | m_view = 0; |
755 | m_all = false; | 755 | m_all = false; |
756 | } | 756 | } |
757 | 757 | ||
758 | OFileViewFileSystem::~OFileViewFileSystem() | 758 | OFileViewFileSystem::~OFileViewFileSystem() |
759 | { | 759 | { |
760 | } | 760 | } |
761 | 761 | ||
762 | QString OFileViewFileSystem::selectedName()const | 762 | QString OFileViewFileSystem::selectedName()const |
763 | { | 763 | { |
764 | if (!m_view ) | 764 | if (!m_view ) |
765 | return QString::null; | 765 | return QString::null; |
766 | 766 | ||
767 | QString cFN=currentFileName(); | 767 | QString cFN=currentFileName(); |
768 | if (cFN.startsWith("/")) return cFN; | 768 | if (cFN.startsWith("/")) return cFN; |
769 | return m_view->currentDir() + "/" + cFN; | 769 | return m_view->currentDir() + "/" + cFN; |
770 | } | 770 | } |