author | llornkcor <llornkcor> | 2002-04-14 21:40:33 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-14 21:40:33 (UTC) |
commit | f519bc8b0dd5e1f183b8eb2b0c7f59787afe130c (patch) (side-by-side diff) | |
tree | 137200abe04002cbcd27176352ab2f5ec0d4f636 | |
parent | 9c779ca27c9e44c2bae69892d060e628e5ea5bd3 (diff) | |
download | opie-f519bc8b0dd5e1f183b8eb2b0c7f59787afe130c.zip opie-f519bc8b0dd5e1f183b8eb2b0c7f59787afe130c.tar.gz opie-f519bc8b0dd5e1f183b8eb2b0c7f59787afe130c.tar.bz2 |
fixed trying to open .desktop files- give user a choice: .desktop or file linked too
-rw-r--r-- | core/apps/textedit/textedit.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index cc3ccbc..834bd8c 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -613,78 +613,92 @@ void TextEdit::findNext() void TextEdit::findClose() { searchVisible = FALSE; searchBar->hide(); Config cfg("TextEdit"); cfg.setGroup("View"); cfg.writeEntry("SearchBar","Closed"); cfg.write(); } void TextEdit::search() { editor->find( searchEdit->text(), FALSE, FALSE ); } void TextEdit::newFile( const DocLnk &f ) { DocLnk nf = f; nf.setType("text/plain"); clear(); setWState (WState_Reserved1 ); editor->setFocus(); doc = new DocLnk(nf); currentFileName = "Unnamed"; qDebug("newFile "+currentFileName); updateCaption( currentFileName); // editor->setEdited( FALSE); } void TextEdit::openFile( const QString &f ) { - + qDebug("filename is "+ f); + QString filer; // bFromDocView = TRUE; + if(f.find(".desktop",0,TRUE)) { + switch ( QMessageBox::warning(this,tr("Text Editor"), + tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), + tr(".desktop File"),tr("Link"),0,0,1) ) { + case 0: + filer = f; + break; + case 1: + DocLnk sf(f); + filer = sf.file(); + break; + } + } DocLnk nf; nf.setType("text/plain"); - nf.setFile(f); - currentFileName=f; + nf.setFile(filer); + currentFileName=filer; QFileInfo fi( currentFileName); nf.setName(fi.baseName()); - qDebug("openFile string"+currentFileName); + qDebug("openFile string "+currentFileName); openFile(nf); showEditTools(); // Show filename in caption - QString name = f; + QString name = filer; 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" ); } // fileNew(); if ( doc ) delete doc; doc = new DocLnk(f); editor->setText(txt); editor->setEdited( FALSE); edited1=FALSE; edited=FALSE; doc->setName(currentFileName); updateCaption(); } void TextEdit::showEditTools() @@ -828,70 +842,65 @@ bool TextEdit::saveAs() delete fileSaveDlg; return true; } //end saveAs void TextEdit::clear() { delete doc; doc = 0; editor->clear(); } void TextEdit::updateCaption( const QString &name ) { if ( !doc ) setCaption( tr("Text Editor") ); else { QString s = name; if ( s.isNull() ) s = doc->name(); if ( s.isEmpty() ) { s = tr( "Unnamed" ); currentFileName=s; } if(s.left(1) == "/") s = s.right(s.length()-1); setCaption( s + " - " + tr("Text Editor") ); } } void TextEdit::setDocument(const QString& fileref) { bFromDocView = TRUE; - if(fileref.find(".desktop",0,TRUE) == -1) { - openFile(fileref); - } else { - qDebug("is desktop file"); - openFile(DocLnk(fileref)); - } + openFile(fileref); editor->setEdited(TRUE); edited1=FALSE; edited=TRUE; doSearchBar(); } void TextEdit::closeEvent( QCloseEvent *e ) { bFromDocView = FALSE; e->accept(); } void TextEdit::accept() { //if(caption() !="Unnamed") if(edited1) saveAs(); exit(0); } void TextEdit::changeFont() { FontDatabase fdb; QFont defaultFont=editor->font(); QFontInfo fontInfo(defaultFont); Config cfg("TextEdit"); cfg.setGroup("Font"); QString family = cfg.readEntry("Family", fontInfo.family()); QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |