summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-03-16 21:13:17 (UTC)
committer llornkcor <llornkcor>2003-03-16 21:13:17 (UTC)
commita637dff6d55b28cba58b8116b457c5bf46daab57 (patch) (side-by-side diff)
tree8698751b7d4c4817f83844898a697d5921d35ae5
parent75ebe1838923e121cb093310f7f7c1b021abdcc1 (diff)
downloadopie-a637dff6d55b28cba58b8116b457c5bf46daab57.zip
opie-a637dff6d55b28cba58b8116b457c5bf46daab57.tar.gz
opie-a637dff6d55b28cba58b8116b457c5bf46daab57.tar.bz2
fix open .desktop file
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 5edf102..59a605a 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -354,65 +354,64 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
a->addTo( searchBar );
edit->insertSeparator();
a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
a->addTo( edit );
searchBar->hide();
editor = new QpeEditor( this );
setCentralWidget( editor );
editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
connect( editor, SIGNAL( textChanged() ),
this, SLOT( editorChanged() ) );
QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold);
Config cfg("TextEdit");
cfg. setGroup ( "Font" );
QFont defaultFont = editor-> font ( );
QString family = cfg. readEntry ( "Family", defaultFont. family ( ));
int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( ));
int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( ));
bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( ));
defaultFont = QFont ( family, size, weight, italic );
editor-> setFont ( defaultFont );
-
// updateCaption();
cfg.setGroup ( "View" );
promptExit = cfg.readBoolEntry ( "PromptExit", false );
openDesktop = cfg.readBoolEntry ( "OpenDesktop", true );
filePerms = cfg.readBoolEntry ( "FilePermissions", false );
useSearchBar = cfg.readBoolEntry ( "SearchBar", false );
startWithNew = cfg.readBoolEntry ( "startNew", true);
featureAutoSave = cfg.readBoolEntry( "autosave", false);
if(useSearchBar) searchBarAction->setOn(true);
if(promptExit) nAdvanced->setOn( true );
if(openDesktop) desktopAction->setOn( true );
if(filePerms) filePermAction->setOn( true );
if(startWithNew) nStart->setOn( true );
if(featureAutoSave) nAutoSave->setOn(true);
// {
// doTimer(true);
// }
bool wrap = cfg. readBoolEntry ( "Wrap", true );
wa-> setOn ( wrap );
setWordWrap ( wrap );
/////////////////
if( qApp->argc() > 1) {
currentFileName=qApp->argv()[1];
QFileInfo fi(currentFileName);
@@ -670,97 +669,105 @@ void TextEdit::newFile( const DocLnk &f ) {
qDebug("newFile "+currentFileName);
updateCaption( currentFileName);
// editor->setEdited( false);
}
void TextEdit::openDotFile( const QString &f ) {
if(!currentFileName.isEmpty()) {
currentFileName=f;
qDebug("openFile dotfile " + currentFileName);
QString txt;
QFile file(f);
file.open(IO_ReadWrite);
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 ) {
qDebug("filename is "+ f);
QString filer;
QFileInfo fi( f);
// bFromDocView = true;
- if(f.find(".desktop",0,true) != -1 && !openDesktop ) {
+ 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:
+ tr(".desktop File"),tr("Linked Document"),0,1,1) )
+ {
+ case 0: //desktop
filer = f;
break;
- case 1:
+ case 1: //linked
DocLnk sf(f);
filer = sf.file();
break;
+ };
}
- } else if(fi.baseName().left(1) == "") {
+ else if(fi.baseName().left(1) == "")
+ {
+ qDebug("opening dotfile");
currentFileName=f;
openDotFile(currentFileName);
- } else {
+ return;
+ }
+ else
+ {
DocLnk sf(f);
filer = sf.file();
if(filer.right(1) == "/")
filer = f;
+ }
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filer);
currentFileName=filer;
nf.setName(fi.baseName());
openFile(nf);
qDebug("openFile string "+currentFileName);
- }
showEditTools();
// Show filename in caption
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.file();
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();
setTimer();