Diffstat (limited to 'libopie2/opieui/fileselector/ofileselector.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index b06defd..346eeae 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp | |||
@@ -419,28 +419,31 @@ void OFileViewFileListView::reread( bool all ) | |||
419 | else | 419 | else |
420 | m_btnNew->hide(); | 420 | m_btnNew->hide(); |
421 | 421 | ||
422 | m_mimes = selector()->currentMimeType(); | 422 | m_mimes = selector()->currentMimeType(); |
423 | m_all = all; | 423 | m_all = all; |
424 | 424 | ||
425 | QDir dir( m_currentDir ); | 425 | QDir dir( m_currentDir ); |
426 | if (!dir.exists() ) | 426 | if (!dir.exists() ) |
427 | return; | 427 | return; |
428 | 428 | ||
429 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 429 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
430 | int filter; | 430 | int filter; |
431 | filter = QDir::Dirs; | ||
432 | if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) | ||
433 | filter = filter | QDir::Files | QDir::All; | ||
434 | |||
431 | if (m_all ) | 435 | if (m_all ) |
432 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 436 | filter = filter | QDir::Hidden; |
433 | else | 437 | |
434 | filter = QDir::Files | QDir::Dirs | QDir::All; | ||
435 | dir.setFilter( filter ); | 438 | dir.setFilter( filter ); |
436 | 439 | ||
437 | // now go through all files | 440 | // now go through all files |
438 | const QFileInfoList *list = dir.entryInfoList(); | 441 | const QFileInfoList *list = dir.entryInfoList(); |
439 | if (!list) | 442 | if (!list) |
440 | { | 443 | { |
441 | cdUP(); | 444 | cdUP(); |
442 | return; | 445 | return; |
443 | } | 446 | } |
444 | 447 | ||
445 | QFileInfoListIterator it( *list ); | 448 | QFileInfoListIterator it( *list ); |
446 | QFileInfo *fi; | 449 | QFileInfo *fi; |
@@ -805,25 +808,25 @@ int OFileViewFileSystem::fileCount()const | |||
805 | 808 | ||
806 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) | 809 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) |
807 | { | 810 | { |
808 | if (!m_view ) | 811 | if (!m_view ) |
809 | { | 812 | { |
810 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 813 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
811 | } | 814 | } |
812 | return m_view; | 815 | return m_view; |
813 | } | 816 | } |
814 | 817 | ||
815 | void OFileViewFileSystem::activate( const QString& str) | 818 | void OFileViewFileSystem::activate( const QString& str) |
816 | { | 819 | { |
817 | m_all = (str != QObject::tr("Files") ); | 820 | m_all = ( str.find( "All" ) != -1 ); |
818 | } | 821 | } |
819 | 822 | ||
820 | 823 | ||
821 | } | 824 | } |
822 | /* Selector */ | 825 | /* Selector */ |
823 | /** | 826 | /** |
824 | * @short new and complete c'tor | 827 | * @short new and complete c'tor |
825 | * | 828 | * |
826 | * Create a OFileSelector to let the user select a file. It can | 829 | * Create a OFileSelector to let the user select a file. It can |
827 | * either be used to open a file, select a save name in a dir or | 830 | * either be used to open a file, select a save name in a dir or |
828 | * as a dropin for the FileSelector. | 831 | * as a dropin for the FileSelector. |
829 | * | 832 | * |
@@ -865,34 +868,49 @@ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | |||
865 | m_selector = sel; | 868 | m_selector = sel; |
866 | 869 | ||
867 | initUI(); | 870 | initUI(); |
868 | m_lneEdit->setText( fileName ); | 871 | m_lneEdit->setText( fileName ); |
869 | initMime(); | 872 | initMime(); |
870 | initViews(); | 873 | initViews(); |
871 | 874 | ||
872 | QString str; | 875 | QString str; |
873 | switch ( m_selector ) | 876 | switch ( m_selector ) |
874 | { | 877 | { |
875 | default: | 878 | default: |
876 | case Normal: | 879 | case Normal: |
880 | if ( m_mode == DIRECTORYSELECTOR ) | ||
881 | str = QObject::tr("Directories"); | ||
882 | else | ||
877 | str = QObject::tr("Documents"); | 883 | str = QObject::tr("Documents"); |
878 | m_cmbView->setCurrentItem( 0 ); | 884 | m_cmbView->setCurrentItem( 0 ); |
879 | break; | 885 | break; |
880 | case Extended: | 886 | case Extended: |
887 | if ( m_mode == DIRECTORYSELECTOR ) | ||
888 | { | ||
889 | str = QObject::tr("Directories"); | ||
890 | m_cmbView->setCurrentItem( 0 ); | ||
891 | } else { | ||
881 | str = QObject::tr("Files"); | 892 | str = QObject::tr("Files"); |
882 | m_cmbView->setCurrentItem( 1 ); | 893 | m_cmbView->setCurrentItem( 1 ); |
894 | } | ||
883 | break; | 895 | break; |
884 | case ExtendedAll: | 896 | case ExtendedAll: |
897 | if ( m_mode == DIRECTORYSELECTOR ) | ||
898 | { | ||
899 | str = QObject::tr("All Directories"); | ||
900 | m_cmbView->setCurrentItem( 1 ); | ||
901 | } else { | ||
885 | str = QObject::tr("All Files"); | 902 | str = QObject::tr("All Files"); |
886 | m_cmbView->setCurrentItem( 2 ); | 903 | m_cmbView->setCurrentItem( 2 ); |
904 | } | ||
887 | break; | 905 | break; |
888 | } | 906 | } |
889 | slotViewChange( str ); | 907 | slotViewChange( str ); |
890 | 908 | ||
891 | } | 909 | } |
892 | 910 | ||
893 | 911 | ||
894 | /** | 912 | /** |
895 | * This a convience c'tor to just substitute the use of FileSelector | 913 | * This a convience c'tor to just substitute the use of FileSelector |
896 | */ | 914 | */ |
897 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 915 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
898 | bool showNew, bool showClose ) | 916 | bool showNew, bool showClose ) |
@@ -976,38 +994,50 @@ void OFileSelector::initMime() | |||
976 | { | 994 | { |
977 | m_cmbMime->insertItem( it.key() ); | 995 | m_cmbMime->insertItem( it.key() ); |
978 | } | 996 | } |
979 | m_cmbMime->setCurrentItem( 0 ); | 997 | m_cmbMime->setCurrentItem( 0 ); |
980 | 998 | ||
981 | connect( m_cmbMime, SIGNAL(activated(int) ), | 999 | connect( m_cmbMime, SIGNAL(activated(int) ), |
982 | this, SLOT(slotMimeTypeChanged() ) ); | 1000 | this, SLOT(slotMimeTypeChanged() ) ); |
983 | 1001 | ||
984 | } | 1002 | } |
985 | 1003 | ||
986 | void OFileSelector::initViews() | 1004 | void OFileSelector::initViews() |
987 | { | 1005 | { |
1006 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) | ||
1007 | { | ||
1008 | m_cmbView->insertItem( QObject::tr("Directories") ); | ||
1009 | m_cmbView->insertItem( QObject::tr("All Directories") ); | ||
1010 | } else { | ||
988 | m_cmbView->insertItem( QObject::tr("Documents") ); | 1011 | m_cmbView->insertItem( QObject::tr("Documents") ); |
989 | m_cmbView->insertItem( QObject::tr("Files") ); | 1012 | m_cmbView->insertItem( QObject::tr("Files") ); |
990 | m_cmbView->insertItem( QObject::tr("All Files") ); | 1013 | m_cmbView->insertItem( QObject::tr("All Files") ); |
1014 | } | ||
1015 | |||
991 | connect(m_cmbView, SIGNAL(activated(const QString&) ), | 1016 | connect(m_cmbView, SIGNAL(activated(const QString&) ), |
992 | this, SLOT(slotViewChange(const QString&) ) ); | 1017 | this, SLOT(slotViewChange(const QString&) ) ); |
993 | 1018 | ||
994 | |||
995 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); | ||
996 | |||
997 | /* see above why add both */ | 1019 | /* see above why add both */ |
998 | OFileViewInterface* in = new OFileViewFileSystem( this ); | 1020 | OFileViewInterface* in = new OFileViewFileSystem( this ); |
1021 | |||
1022 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) | ||
1023 | { | ||
1024 | m_views.insert( QObject::tr("Directories"), in ); | ||
1025 | m_views.insert( QObject::tr("All Directories"), in ); | ||
1026 | } else { | ||
1027 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); | ||
999 | m_views.insert( QObject::tr("Files"), in ); | 1028 | m_views.insert( QObject::tr("Files"), in ); |
1000 | m_views.insert( QObject::tr("All Files"), in ); | 1029 | m_views.insert( QObject::tr("All Files"), in ); |
1001 | } | 1030 | } |
1031 | } | ||
1002 | 1032 | ||
1003 | void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { | 1033 | void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { |
1004 | m_viewsPtr.append( iface ); | 1034 | m_viewsPtr.append( iface ); |
1005 | } | 1035 | } |
1006 | 1036 | ||
1007 | 1037 | ||
1008 | /** | 1038 | /** |
1009 | * d'tor | 1039 | * d'tor |
1010 | */ | 1040 | */ |
1011 | OFileSelector::~OFileSelector() | 1041 | OFileSelector::~OFileSelector() |
1012 | { | 1042 | { |
1013 | m_viewsPtr.setAutoDelete( true ); | 1043 | m_viewsPtr.setAutoDelete( true ); |