author | llornkcor <llornkcor> | 2002-02-24 07:39:56 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-24 07:39:56 (UTC) |
commit | f7be370d10a69cfe78b04687fe728b32d566083a (patch) (side-by-side diff) | |
tree | 6e586d6543cfd3a60e9734b515642bd86fc052cd /core/apps/textedit/textedit.cpp | |
parent | f1c800025cf759ca0d6257a42f548216d217b16b (diff) | |
download | opie-f7be370d10a69cfe78b04687fe728b32d566083a.zip opie-f7be370d10a69cfe78b04687fe728b32d566083a.tar.gz opie-f7be370d10a69cfe78b04687fe728b32d566083a.tar.bz2 |
added file permissions dialog
Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 75 |
1 files changed, 46 insertions, 29 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index c869dc9..515fcdc 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -19,12 +19,13 @@ **********************************************************************/ // changes added by L. J. Potter Sun 02-17-2002 21:31:31 #include "textedit.h" #include "fileBrowser.h" #include "fileSaver.h" +#include "filePermissions.h" #include "fontDialog.h" #include <qpe/fontdatabase.h> #include <qpe/global.h> #include <qpe/fileselector.h> @@ -44,12 +45,15 @@ #include <qmessagebox.h> #include <qobjectlist.h> #include <qpopupmenu.h> #include <qspinbox.h> #include <qtoolbutton.h> #include <qwidgetstack.h> +#include <qcheckbox.h> +#include <unistd.h> +#include <sys/stat.h> #include <stdlib.h> //getenv /* XPM */ static char * filesave_xpm[] = { "16 16 78 1", " c None", @@ -412,13 +416,13 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) fileNew(); } TextEdit::~TextEdit() { -// saveAs(); +// save(); Config cfg("TextEdit"); cfg.setGroup("View"); QFont f = editor->font(); cfg.writeEntry("FontSize",f.pointSize()); cfg.writeEntry("Bold",f.bold()); @@ -691,33 +695,38 @@ void TextEdit::showEditTools() /*! unprompted save */ bool TextEdit::save() { QString file = doc->file(); QString name= doc->name(); + QString rt = editor->text(); currentFileName= name ; qDebug("saveFile "+currentFileName); + struct stat buf; + mode_t mode; + lstat(file.latin1(), &buf); + mode = buf.st_mode; + doc->setName( name); FileManager fm; if ( !fm.saveFile( *doc, rt ) ) { return false; } -// if(doc) -// delete doc; -// doc = 0; editor->setEdited( false ); + + chmod( file.latin1(), mode); return true; } /*! prompted save */ bool TextEdit::saveAs() { - qDebug("saveAsFile "+currentFileName); +// qDebug("saveAsFile "+currentFileName); // case of nothing to save... /// there's always something to save // if ( !doc )//|| !bFromDocView) // { // qDebug("no doc"); // return true; @@ -750,45 +759,52 @@ bool TextEdit::saveAs() docname = "Unnamed"; doc->setName(docname); currentFileName=docname; } } + fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); qDebug("wanna save filename "+currentFileName); fileSaveDlg->exec(); if( fileSaveDlg->result() == 1 ) { - QString fileNm=fileSaveDlg->selectedFileName; - qDebug("saving filename "+fileNm); - QFileInfo fi(fileNm); - currentFileName=fi.fileName(); - if(doc) { - qDebug("doclnk exists"); + QString fileNm=fileSaveDlg->selectedFileName; + qDebug("saving filename "+fileNm); + QFileInfo fi(fileNm); + currentFileName=fi.fileName(); + if(doc) { + qDebug("doclnk exists"); // QString file = doc->file(); // doc->removeFiles(); - delete doc; - DocLnk nf; - nf.setType("text/plain"); - nf.setFile( fileNm); - doc = new DocLnk(nf); + delete doc; + DocLnk nf; + nf.setType("text/plain"); + nf.setFile( fileNm); + doc = new DocLnk(nf); // editor->setText(rt); - qDebug("openFile doclnk "+currentFileName); - } - doc->setName( currentFileName); - updateCaption( currentFileName); - - FileManager fm; - if ( !fm.saveFile( *doc, rt ) ) { - return false; - } -// delete doc; -// doc = 0; - editor->setEdited( false ); + qDebug("openFile doclnk "+currentFileName); + doc->setName( currentFileName); + updateCaption( currentFileName); + + FileManager fm; + if ( !fm.saveFile( *doc, rt ) ) { + return false; + } + if( fileSaveDlg->filePermCheck->isChecked() ) { + filePermissions *filePerm; + filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); + filePerm->exec(); + editor->setEdited( false ); + if( filePerm) + delete filePerm; + } + } } + if(fileSaveDlg) - delete fileSaveDlg; + delete fileSaveDlg; return true; } void TextEdit::clear() { delete doc; @@ -832,12 +848,13 @@ void TextEdit::closeEvent( QCloseEvent *e ) e->accept(); } } void TextEdit::accept() { + save(); close(); // fileOpen(); //godamn thats obnoxious! lemme out!!! } void TextEdit::changeFont() { FontDatabase fdb; |