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) (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 | |||
@@ -17,16 +17,17 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
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> |
29 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
30 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
31 | #include <qpe/applnk.h> | 32 | #include <qpe/applnk.h> |
32 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
@@ -42,16 +43,19 @@ | |||
42 | #include <qfileinfo.h> | 43 | #include <qfileinfo.h> |
43 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
44 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
45 | #include <qobjectlist.h> | 46 | #include <qobjectlist.h> |
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[] = { |
54 | "16 16 78 1", | 58 | "16 16 78 1", |
55 | " c None", | 59 | " c None", |
56 | ". c #343434", | 60 | ". c #343434", |
57 | "+ c #A0A0A0", | 61 | "+ c #A0A0A0", |
@@ -410,17 +414,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
410 | wa->setOn(wrap); | 414 | wa->setOn(wrap); |
411 | updateCaption(); | 415 | updateCaption(); |
412 | 416 | ||
413 | fileNew(); | 417 | fileNew(); |
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(); |
423 | cfg.writeEntry("FontSize",f.pointSize()); | 427 | cfg.writeEntry("FontSize",f.pointSize()); |
424 | cfg.writeEntry("Bold",f.bold()); | 428 | cfg.writeEntry("Bold",f.bold()); |
425 | cfg.writeEntry("Italic",f.italic()); | 429 | cfg.writeEntry("Italic",f.italic()); |
426 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 430 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
@@ -689,37 +693,42 @@ void TextEdit::showEditTools() | |||
689 | } | 693 | } |
690 | 694 | ||
691 | /*! | 695 | /*! |
692 | unprompted save */ | 696 | unprompted save */ |
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 | // { |
722 | // qDebug("no doc"); | 731 | // qDebug("no doc"); |
723 | // return true; | 732 | // return true; |
724 | // } | 733 | // } |
725 | if ( !editor->edited() ) { | 734 | if ( !editor->edited() ) { |
@@ -748,49 +757,56 @@ bool TextEdit::saveAs() | |||
748 | docname = docname.left(40); | 757 | docname = docname.left(40); |
749 | if ( docname.isEmpty() ) | 758 | if ( docname.isEmpty() ) |
750 | docname = "Unnamed"; | 759 | docname = "Unnamed"; |
751 | doc->setName(docname); | 760 | doc->setName(docname); |
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 ) { |
760 | QString fileNm=fileSaveDlg->selectedFileName; | 770 | QString fileNm=fileSaveDlg->selectedFileName; |
761 | qDebug("saving filename "+fileNm); | 771 | qDebug("saving filename "+fileNm); |
762 | QFileInfo fi(fileNm); | 772 | QFileInfo fi(fileNm); |
763 | currentFileName=fi.fileName(); | 773 | currentFileName=fi.fileName(); |
764 | if(doc) { | 774 | if(doc) { |
765 | qDebug("doclnk exists"); | 775 | qDebug("doclnk exists"); |
766 | // QString file = doc->file(); | 776 | // QString file = doc->file(); |
767 | // doc->removeFiles(); | 777 | // doc->removeFiles(); |
768 | delete doc; | 778 | delete doc; |
769 | DocLnk nf; | 779 | DocLnk nf; |
770 | nf.setType("text/plain"); | 780 | nf.setType("text/plain"); |
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 | } | 785 | doc->setName( currentFileName); |
776 | doc->setName( currentFileName); | 786 | updateCaption( currentFileName); |
777 | updateCaption( currentFileName); | 787 | |
778 | 788 | FileManager fm; | |
779 | FileManager fm; | 789 | if ( !fm.saveFile( *doc, rt ) ) { |
780 | if ( !fm.saveFile( *doc, rt ) ) { | 790 | return false; |
781 | return false; | 791 | } |
782 | } | 792 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
783 | // delete doc; | 793 | filePermissions *filePerm; |
784 | // doc = 0; | 794 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); |
785 | editor->setEdited( false ); | 795 | filePerm->exec(); |
796 | editor->setEdited( false ); | ||
797 | if( filePerm) | ||
798 | delete filePerm; | ||
799 | } | ||
800 | } | ||
786 | } | 801 | } |
802 | |||
787 | if(fileSaveDlg) | 803 | if(fileSaveDlg) |
788 | delete fileSaveDlg; | 804 | delete fileSaveDlg; |
789 | return true; | 805 | return true; |
790 | } | 806 | } |
791 | 807 | ||
792 | void TextEdit::clear() | 808 | void TextEdit::clear() |
793 | { | 809 | { |
794 | delete doc; | 810 | delete doc; |
795 | doc = 0; | 811 | doc = 0; |
796 | editor->clear(); | 812 | editor->clear(); |
@@ -830,16 +846,17 @@ void TextEdit::closeEvent( QCloseEvent *e ) | |||
830 | } else { | 846 | } else { |
831 | bFromDocView = FALSE; | 847 | bFromDocView = FALSE; |
832 | e->accept(); | 848 | e->accept(); |
833 | } | 849 | } |
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 | ||
842 | void TextEdit::changeFont() { | 859 | void TextEdit::changeFont() { |
843 | FontDatabase fdb; | 860 | FontDatabase fdb; |
844 | QFont defaultFont=editor->font(); | 861 | QFont defaultFont=editor->font(); |
845 | QFontInfo fontInfo(defaultFont); | 862 | QFontInfo fontInfo(defaultFont); |