author | llornkcor <llornkcor> | 2002-02-24 07:39:56 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-24 07:39:56 (UTC) |
commit | f7be370d10a69cfe78b04687fe728b32d566083a (patch) (unidiff) | |
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) (show whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 33 |
1 files changed, 25 insertions, 8 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 | |||
@@ -21,8 +21,9 @@ | |||
21 | 21 | ||
22 | #include "textedit.h" | 22 | #include "textedit.h" |
23 | #include "fileBrowser.h" | 23 | #include "fileBrowser.h" |
24 | #include "fileSaver.h" | 24 | #include "fileSaver.h" |
25 | #include "filePermissions.h" | ||
25 | 26 | ||
26 | #include "fontDialog.h" | 27 | #include "fontDialog.h" |
27 | 28 | ||
28 | #include <qpe/fontdatabase.h> | 29 | #include <qpe/fontdatabase.h> |
@@ -46,8 +47,11 @@ | |||
46 | #include <qpopupmenu.h> | 47 | #include <qpopupmenu.h> |
47 | #include <qspinbox.h> | 48 | #include <qspinbox.h> |
48 | #include <qtoolbutton.h> | 49 | #include <qtoolbutton.h> |
49 | #include <qwidgetstack.h> | 50 | #include <qwidgetstack.h> |
51 | #include <qcheckbox.h> | ||
52 | #include <unistd.h> | ||
53 | #include <sys/stat.h> | ||
50 | 54 | ||
51 | #include <stdlib.h> //getenv | 55 | #include <stdlib.h> //getenv |
52 | /* XPM */ | 56 | /* XPM */ |
53 | static char * filesave_xpm[] = { | 57 | static char * filesave_xpm[] = { |
@@ -414,9 +418,9 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
414 | } | 418 | } |
415 | 419 | ||
416 | TextEdit::~TextEdit() | 420 | TextEdit::~TextEdit() |
417 | { | 421 | { |
418 | // saveAs(); | 422 | // save(); |
419 | 423 | ||
420 | Config cfg("TextEdit"); | 424 | Config cfg("TextEdit"); |
421 | cfg.setGroup("View"); | 425 | cfg.setGroup("View"); |
422 | QFont f = editor->font(); | 426 | QFont f = editor->font(); |
@@ -693,29 +697,34 @@ void TextEdit::showEditTools() | |||
693 | bool TextEdit::save() | 697 | bool TextEdit::save() |
694 | { | 698 | { |
695 | QString file = doc->file(); | 699 | QString file = doc->file(); |
696 | QString name= doc->name(); | 700 | QString name= doc->name(); |
701 | |||
697 | QString rt = editor->text(); | 702 | QString rt = editor->text(); |
698 | currentFileName= name ; | 703 | currentFileName= name ; |
699 | qDebug("saveFile "+currentFileName); | 704 | qDebug("saveFile "+currentFileName); |
700 | 705 | ||
706 | struct stat buf; | ||
707 | mode_t mode; | ||
708 | lstat(file.latin1(), &buf); | ||
709 | mode = buf.st_mode; | ||
710 | |||
701 | doc->setName( name); | 711 | doc->setName( name); |
702 | FileManager fm; | 712 | FileManager fm; |
703 | if ( !fm.saveFile( *doc, rt ) ) { | 713 | if ( !fm.saveFile( *doc, rt ) ) { |
704 | return false; | 714 | return false; |
705 | } | 715 | } |
706 | // if(doc) | ||
707 | // delete doc; | ||
708 | // doc = 0; | ||
709 | editor->setEdited( false ); | 716 | editor->setEdited( false ); |
717 | |||
718 | chmod( file.latin1(), mode); | ||
710 | return true; | 719 | return true; |
711 | } | 720 | } |
712 | 721 | ||
713 | /*! | 722 | /*! |
714 | prompted save */ | 723 | prompted save */ |
715 | bool TextEdit::saveAs() | 724 | bool TextEdit::saveAs() |
716 | { | 725 | { |
717 | qDebug("saveAsFile "+currentFileName); | 726 | // qDebug("saveAsFile "+currentFileName); |
718 | 727 | ||
719 | // case of nothing to save... /// there's always something to save | 728 | // case of nothing to save... /// there's always something to save |
720 | // if ( !doc )//|| !bFromDocView) | 729 | // if ( !doc )//|| !bFromDocView) |
721 | // { | 730 | // { |
@@ -752,8 +761,9 @@ bool TextEdit::saveAs() | |||
752 | currentFileName=docname; | 761 | currentFileName=docname; |
753 | } | 762 | } |
754 | } | 763 | } |
755 | 764 | ||
765 | |||
756 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); | 766 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); |
757 | qDebug("wanna save filename "+currentFileName); | 767 | qDebug("wanna save filename "+currentFileName); |
758 | fileSaveDlg->exec(); | 768 | fileSaveDlg->exec(); |
759 | if( fileSaveDlg->result() == 1 ) { | 769 | if( fileSaveDlg->result() == 1 ) { |
@@ -771,20 +781,26 @@ bool TextEdit::saveAs() | |||
771 | nf.setFile( fileNm); | 781 | nf.setFile( fileNm); |
772 | doc = new DocLnk(nf); | 782 | doc = new DocLnk(nf); |
773 | // editor->setText(rt); | 783 | // editor->setText(rt); |
774 | qDebug("openFile doclnk "+currentFileName); | 784 | qDebug("openFile doclnk "+currentFileName); |
775 | } | ||
776 | doc->setName( currentFileName); | 785 | doc->setName( currentFileName); |
777 | updateCaption( currentFileName); | 786 | updateCaption( currentFileName); |
778 | 787 | ||
779 | FileManager fm; | 788 | FileManager fm; |
780 | if ( !fm.saveFile( *doc, rt ) ) { | 789 | if ( !fm.saveFile( *doc, rt ) ) { |
781 | return false; | 790 | return false; |
782 | } | 791 | } |
783 | // delete doc; | 792 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
784 | // doc = 0; | 793 | filePermissions *filePerm; |
794 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); | ||
795 | filePerm->exec(); | ||
785 | editor->setEdited( false ); | 796 | editor->setEdited( false ); |
797 | if( filePerm) | ||
798 | delete filePerm; | ||
786 | } | 799 | } |
800 | } | ||
801 | } | ||
802 | |||
787 | if(fileSaveDlg) | 803 | if(fileSaveDlg) |
788 | delete fileSaveDlg; | 804 | delete fileSaveDlg; |
789 | return true; | 805 | return true; |
790 | } | 806 | } |
@@ -834,8 +850,9 @@ void TextEdit::closeEvent( QCloseEvent *e ) | |||
834 | } | 850 | } |
835 | 851 | ||
836 | void TextEdit::accept() | 852 | void TextEdit::accept() |
837 | { | 853 | { |
854 | save(); | ||
838 | close(); | 855 | close(); |
839 | // fileOpen(); //godamn thats obnoxious! lemme out!!! | 856 | // fileOpen(); //godamn thats obnoxious! lemme out!!! |
840 | } | 857 | } |
841 | 858 | ||