summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-24 01:00:52 (UTC)
committer llornkcor <llornkcor>2002-04-24 01:00:52 (UTC)
commit29e4dd18cbbe6d5967561b428a9632629cff3fde (patch) (side-by-side diff)
tree4e3f6daaabd72937b2d1222f22d5797bb4c80b96
parent23f73a3a483a4daf3a26d0e83fd947d4f4118013 (diff)
downloadopie-29e4dd18cbbe6d5967561b428a9632629cff3fde.zip
opie-29e4dd18cbbe6d5967561b428a9632629cff3fde.tar.gz
opie-29e4dd18cbbe6d5967561b428a9632629cff3fde.tar.bz2
changed way of saving files, so a file opened through the file dialog, which is not a DocLnk, gets saved without a DocLnk. I got tired of hearing, 'I edited /etc/so-and-so and it saved it to Documents.' Will make this an option later. :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp40
-rw-r--r--core/apps/textedit/textedit.h2
2 files changed, 33 insertions, 9 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 84888c1..19449cb 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -347,12 +347,14 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
font->insertSeparator();
nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 );
connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) );
nStart->setToggleAction(TRUE);
nStart->addTo( font );
+ font->insertSeparator();
+ font->insertItem(tr("About"), this, SLOT( doAbout()) );
mb->insertItem( tr( "File" ), file );
mb->insertItem( tr( "Edit" ), edit );
mb->insertItem( tr( "View" ), font );
searchBar = new QPEToolBar(this);
@@ -409,12 +411,13 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
if(cfg.readEntry("startNew","TRUE") == "TRUE") {
nStart->setOn(TRUE);
fileNew();
} else {
fileOpen();
}
+
viewSelection = cfg.readNumEntry( "FileView", 0 );
}
void TextEdit::cleanUp()
{
// save();
@@ -501,13 +504,13 @@ void TextEdit::fileNew()
void TextEdit::fileOpen()
{
Config cfg("TextEdit");
cfg.setGroup("View");
bool b=FALSE;
- if(cfg.readEntry("useOldFileDialog") == "TRUE")
+ if(cfg.readEntry("useOldFileDialog") == "TRUE")
b=TRUE;
if(!b) {
QString str = OFileDialog::getOpenFileName( 1,"/","", "text/plain", this );
if(!str.isEmpty() )
openFile( str );
} else {
@@ -527,17 +530,17 @@ void TextEdit::fileOpen()
fileTemp = *f;
fileTemp.right( fileTemp.length()-5);
QString fileName = fileTemp;
if( fileName != "Unnamed" || fileName != "Empty Text" ) {
currentFileName = fileName;
qDebug("please open "+currentFileName);
- openFile(str );
+ openFile(currentFileName );
}
}
viewSelection = browseForFiles->SelectionCombo->currentItem();
- }
+ }
delete browseForFiles;
editor->setEdited( FALSE);
edited1=FALSE;
edited=FALSE;
if(caption().left(1)=="*")
setCaption(caption().right(caption().length()-1));
@@ -660,14 +663,16 @@ void TextEdit::openFile( const QString &f )
break;
case 1:
DocLnk sf(f);
filer = sf.file();
break;
}
- } else
+ } else {
filer = f;
+ fileIs = TRUE;
+ }
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filer);
currentFileName=filer;
QFileInfo fi( currentFileName);
@@ -739,17 +744,28 @@ bool TextEdit::save()
qDebug("saveFile "+currentFileName);
struct stat buf;
mode_t mode;
stat(file.latin1(), &buf);
mode = buf.st_mode;
-
- doc->setName( name);
- FileManager fm;
- if ( !fm.saveFile( *doc, rt ) ) {
- return false;
+ if(!fileIs) {
+ doc->setName( name);
+ FileManager fm;
+ if ( !fm.saveFile( *doc, rt ) ) {
+ return false;
+ }
+ } else {
+ qDebug("regular save file");
+ QFile f(file);
+ if( f.open(IO_WriteOnly)) {
+ f.writeBlock(rt,rt.length());
+ } else {
+ QMessageBox::message("Text Edit","Write Failed");
+ return false;
+ }
+
}
editor->setEdited( FALSE);
edited1=FALSE;
edited=FALSE;
if(caption().left(1)=="*")
setCaption(caption().right(caption().length()-1));
@@ -966,6 +982,12 @@ void TextEdit::receive(const QCString&msg, const QByteArray&) {
qDebug("QCop "+msg);
if ( msg == "setDocument(QString)" ) {
qDebug("bugger all");
}
}
+void TextEdit::doAbout() {
+ QMessageBox::about(0,"Text Edit","Text Edit is copyright\n"
+ "2000 Trolltech AS, and\n"
+ "2002 by L.J.Potter \nljp@llornkcor.com\n"
+ "and is licensed under the GPL");
+}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index edc6fe3..9d27ab0 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -62,15 +62,17 @@ public:
void openFile( const QString & );
QCopChannel * channel;
public slots:
void editorChanged();
void receive(const QCString&, const QByteArray&);
protected:
+ bool fileIs;
void closeEvent( QCloseEvent *e );
void doSearchBar();
private slots:
+ void doAbout();
void setDocument(const QString&);
void changeFont();
void fileNew();
void fileRevert();
void fileOpen();
void changeStartConfig(bool);