summaryrefslogtreecommitdiff
path: root/core/apps/textedit/textedit.cpp
Side-by-side diff
Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 759e440..61beac5 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -622,107 +622,108 @@ void TextEdit::editCopy() {
editor->copy();
#endif
}
void TextEdit::editPaste() {
#ifndef QT_NO_CLIPBOARD
editor->paste();
#endif
}
void TextEdit::editFind() {
searchBar->show();
searchEdit->setFocus();
}
void TextEdit::findNext() {
editor->find( searchEdit->text(), false, false );
}
void TextEdit::findClose() {
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();
setWState (WState_Reserved1 );
editor->setFocus();
doc = new DocLnk(nf);
currentFileName = "Unnamed";
odebug << "newFile "+currentFileName << oendl;
updateCaption( currentFileName);
// editor->setEdited( false);
}
void TextEdit::openDotFile( const QString &f ) {
if(!currentFileName.isEmpty()) {
currentFileName=f;
odebug << "openFile dotfile " + currentFileName << oendl;
QString txt;
QFile file(f);
- file.open(IO_ReadWrite);
+ if (!file.open(IO_ReadWrite))
+ owarn << "Failed to open file " << file.name() << oendl;
+ else {
QTextStream t(&file);
while ( !t.atEnd()) {
txt+=t.readLine()+"\n";
}
editor->setText(txt);
editor->setEdited( false);
edited1=false;
edited=false;
-
-
+ }
}
updateCaption( currentFileName);
}
void TextEdit::openFile( const QString &f ) {
odebug << "filename is "+ f << oendl;
QString filer;
QFileInfo fi( f);
// bFromDocView = true;
if(f.find(".desktop",0,true) != -1 && !openDesktop )
{
switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) )
{
case 0: //desktop
filer = f;
break;
case 1: //linked
DocLnk sf(f);
filer = sf.file();
break;
};
}
else if(fi.baseName().left(1) == "")
{
odebug << "opening dotfile" << oendl;
currentFileName=f;
openDotFile(currentFileName);
return;
}
/*
* The problem is a file where Config(f).isValid() and it does not
* end with .desktop will be treated as desktop file
*/
else if (f.find(".desktop",0,true) != -1 )
{
DocLnk sf(f);
filer = sf.file();
if(filer.right(1) == "/")
filer = f;
}
else
filer = f;
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filer);
currentFileName=filer;