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) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp149
1 files changed, 78 insertions, 71 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
@@ -193,5 +193,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
QPopupMenu *edit = new QPopupMenu( this );
QPopupMenu *advancedMenu = new QPopupMenu(this);
-
+
font = new QPopupMenu( this );
@@ -248,5 +248,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
a->addTo( edit );
#endif
-
+
a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ),
QString::null, 0, this, 0 );
@@ -275,5 +275,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
font->insertSeparator();
font->insertItem(tr("Advanced Features"), advancedMenu);
-
+
QAction *wa = new QAction( tr("Wrap lines"),
QString::null, 0, this, 0 );
@@ -325,5 +325,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
nAutoSave->setToggleAction(true);
nAutoSave->addTo( advancedMenu);
-
+
font->insertSeparator();
@@ -384,5 +384,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
defaultFont = QFont ( family, size, weight, italic );
editor-> setFont ( defaultFont );
-
// updateCaption();
@@ -395,5 +394,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
startWithNew = cfg.readBoolEntry ( "startNew", true);
featureAutoSave = cfg.readBoolEntry( "autosave", false);
-
+
if(useSearchBar) searchBarAction->setOn(true);
if(promptExit) nAdvanced->setOn( true );
@@ -406,5 +405,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
// doTimer(true);
// }
-
+
bool wrap = cfg. readBoolEntry ( "Wrap", true );
wa-> setOn ( wrap );
@@ -414,5 +413,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
if( qApp->argc() > 1) {
currentFileName=qApp->argv()[1];
-
+
QFileInfo fi(currentFileName);
@@ -447,5 +446,5 @@ void TextEdit::closeEvent(QCloseEvent *) {
break;
- case 2:
+ case 2:
{
qApp->quit();
@@ -453,5 +452,5 @@ void TextEdit::closeEvent(QCloseEvent *) {
break;
- case -1:
+ case -1:
break;
};
@@ -459,9 +458,9 @@ void TextEdit::closeEvent(QCloseEvent *) {
else
qApp->quit();
-
+
}
void TextEdit::cleanUp() {
-
+
Config cfg ( "TextEdit" );
cfg. setGroup ( "Font" );
@@ -471,5 +470,5 @@ void TextEdit::cleanUp() {
cfg.writeEntry ( "Weight", f. weight ( ));
cfg.writeEntry ( "Italic", f. italic ( ));
-
+
cfg.setGroup ( "View" );
cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth );
@@ -560,5 +559,5 @@ void TextEdit::setSearchBar(bool b) {
else
searchBar->hide();
- editor->setFocus();
+ editor->setFocus();
}
@@ -676,5 +675,5 @@ void TextEdit::openDotFile( const QString &f ) {
if(!currentFileName.isEmpty()) {
currentFileName=f;
-
+
qDebug("openFile dotfile " + currentFileName);
QString txt;
@@ -696,48 +695,56 @@ void TextEdit::openDotFile( const QString &f ) {
void TextEdit::openFile( const QString &f ) {
- qDebug("filename is "+ f);
- QString filer;
- QFileInfo fi( f);
+ qDebug("filename is "+ f);
+ 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>
+ 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:
- filer = f;
- break;
- case 1:
- DocLnk sf(f);
- filer = sf.file();
- break;
- }
- } else if(fi.baseName().left(1) == "") {
- currentFileName=f;
- openDotFile(currentFileName);
- } else {
- DocLnk sf(f);
- filer = sf.file();
- if(filer.right(1) == "/")
- filer = f;
-
- DocLnk nf;
- nf.setType("text/plain");
- nf.setFile(filer);
- currentFileName=filer;
+ 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) == "")
+ {
+ qDebug("opening dotfile");
+ currentFileName=f;
+ openDotFile(currentFileName);
+ return;
+ }
+ else
+ {
+ DocLnk sf(f);
+ filer = sf.file();
+ if(filer.right(1) == "/")
+ filer = f;
+ }
- nf.setName(fi.baseName());
- openFile(nf);
+ DocLnk nf;
+ nf.setType("text/plain");
+ nf.setFile(filer);
+ currentFileName=filer;
- qDebug("openFile string "+currentFileName);
+ nf.setName(fi.baseName());
+ openFile(nf);
- }
- showEditTools();
- // Show filename in caption
- QString name = filer;
- int sep = name.findRev( '/' );
- if ( sep > 0 )
- name = name.mid( sep+1 );
- updateCaption( name );
+ 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 );
}
@@ -819,5 +826,5 @@ bool TextEdit::save() {
return false;
}
-
+
}
editor->setEdited( false);
@@ -842,5 +849,5 @@ bool TextEdit::saveAs() {
return false;
qDebug("saveAsFile " + currentFileName);
- // case of nothing to save...
+ // case of nothing to save...
// if ( !doc && !currentFileName.isEmpty()) {
// //|| !bFromDocView)
@@ -856,5 +863,5 @@ bool TextEdit::saveAs() {
QString rt = editor->text();
qDebug(currentFileName);
-
+
if( currentFileName.isEmpty()
|| currentFileName == tr("Unnamed")
@@ -913,5 +920,5 @@ bool TextEdit::saveAs() {
QFileInfo fi(fileNm);
currentFileName=fi.fileName();
- if(doc)
+ if(doc)
// QString file = doc->file();
// doc->removeFiles();
@@ -948,5 +955,5 @@ bool TextEdit::saveAs() {
if(caption().left(1)=="*")
setCaption(caption().right(caption().length()-1));
-
+
return true;
}
@@ -962,5 +969,5 @@ void TextEdit::clear() {
void TextEdit::updateCaption( const QString &name ) {
-
+
if ( name.isEmpty() )
setCaption( tr("Text Editor") );
@@ -1030,5 +1037,5 @@ void TextEdit::editDelete() {
}
break;
- case 1:
+ case 1:
// exit
break;
@@ -1057,5 +1064,5 @@ void TextEdit::receive(const QCString&msg, const QByteArray &) {
if ( msg == "setDocument(QString)" ) {
qDebug("bugger all");
-
+
}
@@ -1073,5 +1080,5 @@ void TextEdit::doPrompt(bool b) {
Config cfg("TextEdit");
cfg.setGroup ( "View" );
- cfg.writeEntry ( "PromptExit", b);
+ cfg.writeEntry ( "PromptExit", b);
}
@@ -1080,5 +1087,5 @@ void TextEdit::doDesktop(bool b) {
Config cfg("TextEdit");
cfg.setGroup ( "View" );
- cfg.writeEntry ( "OpenDesktop", b);
+ cfg.writeEntry ( "OpenDesktop", b);
}
@@ -1087,5 +1094,5 @@ void TextEdit::doFilePerms(bool b) {
Config cfg("TextEdit");
cfg.setGroup ( "View" );
- cfg.writeEntry ( "FilePermissions", b);
+ cfg.writeEntry ( "FilePermissions", b);
}
@@ -1113,5 +1120,5 @@ int TextEdit::savePrompt()
break;
- case 1:
+ case 1:
{
return 2;
@@ -1151,11 +1158,11 @@ void TextEdit::doTimer(bool b)
Config cfg("TextEdit");
cfg.setGroup ( "View" );
- cfg.writeEntry ( "autosave", b);
- featureAutoSave = b;
+ cfg.writeEntry ( "autosave", b);
+ featureAutoSave = b;
nAutoSave->setOn(b);
if(b)
{
// qDebug("doTimer true");
- setTimer();
+ setTimer();
}
// else
@@ -1179,5 +1186,5 @@ void TextEdit::gotoLine() {
QWidget *d = QApplication::desktop();
gotoEdit = new QLineEdit( 0, "Goto line");
-
+
gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2));
gotoEdit->setFrame(true);
@@ -1194,5 +1201,5 @@ void TextEdit::doGoto() {
gotoEdit = 0;
}
-
+
bool ok;
int lineNumber = number.toInt(&ok, 10);