-rw-r--r-- | core/apps/textedit/textedit.cpp | 28 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 2 |
2 files changed, 27 insertions, 3 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 84888c1..19449cb 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -347,12 +347,14 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
347 | 347 | ||
348 | font->insertSeparator(); | 348 | font->insertSeparator(); |
349 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 349 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
350 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 350 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
351 | nStart->setToggleAction(TRUE); | 351 | nStart->setToggleAction(TRUE); |
352 | nStart->addTo( font ); | 352 | nStart->addTo( font ); |
353 | font->insertSeparator(); | ||
354 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | ||
353 | 355 | ||
354 | mb->insertItem( tr( "File" ), file ); | 356 | mb->insertItem( tr( "File" ), file ); |
355 | mb->insertItem( tr( "Edit" ), edit ); | 357 | mb->insertItem( tr( "Edit" ), edit ); |
356 | mb->insertItem( tr( "View" ), font ); | 358 | mb->insertItem( tr( "View" ), font ); |
357 | 359 | ||
358 | searchBar = new QPEToolBar(this); | 360 | searchBar = new QPEToolBar(this); |
@@ -409,12 +411,13 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
409 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 411 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
410 | nStart->setOn(TRUE); | 412 | nStart->setOn(TRUE); |
411 | fileNew(); | 413 | fileNew(); |
412 | } else { | 414 | } else { |
413 | fileOpen(); | 415 | fileOpen(); |
414 | } | 416 | } |
417 | |||
415 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 418 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
416 | } | 419 | } |
417 | 420 | ||
418 | void TextEdit::cleanUp() | 421 | void TextEdit::cleanUp() |
419 | { | 422 | { |
420 | // save(); | 423 | // save(); |
@@ -527,13 +530,13 @@ void TextEdit::fileOpen() | |||
527 | fileTemp = *f; | 530 | fileTemp = *f; |
528 | fileTemp.right( fileTemp.length()-5); | 531 | fileTemp.right( fileTemp.length()-5); |
529 | QString fileName = fileTemp; | 532 | QString fileName = fileTemp; |
530 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 533 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
531 | currentFileName = fileName; | 534 | currentFileName = fileName; |
532 | qDebug("please open "+currentFileName); | 535 | qDebug("please open "+currentFileName); |
533 | openFile(str ); | 536 | openFile(currentFileName ); |
534 | } | 537 | } |
535 | } | 538 | } |
536 | viewSelection = browseForFiles->SelectionCombo->currentItem(); | 539 | viewSelection = browseForFiles->SelectionCombo->currentItem(); |
537 | } | 540 | } |
538 | delete browseForFiles; | 541 | delete browseForFiles; |
539 | editor->setEdited( FALSE); | 542 | editor->setEdited( FALSE); |
@@ -660,14 +663,16 @@ void TextEdit::openFile( const QString &f ) | |||
660 | break; | 663 | break; |
661 | case 1: | 664 | case 1: |
662 | DocLnk sf(f); | 665 | DocLnk sf(f); |
663 | filer = sf.file(); | 666 | filer = sf.file(); |
664 | break; | 667 | break; |
665 | } | 668 | } |
666 | } else | 669 | } else { |
667 | filer = f; | 670 | filer = f; |
671 | fileIs = TRUE; | ||
672 | } | ||
668 | 673 | ||
669 | DocLnk nf; | 674 | DocLnk nf; |
670 | nf.setType("text/plain"); | 675 | nf.setType("text/plain"); |
671 | nf.setFile(filer); | 676 | nf.setFile(filer); |
672 | currentFileName=filer; | 677 | currentFileName=filer; |
673 | QFileInfo fi( currentFileName); | 678 | QFileInfo fi( currentFileName); |
@@ -739,18 +744,29 @@ bool TextEdit::save() | |||
739 | qDebug("saveFile "+currentFileName); | 744 | qDebug("saveFile "+currentFileName); |
740 | 745 | ||
741 | struct stat buf; | 746 | struct stat buf; |
742 | mode_t mode; | 747 | mode_t mode; |
743 | stat(file.latin1(), &buf); | 748 | stat(file.latin1(), &buf); |
744 | mode = buf.st_mode; | 749 | mode = buf.st_mode; |
745 | 750 | if(!fileIs) { | |
746 | doc->setName( name); | 751 | doc->setName( name); |
747 | FileManager fm; | 752 | FileManager fm; |
748 | if ( !fm.saveFile( *doc, rt ) ) { | 753 | if ( !fm.saveFile( *doc, rt ) ) { |
749 | return false; | 754 | return false; |
750 | } | 755 | } |
756 | } else { | ||
757 | qDebug("regular save file"); | ||
758 | QFile f(file); | ||
759 | if( f.open(IO_WriteOnly)) { | ||
760 | f.writeBlock(rt,rt.length()); | ||
761 | } else { | ||
762 | QMessageBox::message("Text Edit","Write Failed"); | ||
763 | return false; | ||
764 | } | ||
765 | |||
766 | } | ||
751 | editor->setEdited( FALSE); | 767 | editor->setEdited( FALSE); |
752 | edited1=FALSE; | 768 | edited1=FALSE; |
753 | edited=FALSE; | 769 | edited=FALSE; |
754 | if(caption().left(1)=="*") | 770 | if(caption().left(1)=="*") |
755 | setCaption(caption().right(caption().length()-1)); | 771 | setCaption(caption().right(caption().length()-1)); |
756 | 772 | ||
@@ -966,6 +982,12 @@ void TextEdit::receive(const QCString&msg, const QByteArray&) { | |||
966 | qDebug("QCop "+msg); | 982 | qDebug("QCop "+msg); |
967 | if ( msg == "setDocument(QString)" ) { | 983 | if ( msg == "setDocument(QString)" ) { |
968 | qDebug("bugger all"); | 984 | qDebug("bugger all"); |
969 | } | 985 | } |
970 | 986 | ||
971 | } | 987 | } |
988 | void TextEdit::doAbout() { | ||
989 | QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" | ||
990 | "2000 Trolltech AS, and\n" | ||
991 | "2002 by L.J.Potter \nljp@llornkcor.com\n" | ||
992 | "and is licensed under the GPL"); | ||
993 | } | ||
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index edc6fe3..9d27ab0 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -62,15 +62,17 @@ public: | |||
62 | void openFile( const QString & ); | 62 | void openFile( const QString & ); |
63 | QCopChannel * channel; | 63 | QCopChannel * channel; |
64 | public slots: | 64 | public slots: |
65 | void editorChanged(); | 65 | void editorChanged(); |
66 | void receive(const QCString&, const QByteArray&); | 66 | void receive(const QCString&, const QByteArray&); |
67 | protected: | 67 | protected: |
68 | bool fileIs; | ||
68 | void closeEvent( QCloseEvent *e ); | 69 | void closeEvent( QCloseEvent *e ); |
69 | void doSearchBar(); | 70 | void doSearchBar(); |
70 | private slots: | 71 | private slots: |
72 | void doAbout(); | ||
71 | void setDocument(const QString&); | 73 | void setDocument(const QString&); |
72 | void changeFont(); | 74 | void changeFont(); |
73 | void fileNew(); | 75 | void fileNew(); |
74 | void fileRevert(); | 76 | void fileRevert(); |
75 | void fileOpen(); | 77 | void fileOpen(); |
76 | void changeStartConfig(bool); | 78 | void changeStartConfig(bool); |