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 | |||
@@ -1,940 +1,966 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
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 | #include "filePermissions.h" |
26 | 26 | ||
27 | #include "fontDialog.h" | 27 | #include "fontDialog.h" |
28 | 28 | ||
29 | #include <qpe/fontdatabase.h> | 29 | #include <qpe/fontdatabase.h> |
30 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
31 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
32 | #include <qpe/applnk.h> | 32 | #include <qpe/applnk.h> |
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
37 | #include <qpe/qpetoolbar.h> | 37 | #include <qpe/qpetoolbar.h> |
38 | //#include <qpe/finddialog.h> | 38 | //#include <qpe/finddialog.h> |
39 | 39 | ||
40 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
41 | #include <qaction.h> | 41 | #include <qaction.h> |
42 | #include <qcolordialog.h> | 42 | #include <qcolordialog.h> |
43 | #include <qfileinfo.h> | 43 | #include <qfileinfo.h> |
44 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qobjectlist.h> | 46 | #include <qobjectlist.h> |
47 | #include <qpopupmenu.h> | 47 | #include <qpopupmenu.h> |
48 | #include <qspinbox.h> | 48 | #include <qspinbox.h> |
49 | #include <qtoolbutton.h> | 49 | #include <qtoolbutton.h> |
50 | #include <qwidgetstack.h> | 50 | #include <qwidgetstack.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <unistd.h> | 52 | #include <unistd.h> |
53 | #include <sys/stat.h> | 53 | #include <sys/stat.h> |
54 | 54 | ||
55 | #include <stdlib.h> //getenv | 55 | #include <stdlib.h> //getenv |
56 | /* XPM */ | 56 | /* XPM */ |
57 | static char * filesave_xpm[] = { | 57 | static char * filesave_xpm[] = { |
58 | "16 16 78 1", | 58 | "16 16 78 1", |
59 | " c None", | 59 | " c None", |
60 | ". c #343434", | 60 | ". c #343434", |
61 | "+ c #A0A0A0", | 61 | "+ c #A0A0A0", |
62 | "@ c #565656", | 62 | "@ c #565656", |
63 | "# c #9E9E9E", | 63 | "# c #9E9E9E", |
64 | "$ c #525252", | 64 | "$ c #525252", |
65 | "% c #929292", | 65 | "% c #929292", |
66 | "& c #676767", | 66 | "& c #676767", |
67 | "* c #848484", | 67 | "* c #848484", |
68 | "= c #666666", | 68 | "= c #666666", |
69 | "- c #D8D8D8", | 69 | "- c #D8D8D8", |
70 | "; c #FFFFFF", | 70 | "; c #FFFFFF", |
71 | "> c #DBDBDB", | 71 | "> c #DBDBDB", |
72 | ", c #636363", | 72 | ", c #636363", |
73 | "' c #989898", | 73 | "' c #989898", |
74 | ") c #2D2D2D", | 74 | ") c #2D2D2D", |
75 | "! c #909090", | 75 | "! c #909090", |
76 | "~ c #AEAEAE", | 76 | "~ c #AEAEAE", |
77 | "{ c #EAEAEA", | 77 | "{ c #EAEAEA", |
78 | "] c #575757", | 78 | "] c #575757", |
79 | "^ c #585858", | 79 | "^ c #585858", |
80 | "/ c #8A8A8A", | 80 | "/ c #8A8A8A", |
81 | "( c #828282", | 81 | "( c #828282", |
82 | "_ c #6F6F6F", | 82 | "_ c #6F6F6F", |
83 | ": c #C9C9C9", | 83 | ": c #C9C9C9", |
84 | "< c #050505", | 84 | "< c #050505", |
85 | "[ c #292929", | 85 | "[ c #292929", |
86 | "} c #777777", | 86 | "} c #777777", |
87 | "| c #616161", | 87 | "| c #616161", |
88 | "1 c #3A3A3A", | 88 | "1 c #3A3A3A", |
89 | "2 c #BEBEBE", | 89 | "2 c #BEBEBE", |
90 | "3 c #2C2C2C", | 90 | "3 c #2C2C2C", |
91 | "4 c #7C7C7C", | 91 | "4 c #7C7C7C", |
92 | "5 c #F6F6F6", | 92 | "5 c #F6F6F6", |
93 | "6 c #FCFCFC", | 93 | "6 c #FCFCFC", |
94 | "7 c #6B6B6B", | 94 | "7 c #6B6B6B", |
95 | "8 c #959595", | 95 | "8 c #959595", |
96 | "9 c #4F4F4F", | 96 | "9 c #4F4F4F", |
97 | "0 c #808080", | 97 | "0 c #808080", |
98 | "a c #767676", | 98 | "a c #767676", |
99 | "b c #818181", | 99 | "b c #818181", |
100 | "c c #B8B8B8", | 100 | "c c #B8B8B8", |
101 | "d c #FBFBFB", | 101 | "d c #FBFBFB", |
102 | "e c #F9F9F9", | 102 | "e c #F9F9F9", |
103 | "f c #CCCCCC", | 103 | "f c #CCCCCC", |
104 | "g c #030303", | 104 | "g c #030303", |
105 | "h c #737373", | 105 | "h c #737373", |
106 | "i c #7A7A7A", | 106 | "i c #7A7A7A", |
107 | "j c #7E7E7E", | 107 | "j c #7E7E7E", |
108 | "k c #6A6A6A", | 108 | "k c #6A6A6A", |
109 | "l c #FAFAFA", | 109 | "l c #FAFAFA", |
110 | "m c #505050", | 110 | "m c #505050", |
111 | "n c #9D9D9D", | 111 | "n c #9D9D9D", |
112 | "o c #333333", | 112 | "o c #333333", |
113 | "p c #7B7B7B", | 113 | "p c #7B7B7B", |
114 | "q c #787878", | 114 | "q c #787878", |
115 | "r c #696969", | 115 | "r c #696969", |
116 | "s c #494949", | 116 | "s c #494949", |
117 | "t c #555555", | 117 | "t c #555555", |
118 | "u c #949494", | 118 | "u c #949494", |
119 | "v c #E6E6E6", | 119 | "v c #E6E6E6", |
120 | "w c #424242", | 120 | "w c #424242", |
121 | "x c #515151", | 121 | "x c #515151", |
122 | "y c #535353", | 122 | "y c #535353", |
123 | "z c #3E3E3E", | 123 | "z c #3E3E3E", |
124 | "A c #D4D4D4", | 124 | "A c #D4D4D4", |
125 | "B c #0C0C0C", | 125 | "B c #0C0C0C", |
126 | "C c #353535", | 126 | "C c #353535", |
127 | "D c #474747", | 127 | "D c #474747", |
128 | "E c #ECECEC", | 128 | "E c #ECECEC", |
129 | "F c #919191", | 129 | "F c #919191", |
130 | "G c #7D7D7D", | 130 | "G c #7D7D7D", |
131 | "H c #000000", | 131 | "H c #000000", |
132 | "I c #404040", | 132 | "I c #404040", |
133 | "J c #858585", | 133 | "J c #858585", |
134 | "K c #323232", | 134 | "K c #323232", |
135 | "L c #D0D0D0", | 135 | "L c #D0D0D0", |
136 | "M c #1C1C1C", | 136 | "M c #1C1C1C", |
137 | " ...+ ", | 137 | " ...+ ", |
138 | " @#$%&..+ ", | 138 | " @#$%&..+ ", |
139 | " .*=-;;>,..+ ", | 139 | " .*=-;;>,..+ ", |
140 | " ')!~;;;;;;{]..", | 140 | " ')!~;;;;;;{]..", |
141 | " ^/(-;;;;;;;_:<", | 141 | " ^/(-;;;;;;;_:<", |
142 | " [}|;;;;;;;{12$", | 142 | " [}|;;;;;;;{12$", |
143 | " #34-55;;;;678$+", | 143 | " #34-55;;;;678$+", |
144 | " 90ab=c;dd;e1fg ", | 144 | " 90ab=c;dd;e1fg ", |
145 | " [ahij((kbl0mn$ ", | 145 | " [ahij((kbl0mn$ ", |
146 | " op^q^^7r&]s/$+ ", | 146 | " op^q^^7r&]s/$+ ", |
147 | "@btu;vbwxy]zAB ", | 147 | "@btu;vbwxy]zAB ", |
148 | "CzDEvEv;;DssF$ ", | 148 | "CzDEvEv;;DssF$ ", |
149 | "G.H{E{E{IxsJ$+ ", | 149 | "G.H{E{E{IxsJ$+ ", |
150 | " +...vEKxzLM ", | 150 | " +...vEKxzLM ", |
151 | " +...z]n$ ", | 151 | " +...z]n$ ", |
152 | " +... "}; | 152 | " +... "}; |
153 | 153 | ||
154 | 154 | ||
155 | #if QT_VERSION < 300 | 155 | #if QT_VERSION < 300 |
156 | 156 | ||
157 | class QpeEditor : public QMultiLineEdit | 157 | class QpeEditor : public QMultiLineEdit |
158 | { | 158 | { |
159 | // Q_OBJECT | 159 | // Q_OBJECT |
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 | }; |
180 | 180 | ||
181 | 181 | ||
182 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 182 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
183 | bool backwards ) | 183 | bool backwards ) |
184 | { | 184 | { |
185 | static bool wrap = FALSE; | 185 | static bool wrap = FALSE; |
186 | int line, col; | 186 | int line, col; |
187 | if ( wrap ) { | 187 | if ( wrap ) { |
188 | if ( !backwards ) | 188 | if ( !backwards ) |
189 | line = col = 0; | 189 | line = col = 0; |
190 | wrap = FALSE; | 190 | wrap = FALSE; |
191 | // emit searchWrapped(); | 191 | // emit searchWrapped(); |
192 | } else { | 192 | } else { |
193 | getCursorPosition( &line, &col ); | 193 | getCursorPosition( &line, &col ); |
194 | } | 194 | } |
195 | //ignore backwards for now.... | 195 | //ignore backwards for now.... |
196 | if ( !backwards ) { | 196 | if ( !backwards ) { |
197 | for ( ; ; ) { | 197 | for ( ; ; ) { |
198 | if ( line >= numLines() ) { | 198 | if ( line >= numLines() ) { |
199 | wrap = TRUE; | 199 | wrap = TRUE; |
200 | //emit notFound(); | 200 | //emit notFound(); |
201 | break; | 201 | break; |
202 | } | 202 | } |
203 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 203 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
204 | if ( findCol >= 0 ) { | 204 | if ( findCol >= 0 ) { |
205 | setCursorPosition( line, findCol, FALSE ); | 205 | setCursorPosition( line, findCol, FALSE ); |
206 | col = findCol + txt.length(); | 206 | col = findCol + txt.length(); |
207 | setCursorPosition( line, col, TRUE ); | 207 | setCursorPosition( line, col, TRUE ); |
208 | 208 | ||
209 | //found = TRUE; | 209 | //found = TRUE; |
210 | break; | 210 | break; |
211 | } | 211 | } |
212 | line++; | 212 | line++; |
213 | col = 0; | 213 | col = 0; |
214 | } | 214 | } |
215 | 215 | ||
216 | } | 216 | } |
217 | 217 | ||
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | #else | 221 | #else |
222 | 222 | ||
223 | #error "Must make a QpeEditor that inherits QTextEdit" | 223 | #error "Must make a QpeEditor that inherits QTextEdit" |
224 | 224 | ||
225 | #endif | 225 | #endif |
226 | 226 | ||
227 | 227 | ||
228 | 228 | ||
229 | 229 | ||
230 | static int u_id = 1; | 230 | static int u_id = 1; |
231 | static int get_unique_id() | 231 | static int get_unique_id() |
232 | { | 232 | { |
233 | return u_id++; | 233 | return u_id++; |
234 | } | 234 | } |
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 | ||
252 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 253 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
253 | QPopupMenu *file = new QPopupMenu( this ); | 254 | QPopupMenu *file = new QPopupMenu( this ); |
254 | QPopupMenu *edit = new QPopupMenu( this ); | 255 | QPopupMenu *edit = new QPopupMenu( this ); |
255 | font = new QPopupMenu( this ); | 256 | font = new QPopupMenu( this ); |
256 | 257 | ||
257 | bar = new QPEToolBar( this ); | 258 | bar = new QPEToolBar( this ); |
258 | editBar = bar; | 259 | editBar = bar; |
259 | 260 | ||
260 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 261 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
261 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 262 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
262 | a->addTo( bar ); | 263 | a->addTo( bar ); |
263 | a->addTo( file ); | 264 | a->addTo( file ); |
264 | 265 | ||
265 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 266 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
266 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 267 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
267 | // a->addTo( bar ); | 268 | // a->addTo( bar ); |
268 | a->addTo( file ); | 269 | a->addTo( file ); |
269 | 270 | ||
270 | a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 271 | a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
271 | connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) ); | 272 | connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) ); |
272 | a->addTo( bar ); | 273 | a->addTo( bar ); |
273 | a->addTo( file ); | 274 | a->addTo( file ); |
274 | 275 | ||
275 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 276 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
276 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 277 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
277 | // a->addTo( bar ); | 278 | // a->addTo( bar ); |
278 | file->insertSeparator(); | 279 | file->insertSeparator(); |
279 | a->addTo( file ); | 280 | a->addTo( file ); |
280 | 281 | ||
281 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 282 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
282 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 283 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
283 | a->addTo( file ); | 284 | a->addTo( file ); |
284 | 285 | ||
285 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 286 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); |
286 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 287 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
287 | a->addTo( editBar ); | 288 | a->addTo( editBar ); |
288 | a->addTo( edit ); | 289 | a->addTo( edit ); |
289 | 290 | ||
290 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 291 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); |
291 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 292 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
292 | a->addTo( editBar ); | 293 | a->addTo( editBar ); |
293 | a->addTo( edit ); | 294 | a->addTo( edit ); |
294 | 295 | ||
295 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 296 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
296 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 297 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
297 | a->addTo( editBar ); | 298 | a->addTo( editBar ); |
298 | a->addTo( edit ); | 299 | a->addTo( edit ); |
299 | 300 | ||
300 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 301 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
301 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 302 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
302 | edit->insertSeparator(); | 303 | edit->insertSeparator(); |
303 | a->addTo( bar ); | 304 | a->addTo( bar ); |
304 | a->addTo( edit ); | 305 | a->addTo( edit ); |
305 | 306 | ||
306 | 307 | ||
307 | int defsize; | 308 | int defsize; |
308 | bool defb, defi, wrap; | 309 | bool defb, defi, wrap; |
309 | 310 | ||
310 | Config cfg("TextEdit"); | 311 | Config cfg("TextEdit"); |
311 | cfg.setGroup("View"); | 312 | cfg.setGroup("View"); |
312 | defsize = cfg.readNumEntry("FontSize",10); | 313 | defsize = cfg.readNumEntry("FontSize",10); |
313 | defb = cfg.readBoolEntry("Bold",FALSE); | 314 | defb = cfg.readBoolEntry("Bold",FALSE); |
314 | defi = cfg.readBoolEntry("Italic",FALSE); | 315 | defi = cfg.readBoolEntry("Italic",FALSE); |
315 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 316 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
316 | 317 | ||
317 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 318 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
318 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 319 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
319 | zin->addTo( font ); | 320 | zin->addTo( font ); |
320 | 321 | ||
321 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 322 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
322 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 323 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
323 | zout->addTo( font ); | 324 | zout->addTo( font ); |
324 | 325 | ||
325 | font->insertSeparator(); | 326 | font->insertSeparator(); |
326 | 327 | ||
327 | #if 0 | 328 | #if 0 |
328 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 329 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
329 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 330 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
330 | ba->setToggleAction(TRUE); | 331 | ba->setToggleAction(TRUE); |
331 | ba->addTo( font ); | 332 | ba->addTo( font ); |
332 | 333 | ||
333 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 334 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
334 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 335 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
335 | ia->setToggleAction(TRUE); | 336 | ia->setToggleAction(TRUE); |
336 | ia->addTo( font ); | 337 | ia->addTo( font ); |
337 | 338 | ||
338 | ba->setOn(defb); | 339 | ba->setOn(defb); |
339 | ia->setOn(defi); | 340 | ia->setOn(defi); |
340 | 341 | ||
341 | font->insertSeparator(); | 342 | font->insertSeparator(); |
342 | #endif | 343 | #endif |
343 | 344 | ||
344 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 345 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
345 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 346 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
346 | wa->setToggleAction(TRUE); | 347 | wa->setToggleAction(TRUE); |
347 | wa->addTo( font ); | 348 | wa->addTo( font ); |
348 | 349 | ||
349 | font->insertSeparator(); | 350 | font->insertSeparator(); |
350 | font->insertItem("Font", this, SLOT(changeFont()) ); | 351 | font->insertItem("Font", this, SLOT(changeFont()) ); |
351 | 352 | ||
352 | font->insertSeparator(); | 353 | font->insertSeparator(); |
353 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 354 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
354 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 355 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
355 | nStart->setToggleAction(TRUE); | 356 | nStart->setToggleAction(TRUE); |
356 | nStart->addTo( font ); | 357 | nStart->addTo( font ); |
357 | 358 | ||
358 | mb->insertItem( tr( "File" ), file ); | 359 | mb->insertItem( tr( "File" ), file ); |
359 | mb->insertItem( tr( "Edit" ), edit ); | 360 | mb->insertItem( tr( "Edit" ), edit ); |
360 | mb->insertItem( tr( "View" ), font ); | 361 | mb->insertItem( tr( "View" ), font ); |
361 | 362 | ||
362 | searchBar = new QPEToolBar(this); | 363 | searchBar = new QPEToolBar(this); |
363 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 364 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
364 | 365 | ||
365 | searchBar->setHorizontalStretchable( TRUE ); | 366 | searchBar->setHorizontalStretchable( TRUE ); |
366 | 367 | ||
367 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 368 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
368 | searchBar->setStretchableWidget( searchEdit ); | 369 | searchBar->setStretchableWidget( searchEdit ); |
369 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 370 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
370 | this, SLOT( search() ) ); | 371 | this, SLOT( search() ) ); |
371 | 372 | ||
372 | 373 | ||
373 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 374 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
374 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 375 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
375 | a->addTo( searchBar ); | 376 | a->addTo( searchBar ); |
376 | a->addTo( edit ); | 377 | a->addTo( edit ); |
377 | 378 | ||
378 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 379 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
379 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 380 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
380 | a->addTo( searchBar ); | 381 | a->addTo( searchBar ); |
381 | 382 | ||
382 | edit->insertSeparator(); | 383 | edit->insertSeparator(); |
383 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 384 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
384 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 385 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
385 | a->addTo( edit ); | 386 | a->addTo( edit ); |
386 | 387 | ||
387 | searchBar->hide(); | 388 | searchBar->hide(); |
388 | 389 | ||
389 | editorStack = new QWidgetStack( this ); | 390 | editorStack = new QWidgetStack( this ); |
390 | setCentralWidget( editorStack ); | 391 | setCentralWidget( editorStack ); |
391 | 392 | ||
392 | searchVisible = FALSE; | 393 | searchVisible = FALSE; |
393 | 394 | ||
394 | fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy | 395 | fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy |
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 | ||
411 | cfg.setGroup("Font"); | 413 | cfg.setGroup("Font"); |
412 | QString family = cfg.readEntry("Family", fontInfo.family()); | 414 | QString family = cfg.readEntry("Family", fontInfo.family()); |
413 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 415 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
414 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 416 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
415 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 417 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
416 | 418 | ||
417 | defaultFont = fdb.font(family,style,i_size,charSet); | 419 | defaultFont = fdb.font(family,style,i_size,charSet); |
418 | editor->setFont( defaultFont); | 420 | editor->setFont( defaultFont); |
419 | 421 | ||
420 | wa->setOn(wrap); | 422 | wa->setOn(wrap); |
421 | updateCaption(); | 423 | updateCaption(); |
422 | 424 | ||
423 | cfg.setGroup("View"); | 425 | cfg.setGroup("View"); |
424 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 426 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
425 | nStart->setOn(TRUE); | 427 | nStart->setOn(TRUE); |
426 | fileNew(); | 428 | fileNew(); |
427 | } else { | 429 | } else { |
428 | fileOpen(); | 430 | fileOpen(); |
429 | } | 431 | } |
430 | 432 | ||
431 | } | 433 | } |
432 | 434 | ||
433 | TextEdit::~TextEdit() | 435 | TextEdit::~TextEdit() |
434 | { | 436 | { |
435 | // save(); | 437 | // save(); |
436 | 438 | ||
437 | Config cfg("TextEdit"); | 439 | Config cfg("TextEdit"); |
438 | cfg.setGroup("View"); | 440 | cfg.setGroup("View"); |
439 | QFont f = editor->font(); | 441 | QFont f = editor->font(); |
440 | cfg.writeEntry("FontSize",f.pointSize()); | 442 | cfg.writeEntry("FontSize",f.pointSize()); |
441 | cfg.writeEntry("Bold",f.bold()); | 443 | cfg.writeEntry("Bold",f.bold()); |
442 | cfg.writeEntry("Italic",f.italic()); | 444 | cfg.writeEntry("Italic",f.italic()); |
443 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 445 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
444 | } | 446 | } |
445 | 447 | ||
446 | void TextEdit::zoomIn() | 448 | void TextEdit::zoomIn() |
447 | { | 449 | { |
448 | setFontSize(editor->font().pointSize()+1,FALSE); | 450 | setFontSize(editor->font().pointSize()+1,FALSE); |
449 | } | 451 | } |
450 | 452 | ||
451 | void TextEdit::zoomOut() | 453 | void TextEdit::zoomOut() |
452 | { | 454 | { |
453 | setFontSize(editor->font().pointSize()-1,TRUE); | 455 | setFontSize(editor->font().pointSize()-1,TRUE); |
454 | } | 456 | } |
455 | 457 | ||
456 | 458 | ||
457 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 459 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
458 | { | 460 | { |
459 | int s=10; | 461 | int s=10; |
460 | for (int i=0; i<nfontsizes; i++) { | 462 | for (int i=0; i<nfontsizes; i++) { |
461 | if ( fontsize[i] == sz ) { | 463 | if ( fontsize[i] == sz ) { |
462 | s = sz; | 464 | s = sz; |
463 | break; | 465 | break; |
464 | } else if ( round_down_not_up ) { | 466 | } else if ( round_down_not_up ) { |
465 | if ( fontsize[i] < sz ) | 467 | if ( fontsize[i] < sz ) |
466 | s = fontsize[i]; | 468 | s = fontsize[i]; |
467 | } else { | 469 | } else { |
468 | if ( fontsize[i] > sz ) { | 470 | if ( fontsize[i] > sz ) { |
469 | s = fontsize[i]; | 471 | s = fontsize[i]; |
470 | break; | 472 | break; |
471 | } | 473 | } |
472 | } | 474 | } |
473 | } | 475 | } |
474 | 476 | ||
475 | QFont f = editor->font(); | 477 | QFont f = editor->font(); |
476 | f.setPointSize(s); | 478 | f.setPointSize(s); |
477 | editor->setFont(f); | 479 | editor->setFont(f); |
478 | 480 | ||
479 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 481 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
480 | zout->setEnabled(s != fontsize[0]); | 482 | zout->setEnabled(s != fontsize[0]); |
481 | } | 483 | } |
482 | 484 | ||
483 | void TextEdit::setBold(bool y) | 485 | void TextEdit::setBold(bool y) |
484 | { | 486 | { |
485 | QFont f = editor->font(); | 487 | QFont f = editor->font(); |
486 | f.setBold(y); | 488 | f.setBold(y); |
487 | editor->setFont(f); | 489 | editor->setFont(f); |
488 | } | 490 | } |
489 | 491 | ||
490 | void TextEdit::setItalic(bool y) | 492 | void TextEdit::setItalic(bool y) |
491 | { | 493 | { |
492 | QFont f = editor->font(); | 494 | QFont f = editor->font(); |
493 | f.setItalic(y); | 495 | f.setItalic(y); |
494 | editor->setFont(f); | 496 | editor->setFont(f); |
495 | } | 497 | } |
496 | 498 | ||
497 | void TextEdit::setWordWrap(bool y) | 499 | void TextEdit::setWordWrap(bool y) |
498 | { | 500 | { |
499 | bool state = editor->edited(); | 501 | bool state = editor->edited(); |
500 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 502 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
501 | editor->setEdited( state ); | 503 | editor->setEdited( state ); |
502 | } | 504 | } |
503 | 505 | ||
504 | void TextEdit::fileNew() | 506 | void TextEdit::fileNew() |
505 | { | 507 | { |
506 | if( !bFromDocView ) { | 508 | if( !bFromDocView ) { |
507 | saveAs(); | 509 | saveAs(); |
508 | } | 510 | } |
509 | newFile(DocLnk()); | 511 | newFile(DocLnk()); |
510 | } | 512 | } |
511 | 513 | ||
512 | void TextEdit::fileOpen() | 514 | void TextEdit::fileOpen() |
513 | { | 515 | { |
514 | // if ( !save() ) { | 516 | // if ( !save() ) { |
515 | // if ( QMessageBox::critical( this, tr( "Out of space" ), | 517 | // if ( QMessageBox::critical( this, tr( "Out of space" ), |
516 | // tr( "Text Editor was unable to\n" | 518 | // tr( "Text Editor was unable to\n" |
517 | // "save your changes.\n" | 519 | // "save your changes.\n" |
518 | // "Free some space and try again.\n" | 520 | // "Free some space and try again.\n" |
519 | // "\nContinue anyway?" ), | 521 | // "\nContinue anyway?" ), |
520 | // QMessageBox::Yes|QMessageBox::Escape, | 522 | // QMessageBox::Yes|QMessageBox::Escape, |
521 | // QMessageBox::No|QMessageBox::Default ) | 523 | // QMessageBox::No|QMessageBox::Default ) |
522 | // != QMessageBox::Yes ) | 524 | // != QMessageBox::Yes ) |
523 | // return; | 525 | // return; |
524 | // else { | 526 | // else { |
525 | // delete doc; | 527 | // delete doc; |
526 | // doc = 0; | 528 | // doc = 0; |
527 | // } | 529 | // } |
528 | // } | 530 | // } |
529 | menu->hide(); | 531 | menu->hide(); |
530 | editBar->hide(); | 532 | editBar->hide(); |
531 | searchBar->hide(); | 533 | searchBar->hide(); |
532 | clearWState (WState_Reserved1 ); | 534 | clearWState (WState_Reserved1 ); |
533 | editorStack->raiseWidget( fileSelector ); | 535 | editorStack->raiseWidget( fileSelector ); |
534 | fileSelector->reread(); | 536 | fileSelector->reread(); |
535 | updateCaption(); | 537 | updateCaption(); |
536 | } | 538 | } |
537 | 539 | ||
538 | void TextEdit::newFileOpen() | 540 | void TextEdit::newFileOpen() |
539 | { | 541 | { |
540 | browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); | 542 | browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); |
541 | if( browseForFiles->exec() != -1 ) { | 543 | if( browseForFiles->exec() != -1 ) { |
542 | QString selFile= browseForFiles->selectedFileName; | 544 | QString selFile= browseForFiles->selectedFileName; |
543 | QStringList fileList=browseForFiles->fileList; | 545 | QStringList fileList=browseForFiles->fileList; |
544 | qDebug(selFile); | 546 | qDebug(selFile); |
545 | QStringList::ConstIterator f; | 547 | QStringList::ConstIterator f; |
546 | QString fileTemp; | 548 | QString fileTemp; |
547 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 549 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
548 | fileTemp = *f; | 550 | fileTemp = *f; |
549 | fileTemp.right( fileTemp.length()-5); | 551 | fileTemp.right( fileTemp.length()-5); |
550 | QString fileName = fileTemp; | 552 | QString fileName = fileTemp; |
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))); |
568 | 573 | ||
569 | //case sensitive, backwards, [category] | 574 | //case sensitive, backwards, [category] |
570 | 575 | ||
571 | connect( editor, SIGNAL(notFound()), | 576 | connect( editor, SIGNAL(notFound()), |
572 | &frmFind, SLOT(slotNotFound()) ); | 577 | &frmFind, SLOT(slotNotFound()) ); |
573 | connect( editor, SIGNAL(searchWrapped()), | 578 | connect( editor, SIGNAL(searchWrapped()), |
574 | &frmFind, SLOT(slotWrapAround()) ); | 579 | &frmFind, SLOT(slotWrapAround()) ); |
575 | 580 | ||
576 | frmFind.exec(); | 581 | frmFind.exec(); |
577 | 582 | ||
578 | 583 | ||
579 | } | 584 | } |
580 | #endif | 585 | #endif |
581 | 586 | ||
582 | void TextEdit::fileRevert() | 587 | void TextEdit::fileRevert() |
583 | { | 588 | { |
584 | clear(); | 589 | clear(); |
585 | fileOpen(); | 590 | fileOpen(); |
586 | } | 591 | } |
587 | 592 | ||
588 | void TextEdit::editCut() | 593 | void TextEdit::editCut() |
589 | { | 594 | { |
590 | #ifndef QT_NO_CLIPBOARD | 595 | #ifndef QT_NO_CLIPBOARD |
591 | editor->cut(); | 596 | editor->cut(); |
592 | #endif | 597 | #endif |
593 | } | 598 | } |
594 | 599 | ||
595 | void TextEdit::editCopy() | 600 | void TextEdit::editCopy() |
596 | { | 601 | { |
597 | #ifndef QT_NO_CLIPBOARD | 602 | #ifndef QT_NO_CLIPBOARD |
598 | editor->copy(); | 603 | editor->copy(); |
599 | #endif | 604 | #endif |
600 | } | 605 | } |
601 | 606 | ||
602 | void TextEdit::editPaste() | 607 | void TextEdit::editPaste() |
603 | { | 608 | { |
604 | #ifndef QT_NO_CLIPBOARD | 609 | #ifndef QT_NO_CLIPBOARD |
605 | editor->paste(); | 610 | editor->paste(); |
606 | #endif | 611 | #endif |
607 | } | 612 | } |
608 | 613 | ||
609 | void TextEdit::editFind() | 614 | void TextEdit::editFind() |
610 | { | 615 | { |
611 | searchBar->show(); | 616 | searchBar->show(); |
612 | searchVisible = TRUE; | 617 | searchVisible = TRUE; |
613 | searchEdit->setFocus(); | 618 | searchEdit->setFocus(); |
614 | } | 619 | } |
615 | 620 | ||
616 | void TextEdit::findNext() | 621 | void TextEdit::findNext() |
617 | { | 622 | { |
618 | editor->find( searchEdit->text(), FALSE, FALSE ); | 623 | editor->find( searchEdit->text(), FALSE, FALSE ); |
619 | 624 | ||
620 | } | 625 | } |
621 | 626 | ||
622 | void TextEdit::findClose() | 627 | void TextEdit::findClose() |
623 | { | 628 | { |
624 | searchVisible = FALSE; | 629 | searchVisible = FALSE; |
625 | searchBar->hide(); | 630 | searchBar->hide(); |
626 | } | 631 | } |
627 | 632 | ||
628 | void TextEdit::search() | 633 | void TextEdit::search() |
629 | { | 634 | { |
630 | editor->find( searchEdit->text(), FALSE, FALSE ); | 635 | editor->find( searchEdit->text(), FALSE, FALSE ); |
631 | } | 636 | } |
632 | 637 | ||
633 | void TextEdit::newFile( const DocLnk &f ) | 638 | void TextEdit::newFile( const DocLnk &f ) |
634 | { | 639 | { |
635 | DocLnk nf = f; | 640 | DocLnk nf = f; |
636 | nf.setType("text/plain"); | 641 | nf.setType("text/plain"); |
637 | clear(); | 642 | clear(); |
638 | editorStack->raiseWidget( editor ); | 643 | editorStack->raiseWidget( editor ); |
639 | setWState (WState_Reserved1 ); | 644 | setWState (WState_Reserved1 ); |
640 | editor->setFocus(); | 645 | editor->setFocus(); |
641 | doc = new DocLnk(nf); | 646 | doc = new DocLnk(nf); |
642 | qDebug("newFile "+currentFileName); | 647 | qDebug("newFile "+currentFileName); |
643 | updateCaption(currentFileName); | 648 | updateCaption(currentFileName); |
644 | } | 649 | } |
645 | 650 | ||
646 | void TextEdit::openFile( const QString &f ) | 651 | void TextEdit::openFile( const QString &f ) |
647 | { | 652 | { |
648 | bFromDocView = TRUE; | 653 | bFromDocView = TRUE; |
649 | DocLnk nf; | 654 | DocLnk nf; |
650 | nf.setType("text/plain"); | 655 | nf.setType("text/plain"); |
651 | nf.setFile(f); | 656 | nf.setFile(f); |
652 | currentFileName=f; | 657 | currentFileName=f; |
653 | QFileInfo fi( currentFileName); | 658 | QFileInfo fi( currentFileName); |
654 | nf.setName(fi.baseName()); | 659 | nf.setName(fi.baseName()); |
655 | qDebug("openFile string"+currentFileName); | 660 | qDebug("openFile string"+currentFileName); |
656 | 661 | ||
657 | openFile(nf); | 662 | openFile(nf); |
658 | showEditTools(); | 663 | showEditTools(); |
659 | // Show filename in caption | 664 | // Show filename in caption |
660 | QString name = f; | 665 | QString name = f; |
661 | int sep = name.findRev( '/' ); | 666 | int sep = name.findRev( '/' ); |
662 | if ( sep > 0 ) | 667 | if ( sep > 0 ) |
663 | name = name.mid( sep+1 ); | 668 | name = name.mid( sep+1 ); |
664 | updateCaption( name ); | 669 | updateCaption( name ); |
665 | } | 670 | } |
666 | 671 | ||
667 | void TextEdit::openFile( const DocLnk &f ) | 672 | void TextEdit::openFile( const DocLnk &f ) |
668 | { | 673 | { |
669 | // clear(); | 674 | // clear(); |
670 | bFromDocView = TRUE; | 675 | bFromDocView = TRUE; |
671 | FileManager fm; | 676 | FileManager fm; |
672 | QString txt; | 677 | QString txt; |
673 | currentFileName=f.name(); | 678 | currentFileName=f.name(); |
674 | qDebug("openFile doclnk " + currentFileName); | 679 | qDebug("openFile doclnk " + currentFileName); |
675 | if ( !fm.loadFile( f, txt ) ) { | 680 | if ( !fm.loadFile( f, txt ) ) { |
676 | // ####### could be a new file | 681 | // ####### could be a new file |
677 | qDebug( "Cannot open file" ); | 682 | qDebug( "Cannot open file" ); |
678 | 683 | ||
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 ) |
696 | // close(); | 705 | // close(); |
697 | // clear(); | 706 | // clear(); |
698 | fileSelector->hide(); | 707 | fileSelector->hide(); |
699 | menu->show(); | 708 | menu->show(); |
700 | editBar->show(); | 709 | editBar->show(); |
701 | if ( searchVisible ) | 710 | if ( searchVisible ) |
702 | searchBar->show(); | 711 | searchBar->show(); |
703 | // updateCaption(); | 712 | // updateCaption(); |
704 | editorStack->raiseWidget( editor ); | 713 | editorStack->raiseWidget( editor ); |
705 | setWState (WState_Reserved1 ); | 714 | setWState (WState_Reserved1 ); |
706 | } | 715 | } |
707 | 716 | ||
708 | /*! | 717 | /*! |
709 | unprompted save */ | 718 | unprompted save */ |
710 | bool TextEdit::save() | 719 | bool TextEdit::save() |
711 | { | 720 | { |
712 | QString file = doc->file(); | 721 | QString file = doc->file(); |
713 | qDebug(file); | 722 | qDebug(file); |
714 | QString name= doc->name(); | 723 | QString name= doc->name(); |
715 | qDebug(name); | 724 | qDebug(name); |
716 | QString rt = editor->text(); | 725 | QString rt = editor->text(); |
717 | if( !rt.isEmpty() ) { | 726 | if( !rt.isEmpty() ) { |
718 | if(name.isEmpty()) { | 727 | if(name.isEmpty()) { |
719 | saveAs(); | 728 | saveAs(); |
720 | } else { | 729 | } else { |
721 | currentFileName= name ; | 730 | currentFileName= name ; |
722 | qDebug("saveFile "+currentFileName); | 731 | qDebug("saveFile "+currentFileName); |
723 | 732 | ||
724 | struct stat buf; | 733 | struct stat buf; |
725 | mode_t mode; | 734 | mode_t mode; |
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 | ||
743 | /*! | 756 | /*! |
744 | prompted save */ | 757 | prompted save */ |
745 | bool TextEdit::saveAs() | 758 | bool TextEdit::saveAs() |
746 | { | 759 | { |
747 | // qDebug("saveAsFile "+currentFileName); | 760 | // qDebug("saveAsFile "+currentFileName); |
748 | 761 | ||
749 | // case of nothing to save... /// there's always something to save | 762 | // case of nothing to save... /// there's always something to save |
750 | // if ( !doc )//|| !bFromDocView) | 763 | // if ( !doc )//|| !bFromDocView) |
751 | // { | 764 | // { |
752 | // qDebug("no doc"); | 765 | // qDebug("no doc"); |
753 | // return true; | 766 | // return true; |
754 | // } | 767 | // } |
755 | if ( !editor->edited() ) { | 768 | if ( !editor->edited() ) { |
756 | delete doc; | 769 | delete doc; |
757 | doc = 0; | 770 | doc = 0; |
758 | return true; | 771 | return true; |
759 | } | 772 | } |
760 | 773 | ||
761 | QString rt = editor->text(); | 774 | QString rt = editor->text(); |
762 | qDebug(currentFileName); | 775 | qDebug(currentFileName); |
763 | 776 | ||
764 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { | 777 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { |
765 | qDebug("do silly TT filename thing"); | 778 | qDebug("do silly TT filename thing"); |
766 | if ( doc->name().isEmpty() ) { | 779 | if ( doc->name().isEmpty() ) { |
767 | QString pt = rt.simplifyWhiteSpace(); | 780 | QString pt = rt.simplifyWhiteSpace(); |
768 | int i = pt.find( ' ' ); | 781 | int i = pt.find( ' ' ); |
769 | QString docname = pt; | 782 | QString docname = pt; |
770 | if ( i > 0 ) | 783 | if ( i > 0 ) |
771 | docname = pt.left( i ); | 784 | docname = pt.left( i ); |
772 | // remove "." at the beginning | 785 | // remove "." at the beginning |
773 | while( docname.startsWith( "." ) ) | 786 | while( docname.startsWith( "." ) ) |
774 | docname = docname.mid( 1 ); | 787 | docname = docname.mid( 1 ); |
775 | docname.replace( QRegExp("/"), "_" ); | 788 | docname.replace( QRegExp("/"), "_" ); |
776 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 789 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
777 | if ( docname.length() > 40 ) | 790 | if ( docname.length() > 40 ) |
778 | docname = docname.left(40); | 791 | docname = docname.left(40); |
779 | if ( docname.isEmpty() ) | 792 | if ( docname.isEmpty() ) |
780 | docname = "Unnamed"; | 793 | docname = "Unnamed"; |
781 | doc->setName(docname); | 794 | doc->setName(docname); |
782 | currentFileName=docname; | 795 | currentFileName=docname; |
783 | } | 796 | } |
784 | } | 797 | } |
785 | 798 | ||
786 | 799 | ||
787 | fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName); | 800 | fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName); |
788 | qDebug("wanna save filename "+currentFileName); | 801 | qDebug("wanna save filename "+currentFileName); |
789 | fileSaveDlg->exec(); | 802 | fileSaveDlg->exec(); |
790 | if( fileSaveDlg->result() == 1 ) { | 803 | if( fileSaveDlg->result() == 1 ) { |
791 | QString fileNm=fileSaveDlg->selectedFileName; | 804 | QString fileNm=fileSaveDlg->selectedFileName; |
792 | qDebug("saving filename "+fileNm); | 805 | qDebug("saving filename "+fileNm); |
793 | QFileInfo fi(fileNm); | 806 | QFileInfo fi(fileNm); |
794 | currentFileName=fi.fileName(); | 807 | currentFileName=fi.fileName(); |
795 | if(doc) { | 808 | if(doc) { |
796 | // QString file = doc->file(); | 809 | // QString file = doc->file(); |
797 | // doc->removeFiles(); | 810 | // doc->removeFiles(); |
798 | delete doc; | 811 | delete doc; |
799 | DocLnk nf; | 812 | DocLnk nf; |
800 | nf.setType("text/plain"); | 813 | nf.setType("text/plain"); |
801 | nf.setFile( fileNm); | 814 | nf.setFile( fileNm); |
802 | doc = new DocLnk(nf); | 815 | doc = new DocLnk(nf); |
803 | // editor->setText(rt); | 816 | // editor->setText(rt); |
804 | // qDebug("openFile doclnk "+currentFileName); | 817 | // qDebug("openFile doclnk "+currentFileName); |
805 | doc->setName( currentFileName); | 818 | doc->setName( currentFileName); |
806 | updateCaption( currentFileName); | 819 | updateCaption( currentFileName); |
807 | 820 | ||
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 | { |
830 | delete doc; | 848 | delete doc; |
831 | doc = 0; | 849 | doc = 0; |
832 | editor->clear(); | 850 | editor->clear(); |
833 | } | 851 | } |
834 | 852 | ||
835 | void TextEdit::updateCaption( const QString &name ) | 853 | void TextEdit::updateCaption( const QString &name ) |
836 | { | 854 | { |
837 | if ( !doc ) | 855 | if ( !doc ) |
838 | setCaption( tr("Text Editor") ); | 856 | setCaption( tr("Text Editor") ); |
839 | else { | 857 | else { |
840 | QString s = name; | 858 | QString s = name; |
841 | if ( s.isNull() ) | 859 | if ( s.isNull() ) |
842 | s = doc->name(); | 860 | s = doc->name(); |
843 | if ( s.isEmpty() ) { | 861 | if ( s.isEmpty() ) { |
844 | s = tr( "Unnamed" ); | 862 | s = tr( "Unnamed" ); |
845 | currentFileName=s; | 863 | currentFileName=s; |
846 | } | 864 | } |
847 | 865 | ||
848 | setCaption( s + " - " + tr("Text Editor") ); | 866 | setCaption( s + " - " + tr("Text Editor") ); |
849 | } | 867 | } |
850 | } | 868 | } |
851 | 869 | ||
852 | void TextEdit::setDocument(const QString& fileref) | 870 | void TextEdit::setDocument(const QString& fileref) |
853 | { | 871 | { |
854 | bFromDocView = TRUE; | 872 | bFromDocView = TRUE; |
855 | qDebug("setDocument "+fileref); | 873 | qDebug("setDocument "+fileref); |
856 | bFromDocView = TRUE; | 874 | bFromDocView = TRUE; |
857 | if(fileref.find(".desktop",0,TRUE) == -1) { | 875 | if(fileref.find(".desktop",0,TRUE) == -1) { |
858 | openFile(fileref); | 876 | openFile(fileref); |
859 | } else { | 877 | } else { |
860 | openFile(DocLnk(fileref)); | 878 | openFile(DocLnk(fileref)); |
861 | } | 879 | } |
862 | } | 880 | } |
863 | 881 | ||
864 | void TextEdit::closeEvent( QCloseEvent *e ) | 882 | void TextEdit::closeEvent( QCloseEvent *e ) |
865 | { | 883 | { |
866 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { | 884 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { |
867 | e->ignore(); | 885 | e->ignore(); |
868 | repaint(); | 886 | repaint(); |
869 | // fileRevert(); | 887 | // fileRevert(); |
870 | 888 | ||
871 | } else { | 889 | } else { |
872 | bFromDocView = FALSE; | 890 | bFromDocView = FALSE; |
873 | e->accept(); | 891 | e->accept(); |
874 | } | 892 | } |
875 | } | 893 | } |
876 | 894 | ||
877 | void TextEdit::accept() | 895 | void TextEdit::accept() |
878 | { | 896 | { |
879 | QString file = doc->file(); | 897 | QString file = doc->file(); |
880 | if (file.find("_.txt",0,TRUE) ==-1) | 898 | if (file.find("_.txt",0,TRUE) ==-1) |
881 | save(); | 899 | save(); |
882 | else { | 900 | else { |
883 | QFile(file).remove(); | 901 | QFile(file).remove(); |
884 | } | 902 | } |
885 | exit(0); | 903 | exit(0); |
886 | 904 | ||
887 | } | 905 | } |
888 | 906 | ||
889 | void TextEdit::changeFont() { | 907 | void TextEdit::changeFont() { |
890 | FontDatabase fdb; | 908 | FontDatabase fdb; |
891 | QFont defaultFont=editor->font(); | 909 | QFont defaultFont=editor->font(); |
892 | QFontInfo fontInfo(defaultFont); | 910 | QFontInfo fontInfo(defaultFont); |
893 | Config cfg("TextEdit"); | 911 | Config cfg("TextEdit"); |
894 | cfg.setGroup("Font"); | 912 | cfg.setGroup("Font"); |
895 | QString family = cfg.readEntry("Family", fontInfo.family()); | 913 | QString family = cfg.readEntry("Family", fontInfo.family()); |
896 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 914 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
897 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 915 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
898 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 916 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
899 | 917 | ||
900 | defaultFont = fdb.font(family,style,i_size,charSet); | 918 | defaultFont = fdb.font(family,style,i_size,charSet); |
901 | 919 | ||
902 | FontDialog *fontDlg; | 920 | FontDialog *fontDlg; |
903 | fontDlg=new FontDialog(this,"FontDialog",TRUE); | 921 | fontDlg=new FontDialog(this,"FontDialog",TRUE); |
904 | 922 | ||
905 | fontDlg->exec(); | 923 | fontDlg->exec(); |
906 | 924 | ||
907 | QFont myFont=fontDlg->selectedFont; | 925 | QFont myFont=fontDlg->selectedFont; |
908 | editor->setFont( myFont); | 926 | editor->setFont( myFont); |
909 | delete fontDlg; | 927 | delete fontDlg; |
910 | 928 | ||
911 | } | 929 | } |
912 | 930 | ||
913 | void TextEdit::editDelete() | 931 | void TextEdit::editDelete() |
914 | { | 932 | { |
915 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { | 933 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { |
916 | case 0: | 934 | case 0: |
917 | if(doc) { | 935 | if(doc) { |
918 | doc->removeFiles(); | 936 | doc->removeFiles(); |
919 | clear(); | 937 | clear(); |
920 | setCaption( tr("Text Editor") ); | 938 | setCaption( tr("Text Editor") ); |
921 | } | 939 | } |
922 | break; | 940 | break; |
923 | case 1: | 941 | case 1: |
924 | // exit | 942 | // exit |
925 | break; | 943 | break; |
926 | }; | 944 | }; |
927 | } | 945 | } |
928 | 946 | ||
929 | void TextEdit::changeStartConfig( bool b ) { | 947 | void TextEdit::changeStartConfig( bool b ) { |
930 | 948 | ||
931 | Config cfg("TextEdit"); | 949 | Config cfg("TextEdit"); |
932 | cfg.setGroup("View"); | 950 | cfg.setGroup("View"); |
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 | |||
@@ -1,118 +1,121 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // additions made by L.J. Potter Sun 02-17-2002 22:27:46 | 20 | // additions made by L.J. Potter Sun 02-17-2002 22:27:46 |
21 | 21 | ||
22 | #ifndef TEXTEDIT_H | 22 | #ifndef TEXTEDIT_H |
23 | #define TEXTEDIT_H | 23 | #define TEXTEDIT_H |
24 | 24 | ||
25 | #define QTEXTEDIT_OPEN_API | 25 | #define QTEXTEDIT_OPEN_API |
26 | 26 | ||
27 | #include "fileBrowser.h" | 27 | #include "fileBrowser.h" |
28 | #include "fileSaver.h" | 28 | #include "fileSaver.h" |
29 | 29 | ||
30 | #include <qpe/filemanager.h> | 30 | #include <qpe/filemanager.h> |
31 | 31 | ||
32 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | #include <qlist.h> | 34 | #include <qlist.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | 36 | ||
37 | class QAction; | 37 | class QAction; |
38 | class QWidgetStack; | 38 | class QWidgetStack; |
39 | class QToolButton; | 39 | class QToolButton; |
40 | class QPopupMenu; | 40 | class QPopupMenu; |
41 | class QToolBar; | 41 | class QToolBar; |
42 | class QLineEdit; | 42 | class QLineEdit; |
43 | class QAction; | 43 | class QAction; |
44 | class FileSelector; | 44 | class FileSelector; |
45 | class QpeEditor; | 45 | class QpeEditor; |
46 | class QPopupMenu; | 46 | class QPopupMenu; |
47 | 47 | ||
48 | class TextEdit : public QMainWindow | 48 | 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(); |
67 | void fileOpen(); | 70 | void fileOpen(); |
68 | void newFileOpen(); | 71 | void newFileOpen(); |
69 | void changeStartConfig(bool); | 72 | void changeStartConfig(bool); |
70 | bool save(); | 73 | bool save(); |
71 | bool saveAs(); | 74 | bool saveAs(); |
72 | 75 | ||
73 | 76 | ||
74 | void editCut(); | 77 | void editCut(); |
75 | void editCopy(); | 78 | void editCopy(); |
76 | void editPaste(); | 79 | void editPaste(); |
77 | void editFind(); | 80 | void editFind(); |
78 | void editDelete(); | 81 | void editDelete(); |
79 | 82 | ||
80 | void findNext(); | 83 | void findNext(); |
81 | void findClose(); | 84 | void findClose(); |
82 | 85 | ||
83 | void search(); | 86 | void search(); |
84 | void accept(); | 87 | void accept(); |
85 | 88 | ||
86 | void newFile( const DocLnk & ); | 89 | void newFile( const DocLnk & ); |
87 | void openFile( const DocLnk & ); | 90 | void openFile( const DocLnk & ); |
88 | void showEditTools(); | 91 | void showEditTools(); |
89 | 92 | ||
90 | void zoomIn(); | 93 | void zoomIn(); |
91 | void zoomOut(); | 94 | void zoomOut(); |
92 | void setBold(bool y); | 95 | void setBold(bool y); |
93 | void setItalic(bool y); | 96 | void setItalic(bool y); |
94 | void setWordWrap(bool y); | 97 | void setWordWrap(bool y); |
95 | 98 | ||
96 | private: | 99 | private: |
97 | void colorChanged( const QColor &c ); | 100 | void colorChanged( const QColor &c ); |
98 | void clear(); | 101 | void clear(); |
99 | void updateCaption( const QString &name=QString::null ); | 102 | void updateCaption( const QString &name=QString::null ); |
100 | void setFontSize(int sz, bool round_down_not_up); | 103 | void setFontSize(int sz, bool round_down_not_up); |
101 | 104 | ||
102 | private: | 105 | private: |
103 | QWidgetStack *editorStack; | 106 | QWidgetStack *editorStack; |
104 | FileSelector *fileSelector; | 107 | FileSelector *fileSelector; |
105 | fileSaver *fileSaveDlg; | 108 | fileSaver *fileSaveDlg; |
106 | fileBrowser *browseForFiles; | 109 | fileBrowser *browseForFiles; |
107 | 110 | ||
108 | QpeEditor* editor; | 111 | QpeEditor* editor; |
109 | QToolBar *menu, *editBar, *searchBar; | 112 | QToolBar *menu, *editBar, *searchBar; |
110 | QLineEdit *searchEdit; | 113 | QLineEdit *searchEdit; |
111 | DocLnk *doc; | 114 | DocLnk *doc; |
112 | bool searchVisible; | 115 | bool searchVisible; |
113 | bool bFromDocView; | 116 | bool bFromDocView; |
114 | QAction *zin, *zout; | 117 | QAction *zin, *zout; |
115 | QString currentFileName; | 118 | QString currentFileName; |
116 | }; | 119 | }; |
117 | 120 | ||
118 | #endif | 121 | #endif |