-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 24 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.h | 3 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector_p.h | 1 |
3 files changed, 26 insertions, 2 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 346eeae..e8d502f 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp @@ -525,16 +525,24 @@ bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) { slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); return true; } } return false; } +/** + * @return true if the item show all files or directories + */ +bool OFileViewFileListView::allItem( const QString& item )const +{ + return m_sel->allItem( item ); +} + void OFileViewFileListView::connectSlots() { connect(m_view, SIGNAL(clicked(QListViewItem*) ), this, SLOT(slotCurrentChanged(QListViewItem*) ) ); connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); } @@ -812,17 +820,17 @@ QWidget* OFileViewFileSystem::widget( QWidget* parent ) { m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); } return m_view; } void OFileViewFileSystem::activate( const QString& str) { - m_all = ( str.find( "All" ) != -1 ); + m_all = m_view->allItem( str ); } } /* Selector */ /** * @short new and complete c'tor * @@ -862,16 +870,18 @@ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, m_shNew = showNew; m_shClose = showClose; m_mimeType = mimetypes; m_startDir = dirName; m_mode = mode; m_selector = sel; + m_allList = new QStringList(); + initUI(); m_lneEdit->setText( fileName ); initMime(); initViews(); QString str; switch ( m_selector ) { @@ -1018,20 +1028,22 @@ void OFileSelector::initViews() /* see above why add both */ OFileViewInterface* in = new OFileViewFileSystem( this ); if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) { m_views.insert( QObject::tr("Directories"), in ); m_views.insert( QObject::tr("All Directories"), in ); + m_allList->append( QObject::tr("All Directories") ); } else { m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); m_views.insert( QObject::tr("Files"), in ); m_views.insert( QObject::tr("All Files"), in ); + m_allList->append( QObject::tr("All Files") ); } } void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { m_viewsPtr.append( iface ); } @@ -1141,16 +1153,24 @@ int OFileSelector::mode()const /** * @return the Selector of the OFileSelector */ int OFileSelector::selector()const { return m_selector; } +/** + * @return true if the item show all files or directories + */ +bool OFileSelector::allItem( const QString& item )const +{ + return ( m_allList->findIndex( item ) != -1 ); +} + QStringList OFileSelector::currentMimeType()const { return m_mimeType[m_cmbMime->currentText()]; } void OFileSelector::slotMimeTypeChanged() { reread(); @@ -1170,25 +1190,25 @@ void OFileSelector::slotFileBridge( const QString& str) } void OFileSelector::slotViewChange( const QString& view ) { OFileViewInterface* interface = m_views[view]; if (!interface) return; - interface->activate( view ); if (m_current) m_stack->removeWidget( m_current->widget( m_stack ) ); static int id = 1; m_stack->addWidget( interface->widget(m_stack), id ); m_stack->raiseWidget( id ); + interface->activate( view ); interface->reread(); m_current = interface; id++; } void OFileSelector::setNewVisible( bool b ) { diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h index b1cd405..d96712a 100644 --- a/libopie2/opieui/fileselector/ofileselector.h +++ b/libopie2/opieui/fileselector/ofileselector.h @@ -116,16 +116,17 @@ public: DocLnk selectedDocument()const; int fileCount()const; void reread(); int mode()const; int selector()const; + bool allItem( const QString& )const; /** * Set the Icon visible * @param b Show or Hide the New Button */ void setNewVisible( bool b ); /** @@ -207,16 +208,18 @@ private: QList<Internal::OFileViewInterface> m_viewsPtr; QHBox* m_nameBox; // the LineEdit + Label is hold here QHBox* m_cmbBox; // this holds the two combo boxes QString m_startDir; int m_mode; int m_selector; + QStringList* m_allList; + struct Data; // used for future versions Data *d; private slots: void slotMimeTypeChanged(); /* will set the text of the lineedit and emit a fileChanged signal */ void slotDocLnkBridge( const DocLnk& ); diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h index a3ef8e2..252a7f5 100644 --- a/libopie2/opieui/fileselector/ofileselector_p.h +++ b/libopie2/opieui/fileselector/ofileselector_p.h @@ -147,16 +147,17 @@ class OFileViewFileListView : public QWidget public: OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); ~OFileViewFileListView(); OFileSelectorItem* currentItem()const; void reread( bool all = false ); int fileCount()const; QString currentDir()const; + bool allItem( const QString& )const; protected: bool eventFilter (QObject *o, QEvent *e); private slots: void slotNew(); // will emit newSelected void cdUP(); void cdHome(); void cdDoc(); void changeDir( const QString& ); |