author | llornkcor <llornkcor> | 2002-02-19 01:29:58 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-19 01:29:58 (UTC) |
commit | 994691c1659fdac4980b0319aa8fab1c98ef3c73 (patch) (side-by-side diff) | |
tree | a7fa94deb3cbd4c7cda17f184eed634bbc0caac4 | |
parent | fe66103c21d3337bb6c7fc7ad112cbdedd255d67 (diff) | |
download | opie-994691c1659fdac4980b0319aa8fab1c98ef3c73.zip opie-994691c1659fdac4980b0319aa8fab1c98ef3c73.tar.gz opie-994691c1659fdac4980b0319aa8fab1c98ef3c73.tar.bz2 |
bug- saveas
-rw-r--r-- | core/apps/textedit/textedit.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 019ffee..197b28b 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -408,356 +408,358 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) editor->setFont( defaultFont); wa->setOn(wrap); updateCaption(); fileNew(); } TextEdit::~TextEdit() { // saveAs(); Config cfg("TextEdit"); cfg.setGroup("View"); QFont f = editor->font(); cfg.writeEntry("FontSize",f.pointSize()); cfg.writeEntry("Bold",f.bold()); cfg.writeEntry("Italic",f.italic()); cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); } void TextEdit::zoomIn() { setFontSize(editor->font().pointSize()+1,FALSE); } void TextEdit::zoomOut() { setFontSize(editor->font().pointSize()-1,TRUE); } void TextEdit::setFontSize(int sz, bool round_down_not_up) { int s=10; for (int i=0; i<nfontsizes; i++) { if ( fontsize[i] == sz ) { s = sz; break; } else if ( round_down_not_up ) { if ( fontsize[i] < sz ) s = fontsize[i]; } else { if ( fontsize[i] > sz ) { s = fontsize[i]; break; } } } QFont f = editor->font(); f.setPointSize(s); editor->setFont(f); zin->setEnabled(s != fontsize[nfontsizes-1]); zout->setEnabled(s != fontsize[0]); } void TextEdit::setBold(bool y) { QFont f = editor->font(); f.setBold(y); editor->setFont(f); } void TextEdit::setItalic(bool y) { QFont f = editor->font(); f.setItalic(y); editor->setFont(f); } void TextEdit::setWordWrap(bool y) { bool state = editor->edited(); editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); editor->setEdited( state ); } void TextEdit::fileNew() { if( !bFromDocView ) { saveAs(); } newFile(DocLnk()); } void TextEdit::fileOpen() { // if ( !save() ) { // if ( QMessageBox::critical( this, tr( "Out of space" ), // tr( "Text Editor was unable to\n" // "save your changes.\n" // "Free some space and try again.\n" // "\nContinue anyway?" ), // QMessageBox::Yes|QMessageBox::Escape, // QMessageBox::No|QMessageBox::Default ) // != QMessageBox::Yes ) // return; // else { // delete doc; // doc = 0; // } // } menu->hide(); editBar->hide(); searchBar->hide(); clearWState (WState_Reserved1 ); editorStack->raiseWidget( fileSelector ); fileSelector->reread(); updateCaption(); } void TextEdit::newFileOpen() { browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); if( browseForFiles->exec() != -1 ) { QString selFile= browseForFiles->selectedFileName; QStringList fileList=browseForFiles->fileList; qDebug(selFile); QStringList::ConstIterator f; QString fileTemp; for ( f = fileList.begin(); f != fileList.end(); f++ ) { fileTemp = *f; fileTemp.right( fileTemp.length()-5); QString fileName = fileTemp; if( fileName != "Unnamed" || fileName != "Empty Text" ) { currentFileName = fileName; -// qDebug("please open "+currentFileName); + qDebug("please open "+currentFileName); openFile(fileName ); } } } delete browseForFiles; editor->setEdited( true ); } #if 0 void TextEdit::slotFind() { FindDialog frmFind( "Text Editor", this ); connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), editor, SLOT(slotDoFind( const QString&,bool,bool))); //case sensitive, backwards, [category] connect( editor, SIGNAL(notFound()), &frmFind, SLOT(slotNotFound()) ); connect( editor, SIGNAL(searchWrapped()), &frmFind, SLOT(slotWrapAround()) ); frmFind.exec(); } #endif void TextEdit::fileRevert() { clear(); fileOpen(); } void TextEdit::editCut() { #ifndef QT_NO_CLIPBOARD editor->cut(); #endif } void TextEdit::editCopy() { #ifndef QT_NO_CLIPBOARD editor->copy(); #endif } void TextEdit::editPaste() { #ifndef QT_NO_CLIPBOARD editor->paste(); #endif } void TextEdit::editFind() { searchBar->show(); searchVisible = TRUE; searchEdit->setFocus(); } void TextEdit::findNext() { editor->find( searchEdit->text(), FALSE, FALSE ); } void TextEdit::findClose() { searchVisible = FALSE; searchBar->hide(); } void TextEdit::search() { editor->find( searchEdit->text(), FALSE, FALSE ); } void TextEdit::newFile( const DocLnk &f ) { DocLnk nf = f; nf.setType("text/plain"); clear(); editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); editor->setFocus(); doc = new DocLnk(nf); qDebug("newFile "+currentFileName); updateCaption(currentFileName); } void TextEdit::openFile( const QString &f ) { bFromDocView = TRUE; DocLnk nf; nf.setType("text/plain"); nf.setFile(f); currentFileName=f; + QFileInfo fi( currentFileName); + nf.setName(fi.baseName()); qDebug("openFile string"+currentFileName); openFile(nf); showEditTools(); // Show filename in caption QString name = f; int sep = name.findRev( '/' ); if ( sep > 0 ) name = name.mid( sep+1 ); updateCaption( name ); } void TextEdit::openFile( const DocLnk &f ) { // clear(); bFromDocView = TRUE; FileManager fm; QString txt; currentFileName=f.name(); qDebug("openFile doclnk " + currentFileName); if ( !fm.loadFile( f, txt ) ) { // ####### could be a new file qDebug( "Cannot open file" ); //return; } fileNew(); if ( doc ) delete doc; doc = new DocLnk(f); editor->setText(txt); editor->setEdited( false); qDebug("openFile doclnk "+currentFileName); doc->setName(currentFileName); updateCaption(); } void TextEdit::showEditTools() { // if ( !doc ) // close(); // clear(); fileSelector->hide(); menu->show(); editBar->show(); if ( searchVisible ) searchBar->show(); // updateCaption(); editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); } /*! unprompted save */ bool TextEdit::save() { QString file = doc->file(); QString name= doc->name(); QString rt = editor->text(); currentFileName= name ; qDebug("saveFile "+currentFileName); doc->setName( name); FileManager fm; if ( !fm.saveFile( *doc, rt ) ) { return false; } // if(doc) // delete doc; // doc = 0; editor->setEdited( false ); return true; } /*! prompted save */ bool TextEdit::saveAs() { qDebug("saveAsFile "+currentFileName); // case of nothing to save... /// there's always something 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 == "Unnamed") { 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 ); // remove "." at the beginning while( docname.startsWith( "." ) ) docname = docname.mid( 1 ); docname.replace( QRegExp("/"), "_" ); // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. if ( docname.length() > 40 ) docname = docname.left(40); if ( docname.isEmpty() ) docname = "Unnamed"; doc->setName(docname); currentFileName=docname; } } fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); qDebug("wanna save filename "+currentFileName); fileSaveDlg->exec(); if( fileSaveDlg->result() == 1 ) { QString fileNm=fileSaveDlg->selectedFileName; qDebug("saving filename "+fileNm); QFileInfo fi(fileNm); currentFileName=fi.fileName(); if(doc) { qDebug("doclnk exists"); |