Diffstat (limited to 'libopie/ofileselector/ofileselector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 102 |
1 files changed, 89 insertions, 13 deletions
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index 91a510f..7f38f5b 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp | |||
@@ -367,13 +367,7 @@ void OFileSelector::slotCancel() | |||
367 | /* switch the views */ | 367 | /* switch the views */ |
368 | void OFileSelector::slotViewCheck(const QString &sel) | 368 | void OFileSelector::slotViewCheck(const QString &sel) |
369 | { | 369 | { |
370 | if( sel == tr("Documents" ) ){ | 370 | setView( sel ); |
371 | initializeOldSelector(); | ||
372 | m_selector = Normal; | ||
373 | |||
374 | }else { | ||
375 | ; | ||
376 | } | ||
377 | } | 371 | } |
378 | 372 | ||
379 | QString OFileSelector::currentMimeType() const{ | 373 | QString OFileSelector::currentMimeType() const{ |
@@ -474,7 +468,6 @@ void OFileSelector::init() | |||
474 | initToolbar(); | 468 | initToolbar(); |
475 | 469 | ||
476 | /* initialize the file lister */ | 470 | /* initialize the file lister */ |
477 | initLister(); | ||
478 | if( m_selector == Normal ){ | 471 | if( m_selector == Normal ){ |
479 | QString mime; | 472 | QString mime; |
480 | if (!m_autoMime) { | 473 | if (!m_autoMime) { |
@@ -648,6 +641,7 @@ void OFileSelector::initializeChooser() | |||
648 | 641 | ||
649 | 642 | ||
650 | updateMimeCheck(); | 643 | updateMimeCheck(); |
644 | fillList(); | ||
651 | 645 | ||
652 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 646 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
653 | this, SLOT( slotViewCheck(const QString & ) ) ); | 647 | this, SLOT( slotViewCheck(const QString & ) ) ); |
@@ -723,10 +717,6 @@ void OFileSelector::initToolbar() { | |||
723 | m_mainView->setToolbar( m_pseudo ); | 717 | m_mainView->setToolbar( m_pseudo ); |
724 | m_lay->addWidget( m_mainView, 100 ); | 718 | m_lay->addWidget( m_mainView, 100 ); |
725 | } | 719 | } |
726 | /* initialize the OLocalLister */ | ||
727 | void OFileSelector::initLister() { | ||
728 | m_lister = new OLocalLister(this); | ||
729 | } | ||
730 | /* put default locations into the bar */ | 720 | /* put default locations into the bar */ |
731 | void OFileSelector::initLocations () { | 721 | void OFileSelector::initLocations () { |
732 | 722 | ||
@@ -939,7 +929,54 @@ void OFileSelector::reparse() | |||
939 | } | 929 | } |
940 | // reenable painting and updates | 930 | // reenable painting and updates |
941 | } | 931 | } |
942 | 932 | /* switch lister to @param lister */ | |
933 | void OFileSelector::setLister(const QString& lister) { | ||
934 | QStringList listerList = factory()->lister(); | ||
935 | |||
936 | if (listerList.contains(lister) ) { | ||
937 | delete (OLister*) m_lister; | ||
938 | m_lister = factory()->lister( lister, this ); | ||
939 | }else if (!m_lister ) { | ||
940 | /* | ||
941 | * if we do not have a lister | ||
942 | * we need to take the default one | ||
943 | */ | ||
944 | m_lister = new OLocalLister(this); | ||
945 | } | ||
946 | m_listerName = lister; | ||
947 | } | ||
948 | void OFileSelector::setView( const QString& lis ) { | ||
949 | qWarning("setView "); | ||
950 | fillList(); | ||
951 | if ( lis == tr("Documents") ) { | ||
952 | m_selector = Normal; | ||
953 | delete m_lister; | ||
954 | delete m_fileView; | ||
955 | m_lister = 0l; | ||
956 | m_fileView = 0l; | ||
957 | initializeOldSelector(); | ||
958 | }else { | ||
959 | QString list; | ||
960 | |||
961 | delete m_lister; | ||
962 | delete m_fileView; | ||
963 | delete m_select; | ||
964 | m_lister =0l; | ||
965 | m_fileView = 0l; | ||
966 | m_select = 0l; | ||
967 | if ( lis.startsWith("All") ) { | ||
968 | m_selector = ExtendedAll; | ||
969 | list = lis.mid(4 ).stripWhiteSpace(); | ||
970 | } else{ | ||
971 | list = lis; | ||
972 | m_selector = Extended; | ||
973 | } | ||
974 | setLister(m_listerName); | ||
975 | m_fileView = factory()->view( list, this, m_mainView ); | ||
976 | m_mainView->setWidget( m_fileView->widget() ); | ||
977 | reparse(); | ||
978 | } | ||
979 | } | ||
943 | /* | 980 | /* |
944 | * the factory | 981 | * the factory |
945 | */ | 982 | */ |
@@ -950,6 +987,27 @@ void OFileSelector::initFactory() { | |||
950 | /* the factory is just a dummy */ | 987 | /* the factory is just a dummy */ |
951 | m_fileFactory->addView(tr("Documents"), newFileListView ); | 988 | m_fileFactory->addView(tr("Documents"), newFileListView ); |
952 | } | 989 | } |
990 | void OFileSelector::fillList() { | ||
991 | qWarning("fill list"); | ||
992 | if (!m_viewCheck ) | ||
993 | return; | ||
994 | |||
995 | m_viewCheck->clear(); | ||
996 | QStringList list = factory()->views(); | ||
997 | qWarning("views: " + list.join(";") ); | ||
998 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
999 | qWarning( (*it) ); | ||
1000 | if ( (*it) == tr("Documents") ) { | ||
1001 | m_viewCheck->insertItem( (*it) ); | ||
1002 | }else{ | ||
1003 | m_viewCheck->insertItem( (*it) ); | ||
1004 | m_viewCheck->insertItem( tr("All ") + (*it) ); | ||
1005 | } | ||
1006 | } | ||
1007 | } | ||
1008 | OFileFactory* OFileSelector::factory() { | ||
1009 | return m_fileFactory; | ||
1010 | } | ||
953 | 1011 | ||
954 | 1012 | ||
955 | OFileView* OFileSelector::currentView() { | 1013 | OFileView* OFileSelector::currentView() { |
@@ -1022,3 +1080,21 @@ void OFileSelector::initializeOldSelector() { | |||
1022 | //connect to close me and other signals as well | 1080 | //connect to close me and other signals as well |
1023 | m_mainView->setWidget( m_select ); | 1081 | m_mainView->setWidget( m_select ); |
1024 | } | 1082 | } |
1083 | /* | ||
1084 | * initialize the listview | ||
1085 | * we will call fillList | ||
1086 | * setLister | ||
1087 | * with QString::null to get the default | ||
1088 | * setView with either Files or All Files | ||
1089 | * depending on Extended | ||
1090 | */ | ||
1091 | void OFileSelector::initializeView() { | ||
1092 | setLister(QString::null); | ||
1093 | fillList(); | ||
1094 | if (m_selector == Extended ) { | ||
1095 | setView( tr("Files") ); | ||
1096 | }else{ | ||
1097 | setView( tr("All Files") ); | ||
1098 | } | ||
1099 | } | ||
1100 | |||