-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 35 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 3 |
2 files changed, 28 insertions, 10 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 7a3a703..8c942a1 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp @@ -153,4 +153,5 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags currentDir.setPath(QDir::currentDirPath()); currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); + currentDir.setNameFilter(filterStr); populateList(); @@ -162,8 +163,4 @@ fileBrowser::~fileBrowser() } -void fileBrowser::setMimeType(const QString &type) { - mimeType = type; -} - void fileBrowser::setFileView( int selection ) { @@ -180,5 +177,4 @@ void fileBrowser::populateList() currentDir.setMatchAllDirs(TRUE); - currentDir.setNameFilter(filterStr); // currentDir.setNameFilter("*.txt;*.etx"); QString fileL, fileS, fileDate; @@ -387,5 +383,5 @@ void fileBrowser::showListMenu(QListViewItem *item) { else m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); - m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); + m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); m.insertSeparator(); @@ -482,5 +478,27 @@ void fileBrowser::showType(const QString &t) { qDebug(t); - mimeType = t+"/*"; + if(t.find("All",0,TRUE) != -1) { + filterStr = "*"; + } else { + QStringList list = mimetypes.grep( t,TRUE); + QString ext; + for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { + mimeType =(*it); + MimeType mt( mimeType); + qDebug("mime "+mimeType); +// qDebug("description "+mt.description()); +// qDebug( "id "+mt.id()); + qDebug("extension "+mt.extension()); + if( mt.extension().isEmpty()) + filterStr = "*"; + else + filterStr = "*."+ mt.extension()+" "; +// printf( "%s \n", (*it).latin1() ); + } + } + currentDir.setNameFilter(filterStr); + + populateList(); + update(); // if(fileSelector) { // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); @@ -492,5 +510,4 @@ void fileBrowser::showType(const QString &t) { // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); // fileSelector->reread(); - repaint(); // if ( t == tr("All") ) { // icons->setTypeFilter("",TRUE); @@ -502,4 +519,5 @@ void fileBrowser::showType(const QString &t) { QStringList fileBrowser::getMimeTypes() { + QStringList r; AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); @@ -513,4 +531,5 @@ QStringList fileBrowser::getMimeTypes() { for ( f = maj.begin(); f != maj.end(); f++ ) { QString temp = *f; + mimetypes << temp; int sl = temp.find('/'); if (sl >= 0) { diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h index 1138d80..339483f 100644 --- a/core/apps/textedit/fileBrowser.h +++ b/core/apps/textedit/fileBrowser.h @@ -59,5 +59,4 @@ public: public slots: void setFileView( int ); - void setMimeType(const QString &); private: @@ -68,5 +67,5 @@ private: QString filterStr, mimeType; QDir currentDir; - QStringList dirPathStringList; + QStringList dirPathStringList, mimetypes; QListViewItem * item; QComboBox *dirPathCombo; |