-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 30 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.h | 3 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector_p.h | 2 |
3 files changed, 12 insertions, 23 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index e8d502f..01a51a2 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp @@ -143,32 +143,38 @@ void OFileViewInterface::fileSelected( const DocLnk& lnk) void OFileViewInterface::setCurrentFileName( const QString& str ) { selector()->m_lneEdit->setText( str ); } QString OFileViewInterface::currentFileName()const { return selector()->m_lneEdit->text(); } QString OFileViewInterface::startDirectory()const { return selector()->m_startDir; } +bool OFileViewInterface::allItem( const QString& item )const +{ + return selector()->m_allList.contains( item ); +} + + ODocumentFileView::ODocumentFileView( OFileSelector* selector ) :OFileViewInterface( selector ) { m_selector = 0; setName( QObject::tr("Documents") ); } ODocumentFileView::~ODocumentFileView() { } QString ODocumentFileView::selectedName()const { if (!m_selector) return QString::null; @@ -517,40 +523,32 @@ OFileSelector* OFileViewFileListView::selector() } bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *k = (QKeyEvent *)e; if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { 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) ) ); } void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { if (!item) return; #if 0 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); @@ -812,33 +810,33 @@ int OFileViewFileSystem::fileCount()const if (!m_view ) return -1; return m_view->fileCount(); } QWidget* OFileViewFileSystem::widget( QWidget* parent ) { if (!m_view ) { m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); } return m_view; } void OFileViewFileSystem::activate( const QString& str ) { - m_all = m_view->allItem( str ); + m_all = allItem( str ); } } /* Selector */ /** * @short new and complete c'tor * * Create a OFileSelector to let the user select a file. It can * either be used to open a file, select a save name in a dir or * as a dropin for the FileSelector. * * <pre> * QMap<QString, QStringList> mimeTypes; * QStringList types; * types << "text@slash* "; @@ -862,33 +860,33 @@ void OFileViewFileSystem::activate( const QString& str ) */ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, const QString& dirName, const QString& fileName, const MimeTypes& mimetypes, bool showNew, bool showClose) :QWidget( parent, "OFileSelector" ) { m_current = 0; m_shNew = showNew; m_shClose = showClose; m_mimeType = mimetypes; m_startDir = dirName; m_mode = mode; m_selector = sel; - m_allList = new QStringList(); + m_allList = QStringList(); initUI(); m_lneEdit->setText( fileName ); initMime(); initViews(); QString str; switch ( m_selector ) { default: case Normal: if ( m_mode == DIRECTORYSELECTOR ) str = QObject::tr("Directories"); else str = QObject::tr("Documents"); m_cmbView->setCurrentItem( 0 ); @@ -1020,38 +1018,38 @@ void OFileSelector::initViews() } else { m_cmbView->insertItem( QObject::tr("Documents") ); m_cmbView->insertItem( QObject::tr("Files") ); m_cmbView->insertItem( QObject::tr("All Files") ); } connect(m_cmbView, SIGNAL(activated(const QString&) ), this, SLOT(slotViewChange(const QString&) ) ); /* 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") ); + 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") ); + m_allList.append( QObject::tr("All Files") ); } } void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { m_viewsPtr.append( iface ); } /** * d'tor */ OFileSelector::~OFileSelector() { m_viewsPtr.setAutoDelete( true ); m_viewsPtr.clear(); } @@ -1145,40 +1143,32 @@ MimeTypes OFileSelector::mimeTypes()const * @return the Mode of the OFileSelector */ int OFileSelector::mode()const { return m_mode; } /** * @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(); } void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) { m_lneEdit->setText( lnk.name() ); emit fileSelected( lnk ); emit fileSelected( lnk.name() ); } diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h index d96712a..d166afd 100644 --- a/libopie2/opieui/fileselector/ofileselector.h +++ b/libopie2/opieui/fileselector/ofileselector.h @@ -108,33 +108,32 @@ public: const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); ~OFileSelector(); const DocLnk* selected(); QString selectedName()const; QString selectedPath()const; QString directory()const; 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 ); /** * Set the Icon visible */ void setCloseVisible( bool b ); /** * Set the Name Line visible */ void setNameVisible( bool b ); @@ -200,33 +199,33 @@ private: Internal::OFileViewInterface* currentView() const; // returns the currentView Internal::OFileViewInterface* m_current; // here is the view saved bool m_shNew : 1; // should we show New? bool m_shClose : 1; // should we show Close? MimeTypes m_mimeType; // list of mimetypes QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr /* views register themselves automatically */ 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; + 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& ); void slotFileBridge( const QString& ); void slotViewChange( const QString& ); bool eventFilter (QObject *o, QEvent *e); }; diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h index 252a7f5..790d2bd 100644 --- a/libopie2/opieui/fileselector/ofileselector_p.h +++ b/libopie2/opieui/fileselector/ofileselector_p.h @@ -62,32 +62,33 @@ class OFileSelector; namespace Internal { class OFileViewInterface { public: OFileViewInterface( OFileSelector* selector ); virtual ~OFileViewInterface(); virtual QString selectedName()const = 0; virtual QString selectedPath()const = 0; virtual QString directory()const = 0; virtual void reread() = 0; virtual int fileCount()const = 0; virtual DocLnk selectedDocument()const; virtual QWidget* widget( QWidget* parent) = 0; virtual void activate( const QString& ); QString name()const; + bool allItem( const QString& )const; protected: OFileSelector* selector()const; void setName( const QString& ); bool showNew()const; bool showClose()const; MimeTypes mimeTypes()const; QStringList currentMimeType()const; QString startDirectory()const; protected: void ok(); void cancel(); void closeMe(); void fileSelected( const QString& ); void fileSelected( const DocLnk& ); void setCurrentFileName( const QString& ); QString currentFileName()const; @@ -139,33 +140,32 @@ private: bool m_locked : 1; bool m_isDir : 1; QString m_dir; }; class OFileViewFileListView : public QWidget { Q_OBJECT 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& ); void slotCurrentChanged( QListViewItem* ); void slotClicked(int, QListViewItem*, const QPoint&, int ); void slotFSActivated(int); protected: OFileSelector* selector(); private: |