-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 | |||
@@ -151,8 +151,9 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
151 | updateMimeTypeMenu() ; | 151 | updateMimeTypeMenu() ; |
152 | 152 | ||
153 | currentDir.setPath(QDir::currentDirPath()); | 153 | currentDir.setPath(QDir::currentDirPath()); |
154 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); | 154 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); |
155 | currentDir.setNameFilter(filterStr); | ||
155 | 156 | ||
156 | populateList(); | 157 | populateList(); |
157 | move(0,15); | 158 | move(0,15); |
158 | } | 159 | } |
@@ -160,12 +161,8 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
160 | fileBrowser::~fileBrowser() | 161 | fileBrowser::~fileBrowser() |
161 | { | 162 | { |
162 | } | 163 | } |
163 | 164 | ||
164 | void fileBrowser::setMimeType(const QString &type) { | ||
165 | mimeType = type; | ||
166 | } | ||
167 | |||
168 | void fileBrowser::setFileView( int selection ) | 165 | void fileBrowser::setFileView( int selection ) |
169 | { | 166 | { |
170 | SelectionCombo->setCurrentItem( selection ); | 167 | SelectionCombo->setCurrentItem( selection ); |
171 | selectionChanged( SelectionCombo->currentText() ); | 168 | selectionChanged( SelectionCombo->currentText() ); |
@@ -178,9 +175,8 @@ void fileBrowser::populateList() | |||
178 | //qDebug(currentDir.canonicalPath()); | 175 | //qDebug(currentDir.canonicalPath()); |
179 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 176 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
180 | currentDir.setMatchAllDirs(TRUE); | 177 | currentDir.setMatchAllDirs(TRUE); |
181 | 178 | ||
182 | currentDir.setNameFilter(filterStr); | ||
183 | // currentDir.setNameFilter("*.txt;*.etx"); | 179 | // currentDir.setNameFilter("*.txt;*.etx"); |
184 | QString fileL, fileS, fileDate; | 180 | QString fileL, fileS, fileDate; |
185 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 181 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
186 | QFileInfoListIterator it(*list); | 182 | QFileInfoListIterator it(*list); |
@@ -385,9 +381,9 @@ void fileBrowser::showListMenu(QListViewItem *item) { | |||
385 | if( item->text(0).find("/",0,TRUE)) | 381 | if( item->text(0).find("/",0,TRUE)) |
386 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); | 382 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); |
387 | else | 383 | else |
388 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 384 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
389 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); | 385 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); |
390 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 386 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
391 | m.insertSeparator(); | 387 | m.insertSeparator(); |
392 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 388 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
393 | m.exec( QCursor::pos() ); | 389 | m.exec( QCursor::pos() ); |
@@ -480,9 +476,31 @@ void fileBrowser::updateMimeTypeMenu() { | |||
480 | 476 | ||
481 | void fileBrowser::showType(const QString &t) { | 477 | void fileBrowser::showType(const QString &t) { |
482 | 478 | ||
483 | qDebug(t); | 479 | qDebug(t); |
484 | mimeType = t+"/*"; | 480 | if(t.find("All",0,TRUE) != -1) { |
481 | filterStr = "*"; | ||
482 | } else { | ||
483 | QStringList list = mimetypes.grep( t,TRUE); | ||
484 | QString ext; | ||
485 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
486 | mimeType =(*it); | ||
487 | MimeType mt( mimeType); | ||
488 | qDebug("mime "+mimeType); | ||
489 | // qDebug("description "+mt.description()); | ||
490 | // qDebug( "id "+mt.id()); | ||
491 | qDebug("extension "+mt.extension()); | ||
492 | if( mt.extension().isEmpty()) | ||
493 | filterStr = "*"; | ||
494 | else | ||
495 | filterStr = "*."+ mt.extension()+" "; | ||
496 | // printf( "%s \n", (*it).latin1() ); | ||
497 | } | ||
498 | } | ||
499 | currentDir.setNameFilter(filterStr); | ||
500 | |||
501 | populateList(); | ||
502 | update(); | ||
485 | // if(fileSelector) { | 503 | // if(fileSelector) { |
486 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 504 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
487 | // delete fileSelector; | 505 | // delete fileSelector; |
488 | // } | 506 | // } |
@@ -490,9 +508,8 @@ void fileBrowser::showType(const QString &t) { | |||
490 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 508 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
491 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 509 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
492 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 510 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
493 | // fileSelector->reread(); | 511 | // fileSelector->reread(); |
494 | repaint(); | ||
495 | // if ( t == tr("All") ) { | 512 | // if ( t == tr("All") ) { |
496 | // icons->setTypeFilter("",TRUE); | 513 | // icons->setTypeFilter("",TRUE); |
497 | // } else { | 514 | // } else { |
498 | // icons->setTypeFilter(t+"/*",TRUE); | 515 | // icons->setTypeFilter(t+"/*",TRUE); |
@@ -500,8 +517,9 @@ void fileBrowser::showType(const QString &t) { | |||
500 | 517 | ||
501 | } | 518 | } |
502 | 519 | ||
503 | QStringList fileBrowser::getMimeTypes() { | 520 | QStringList fileBrowser::getMimeTypes() { |
521 | |||
504 | QStringList r; | 522 | QStringList r; |
505 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); | 523 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); |
506 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); | 524 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); |
507 | file.open( IO_WriteOnly|IO_Truncate);//) | 525 | file.open( IO_WriteOnly|IO_Truncate);//) |
@@ -511,8 +529,9 @@ QStringList fileBrowser::getMimeTypes() { | |||
511 | QStringList maj = l->mimeTypes(); | 529 | QStringList maj = l->mimeTypes(); |
512 | QStringList::ConstIterator f; | 530 | QStringList::ConstIterator f; |
513 | for ( f = maj.begin(); f != maj.end(); f++ ) { | 531 | for ( f = maj.begin(); f != maj.end(); f++ ) { |
514 | QString temp = *f; | 532 | QString temp = *f; |
533 | mimetypes << temp; | ||
515 | int sl = temp.find('/'); | 534 | int sl = temp.find('/'); |
516 | if (sl >= 0) { | 535 | if (sl >= 0) { |
517 | QString k = temp.left(sl); | 536 | QString k = temp.left(sl); |
518 | if( r.grep(k,TRUE).isEmpty() ) { | 537 | if( r.grep(k,TRUE).isEmpty() ) { |
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 | |||
@@ -57,18 +57,17 @@ public: | |||
57 | QStringList fileList; | 57 | QStringList fileList; |
58 | QComboBox *SelectionCombo; | 58 | QComboBox *SelectionCombo; |
59 | public slots: | 59 | public slots: |
60 | void setFileView( int ); | 60 | void setFileView( int ); |
61 | void setMimeType(const QString &); | ||
62 | 61 | ||
63 | private: | 62 | private: |
64 | // QDict<void> mimes; | 63 | // QDict<void> mimes; |
65 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; | 64 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; |
66 | QListView* ListView; | 65 | QListView* ListView; |
67 | QLabel *dirLabel; | 66 | QLabel *dirLabel; |
68 | QString filterStr, mimeType; | 67 | QString filterStr, mimeType; |
69 | QDir currentDir; | 68 | QDir currentDir; |
70 | QStringList dirPathStringList; | 69 | QStringList dirPathStringList, mimetypes; |
71 | QListViewItem * item; | 70 | QListViewItem * item; |
72 | QComboBox *dirPathCombo; | 71 | QComboBox *dirPathCombo; |
73 | MenuButton *typemb; | 72 | MenuButton *typemb; |
74 | QWidgetStack *FileStack; | 73 | QWidgetStack *FileStack; |