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 | 102 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.h | 8 |
2 files changed, 95 insertions, 15 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 @@ -358,31 +358,25 @@ QValueList<DocLnk> OFileSelector::selectedDocuments() const void OFileSelector::slotOk() { emit ok(); } void OFileSelector::slotCancel() { emit cancel(); } /* switch the views */ void OFileSelector::slotViewCheck(const QString &sel) { - if( sel == tr("Documents" ) ){ - initializeOldSelector(); - m_selector = Normal; - - }else { -; - } + setView( sel ); } QString OFileSelector::currentMimeType() const{ QString mime; QString currentText; if (m_shChooser && m_mimeCheck ) currentText = m_mimeCheck->currentText(); qWarning("CurrentText" + currentText ); if (tr("All") == currentText ) return QString::null; else if (currentText.isEmpty() ) { ; @@ -465,25 +459,24 @@ void OFileSelector::locationComboChanged() reparse(); } void OFileSelector::init() { initFactory(); m_lay = new QVBoxLayout( this ); m_lay->setSpacing(0 ); /* take care of the main view... */ initToolbar(); /* initialize the file lister */ - initLister(); if( m_selector == Normal ){ QString mime; if (!m_autoMime) { if (!m_mimetypes.isEmpty() ) { QMap<QString, QStringList>::Iterator it; it = m_mimetypes.begin(); // cause we're in the init mime = it.data().join(";"); } } initializeOldSelector(); }else{ initializeView(); @@ -639,24 +632,25 @@ void OFileSelector::updateMimeCheck() { void OFileSelector::initializeChooser() { if( m_boxView == 0 ){ m_boxView = new QHBox( this ); m_viewCheck = new QComboBox( m_boxView, "view check"); m_mimeCheck = new QComboBox( m_boxView, "mime check"); m_boxView->setSpacing( 8 ); m_lay->addWidget(m_boxView, 0 ); updateMimeCheck(); + fillList(); connect( m_viewCheck, SIGNAL( activated(const QString & ) ), this, SLOT( slotViewCheck(const QString & ) ) ); connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), this, SLOT( slotMimeCheck( const QString & ) ) ); } } /* generate the buttons for the toolbar */ void OFileSelector::initToolbar() { m_mainView = new OFileSelectorMain( this ); /* now generate the tool bar */ @@ -714,28 +708,24 @@ void OFileSelector::initToolbar() { if( !m_shTool ){ m_location->hide( ); m_up->hide( ); m_homeButton->hide( ); m_docButton->hide( ); } if(!m_shClose ) m_close->hide(); m_mainView->setToolbar( m_pseudo ); m_lay->addWidget( m_mainView, 100 ); } -/* initialize the OLocalLister */ -void OFileSelector::initLister() { - m_lister = new OLocalLister(this); -} /* put default locations into the bar */ void OFileSelector::initLocations () { // let;s fill the Location ComboBox StorageInfo storage; const QList<FileSystem> &fs = storage.fileSystems(); QListIterator<FileSystem> it ( fs ); for( ; it.current(); ++it ){ const QString disk = (*it)->name(); const QString path = (*it)->path(); m_location->insertItem(path+ "<-"+disk ); } @@ -930,35 +920,103 @@ void OFileSelector::reparse() currentLister()->reparse( m_currentDir ); /* we're done with adding let's sort */ currentView()->sort(); if( m_shTool ){ m_location->insertItem( m_currentDir ); } // reenable painting and updates } - +/* 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(); + } +} /* * the factory */ void OFileSelector::initFactory() { m_fileFactory = new OFileFactory(); m_fileFactory->addLister(tr("Files"), newLocalLister ); m_fileFactory->addView(tr("List View"), newFileListView ); /* the factory is just a dummy */ m_fileFactory->addView(tr("Documents"), newFileListView ); } +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; +} OFileView* OFileSelector::currentView() { return m_fileView; } OFileView* OFileSelector::currentView() const{ return m_fileView; } int OFileSelector::filter() { int filter; if ( m_selector == ExtendedAll ) filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; @@ -1013,12 +1071,30 @@ void OFileSelector::initializeOldSelector() { m_mainView, "fileselector", FALSE, FALSE); m_select->setCategorySelectVisible( FALSE ); m_select->setTypeComboVisible( FALSE ); connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); connect(m_select, SIGNAL(closeMe() ), this, SIGNAL(closeMe() ) ); //connect to close me and other signals as well m_mainView->setWidget( m_select ); } +/* + * 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 @@ -28,24 +28,25 @@ If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef opiefileselector_h #define opiefileselector_h #include <qpe/fileselector.h> #include <qdir.h> +#include <qguardedptr.h> #include <qwidget.h> #include <qstring.h> #include <qpixmap.h> #include <qstringlist.h> #include <qmap.h> #include <qvaluelist.h> #include <qpe/applnk.h> #include <qlistview.h> /** This is OPIEs FileDialog Widget. You can use it * as a dropin replacement of the fileselector and @@ -222,24 +223,26 @@ class OFileSelector : public QWidget { bool setPermission() const; /** * set ther permission to bool */ void setPermissionChecked( bool check ); /** * set the Selector Mode */ void setMode( int ); + void setLister( const QString& name ); + void setView( const QString& all ); /** * whether or not to show dirs */ bool showDirs()const { return m_dir; } /** * setShowDirs */ void setShowDirs(bool ); /** * set CaseSensetive @@ -368,24 +371,25 @@ class OFileSelector : public QWidget { void locationComboChanged(); private: void init(); void updateMimes(); private: OFileFactory* m_fileFactory; OFileSelectorMain* m_mainView; OLister* m_lister; + QString m_listerName; OFileView* m_fileView; FileSelector* m_select; int m_mode, m_selector; QComboBox *m_location, *m_mimeCheck, *m_viewCheck; QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; QPushButton *m_reread, @@ -437,28 +441,28 @@ class OFileSelector : public QWidget { void initializeChooser(); void initializePerm(); void initPics(); bool compliesMime(const QString &path, const QString &mime); bool compliesMime(const QString& mime ); /** * Updates the QComboBox with the current mimetypes */ void updateMimeCheck(); void initializeOldSelector(); - void initLister(); void initToolbar(); void initLocations(); - void initializeView() {}; // FIXME + void initializeView(); // FIXME + void fillList(); void initFactory(); /** * Returns the current mimetype */ QString currentMimeType()const; class OFileSelectorPrivate; OFileSelectorPrivate *d; static QMap<QString,QPixmap> *m_pixmaps; private slots: void slotFileSelected(const QString & ); // not really meant to be a slot void slotFileBridgeSelected( const DocLnk & ); |