Diffstat (limited to 'core/apps/textedit/fileBrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 35 |
1 files changed, 27 insertions, 8 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 @@ -151,8 +151,9 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags updateMimeTypeMenu() ; currentDir.setPath(QDir::currentDirPath()); currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); + currentDir.setNameFilter(filterStr); populateList(); move(0,15); } @@ -160,12 +161,8 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fileBrowser::~fileBrowser() { } -void fileBrowser::setMimeType(const QString &type) { - mimeType = type; -} - void fileBrowser::setFileView( int selection ) { SelectionCombo->setCurrentItem( selection ); selectionChanged( SelectionCombo->currentText() ); @@ -178,9 +175,8 @@ void fileBrowser::populateList() //qDebug(currentDir.canonicalPath()); currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentDir.setMatchAllDirs(TRUE); - currentDir.setNameFilter(filterStr); // currentDir.setNameFilter("*.txt;*.etx"); QString fileL, fileS, fileDate; const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); QFileInfoListIterator it(*list); @@ -385,9 +381,9 @@ void fileBrowser::showListMenu(QListViewItem *item) { if( item->text(0).find("/",0,TRUE)) m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); 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(); m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); m.exec( QCursor::pos() ); @@ -480,9 +476,31 @@ void fileBrowser::updateMimeTypeMenu() { 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 & ) ) ); // delete fileSelector; // } @@ -490,9 +508,8 @@ void fileBrowser::showType(const QString &t) { // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); // fileSelector->reread(); - repaint(); // if ( t == tr("All") ) { // icons->setTypeFilter("",TRUE); // } else { // icons->setTypeFilter(t+"/*",TRUE); @@ -500,8 +517,9 @@ void fileBrowser::showType(const QString &t) { } QStringList fileBrowser::getMimeTypes() { + QStringList r; AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); QFile file( QPEApplication::qpeDir()+"etc/available.mime"); file.open( IO_WriteOnly|IO_Truncate);//) @@ -511,8 +529,9 @@ QStringList fileBrowser::getMimeTypes() { QStringList maj = l->mimeTypes(); QStringList::ConstIterator f; for ( f = maj.begin(); f != maj.end(); f++ ) { QString temp = *f; + mimetypes << temp; int sl = temp.find('/'); if (sl >= 0) { QString k = temp.left(sl); if( r.grep(k,TRUE).isEmpty() ) { |