author | llornkcor <llornkcor> | 2002-04-10 19:08:30 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-10 19:08:30 (UTC) |
commit | 11d754ffa429875b526c49f125d8a844c5cda3d8 (patch) (unidiff) | |
tree | 4b2fa1f980e62dad5a0ae465c95eb627df32cdd9 /core/apps/textedit | |
parent | 5504a71f3e65673a3eea23051d0043f2b483276b (diff) | |
download | opie-11d754ffa429875b526c49f125d8a844c5cda3d8.zip opie-11d754ffa429875b526c49f125d8a844c5cda3d8.tar.gz opie-11d754ffa429875b526c49f125d8a844c5cda3d8.tar.bz2 |
bug fix
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 28 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 99 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 7 |
3 files changed, 73 insertions, 61 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index bc99348..f322513 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -50,3 +50,3 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
50 | if ( !name ) | 50 | if ( !name ) |
51 | setName( tr("fileBrowser") ); | 51 | setName( "fileBrowser" ); |
52 | setCaption(tr( name ) ); | 52 | setCaption(tr( name ) ); |
@@ -122,3 +122,3 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
122 | ListView->setColumnWidth(1,-1); | 122 | ListView->setColumnWidth(1,-1); |
123 | ListView->addColumn( tr("Date"),-1); | 123 | ListView->addColumn( "Date",-1); |
124 | 124 | ||
@@ -136,3 +136,3 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
136 | FileStack->addWidget( ListView, get_unique_id() ); | 136 | FileStack->addWidget( ListView, get_unique_id() ); |
137 | 137 | mimeType="text/plain"; | |
138 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 138 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
@@ -350,3 +350,3 @@ void fileBrowser::selectionChanged( const QString &select ) | |||
350 | { | 350 | { |
351 | if ( select == tr("Documents")) { | 351 | if ( select == "Documents") { |
352 | FileStack->raiseWidget( fileSelector ); | 352 | FileStack->raiseWidget( fileSelector ); |
@@ -357,3 +357,3 @@ void fileBrowser::selectionChanged( const QString &select ) | |||
357 | } else { | 357 | } else { |
358 | if ( select == tr("All files") ) | 358 | if ( select == "All files" ) |
359 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); | 359 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); |
@@ -414,3 +414,3 @@ void fileBrowser::makDir() { | |||
414 | InputDialog *fileDlg; | 414 | InputDialog *fileDlg; |
415 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 415 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
416 | fileDlg->exec(); | 416 | fileDlg->exec(); |
@@ -427,3 +427,3 @@ void fileBrowser::localRename() { | |||
427 | InputDialog *fileDlg; | 427 | InputDialog *fileDlg; |
428 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 428 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
429 | fileDlg->setTextEdit((const QString &) curFile); | 429 | fileDlg->setTextEdit((const QString &) curFile); |
@@ -434,3 +434,3 @@ void fileBrowser::localRename() { | |||
434 | if( rename(oldname.latin1(), newName.latin1())== -1) | 434 | if( rename(oldname.latin1(), newName.latin1())== -1) |
435 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 435 | QMessageBox::message("Note","Could not rename"); |
436 | } | 436 | } |
@@ -442,4 +442,4 @@ void fileBrowser::localDelete() { | |||
442 | if(QDir(f).exists() ) { | 442 | if(QDir(f).exists() ) { |
443 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 443 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
444 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { | 444 | " ?\nIt must be empty","Yes","No",0,0,1) ) { |
445 | case 0: { | 445 | case 0: { |
@@ -456,4 +456,4 @@ void fileBrowser::localDelete() { | |||
456 | } else { | 456 | } else { |
457 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 457 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |
458 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 458 | +" ?","Yes","No",0,0,1) ) { |
459 | case 0: { | 459 | case 0: { |
@@ -495,3 +495,3 @@ void fileBrowser::showType(const QString &t) { | |||
495 | qDebug(t); | 495 | qDebug(t); |
496 | if(t.find(tr("All"),0,TRUE) != -1) { | 496 | if(t.find("All",0,TRUE) != -1) { |
497 | filterStr = "*"; | 497 | filterStr = "*"; |
@@ -607,3 +607,3 @@ InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags | |||
607 | if ( !name ) | 607 | if ( !name ) |
608 | setName( tr("InputDialog") ); | 608 | setName( "InputDialog" ); |
609 | resize( 234, 50 ); | 609 | resize( 234, 50 ); |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 6804918..943fecd 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -37,2 +37,3 @@ | |||
37 | #include <qpe/qpetoolbar.h> | 37 | #include <qpe/qpetoolbar.h> |
38 | #include <qpe/qcopenvelope_qws.h> | ||
38 | //#include <qpe/finddialog.h> | 39 | //#include <qpe/finddialog.h> |
@@ -240,2 +241,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
240 | 241 | ||
242 | channel = new QCopChannel( "QPE/Application/textedit", this ); | ||
243 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
244 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | ||
245 | |||
241 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 246 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
@@ -399,9 +404,9 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
399 | 404 | ||
400 | cfg.setGroup("View"); | 405 | cfg.setGroup("View"); |
401 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 406 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
402 | nStart->setOn(TRUE); | 407 | nStart->setOn(TRUE); |
403 | fileNew(); | 408 | fileNew(); |
404 | } else { | 409 | } else { |
405 | fileOpen(); | 410 | fileOpen(); |
406 | } | 411 | } |
407 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 412 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
@@ -487,5 +492,5 @@ void TextEdit::fileNew() | |||
487 | { | 492 | { |
488 | if( !bFromDocView ) { | 493 | // if( !bFromDocView ) { |
489 | saveAs(); | 494 | // saveAs(); |
490 | } | 495 | // } |
491 | newFile(DocLnk()); | 496 | newFile(DocLnk()); |
@@ -495,5 +500,7 @@ void TextEdit::fileOpen() | |||
495 | { | 500 | { |
496 | browseForFiles=new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // | 501 | browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // |
497 | browseForFiles->setFileView( viewSelection ); | 502 | browseForFiles->setFileView( viewSelection ); |
498 | browseForFiles->showMaximized(); | 503 | browseForFiles->showMaximized(); |
504 | // if( result != -1 ) | ||
505 | |||
499 | if( browseForFiles->exec() != -1 ) { | 506 | if( browseForFiles->exec() != -1 ) { |
@@ -620,4 +627,6 @@ void TextEdit::newFile( const DocLnk &f ) | |||
620 | doc = new DocLnk(nf); | 627 | doc = new DocLnk(nf); |
628 | currentFileName = "Unnamed"; | ||
621 | qDebug("newFile "+currentFileName); | 629 | qDebug("newFile "+currentFileName); |
622 | updateCaption(currentFileName); | 630 | updateCaption( currentFileName); |
631 | // editor->setEdited( FALSE); | ||
623 | } | 632 | } |
@@ -627,3 +636,3 @@ void TextEdit::openFile( const QString &f ) | |||
627 | 636 | ||
628 | bFromDocView = TRUE; | 637 | // bFromDocView = TRUE; |
629 | DocLnk nf; | 638 | DocLnk nf; |
@@ -638,3 +647,3 @@ void TextEdit::openFile( const QString &f ) | |||
638 | showEditTools(); | 647 | showEditTools(); |
639 | // Show filename in caption | 648 | // Show filename in caption |
640 | QString name = f; | 649 | QString name = f; |
@@ -642,3 +651,3 @@ void TextEdit::openFile( const QString &f ) | |||
642 | if ( sep > 0 ) | 651 | if ( sep > 0 ) |
643 | name = name.mid( sep+1 ); | 652 | name = name.mid( sep+1 ); |
644 | updateCaption( name ); | 653 | updateCaption( name ); |
@@ -649,3 +658,3 @@ void TextEdit::openFile( const DocLnk &f ) | |||
649 | // clear(); | 658 | // clear(); |
650 | bFromDocView = TRUE; | 659 | // bFromDocView = TRUE; |
651 | FileManager fm; | 660 | FileManager fm; |
@@ -655,11 +664,8 @@ void TextEdit::openFile( const DocLnk &f ) | |||
655 | if ( !fm.loadFile( f, txt ) ) { | 664 | if ( !fm.loadFile( f, txt ) ) { |
656 | // ####### could be a new file | 665 | // ####### could be a new file |
657 | qDebug( "Cannot open file" ); | 666 | qDebug( "Cannot open file" ); |
658 | |||
659 | //return; | ||
660 | } | 667 | } |
661 | 668 | // fileNew(); | |
662 | fileNew(); | ||
663 | if ( doc ) | 669 | if ( doc ) |
664 | delete doc; | 670 | delete doc; |
665 | doc = new DocLnk(f); | 671 | doc = new DocLnk(f); |
@@ -670,3 +676,2 @@ void TextEdit::openFile( const DocLnk &f ) | |||
670 | 676 | ||
671 | qDebug("openFile doclnk "+currentFileName); | ||
672 | doc->setName(currentFileName); | 677 | doc->setName(currentFileName); |
@@ -693,5 +698,5 @@ bool TextEdit::save() | |||
693 | QString file = doc->file(); | 698 | QString file = doc->file(); |
694 | qDebug(file); | 699 | qDebug("saver file "+file); |
695 | QString name= doc->name(); | 700 | QString name= doc->name(); |
696 | qDebug(name); | 701 | qDebug("File named "+name); |
697 | QString rt = editor->text(); | 702 | QString rt = editor->text(); |
@@ -733,9 +738,8 @@ bool TextEdit::saveAs() | |||
733 | // qDebug("saveAsFile "+currentFileName); | 738 | // qDebug("saveAsFile "+currentFileName); |
734 | 739 | // case of nothing to save... | |
735 | // case of nothing to save... /// there's always something to save | 740 | if ( !doc )//|| !bFromDocView) |
736 | // if ( !doc )//|| !bFromDocView) | 741 | { |
737 | // { | 742 | qDebug("no doc"); |
738 | // qDebug("no doc"); | 743 | return true; |
739 | // return true; | 744 | } |
740 | // } | ||
741 | if ( !editor->edited() ) { | 745 | if ( !editor->edited() ) { |
@@ -749,3 +753,3 @@ bool TextEdit::saveAs() | |||
749 | 753 | ||
750 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed")) { | 754 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { |
751 | qDebug("do silly TT filename thing"); | 755 | qDebug("do silly TT filename thing"); |
@@ -816,3 +820,3 @@ bool TextEdit::saveAs() | |||
816 | return true; | 820 | return true; |
817 | } | 821 | } //end saveAs |
818 | 822 | ||
@@ -837,3 +841,4 @@ void TextEdit::updateCaption( const QString &name ) | |||
837 | } | 841 | } |
838 | 842 | if(s.left(1) == "/") | |
843 | s = s.right(s.length()-1); | ||
839 | setCaption( s + " - " + tr("Text Editor") ); | 844 | setCaption( s + " - " + tr("Text Editor") ); |
@@ -845,8 +850,7 @@ void TextEdit::setDocument(const QString& fileref) | |||
845 | bFromDocView = TRUE; | 850 | bFromDocView = TRUE; |
846 | qDebug("setDocument "+fileref); | ||
847 | bFromDocView = TRUE; | ||
848 | if(fileref.find(".desktop",0,TRUE) == -1) { | 851 | if(fileref.find(".desktop",0,TRUE) == -1) { |
849 | openFile(fileref); | 852 | openFile(fileref); |
850 | } else { | 853 | } else { |
851 | openFile(DocLnk(fileref)); | 854 | qDebug("is desktop file"); |
855 | openFile(DocLnk(fileref)); | ||
852 | } | 856 | } |
@@ -866,8 +870,5 @@ void TextEdit::accept() | |||
866 | { | 870 | { |
867 | QString file = doc->file(); | 871 | //if(caption() !="Unnamed") |
868 | if (file.find("_.txt",0,TRUE) ==-1) | 872 | if(edited1) |
869 | save(); | 873 | saveAs(); |
870 | else { | ||
871 | QFile(file).remove(); | ||
872 | } | ||
873 | exit(0); | 874 | exit(0); |
@@ -936 +937,9 @@ void TextEdit::editorChanged() { | |||
936 | } | 937 | } |
938 | |||
939 | void TextEdit::receive(const QCString&msg, const QByteArray&) { | ||
940 | qDebug("QCop "+msg); | ||
941 | if ( msg == "setDocument(QString)" ) { | ||
942 | qDebug("bugger all"); | ||
943 | } | ||
944 | |||
945 | } | ||
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index af69518..61fa2a0 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -30,2 +30,5 @@ | |||
30 | #include <qpe/filemanager.h> | 30 | #include <qpe/filemanager.h> |
31 | #include <qpe/qcopenvelope_qws.h> | ||
32 | |||
33 | #include <opie/ofileselector.h> | ||
31 | 34 | ||
@@ -59,5 +62,6 @@ public: | |||
59 | void openFile( const QString & ); | 62 | void openFile( const QString & ); |
63 | QCopChannel * channel; | ||
60 | public slots: | 64 | public slots: |
61 | void editorChanged(); | 65 | void editorChanged(); |
62 | 66 | void receive(const QCString&, const QByteArray&); | |
63 | protected: | 67 | protected: |
@@ -108,3 +112,2 @@ private: | |||
108 | fileBrowser *browseForFiles; | 112 | fileBrowser *browseForFiles; |
109 | |||
110 | QpeEditor* editor; | 113 | QpeEditor* editor; |