summaryrefslogtreecommitdiff
path: root/core/apps/textedit/textedit.cpp
authorllornkcor <llornkcor>2002-04-24 01:00:52 (UTC)
committer llornkcor <llornkcor>2002-04-24 01:00:52 (UTC)
commit29e4dd18cbbe6d5967561b428a9632629cff3fde (patch) (unidiff)
tree4e3f6daaabd72937b2d1222f22d5797bb4c80b96 /core/apps/textedit/textedit.cpp
parent23f73a3a483a4daf3a26d0e83fd947d4f4118013 (diff)
downloadopie-29e4dd18cbbe6d5967561b428a9632629cff3fde.zip
opie-29e4dd18cbbe6d5967561b428a9632629cff3fde.tar.gz
opie-29e4dd18cbbe6d5967561b428a9632629cff3fde.tar.bz2
changed way of saving files, so a file opened through the file dialog, which is not a DocLnk, gets saved without a DocLnk. I got tired of hearing, 'I edited /etc/so-and-so and it saved it to Documents.' Will make this an option later. :)
Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp40
1 files changed, 31 insertions, 9 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
@@ -350,6 +350,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
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 );
@@ -412,6 +414,7 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
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
@@ -504,7 +507,7 @@ void TextEdit::fileOpen()
504 Config cfg("TextEdit"); 507 Config cfg("TextEdit");
505 cfg.setGroup("View"); 508 cfg.setGroup("View");
506 bool b=FALSE; 509 bool b=FALSE;
507 if(cfg.readEntry("useOldFileDialog") == "TRUE") 510 if(cfg.readEntry("useOldFileDialog") == "TRUE")
508 b=TRUE; 511 b=TRUE;
509 if(!b) { 512 if(!b) {
510 QString str = OFileDialog::getOpenFileName( 1,"/","", "text/plain", this ); 513 QString str = OFileDialog::getOpenFileName( 1,"/","", "text/plain", this );
@@ -530,11 +533,11 @@ void TextEdit::fileOpen()
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);
540 edited1=FALSE; 543 edited1=FALSE;
@@ -663,8 +666,10 @@ void TextEdit::openFile( const QString &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");
@@ -742,11 +747,22 @@ bool TextEdit::save()
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;
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
750 } 766 }
751 editor->setEdited( FALSE); 767 editor->setEdited( FALSE);
752 edited1=FALSE; 768 edited1=FALSE;
@@ -969,3 +985,9 @@ void TextEdit::receive(const QCString&msg, const QByteArray&) {
969 } 985 }
970 986
971} 987}
988void 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}