author | leseb <leseb> | 2002-06-05 19:54:59 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-05 19:54:59 (UTC) |
commit | d16b4fecd10dbce1bb5fc0f58e78469ba40f6ec5 (patch) (side-by-side diff) | |
tree | 3cbcce663397e5e8ceb0f4227d0714ee8a883165 | |
parent | 7e61a0450682589c5ec5a8009df3b6ec36dbb5a0 (diff) | |
download | opie-d16b4fecd10dbce1bb5fc0f58e78469ba40f6ec5.zip opie-d16b4fecd10dbce1bb5fc0f58e78469ba40f6ec5.tar.gz opie-d16b4fecd10dbce1bb5fc0f58e78469ba40f6ec5.tar.bz2 |
Fix bug #352 (utf8 format when saving!)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index f99f259..c1f74bb 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -714,97 +714,98 @@ void TextEdit::openFile( const DocLnk &f ) doc->setName(currentFileName); updateCaption(); } void TextEdit::showEditTools() { // if ( !doc ) // close(); // clear(); menu->show(); editBar->show(); if ( searchVisible ) searchBar->show(); // updateCaption(); setWState (WState_Reserved1 ); } /*! unprompted save */ bool TextEdit::save() { QString file = doc->file(); qDebug("saver file "+file); QString name= doc->name(); qDebug("File named "+name); QString rt = editor->text(); if( !rt.isEmpty() ) { if(name.isEmpty()) { saveAs(); } else { currentFileName= name ; qDebug("saveFile "+currentFileName); struct stat buf; mode_t mode; stat(file.latin1(), &buf); mode = buf.st_mode; if(!fileIs) { doc->setName( name); FileManager fm; if ( !fm.saveFile( *doc, rt ) ) { return false; } } else { qDebug("regular save file"); QFile f(file); if( f.open(IO_WriteOnly)) { - f.writeBlock(rt,rt.length()); + QCString crt = rt.utf8(); + f.writeBlock(crt,crt.length()); } else { QMessageBox::message("Text Edit","Write Failed"); return false; } } editor->setEdited( FALSE); edited1=FALSE; edited=FALSE; if(caption().left(1)=="*") setCaption(caption().right(caption().length()-1)); chmod( file.latin1(), mode); } return true; } return false; } /*! prompted save */ bool TextEdit::saveAs() { // qDebug("saveAsFile "+currentFileName); // case of nothing to save... if ( !doc )//|| !bFromDocView) { qDebug("no doc"); return true; } if ( !editor->edited() ) { delete doc; doc = 0; return true; } QString rt = editor->text(); qDebug(currentFileName); if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { qDebug("do silly TT filename thing"); if ( doc->name().isEmpty() ) { QString pt = rt.simplifyWhiteSpace(); int i = pt.find( ' ' ); QString docname = pt; if ( i > 0 ) docname = pt.left( i ); |