author | zecke <zecke> | 2002-06-26 18:58:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-26 18:58:37 (UTC) |
commit | f6800ca0bed431aac90f09ec98e481fb424c7b31 (patch) (unidiff) | |
tree | a9c9687cc0cecc9a5f4b9caf77662f7735faf941 /libopie | |
parent | 8896b1ffe8ffd4da2395a050de63473ba37a2dec (diff) | |
download | opie-f6800ca0bed431aac90f09ec98e481fb424c7b31.zip opie-f6800ca0bed431aac90f09ec98e481fb424c7b31.tar.gz opie-f6800ca0bed431aac90f09ec98e481fb424c7b31.tar.bz2 |
Fix mimetype handling
-rw-r--r-- | libopie/ofileselector.cc | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 6c59f89..74b308e 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -598,130 +598,131 @@ void OFileSelector::updateMimes() | |||
598 | QListIterator<DocLnk> dit( set.children() ); | 598 | QListIterator<DocLnk> dit( set.children() ); |
599 | for( ; dit.current(); ++dit ){ | 599 | for( ; dit.current(); ++dit ){ |
600 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 600 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
601 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 601 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
602 | } | 602 | } |
603 | }// else done in reparse | 603 | }// else done in reparse |
604 | } | 604 | } |
605 | } | 605 | } |
606 | void OFileSelector::initVars() | 606 | void OFileSelector::initVars() |
607 | { | 607 | { |
608 | if( m_mimetypes.isEmpty() ) | 608 | if( m_mimetypes.isEmpty() ) |
609 | m_autoMime = true; | 609 | m_autoMime = true; |
610 | else | 610 | else |
611 | m_autoMime = false; | 611 | m_autoMime = false; |
612 | m_shClose = false; | 612 | m_shClose = false; |
613 | m_shNew = false; | 613 | m_shNew = false; |
614 | m_shTool = true; | 614 | m_shTool = true; |
615 | m_shPerm = false; | 615 | m_shPerm = false; |
616 | m_shLne = true; | 616 | m_shLne = true; |
617 | m_shChooser = true; | 617 | m_shChooser = true; |
618 | m_shYesNo = true; | 618 | m_shYesNo = true; |
619 | m_case = false; | 619 | m_case = false; |
620 | m_dir = true; | 620 | m_dir = true; |
621 | m_files = true; | 621 | m_files = true; |
622 | m_showPopup = false; | 622 | m_showPopup = false; |
623 | if(m_pixmaps == 0 ) // init the pixmaps | 623 | if(m_pixmaps == 0 ) // init the pixmaps |
624 | initPics(); | 624 | initPics(); |
625 | 625 | ||
626 | // pointers | 626 | // pointers |
627 | m_location = 0; | 627 | m_location = 0; |
628 | m_mimeCheck = 0; | 628 | m_mimeCheck = 0; |
629 | m_viewCheck = 0; | 629 | m_viewCheck = 0; |
630 | m_homeButton = 0; | 630 | m_homeButton = 0; |
631 | m_docButton = 0; | 631 | m_docButton = 0; |
632 | m_hideButton = 0; | 632 | m_hideButton = 0; |
633 | m_ok = 0; | 633 | m_ok = 0; |
634 | m_cancel = 0; | 634 | m_cancel = 0; |
635 | m_reread = 0; | 635 | m_reread = 0; |
636 | m_up = 0; | 636 | m_up = 0; |
637 | m_View = 0; | 637 | m_View = 0; |
638 | m_checkPerm = 0; | 638 | m_checkPerm = 0; |
639 | m_pseudo = 0; | 639 | m_pseudo = 0; |
640 | m_pseudoLayout = 0; | 640 | m_pseudoLayout = 0; |
641 | m_select = 0; | 641 | m_select = 0; |
642 | m_stack = 0; | 642 | m_stack = 0; |
643 | m_lay = 0; | 643 | m_lay = 0; |
644 | m_Oselector = 0; | 644 | m_Oselector = 0; |
645 | m_boxToolbar = 0; | 645 | m_boxToolbar = 0; |
646 | m_boxOk = 0; | 646 | m_boxOk = 0; |
647 | m_boxName = 0; | 647 | m_boxName = 0; |
648 | m_boxView = 0; | 648 | m_boxView = 0; |
649 | m_custom = 0; | 649 | m_custom = 0; |
650 | m_edit = 0; | 650 | m_edit = 0; |
651 | m_fnLabel = 0; | 651 | m_fnLabel = 0; |
652 | m_new = 0; | 652 | m_new = 0; |
653 | m_close = 0; | 653 | m_close = 0; |
654 | } | 654 | } |
655 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) | 655 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) |
656 | { | 656 | { |
657 | if(!m_files) | 657 | if(!m_files) |
658 | return; | 658 | return; |
659 | // if( !compliesMime(info->absFilePath(), mime ) ) | 659 | // if( !compliesMime(info->absFilePath(), mime ) ) |
660 | // return; | 660 | // return; |
661 | MimeType type( info->absFilePath() ); | 661 | MimeType type( info->absFilePath() ); |
662 | if( mime != tr("All") && type.id() != mime ) | 662 | if (!compliesMime( type.id() ) ) |
663 | return; | 663 | return; |
664 | |||
664 | QPixmap pix = type.pixmap(); | 665 | QPixmap pix = type.pixmap(); |
665 | QString dir; | 666 | QString dir; |
666 | QString name; | 667 | QString name; |
667 | bool locked; | 668 | bool locked; |
668 | if( pix.isNull() ) | 669 | if( pix.isNull() ) |
669 | pix = Resource::loadPixmap( "UnknownDocument-14"); | 670 | pix = Resource::loadPixmap( "UnknownDocument-14"); |
670 | dir = info->dirPath( true ); | 671 | dir = info->dirPath( true ); |
671 | if( symlink ) | 672 | if( symlink ) |
672 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); | 673 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); |
673 | else { | 674 | else { |
674 | name = info->fileName(); | 675 | name = info->fileName(); |
675 | if( ( m_mode == OPEN && !info->isReadable() )|| | 676 | if( ( m_mode == OPEN && !info->isReadable() )|| |
676 | ( m_mode == SAVE && !info->isWritable() ) ){ | 677 | ( m_mode == SAVE && !info->isWritable() ) ){ |
677 | 678 | ||
678 | locked = true; pix = Resource::loadPixmap("locked"); | 679 | locked = true; pix = Resource::loadPixmap("locked"); |
679 | } | 680 | } |
680 | } | 681 | } |
681 | new OFileSelectorItem( m_View, pix, name, | 682 | new OFileSelectorItem( m_View, pix, name, |
682 | info->lastModified().toString(), | 683 | info->lastModified().toString(), |
683 | QString::number( info->size() ), | 684 | QString::number( info->size() ), |
684 | dir, locked ); | 685 | dir, locked ); |
685 | } | 686 | } |
686 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 687 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
687 | { | 688 | { |
688 | if(!m_dir) | 689 | if(!m_dir) |
689 | return; | 690 | return; |
690 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ | 691 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ |
691 | bool locked = false; | 692 | bool locked = false; |
692 | QString name; | 693 | QString name; |
693 | QPixmap pix; | 694 | QPixmap pix; |
694 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | 695 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ |
695 | locked = true; | 696 | locked = true; |
696 | if( symlink ) | 697 | if( symlink ) |
697 | pix = (*m_pixmaps)["symlinkedlocked"]; | 698 | pix = (*m_pixmaps)["symlinkedlocked"]; |
698 | else | 699 | else |
699 | pix = Resource::loadPixmap("lockedfolder"); | 700 | pix = Resource::loadPixmap("lockedfolder"); |
700 | }else { // readable | 701 | }else { // readable |
701 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; | 702 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; |
702 | } | 703 | } |
703 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; | 704 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; |
704 | new OFileSelectorItem( m_View, pix, name, | 705 | new OFileSelectorItem( m_View, pix, name, |
705 | info->lastModified().toString(), | 706 | info->lastModified().toString(), |
706 | QString::number( info->size() ), | 707 | QString::number( info->size() ), |
707 | info->dirPath( true ), locked, | 708 | info->dirPath( true ), locked, |
708 | true ); | 709 | true ); |
709 | 710 | ||
710 | }// else CUSTOM View | 711 | }// else CUSTOM View |
711 | } | 712 | } |
712 | void OFileSelector::delItems() | 713 | void OFileSelector::delItems() |
713 | { | 714 | { |
714 | 715 | ||
715 | } | 716 | } |
716 | void OFileSelector::initializeName() | 717 | void OFileSelector::initializeName() |
717 | { | 718 | { |
718 | /** Name Layout Line | 719 | /** Name Layout Line |
719 | * This is the Layout line arranged in | 720 | * This is the Layout line arranged in |
720 | * horizontal way each components | 721 | * horizontal way each components |
721 | * are next to each other | 722 | * are next to each other |
722 | * but we will only do this if | 723 | * but we will only do this if |
723 | * we didn't initialize a while ago. | 724 | * we didn't initialize a while ago. |
724 | */ | 725 | */ |
725 | if( m_boxName == 0 ){ | 726 | if( m_boxName == 0 ){ |
726 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | 727 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox |
727 | m_fnLabel = new QLabel( m_boxName ); | 728 | m_fnLabel = new QLabel( m_boxName ); |
@@ -879,130 +880,181 @@ void OFileSelector::initializeListView() | |||
879 | m_View->addColumn(" " ); | 880 | m_View->addColumn(" " ); |
880 | m_View->addColumn(tr("Name"), 135 ); | 881 | m_View->addColumn(tr("Name"), 135 ); |
881 | m_View->addColumn(tr("Size"), -1 ); | 882 | m_View->addColumn(tr("Size"), -1 ); |
882 | m_View->addColumn(tr("Date"), 60 ); | 883 | m_View->addColumn(tr("Date"), 60 ); |
883 | m_View->addColumn(tr("Mime Type"), -1 ); | 884 | m_View->addColumn(tr("Mime Type"), -1 ); |
884 | QHeader *header = m_View->header(); | 885 | QHeader *header = m_View->header(); |
885 | header->hide(); | 886 | header->hide(); |
886 | m_View->setSorting( 1 ); | 887 | m_View->setSorting( 1 ); |
887 | m_View->setAllColumnsShowFocus( TRUE ); | 888 | m_View->setAllColumnsShowFocus( TRUE ); |
888 | 889 | ||
889 | connect(m_View, SIGNAL(selectionChanged() ), | 890 | connect(m_View, SIGNAL(selectionChanged() ), |
890 | this, SLOT(slotSelectionChanged() ) ); | 891 | this, SLOT(slotSelectionChanged() ) ); |
891 | 892 | ||
892 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), | 893 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), |
893 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | 894 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); |
894 | 895 | ||
895 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | 896 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), |
896 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | 897 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); |
897 | 898 | ||
898 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | 899 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), |
899 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | 900 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); |
900 | 901 | ||
901 | m_pseudoLayout->addWidget( m_View, 288 ); | 902 | m_pseudoLayout->addWidget( m_View, 288 ); |
902 | m_stack->addWidget( m_pseudo, EXTENDED ); | 903 | m_stack->addWidget( m_pseudo, EXTENDED ); |
903 | } | 904 | } |
904 | } | 905 | } |
905 | void OFileSelector::initializePerm() | 906 | void OFileSelector::initializePerm() |
906 | { | 907 | { |
907 | if( m_checkPerm == 0 ){ | 908 | if( m_checkPerm == 0 ){ |
908 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); | 909 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); |
909 | m_checkPerm->setChecked( false ); | 910 | m_checkPerm->setChecked( false ); |
910 | m_lay->addWidget( m_checkPerm ); | 911 | m_lay->addWidget( m_checkPerm ); |
911 | 912 | ||
912 | } | 913 | } |
913 | } | 914 | } |
914 | void OFileSelector::initPics() | 915 | void OFileSelector::initPics() |
915 | { | 916 | { |
916 | m_pixmaps = new QMap<QString,QPixmap>; | 917 | m_pixmaps = new QMap<QString,QPixmap>; |
917 | QPixmap pm = Resource::loadPixmap( "folder" ); | 918 | QPixmap pm = Resource::loadPixmap( "folder" ); |
918 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 919 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
919 | QPainter painter( &pm ); | 920 | QPainter painter( &pm ); |
920 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 921 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
921 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 922 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
922 | m_pixmaps->insert("dirsymlink", pm ); | 923 | m_pixmaps->insert("dirsymlink", pm ); |
923 | 924 | ||
924 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 925 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
925 | QPainter pen(&pm2 ); | 926 | QPainter pen(&pm2 ); |
926 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 927 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
927 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 928 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
928 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 929 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
929 | } | 930 | } |
930 | // if a mime complies with the m_mimeCheck->currentItem | 931 | // if a mime complies with the m_mimeCheck->currentItem |
931 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | 932 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) |
932 | { | 933 | { |
933 | if( mime == "All" ) | 934 | if( mime == "All" ) |
934 | return true; | 935 | return true; |
935 | MimeType type( path ); | 936 | MimeType type( path ); |
936 | if( type.id() == mime ) | 937 | if( type.id() == mime ) |
937 | return true; | 938 | return true; |
938 | return false; | 939 | return false; |
939 | } | 940 | } |
940 | /* check if the mimetype in mime | 941 | /* check if the mimetype in mime |
941 | * complies with the one which is current | 942 | * complies with the one which is current |
942 | */ | 943 | */ |
944 | /* | ||
945 | * We've the mimetype of the file | ||
946 | * We need to get the stringlist of the current mimetype | ||
947 | * | ||
948 | * mime = image/jpeg | ||
949 | * QStringList = 'image/*' | ||
950 | * or QStringList = image/jpeg;image/png;application/x-ogg | ||
951 | * or QStringList = application/x-ogg;image/*; | ||
952 | * with all these mime filters it should get acceptes | ||
953 | * to do so we need to look if mime is contained inside | ||
954 | * the stringlist | ||
955 | * if it's contained return true | ||
956 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' | ||
957 | * is contained in the mimefilter and then we will | ||
958 | * look if both are equal until the '/' | ||
959 | */ | ||
943 | bool OFileSelector::compliesMime( const QString& mime ) { | 960 | bool OFileSelector::compliesMime( const QString& mime ) { |
961 | qWarning("mimetype is %s", mime.latin1() ); | ||
962 | QString currentText; | ||
963 | if (m_shChooser ) | ||
964 | currentText = m_mimeCheck->currentText(); | ||
944 | 965 | ||
966 | qWarning("current text is %s", currentText.latin1() ); | ||
967 | QMap<QString, QStringList>::Iterator it; | ||
968 | QStringList list; | ||
969 | if ( currentText == tr("All") ) return true; | ||
970 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { | ||
971 | it = m_mimetypes.begin(); | ||
972 | list = it.data(); | ||
973 | }else if ( currentText.isEmpty() ) return true; | ||
974 | else{ | ||
975 | it = m_mimetypes.find(currentText ); | ||
976 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; | ||
977 | else qWarning("found"), list = it.data(); | ||
978 | } | ||
979 | // dump it now | ||
980 | //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
981 | // qWarning( "%s", (*it).latin1() ); | ||
982 | //} | ||
983 | |||
984 | |||
985 | if ( list.contains(mime) ) return true; | ||
986 | qWarning("list doesn't contain it "); | ||
987 | QStringList::Iterator it2; | ||
988 | int pos; | ||
989 | int pos2; | ||
990 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { | ||
991 | pos = (*it2).findRev("/*"); | ||
992 | if ( pos >= 0 ) { | ||
993 | if ( mime.contains( (*it2).left(pos) ) ) return true; | ||
994 | } | ||
995 | } | ||
996 | return false; | ||
945 | } | 997 | } |
946 | void OFileSelector::slotFileSelected( const QString &string ) | 998 | void OFileSelector::slotFileSelected( const QString &string ) |
947 | { | 999 | { |
948 | if( m_shLne ) | 1000 | if( m_shLne ) |
949 | m_edit->setText( string ); | 1001 | m_edit->setText( string ); |
950 | emit fileSelected( string ); | 1002 | emit fileSelected( string ); |
951 | } | 1003 | } |
952 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 1004 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
953 | { | 1005 | { |
954 | slotFileSelected( lnk.name() ); | 1006 | slotFileSelected( lnk.name() ); |
955 | // emit fileSelected( lnk ); | 1007 | // emit fileSelected( lnk ); |
956 | } | 1008 | } |
957 | void OFileSelector::slotSelectionChanged() | 1009 | void OFileSelector::slotSelectionChanged() |
958 | { | 1010 | { |
959 | 1011 | ||
960 | } | 1012 | } |
961 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) | 1013 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) |
962 | { | 1014 | { |
963 | if( item == 0 ) | 1015 | if( item == 0 ) |
964 | return; | 1016 | return; |
965 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 1017 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
966 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) | 1018 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) |
967 | if(!sel->isDir() ){ | 1019 | if(!sel->isDir() ){ |
968 | if( m_shLne ) | 1020 | if( m_shLne ) |
969 | m_edit->setText( sel->text(1) ); | 1021 | m_edit->setText( sel->text(1) ); |
970 | } | 1022 | } |
971 | } | 1023 | } |
972 | } | 1024 | } |
973 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) | 1025 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) |
974 | { | 1026 | { |
975 | if ( item == 0 ) | 1027 | if ( item == 0 ) |
976 | return; | 1028 | return; |
977 | 1029 | ||
978 | if( button != Qt::LeftButton ) | 1030 | if( button != Qt::LeftButton ) |
979 | return; | 1031 | return; |
980 | 1032 | ||
981 | switch( m_selector ){ | 1033 | switch( m_selector ){ |
982 | default: | 1034 | default: |
983 | break; | 1035 | break; |
984 | case EXTENDED: // fall through | 1036 | case EXTENDED: // fall through |
985 | case EXTENDED_ALL:{ | 1037 | case EXTENDED_ALL:{ |
986 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 1038 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
987 | if(!sel->isLocked() ){ | 1039 | if(!sel->isLocked() ){ |
988 | QStringList str = QStringList::split("->", sel->text(1) ); | 1040 | QStringList str = QStringList::split("->", sel->text(1) ); |
989 | if( sel->isDir() ){ | 1041 | if( sel->isDir() ){ |
990 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1042 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
991 | // if MODE Dir m_shLne set the Text | 1043 | // if MODE Dir m_shLne set the Text |
992 | }else{ | 1044 | }else{ |
993 | if( m_shLne ) | 1045 | if( m_shLne ) |
994 | m_edit->setText( str[0].stripWhiteSpace() ); | 1046 | m_edit->setText( str[0].stripWhiteSpace() ); |
995 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1047 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
996 | } | 1048 | } |
997 | } | 1049 | } |
998 | break; | 1050 | break; |
999 | } | 1051 | } |
1000 | } | 1052 | } |
1001 | } | 1053 | } |
1002 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | 1054 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) |
1003 | { | 1055 | { |
1004 | if( item == 0 ) | 1056 | if( item == 0 ) |
1005 | return; | 1057 | return; |
1006 | 1058 | ||
1007 | if( button != Qt::RightButton ) | 1059 | if( button != Qt::RightButton ) |
1008 | return; | 1060 | return; |
@@ -1070,129 +1122,129 @@ void OFileSelector::cdUP() | |||
1070 | } | 1122 | } |
1071 | void OFileSelector::slotHome() | 1123 | void OFileSelector::slotHome() |
1072 | { | 1124 | { |
1073 | cd(QDir::homeDirPath() ); | 1125 | cd(QDir::homeDirPath() ); |
1074 | } | 1126 | } |
1075 | void OFileSelector::slotDoc() | 1127 | void OFileSelector::slotDoc() |
1076 | { | 1128 | { |
1077 | cd(QPEApplication::documentDir() ); | 1129 | cd(QPEApplication::documentDir() ); |
1078 | } | 1130 | } |
1079 | void OFileSelector::slotNavigate( ) | 1131 | void OFileSelector::slotNavigate( ) |
1080 | { | 1132 | { |
1081 | 1133 | ||
1082 | } | 1134 | } |
1083 | // fill the View with life | 1135 | // fill the View with life |
1084 | void OFileSelector::reparse() | 1136 | void OFileSelector::reparse() |
1085 | { | 1137 | { |
1086 | if( m_selector == NORMAL ) | 1138 | if( m_selector == NORMAL ) |
1087 | return; | 1139 | return; |
1088 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) | 1140 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) |
1089 | m_View->clear(); | 1141 | m_View->clear(); |
1090 | else // custom view | 1142 | else // custom view |
1091 | ; // currentView()->clear(); | 1143 | ; // currentView()->clear(); |
1092 | if( m_shChooser) | 1144 | if( m_shChooser) |
1093 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); | 1145 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); |
1094 | 1146 | ||
1095 | QString currentMimeType; | 1147 | QString currentMimeType; |
1096 | // let's update the mimetype | 1148 | // let's update the mimetype |
1097 | if( m_autoMime ){ | 1149 | if( m_autoMime ){ |
1098 | m_mimetypes.clear(); | 1150 | m_mimetypes.clear(); |
1099 | // ok we can change mimetype so we need to be able to give a selection | 1151 | // ok we can change mimetype so we need to be able to give a selection |
1100 | if( m_shChooser ) { | 1152 | if( m_shChooser ) { |
1101 | currentMimeType = m_mimeCheck->currentText(); | 1153 | currentMimeType = m_mimeCheck->currentText(); |
1102 | m_mimeCheck->clear(); | 1154 | m_mimeCheck->clear(); |
1103 | 1155 | ||
1104 | // let's find possible mimetypes | 1156 | // let's find possible mimetypes |
1105 | QDir dir( m_currentDir ); | 1157 | QDir dir( m_currentDir ); |
1106 | dir.setFilter( QDir::Files | QDir::Readable ); | 1158 | dir.setFilter( QDir::Files | QDir::Readable ); |
1107 | dir.setSorting( QDir::Size ); | 1159 | dir.setSorting( QDir::Size ); |
1108 | const QFileInfoList *list = dir.entryInfoList(); | 1160 | const QFileInfoList *list = dir.entryInfoList(); |
1109 | QFileInfoListIterator it( *list ); | 1161 | QFileInfoListIterator it( *list ); |
1110 | QFileInfo *fi; | 1162 | QFileInfo *fi; |
1111 | while( (fi=it.current() ) ) { | 1163 | while( (fi=it.current() ) ) { |
1112 | if( fi->extension() == QString::fromLatin1("desktop") ){ | 1164 | if( fi->extension() == QString::fromLatin1("desktop") ){ |
1113 | ++it; | 1165 | ++it; |
1114 | continue; | 1166 | continue; |
1115 | } | 1167 | } |
1116 | MimeType type( fi->absFilePath() ); | 1168 | MimeType type( fi->absFilePath() ); |
1117 | if( !m_mimetypes.contains( type.id() ) ){ | 1169 | if( !m_mimetypes.contains( type.id() ) ){ |
1118 | //qWarning("Type %s", type.id().latin1() ); | 1170 | //qWarning("Type %s", type.id().latin1() ); |
1119 | m_mimetypes.insert( type.id(), type.id() ); | 1171 | m_mimetypes.insert( type.id(), type.id() ); |
1120 | } | 1172 | } |
1121 | 1173 | ||
1122 | ++it; | 1174 | ++it; |
1123 | } | 1175 | } |
1124 | // add them to the chooser | 1176 | // add them to the chooser |
1125 | updateMimeCheck(); | 1177 | updateMimeCheck(); |
1126 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | 1178 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); |
1127 | currentMimeType = m_mimeCheck->currentText(); | 1179 | currentMimeType = m_mimeCheck->currentText(); |
1128 | } | 1180 | } |
1129 | }else { // no autoMime | 1181 | }else { // no autoMime |
1130 | // let the mimetype be set from out side the m_mimeCheck FEATURE | 1182 | // let the mimetype be set from out side the m_mimeCheck FEATURE |
1131 | 1183 | ||
1132 | if( m_shChooser ){ | 1184 | if( m_shChooser ){ |
1133 | currentMimeType = m_mimeCheck->currentText(); | 1185 | currentMimeType = m_mimeCheck->currentText(); |
1134 | updateMimeCheck(); | 1186 | // updateMimeCheck(); |
1135 | } | 1187 | } |
1136 | } | 1188 | } |
1137 | // now we got our mimetypes we can add the files | 1189 | // now we got our mimetypes we can add the files |
1138 | 1190 | ||
1139 | QDir dir( m_currentDir ); | 1191 | QDir dir( m_currentDir ); |
1140 | 1192 | ||
1141 | int sort; | 1193 | int sort; |
1142 | if ( m_case ) | 1194 | if ( m_case ) |
1143 | sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); | 1195 | sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); |
1144 | else | 1196 | else |
1145 | sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); | 1197 | sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); |
1146 | dir.setSorting( sort ); | 1198 | dir.setSorting( sort ); |
1147 | 1199 | ||
1148 | int filter; | 1200 | int filter; |
1149 | if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){ | 1201 | if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){ |
1150 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 1202 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
1151 | }else | 1203 | }else |
1152 | filter = QDir::Files | QDir::Dirs | QDir::All; | 1204 | filter = QDir::Files | QDir::Dirs | QDir::All; |
1153 | dir.setFilter( filter ); | 1205 | dir.setFilter( filter ); |
1154 | 1206 | ||
1155 | // now go through all files | 1207 | // now go through all files |
1156 | const QFileInfoList *list = dir.entryInfoList(); | 1208 | const QFileInfoList *list = dir.entryInfoList(); |
1157 | QFileInfoListIterator it( *list ); | 1209 | QFileInfoListIterator it( *list ); |
1158 | QFileInfo *fi; | 1210 | QFileInfo *fi; |
1159 | while( (fi=it.current() ) ){ | 1211 | while( (fi=it.current() ) ){ |
1160 | //qWarning("True and only" ); | 1212 | //qWarning("True and only" ); |
1161 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 1213 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
1162 | //qWarning(".. or ." ); | 1214 | //qWarning(".. or ." ); |
1163 | ++it; | 1215 | ++it; |
1164 | continue; | 1216 | continue; |
1165 | } | 1217 | } |
1166 | if( fi->isSymLink() ){ | 1218 | if( fi->isSymLink() ){ |
1167 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 1219 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
1168 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | 1220 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos |
1169 | QFileInfo info( file ); | 1221 | QFileInfo info( file ); |
1170 | if( !info.exists() ){ | 1222 | if( !info.exists() ){ |
1171 | addSymlink( currentMimeType, fi, TRUE ); | 1223 | addSymlink( currentMimeType, fi, TRUE ); |
1172 | break; | 1224 | break; |
1173 | }else if( info.isDir() ){ | 1225 | }else if( info.isDir() ){ |
1174 | addDir( currentMimeType, fi, TRUE ); | 1226 | addDir( currentMimeType, fi, TRUE ); |
1175 | break; | 1227 | break; |
1176 | }else if( info.isFile() ){ | 1228 | }else if( info.isFile() ){ |
1177 | addFile( currentMimeType, fi, TRUE ); | 1229 | addFile( currentMimeType, fi, TRUE ); |
1178 | break; | 1230 | break; |
1179 | }else if( info.isSymLink() ){ | 1231 | }else if( info.isSymLink() ){ |
1180 | file = info.dirPath(true ) + "/" + info.readLink() ; | 1232 | file = info.dirPath(true ) + "/" + info.readLink() ; |
1181 | break; | 1233 | break; |
1182 | }else if( i == 4){ | 1234 | }else if( i == 4){ |
1183 | addSymlink( currentMimeType, fi ); | 1235 | addSymlink( currentMimeType, fi ); |
1184 | } | 1236 | } |
1185 | } // off for loop | 1237 | } // off for loop |
1186 | }else if( fi->isDir() ){ | 1238 | }else if( fi->isDir() ){ |
1187 | addDir( currentMimeType, fi ); | 1239 | addDir( currentMimeType, fi ); |
1188 | }else if( fi->isFile() ){ | 1240 | }else if( fi->isFile() ){ |
1189 | addFile( currentMimeType, fi ); | 1241 | addFile( currentMimeType, fi ); |
1190 | } | 1242 | } |
1191 | //qWarning( "%s", fi->fileName().latin1() ); | 1243 | //qWarning( "%s", fi->fileName().latin1() ); |
1192 | ++it; | 1244 | ++it; |
1193 | } // of while loop | 1245 | } // of while loop |
1194 | m_View->sort(); | 1246 | m_View->sort(); |
1195 | if( m_shTool ){ | 1247 | if( m_shTool ){ |
1196 | m_location->insertItem( m_currentDir ); | 1248 | m_location->insertItem( m_currentDir ); |
1197 | 1249 | ||
1198 | } | 1250 | } |