Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 14bc496..429c195 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -484,9 +484,11 @@ void TextEdit::setWordWrap(bool y) } void TextEdit::fileNew() { - save(); + if( !bFromDocView ) { + save(); + } newFile(DocLnk()); } void TextEdit::fileOpen() @@ -511,29 +513,30 @@ void TextEdit::fileOpen() searchBar->hide(); clearWState (WState_Reserved1 ); editorStack->raiseWidget( fileSelector ); fileSelector->reread(); - updateCaption(); + updateCaption(currentFileName); } void TextEdit::newFileOpen() { fileBrowser *browseForFiles; browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); - browseForFiles->exec(); - 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); - openFile(fileName ); + if( browseForFiles->exec()!= 0 ) { + 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); + openFile(fileName ); + } } } delete browseForFiles; @@ -618,9 +621,9 @@ void TextEdit::newFile( const DocLnk &f ) editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); editor->setFocus(); doc = new DocLnk(nf); - updateCaption(); +// updateCaption(); } void TextEdit::openFile( const QString &f ) { @@ -640,8 +643,9 @@ void TextEdit::openFile( const QString &f ) void TextEdit::openFile( const DocLnk &f ) { // clear(); + bFromDocView = TRUE; FileManager fm; QString txt; if ( !fm.loadFile( f, txt ) ) { // ####### could be a new file @@ -655,9 +659,9 @@ void TextEdit::openFile( const DocLnk &f ) delete doc; doc = new DocLnk(f); editor->setText(txt); editor->setEdited(FALSE); - updateCaption(); + updateCaption(currentFileName); } void TextEdit::showEditTools() { @@ -668,9 +672,9 @@ void TextEdit::showEditTools() menu->show(); editBar->show(); if ( searchVisible ) searchBar->show(); - updateCaption(); +// updateCaption(); editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); } @@ -685,10 +689,11 @@ bool TextEdit::save() return true; } QString rt = editor->text(); - - if(currentFileName.isEmpty() || currentFileName == "Unnamed") { + qDebug(currentFileName); + + if( currentFileName.isEmpty() || currentFileName == "Unnamed") { if ( doc->name().isEmpty() ) { QString pt = rt.simplifyWhiteSpace(); int i = pt.find( ' ' ); @@ -710,13 +715,14 @@ bool TextEdit::save() } fileSaver *fileSaveDlg; fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); - fileSaveDlg->exec(); + if( fileSaveDlg->exec() != 0 ) { QString fileNm=fileSaveDlg->selectedFileName; qDebug("save filename "+fileNm); doc->setName(fileNm); - updateCaption(); + updateCaption(fileNm); + } delete fileSaveDlg; FileManager fm; if ( !fm.saveFile( *doc, rt ) ) { |