author | llornkcor <llornkcor> | 2002-04-19 12:09:05 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-19 12:09:05 (UTC) |
commit | 9233f285e5f3366ca5e1d44892e0797d7ef0608c (patch) (unidiff) | |
tree | f4599e33492b04d7d8a9250d662e8bb814313bdf | |
parent | 6ffbfe7daee3b01b8dce2afa9036b70b187a8fc7 (diff) | |
download | opie-9233f285e5f3366ca5e1d44892e0797d7ef0608c.zip opie-9233f285e5f3366ca5e1d44892e0797d7ef0608c.tar.gz opie-9233f285e5f3366ca5e1d44892e0797d7ef0608c.tar.bz2 |
fixed a slight bugy
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 59 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 75 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 2 |
3 files changed, 77 insertions, 59 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index f322513..fced326 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -10,9 +10,9 @@ | |||
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | //#define QTOPIA_INTERNAL_MIMEEXT | 14 | #define QTOPIA_INTERNAL_MIMEEXT |
15 | #include "fileBrowser.h" | 15 | #include "fileBrowser.h" |
16 | //#include "inputDialog.h" | 16 | //#include "inputDialog.h" |
17 | 17 | ||
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
@@ -49,26 +49,32 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
49 | { | 49 | { |
50 | if ( !name ) | 50 | if ( !name ) |
51 | setName( "fileBrowser" ); | 51 | setName( "fileBrowser" ); |
52 | setCaption(tr( name ) ); | 52 | setCaption(tr( name ) ); |
53 | // mimeType = mimeFilter; | ||
54 | // MimeType mt( mimeType); | ||
55 | // if( mt.extension().isEmpty()) | ||
56 | // QStringList filterList; | ||
57 | // filterList=QStringList::split(";",mimeFilter,FALSE); | ||
58 | // for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { | ||
59 | // printf( "%s \n", (*it).latin1() ); | ||
60 | // } | ||
61 | 53 | ||
62 | filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*"; | 54 | // getMimeTypes(); |
55 | |||
56 | mimeType = mimeFilter; | ||
57 | MimeType mt( mimeType); | ||
58 | |||
59 | if( mt.extension().isEmpty()) { | ||
60 | |||
61 | QStringList filterList; | ||
62 | filterList=QStringList::split(";",mimeFilter,FALSE); | ||
63 | |||
64 | for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { | ||
65 | printf( "%s \n", (*it).latin1() ); | ||
66 | } | ||
67 | |||
68 | filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*"; | ||
63 | 69 | ||
64 | qDebug(filterStr); | 70 | qDebug(filterStr); |
65 | // else | 71 | } else { |
66 | // filterStr = "*."+ mt.extension(); | 72 | filterStr = "*."+ mt.extension(); |
67 | // qDebug("description "+mt.description()); | 73 | // qDebug("description "+mt.description()); |
68 | // qDebug( "id "+mt.id()); | 74 | // qDebug( "id "+mt.id()); |
69 | // qDebug("extension "+mt.extension()); | 75 | // qDebug("extension "+mt.extension()); |
70 | 76 | } | |
71 | // channel = new QCopChannel( "QPE/fileDialog", this ); | 77 | // channel = new QCopChannel( "QPE/fileDialog", this ); |
72 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 78 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
73 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); | 79 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); |
74 | 80 | ||
@@ -233,9 +239,9 @@ void fileBrowser::populateList() | |||
233 | } | 239 | } |
234 | if( fileL.find("->",0,TRUE) != -1) { | 240 | if( fileL.find("->",0,TRUE) != -1) { |
235 | // overlay link image | 241 | // overlay link image |
236 | pm= Resource::loadPixmap( "folder" ); | 242 | pm= Resource::loadPixmap( "folder" ); |
237 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 243 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
238 | QPainter painter( &pm ); | 244 | QPainter painter( &pm ); |
239 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 245 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
240 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 246 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
241 | item->setPixmap( 0, pm); | 247 | item->setPixmap( 0, pm); |
@@ -491,25 +497,27 @@ void fileBrowser::updateMimeTypeMenu() { | |||
491 | } | 497 | } |
492 | 498 | ||
493 | void fileBrowser::showType(const QString &t) { | 499 | void fileBrowser::showType(const QString &t) { |
494 | 500 | ||
495 | qDebug(t); | 501 | // qDebug("Show type "+t); |
496 | if(t.find("All",0,TRUE) != -1) { | 502 | if(t.find("All",0,TRUE) != -1) { |
497 | filterStr = "*"; | 503 | filterStr = "*"; |
498 | } else { | 504 | } else { |
499 | QStringList list = mimetypes.grep( t,TRUE); | 505 | QStringList list = mimetypes.grep( t,TRUE); |
500 | QString ext; | 506 | QString ext; |
501 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 507 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
502 | mimeType =(*it); | 508 | mimeType =(*it); |
503 | MimeType mt( mimeType); | 509 | MimeType mt(mimeType); |
504 | // qDebug("mime "+mimeType); | 510 | |
505 | // qDebug("description "+mt.description()); | 511 | // qDebug("mime "+mimeType); |
506 | // qDebug( "id "+mt.id()); | 512 | // qDebug("description "+mt.description()); |
507 | // qDebug("extension "+mt.extension()); | 513 | // qDebug( "id "+mt.id()); |
508 | // if( mt.extension().isEmpty()) | 514 | // qDebug("extension "+mt.extension()); |
515 | |||
516 | if( mt.extension().isEmpty()) | ||
509 | filterStr = "*"; | 517 | filterStr = "*"; |
510 | // else | 518 | else |
511 | // filterStr = "*."+ mt.extension()+" "; | 519 | filterStr = "*."+ mt.extension()+" "; |
512 | // printf( "%s \n", (*it).latin1() ); | 520 | // printf( "%s \n", (*it).latin1() ); |
513 | } | 521 | } |
514 | } | 522 | } |
515 | currentDir.setNameFilter(filterStr); | 523 | currentDir.setNameFilter(filterStr); |
@@ -545,12 +553,13 @@ QStringList fileBrowser::getMimeTypes() { | |||
545 | QStringList maj = l->mimeTypes(); | 553 | QStringList maj = l->mimeTypes(); |
546 | QStringList::ConstIterator f; | 554 | QStringList::ConstIterator f; |
547 | for ( f = maj.begin(); f != maj.end(); f++ ) { | 555 | for ( f = maj.begin(); f != maj.end(); f++ ) { |
548 | QString temp = *f; | 556 | QString temp = *f; |
557 | qDebug("type "+temp); | ||
549 | mimetypes << temp; | 558 | mimetypes << temp; |
550 | int sl = temp.find('/'); | 559 | int sl = temp.find('/'); |
551 | if (sl >= 0) { | 560 | if (sl >= 0) { |
552 | QString k = temp.left(sl); | 561 | QString k = temp;//.left(sl); |
553 | if( r.grep(k,TRUE).isEmpty() ) { | 562 | if( r.grep(k,TRUE).isEmpty() ) { |
554 | r << k; | 563 | r << k; |
555 | k+="\n"; | 564 | k+="\n"; |
556 | file.writeBlock( k.latin1(), k.length()); | 565 | file.writeBlock( k.latin1(), k.length()); |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 18402d4..84888c1 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -500,41 +500,50 @@ void TextEdit::fileNew() | |||
500 | } | 500 | } |
501 | 501 | ||
502 | void TextEdit::fileOpen() | 502 | void TextEdit::fileOpen() |
503 | { | 503 | { |
504 | QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this ); | 504 | Config cfg("TextEdit"); |
505 | if(!str.isEmpty() ) | 505 | cfg.setGroup("View"); |
506 | openFile( str ); | 506 | bool b=FALSE; |
507 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // | 507 | if(cfg.readEntry("useOldFileDialog") == "TRUE") |
508 | // browseForFiles->setFileView( viewSelection ); | 508 | b=TRUE; |
509 | // browseForFiles->showMaximized(); | 509 | if(!b) { |
510 | // // if( result != -1 ) | 510 | QString str = OFileDialog::getOpenFileName( 1,"/","", "text/plain", this ); |
511 | 511 | if(!str.isEmpty() ) | |
512 | // if( browseForFiles->exec() != -1 ) { | 512 | openFile( str ); |
513 | // QString selFile = browseForFiles->selectedFileName; | 513 | } else { |
514 | // QStringList fileList = browseForFiles->fileList; | 514 | QString str; |
515 | // qDebug(selFile); | 515 | browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // |
516 | // QStringList::ConstIterator f; | 516 | browseForFiles->setFileView( viewSelection ); |
517 | // QString fileTemp; | 517 | browseForFiles->showMaximized(); |
518 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 518 | // if( result != -1 ) |
519 | // fileTemp = *f; | 519 | |
520 | // fileTemp.right( fileTemp.length()-5); | 520 | if( browseForFiles->exec() != -1 ) { |
521 | // QString fileName = fileTemp; | 521 | QString selFile = browseForFiles->selectedFileName; |
522 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 522 | QStringList fileList = browseForFiles->fileList; |
523 | // currentFileName = fileName; | 523 | qDebug(selFile); |
524 | // qDebug("please open "+currentFileName); | 524 | QStringList::ConstIterator f; |
525 | // openFile(str ); | 525 | QString fileTemp; |
526 | // } | 526 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
527 | // } | 527 | fileTemp = *f; |
528 | // viewSelection = browseForFiles->SelectionCombo->currentItem(); | 528 | fileTemp.right( fileTemp.length()-5); |
529 | // } | 529 | QString fileName = fileTemp; |
530 | // delete browseForFiles; | 530 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
531 | // editor->setEdited( FALSE); | 531 | currentFileName = fileName; |
532 | // edited1=FALSE; | 532 | qDebug("please open "+currentFileName); |
533 | // edited=FALSE; | 533 | openFile(str ); |
534 | // if(caption().left(1)=="*") | 534 | } |
535 | // setCaption(caption().right(caption().length()-1)); | 535 | } |
536 | // doSearchBar(); | 536 | viewSelection = browseForFiles->SelectionCombo->currentItem(); |
537 | } | ||
538 | delete browseForFiles; | ||
539 | editor->setEdited( FALSE); | ||
540 | edited1=FALSE; | ||
541 | edited=FALSE; | ||
542 | if(caption().left(1)=="*") | ||
543 | setCaption(caption().right(caption().length()-1)); | ||
544 | doSearchBar(); | ||
545 | } | ||
537 | } | 546 | } |
538 | 547 | ||
539 | void TextEdit::doSearchBar() | 548 | void TextEdit::doSearchBar() |
540 | { | 549 | { |
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 61fa2a0..edc6fe3 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -56,9 +56,9 @@ public: | |||
56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
57 | ~TextEdit(); | 57 | ~TextEdit(); |
58 | 58 | ||
59 | QPopupMenu *font; | 59 | QPopupMenu *font; |
60 | QAction *nStart; | 60 | QAction *nStart, *nFileDlgOpt; |
61 | bool edited, edited1; | 61 | bool edited, edited1; |
62 | void openFile( const QString & ); | 62 | void openFile( const QString & ); |
63 | QCopChannel * channel; | 63 | QCopChannel * channel; |
64 | public slots: | 64 | public slots: |