author | llornkcor <llornkcor> | 2002-03-10 00:09:03 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-10 00:09:03 (UTC) |
commit | 637cea2664defb5414a3897f70b616deba926ffe (patch) (unidiff) | |
tree | 369bac70a10207db8e464dc591b7015cafb0624a | |
parent | 1ad5936cfea54786379c58200d7bbf321dcd6185 (diff) | |
download | opie-637cea2664defb5414a3897f70b616deba926ffe.zip opie-637cea2664defb5414a3897f70b616deba926ffe.tar.gz opie-637cea2664defb5414a3897f70b616deba926ffe.tar.bz2 |
added an asterik in the caption if the text is edited and unsaved
-rw-r--r-- | core/apps/textedit/textedit.cpp | 40 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 5 |
2 files changed, 37 insertions, 8 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 03f3a1e..78c4d8a 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -160,20 +160,20 @@ class QpeEditor : public QMultiLineEdit | |||
160 | public: | 160 | public: |
161 | QpeEditor( QWidget *parent, const char * name = 0 ) | 161 | QpeEditor( QWidget *parent, const char * name = 0 ) |
162 | : QMultiLineEdit( parent, name ) | 162 | : QMultiLineEdit( parent, name ) |
163 | { | 163 | { |
164 | clearTableFlags(); | 164 | clearTableFlags(); |
165 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 165 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
166 | } | 166 | } |
167 | 167 | ||
168 | //public slots: | ||
169 | void find( const QString &txt, bool caseSensitive, | 168 | void find( const QString &txt, bool caseSensitive, |
170 | bool backwards ); | 169 | bool backwards ); |
171 | /* | 170 | //public slots: |
171 | /* | ||
172 | signals: | 172 | signals: |
173 | void notFound(); | 173 | void notFound(); |
174 | void searchWrapped(); | 174 | void searchWrapped(); |
175 | */ | 175 | */ |
176 | 176 | ||
177 | private: | 177 | private: |
178 | 178 | ||
179 | }; | 179 | }; |
@@ -235,17 +235,18 @@ static int get_unique_id() | |||
235 | 235 | ||
236 | static const int nfontsizes = 6; | 236 | static const int nfontsizes = 6; |
237 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 237 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
238 | 238 | ||
239 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 239 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
240 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 240 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) |
241 | { | 241 | { |
242 | doc = 0; | 242 | doc = 0; |
243 | 243 | edited=FALSE; | |
244 | edited1=FALSE; | ||
244 | setToolBarsMovable( FALSE ); | 245 | setToolBarsMovable( FALSE ); |
245 | 246 | ||
246 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 247 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
247 | 248 | ||
248 | QPEToolBar *bar = new QPEToolBar( this ); | 249 | QPEToolBar *bar = new QPEToolBar( this ); |
249 | bar->setHorizontalStretchable( TRUE ); | 250 | bar->setHorizontalStretchable( TRUE ); |
250 | menu = bar; | 251 | menu = bar; |
251 | 252 | ||
@@ -395,16 +396,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
395 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 396 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
396 | connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 397 | connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
397 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); | 398 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); |
398 | // fileOpen(); | 399 | // fileOpen(); |
399 | 400 | ||
400 | editor = new QpeEditor( editorStack ); | 401 | editor = new QpeEditor( editorStack ); |
401 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 402 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
402 | editorStack->addWidget( editor, get_unique_id() ); | 403 | editorStack->addWidget( editor, get_unique_id() ); |
404 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | ||
403 | 405 | ||
404 | resize( 200, 300 ); | 406 | resize( 200, 300 ); |
405 | 407 | ||
406 | // setFontSize(defsize,TRUE); | 408 | // setFontSize(defsize,TRUE); |
407 | FontDatabase fdb; | 409 | FontDatabase fdb; |
408 | QFont defaultFont=editor->font(); | 410 | QFont defaultFont=editor->font(); |
409 | QFontInfo fontInfo(defaultFont); | 411 | QFontInfo fontInfo(defaultFont); |
410 | 412 | ||
@@ -551,17 +553,20 @@ void TextEdit::newFileOpen() | |||
551 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 553 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
552 | currentFileName = fileName; | 554 | currentFileName = fileName; |
553 | qDebug("please open "+currentFileName); | 555 | qDebug("please open "+currentFileName); |
554 | openFile(fileName ); | 556 | openFile(fileName ); |
555 | } | 557 | } |
556 | } | 558 | } |
557 | } | 559 | } |
558 | delete browseForFiles; | 560 | delete browseForFiles; |
559 | editor->setEdited( true ); | 561 | editor->setEdited( FALSE); |
562 | edited1=FALSE; | ||
563 | edited=FALSE; | ||
564 | setCaption(caption().right(caption().length()-1)); | ||
560 | } | 565 | } |
561 | 566 | ||
562 | #if 0 | 567 | #if 0 |
563 | void TextEdit::slotFind() | 568 | void TextEdit::slotFind() |
564 | { | 569 | { |
565 | FindDialog frmFind( "Text Editor", this ); | 570 | FindDialog frmFind( "Text Editor", this ); |
566 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 571 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
567 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 572 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
@@ -679,17 +684,21 @@ void TextEdit::openFile( const DocLnk &f ) | |||
679 | //return; | 684 | //return; |
680 | } | 685 | } |
681 | 686 | ||
682 | fileNew(); | 687 | fileNew(); |
683 | if ( doc ) | 688 | if ( doc ) |
684 | delete doc; | 689 | delete doc; |
685 | doc = new DocLnk(f); | 690 | doc = new DocLnk(f); |
686 | editor->setText(txt); | 691 | editor->setText(txt); |
687 | editor->setEdited( false); | 692 | editor->setEdited( FALSE); |
693 | edited1=FALSE; | ||
694 | edited=FALSE; | ||
695 | setCaption(caption().right(caption().length()-1)); | ||
696 | |||
688 | qDebug("openFile doclnk "+currentFileName); | 697 | qDebug("openFile doclnk "+currentFileName); |
689 | doc->setName(currentFileName); | 698 | doc->setName(currentFileName); |
690 | updateCaption(); | 699 | updateCaption(); |
691 | } | 700 | } |
692 | 701 | ||
693 | void TextEdit::showEditTools() | 702 | void TextEdit::showEditTools() |
694 | { | 703 | { |
695 | // if ( !doc ) | 704 | // if ( !doc ) |
@@ -726,17 +735,21 @@ bool TextEdit::save() | |||
726 | stat(file.latin1(), &buf); | 735 | stat(file.latin1(), &buf); |
727 | mode = buf.st_mode; | 736 | mode = buf.st_mode; |
728 | 737 | ||
729 | doc->setName( name); | 738 | doc->setName( name); |
730 | FileManager fm; | 739 | FileManager fm; |
731 | if ( !fm.saveFile( *doc, rt ) ) { | 740 | if ( !fm.saveFile( *doc, rt ) ) { |
732 | return false; | 741 | return false; |
733 | } | 742 | } |
734 | editor->setEdited( false ); | 743 | editor->setEdited( FALSE); |
744 | edited1=FALSE; | ||
745 | edited=FALSE; | ||
746 | setCaption(caption().right(caption().length()-1)); | ||
747 | |||
735 | 748 | ||
736 | chmod( file.latin1(), mode); | 749 | chmod( file.latin1(), mode); |
737 | } | 750 | } |
738 | return true; | 751 | return true; |
739 | } | 752 | } |
740 | return false; | 753 | return false; |
741 | } | 754 | } |
742 | 755 | ||
@@ -808,22 +821,27 @@ bool TextEdit::saveAs() | |||
808 | FileManager fm; | 821 | FileManager fm; |
809 | if ( !fm.saveFile( *doc, rt ) ) { | 822 | if ( !fm.saveFile( *doc, rt ) ) { |
810 | return false; | 823 | return false; |
811 | } | 824 | } |
812 | if( fileSaveDlg->filePermCheck->isChecked() ) { | 825 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
813 | filePermissions *filePerm; | 826 | filePermissions *filePerm; |
814 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); | 827 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); |
815 | filePerm->exec(); | 828 | filePerm->exec(); |
816 | editor->setEdited( false ); | 829 | |
817 | if( filePerm) | 830 | if( filePerm) |
818 | delete filePerm; | 831 | delete filePerm; |
819 | } | 832 | } |
820 | } | 833 | } |
821 | } | 834 | } |
835 | editor->setEdited( FALSE); | ||
836 | edited1=FALSE; | ||
837 | edited=FALSE; | ||
838 | if(caption().left(1)=="*") | ||
839 | setCaption(caption().right(caption().length()-1)); | ||
822 | 840 | ||
823 | if(fileSaveDlg) | 841 | if(fileSaveDlg) |
824 | delete fileSaveDlg; | 842 | delete fileSaveDlg; |
825 | return true; | 843 | return true; |
826 | } | 844 | } |
827 | 845 | ||
828 | void TextEdit::clear() | 846 | void TextEdit::clear() |
829 | { | 847 | { |
@@ -933,8 +951,16 @@ void TextEdit::changeStartConfig( bool b ) { | |||
933 | if(b) { | 951 | if(b) { |
934 | qDebug("bool"); | 952 | qDebug("bool"); |
935 | cfg.writeEntry("startNew","TRUE"); | 953 | cfg.writeEntry("startNew","TRUE"); |
936 | } else { | 954 | } else { |
937 | cfg.writeEntry("startNew","FALSE"); | 955 | cfg.writeEntry("startNew","FALSE"); |
938 | } | 956 | } |
939 | update(); | 957 | update(); |
940 | } | 958 | } |
959 | |||
960 | void TextEdit::editorChanged() { | ||
961 | if(editor->edited() && edited && !edited1) { | ||
962 | setCaption( "*"+caption()); | ||
963 | edited1=TRUE; | ||
964 | } | ||
965 | edited=TRUE; | ||
966 | } | ||
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index fb58738..e7e20e3 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -49,18 +49,21 @@ class TextEdit : public QMainWindow | |||
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | 51 | ||
52 | public: | 52 | public: |
53 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 53 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
54 | ~TextEdit(); | 54 | ~TextEdit(); |
55 | QPopupMenu *font; | 55 | QPopupMenu *font; |
56 | QAction *nStart; | 56 | QAction *nStart; |
57 | bool edited, edited1; | ||
57 | void openFile( const QString & ); | 58 | void openFile( const QString & ); |
58 | 59 | public slots: | |
60 | void editorChanged(); | ||
61 | |||
59 | protected: | 62 | protected: |
60 | void closeEvent( QCloseEvent *e ); | 63 | void closeEvent( QCloseEvent *e ); |
61 | 64 | ||
62 | private slots: | 65 | private slots: |
63 | void setDocument(const QString&); | 66 | void setDocument(const QString&); |
64 | void changeFont(); | 67 | void changeFont(); |
65 | void fileNew(); | 68 | void fileNew(); |
66 | void fileRevert(); | 69 | void fileRevert(); |