author | zecke <zecke> | 2002-10-05 22:20:57 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-05 22:20:57 (UTC) |
commit | 99425255c4afcd75ee6b2f903487cb958d3acdee (patch) (side-by-side diff) | |
tree | 8cce0b096ce9a000291044def444f30934c79888 | |
parent | 94180a2019a945e6a492405dc6a30420c760529f (diff) | |
download | opie-99425255c4afcd75ee6b2f903487cb958d3acdee.zip opie-99425255c4afcd75ee6b2f903487cb958d3acdee.tar.gz opie-99425255c4afcd75ee6b2f903487cb958d3acdee.tar.bz2 |
So now switching is about to be implemented the next commit will have a completed OListe/OFileView switch
-rw-r--r-- | libopie/ofileselector/odefaultfactories.cpp | 15 | ||||
-rw-r--r-- | libopie/ofileselector/odefaultfactories.h | 14 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 32 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.h | 4 |
4 files changed, 49 insertions, 16 deletions
diff --git a/libopie/ofileselector/odefaultfactories.cpp b/libopie/ofileselector/odefaultfactories.cpp new file mode 100644 index 0000000..c41fbca --- a/dev/null +++ b/libopie/ofileselector/odefaultfactories.cpp @@ -0,0 +1,15 @@ +#include "ofilelistview.h" +#include "olocallister.h" + +#include "odefaultfactories.h" + +extern "C" { + + OFileView* newFileListView( OFileSelector* sel, QWidget* par ) { + return new OFileListView(par, sel ); + } + OLister* newLocalLister( OFileSelector* sel) { + return new OLocalLister( sel ); + } + +}; diff --git a/libopie/ofileselector/odefaultfactories.h b/libopie/ofileselector/odefaultfactories.h new file mode 100644 index 0000000..eb698d3 --- a/dev/null +++ b/libopie/ofileselector/odefaultfactories.h @@ -0,0 +1,14 @@ +#ifndef OPIE_DEFAULT_FACTORIES_H +#define OPIE_DEFAULT_FACTORIES_H + +#include "ofilefactory.h" + +extern "C" { + + OFileView* newFileListView( OFileSelector*, QWidget* parent ); + OLister* newLocalLister(OFileSelector* ); + +}; + + +#endif diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index 458d432..91a510f 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp @@ -25,24 +25,25 @@ #include <qpe/resource.h> #include <qpe/storage.h> #include <unistd.h> #include <stdlib.h> #include <sys/stat.h> #include "ofileview.h" #include "ofileselectormain.h" #include "ofileselector.h" #include "olocallister.h" #include "olister.h" +#include "odefaultfactories.h" QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; namespace { /* let's find the index for a specified string */ int indexByString( const QComboBox *box, const QString &str ){ int index= 0; for(int i= 0; i < box->count(); i++ ){ /* found */ if( str == box->text(i ) ){ index= i; break; @@ -288,27 +289,25 @@ QStringList OFileSelector::selectedNames()const } return list; } /** If mode is set to the Dir selection this will return the selected path. * * */ QString OFileSelector::selectedPath()const { QString path; if( m_selector == Normal ){ path = QPEApplication::documentDir(); - } /*else if( m_selector == Extended || m_selector == ExtendedAll ){ - ; - }*/ + } /* normal case to do */ return path; } QStringList OFileSelector::selectedPaths() const { QStringList list; list << selectedPath(); return list; } QString OFileSelector::directory()const { if( m_selector == Normal ) return QPEApplication::documentDir(); @@ -363,33 +362,26 @@ void OFileSelector::slotOk() } void OFileSelector::slotCancel() { emit cancel(); } /* switch the views */ void OFileSelector::slotViewCheck(const QString &sel) { if( sel == tr("Documents" ) ){ initializeOldSelector(); m_selector = Normal; - }else if( sel == tr("Files") ){ - m_selector = Extended; - - // FIXME call the factory - //reparse(); - }else if( sel == tr("All Files") ){ - m_selector = ExtendedAll; -/* see above - reparse(); */ + }else { +; } } 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,24 +457,25 @@ void OFileSelector::locationComboChanged() { QFileInfo info( m_location->lineEdit()->text() ); qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); if (info.isFile() ) cd(info.dirPath(TRUE) ); //absolute path else cd( m_location->lineEdit()->text() ); 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() ) { @@ -644,28 +637,24 @@ 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 ); - m_viewCheck->insertItem( tr("Documents") ); - m_viewCheck->insertItem( tr("Files") ); - m_viewCheck->insertItem( tr("All Files") ); - /* update to custom views */ updateMimeCheck(); 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 ); @@ -942,24 +931,35 @@ 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 } +/* + * 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 ); +} + 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; else diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h index bf9a26b..3e834fb 100644 --- a/libopie/ofileselector/ofileselector.h +++ b/libopie/ofileselector/ofileselector.h @@ -61,24 +61,25 @@ class QPushButton; class QGridLayout; class QLineEdit; class QLabel; class QWidgetStack; class QHBoxLayout; class QVBoxLayout; class QPopupMenu; class QFileInfo; class QHBox; class OFileView; class OLister; class OFileSelectorMain; +class OFileFactory; // /* the mimetypes one name and a list of mimetypes */ typedef QMap< QString, QStringList> MimeTypes; /** * FIXME later */ struct OPopupMenuFactory { OPopupMenuFactory() {} }; @@ -331,24 +332,25 @@ class OFileSelector : public QWidget { /** * fileCount */ int fileCount(); DocLnk selectedDocument()const; QValueList<DocLnk> selectedDocuments()const; OFileView* currentView(); OFileView* currentView()const; OLister* currentLister()const; + OFileFactory* factory(); int filter(); int sorting(); QPixmap pixmap( const QString& ); /* our tool bar */ QWidget* toolBar(); signals: void fileSelected( const DocLnk & ); void fileSelected( const QString & ); void dirSelected(const QString &dir ); void dirSelected( const QDir& ); void closeMe(); @@ -363,24 +365,25 @@ class OFileSelector : public QWidget { void slotMimeCheck(const QString & ); void slotLocationActivated(const QString & ); void slotInsertLocationPath(const QString &, int); void locationComboChanged(); private: void init(); void updateMimes(); private: + OFileFactory* m_fileFactory; OFileSelectorMain* m_mainView; OLister* m_lister; 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, @@ -438,24 +441,25 @@ class OFileSelector : public QWidget { 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 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 & ); // listview above |