author | zecke <zecke> | 2002-10-06 15:40:28 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-06 15:40:28 (UTC) |
commit | 8d3e63d01c9a37dfd27f3b6bd9429c8a0274d90f (patch) (side-by-side diff) | |
tree | fb73b4dd7035b56fd7271a689e80bc2c2067c719 | |
parent | 24393565a48df6bb65516c25c124280724af9a75 (diff) | |
download | opie-8d3e63d01c9a37dfd27f3b6bd9429c8a0274d90f.zip opie-8d3e63d01c9a37dfd27f3b6bd9429c8a0274d90f.tar.gz opie-8d3e63d01c9a37dfd27f3b6bd9429c8a0274d90f.tar.bz2 |
As promised here is the switching
It's working as expected
I'll clean up it a bit fix some UI bugs
and then put it into the libopie.pro
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 100 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.h | 8 |
2 files changed, 94 insertions, 14 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 @@ -369,9 +369,3 @@ void OFileSelector::slotViewCheck(const QString &sel) { - if( sel == tr("Documents" ) ){ - initializeOldSelector(); - m_selector = Normal; - - }else { -; - } + setView( sel ); } @@ -476,3 +470,2 @@ void OFileSelector::init() /* initialize the file lister */ - initLister(); if( m_selector == Normal ){ @@ -650,2 +643,3 @@ void OFileSelector::initializeChooser() updateMimeCheck(); + fillList(); @@ -725,6 +719,2 @@ void OFileSelector::initToolbar() { } -/* initialize the OLocalLister */ -void OFileSelector::initLister() { - m_lister = new OLocalLister(this); -} /* put default locations into the bar */ @@ -941,3 +931,50 @@ void OFileSelector::reparse() } +/* switch lister to @param lister */ +void OFileSelector::setLister(const QString& lister) { + QStringList listerList = factory()->lister(); + + if (listerList.contains(lister) ) { + delete (OLister*) m_lister; + m_lister = factory()->lister( lister, this ); + }else if (!m_lister ) { + /* + * if we do not have a lister + * we need to take the default one + */ + m_lister = new OLocalLister(this); + } + m_listerName = lister; +} +void OFileSelector::setView( const QString& lis ) { + qWarning("setView "); + fillList(); + if ( lis == tr("Documents") ) { + m_selector = Normal; + delete m_lister; + delete m_fileView; + m_lister = 0l; + m_fileView = 0l; + initializeOldSelector(); + }else { + QString list; + delete m_lister; + delete m_fileView; + delete m_select; + m_lister =0l; + m_fileView = 0l; + m_select = 0l; + if ( lis.startsWith("All") ) { + m_selector = ExtendedAll; + list = lis.mid(4 ).stripWhiteSpace(); + } else{ + list = lis; + m_selector = Extended; + } + setLister(m_listerName); + m_fileView = factory()->view( list, this, m_mainView ); + m_mainView->setWidget( m_fileView->widget() ); + reparse(); + } +} /* @@ -952,2 +989,23 @@ void OFileSelector::initFactory() { } +void OFileSelector::fillList() { + qWarning("fill list"); + if (!m_viewCheck ) + return; + + m_viewCheck->clear(); + QStringList list = factory()->views(); + qWarning("views: " + list.join(";") ); + for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { + qWarning( (*it) ); + if ( (*it) == tr("Documents") ) { + m_viewCheck->insertItem( (*it) ); + }else{ + m_viewCheck->insertItem( (*it) ); + m_viewCheck->insertItem( tr("All ") + (*it) ); + } + } +} +OFileFactory* OFileSelector::factory() { + return m_fileFactory; +} @@ -1024 +1082,19 @@ void OFileSelector::initializeOldSelector() { } +/* + * initialize the listview + * we will call fillList + * setLister + * with QString::null to get the default + * setView with either Files or All Files + * depending on Extended + */ +void OFileSelector::initializeView() { + setLister(QString::null); + fillList(); + if (m_selector == Extended ) { + setView( tr("Files") ); + }else{ + setView( tr("All Files") ); + } +} + diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h index 3e834fb..76c3ced 100644 --- a/libopie/ofileselector/ofileselector.h +++ b/libopie/ofileselector/ofileselector.h @@ -39,2 +39,3 @@ #include <qdir.h> +#include <qguardedptr.h> #include <qwidget.h> @@ -233,2 +234,4 @@ class OFileSelector : public QWidget { + void setLister( const QString& name ); + void setView( const QString& all ); /** @@ -379,2 +382,3 @@ class OFileSelector : public QWidget { OLister* m_lister; + QString m_listerName; OFileView* m_fileView; @@ -448,6 +452,6 @@ class OFileSelector : public QWidget { void initializeOldSelector(); - void initLister(); void initToolbar(); void initLocations(); - void initializeView() {}; // FIXME + void initializeView(); // FIXME + void fillList(); void initFactory(); |