-rw-r--r-- | core/apps/textedit/textedit.cpp | 145 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 18 |
2 files changed, 146 insertions, 17 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index e931f01..1e8ce7f 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,1142 +1,1265 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | // textedit.cpp | 2 | // textedit.cpp |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Opie Environment. | 5 | ** This file is part of Opie Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
14 | #include "textedit.h" | 14 | #include "textedit.h" |
15 | #include "filePermissions.h" | 15 | #include "filePermissions.h" |
16 | 16 | ||
17 | 17 | ||
18 | #include <opie/ofileselector.h> | 18 | #include <opie/ofileselector.h> |
19 | #include <opie/ofiledialog.h> | 19 | #include <opie/ofiledialog.h> |
20 | #include <opie/ofontselector.h> | 20 | #include <opie/ofontselector.h> |
21 | 21 | ||
22 | #include <qpe/fontdatabase.h> | 22 | #include <qpe/fontdatabase.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/fileselector.h> | 24 | #include <qpe/fileselector.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/qpemenubar.h> | 29 | #include <qpe/qpemenubar.h> |
30 | #include <qpe/qpetoolbar.h> | 30 | #include <qpe/qpetoolbar.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <qpoint.h> | 33 | #include <qpoint.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include <qclipboard.h> | 36 | #include <qclipboard.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | #include <qaction.h> | 38 | #include <qaction.h> |
39 | #include <qcolordialog.h> | 39 | #include <qcolordialog.h> |
40 | #include <qfileinfo.h> | 40 | #include <qfileinfo.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qobjectlist.h> | 43 | #include <qobjectlist.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
46 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
47 | #include <qwidgetstack.h> | 47 | #include <qwidgetstack.h> |
48 | #include <qcheckbox.h> | 48 | #include <qcheckbox.h> |
49 | #include <qcombo.h> | 49 | #include <qcombo.h> |
50 | #include <qlayout.h> | 50 | #include <qlayout.h> |
51 | #include <qapplication.h> | 51 | #include <qapplication.h> |
52 | #include <qtimer.h> | ||
53 | #include <qdir.h> | ||
52 | #include <unistd.h> | 54 | #include <unistd.h> |
53 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
54 | #include <stdlib.h> //getenv | 56 | #include <stdlib.h> //getenv |
55 | 57 | ||
56 | 58 | ||
57 | /* XPM */ | 59 | /* XPM */ |
58 | static char * filesave_xpm[] = { | 60 | static char * filesave_xpm[] = { |
59 | "16 16 78 1", | 61 | "16 16 78 1", |
60 | " c None", | 62 | " c None", |
61 | ". c #343434", | 63 | ". c #343434", |
62 | "+ c #A0A0A0", | 64 | "+ c #A0A0A0", |
63 | "@ c #565656", | 65 | "@ c #565656", |
64 | "# c #9E9E9E", | 66 | "# c #9E9E9E", |
65 | "$ c #525252", | 67 | "$ c #525252", |
66 | "% c #929292", | 68 | "% c #929292", |
67 | "& c #676767", | 69 | "& c #676767", |
68 | "* c #848484", | 70 | "* c #848484", |
69 | "= c #666666", | 71 | "= c #666666", |
70 | "- c #D8D8D8", | 72 | "- c #D8D8D8", |
71 | "; c #FFFFFF", | 73 | "; c #FFFFFF", |
72 | "> c #DBDBDB", | 74 | "> c #DBDBDB", |
73 | ", c #636363", | 75 | ", c #636363", |
74 | "' c #989898", | 76 | "' c #989898", |
75 | ") c #2D2D2D", | 77 | ") c #2D2D2D", |
76 | "! c #909090", | 78 | "! c #909090", |
77 | "~ c #AEAEAE", | 79 | "~ c #AEAEAE", |
78 | "{ c #EAEAEA", | 80 | "{ c #EAEAEA", |
79 | "] c #575757", | 81 | "] c #575757", |
80 | "^ c #585858", | 82 | "^ c #585858", |
81 | "/ c #8A8A8A", | 83 | "/ c #8A8A8A", |
82 | "( c #828282", | 84 | "( c #828282", |
83 | "_ c #6F6F6F", | 85 | "_ c #6F6F6F", |
84 | ": c #C9C9C9", | 86 | ": c #C9C9C9", |
85 | "< c #050505", | 87 | "< c #050505", |
86 | "[ c #292929", | 88 | "[ c #292929", |
87 | "} c #777777", | 89 | "} c #777777", |
88 | "| c #616161", | 90 | "| c #616161", |
89 | "1 c #3A3A3A", | 91 | "1 c #3A3A3A", |
90 | "2 c #BEBEBE", | 92 | "2 c #BEBEBE", |
91 | "3 c #2C2C2C", | 93 | "3 c #2C2C2C", |
92 | "4 c #7C7C7C", | 94 | "4 c #7C7C7C", |
93 | "5 c #F6F6F6", | 95 | "5 c #F6F6F6", |
94 | "6 c #FCFCFC", | 96 | "6 c #FCFCFC", |
95 | "7 c #6B6B6B", | 97 | "7 c #6B6B6B", |
96 | "8 c #959595", | 98 | "8 c #959595", |
97 | "9 c #4F4F4F", | 99 | "9 c #4F4F4F", |
98 | "0 c #808080", | 100 | "0 c #808080", |
99 | "a c #767676", | 101 | "a c #767676", |
100 | "b c #818181", | 102 | "b c #818181", |
101 | "c c #B8B8B8", | 103 | "c c #B8B8B8", |
102 | "d c #FBFBFB", | 104 | "d c #FBFBFB", |
103 | "e c #F9F9F9", | 105 | "e c #F9F9F9", |
104 | "f c #CCCCCC", | 106 | "f c #CCCCCC", |
105 | "g c #030303", | 107 | "g c #030303", |
106 | "h c #737373", | 108 | "h c #737373", |
107 | "i c #7A7A7A", | 109 | "i c #7A7A7A", |
108 | "j c #7E7E7E", | 110 | "j c #7E7E7E", |
109 | "k c #6A6A6A", | 111 | "k c #6A6A6A", |
110 | "l c #FAFAFA", | 112 | "l c #FAFAFA", |
111 | "m c #505050", | 113 | "m c #505050", |
112 | "n c #9D9D9D", | 114 | "n c #9D9D9D", |
113 | "o c #333333", | 115 | "o c #333333", |
114 | "p c #7B7B7B", | 116 | "p c #7B7B7B", |
115 | "q c #787878", | 117 | "q c #787878", |
116 | "r c #696969", | 118 | "r c #696969", |
117 | "s c #494949", | 119 | "s c #494949", |
118 | "t c #555555", | 120 | "t c #555555", |
119 | "u c #949494", | 121 | "u c #949494", |
120 | "v c #E6E6E6", | 122 | "v c #E6E6E6", |
121 | "w c #424242", | 123 | "w c #424242", |
122 | "x c #515151", | 124 | "x c #515151", |
123 | "y c #535353", | 125 | "y c #535353", |
124 | "z c #3E3E3E", | 126 | "z c #3E3E3E", |
125 | "A c #D4D4D4", | 127 | "A c #D4D4D4", |
126 | "B c #0C0C0C", | 128 | "B c #0C0C0C", |
127 | "C c #353535", | 129 | "C c #353535", |
128 | "D c #474747", | 130 | "D c #474747", |
129 | "E c #ECECEC", | 131 | "E c #ECECEC", |
130 | "F c #919191", | 132 | "F c #919191", |
131 | "G c #7D7D7D", | 133 | "G c #7D7D7D", |
132 | "H c #000000", | 134 | "H c #000000", |
133 | "I c #404040", | 135 | "I c #404040", |
134 | "J c #858585", | 136 | "J c #858585", |
135 | "K c #323232", | 137 | "K c #323232", |
136 | "L c #D0D0D0", | 138 | "L c #D0D0D0", |
137 | "M c #1C1C1C", | 139 | "M c #1C1C1C", |
138 | " ...+ ", | 140 | " ...+ ", |
139 | " @#$%&..+ ", | 141 | " @#$%&..+ ", |
140 | " .*=-;;>,..+ ", | 142 | " .*=-;;>,..+ ", |
141 | " ')!~;;;;;;{]..", | 143 | " ')!~;;;;;;{]..", |
142 | " ^/(-;;;;;;;_:<", | 144 | " ^/(-;;;;;;;_:<", |
143 | " [}|;;;;;;;{12$", | 145 | " [}|;;;;;;;{12$", |
144 | " #34-55;;;;678$+", | 146 | " #34-55;;;;678$+", |
145 | " 90ab=c;dd;e1fg ", | 147 | " 90ab=c;dd;e1fg ", |
146 | " [ahij((kbl0mn$ ", | 148 | " [ahij((kbl0mn$ ", |
147 | " op^q^^7r&]s/$+ ", | 149 | " op^q^^7r&]s/$+ ", |
148 | "@btu;vbwxy]zAB ", | 150 | "@btu;vbwxy]zAB ", |
149 | "CzDEvEv;;DssF$ ", | 151 | "CzDEvEv;;DssF$ ", |
150 | "G.H{E{E{IxsJ$+ ", | 152 | "G.H{E{E{IxsJ$+ ", |
151 | " +...vEKxzLM ", | 153 | " +...vEKxzLM ", |
152 | " +...z]n$ ", | 154 | " +...z]n$ ", |
153 | " +... "}; | 155 | " +... "}; |
154 | 156 | ||
155 | 157 | ||
156 | #if QT_VERSION < 300 | 158 | #if QT_VERSION < 300 |
157 | 159 | ||
158 | class QpeEditor : public QMultiLineEdit | 160 | class QpeEditor : public QMultiLineEdit |
159 | { | 161 | { |
160 | 162 | ||
161 | public: | 163 | public: |
162 | QpeEditor( QWidget *parent, const char * name = 0 ) | 164 | QpeEditor( QWidget *parent, const char * name = 0 ) |
163 | : QMultiLineEdit( parent, name ) { | 165 | : QMultiLineEdit( parent, name ) { |
164 | clearTableFlags(); | 166 | clearTableFlags(); |
165 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 167 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
166 | } | 168 | } |
167 | 169 | ||
168 | void find( const QString &txt, bool caseSensitive, | 170 | void find( const QString &txt, bool caseSensitive, |
169 | bool backwards ); | 171 | bool backwards ); |
170 | protected: | 172 | protected: |
171 | bool markIt; | 173 | bool markIt; |
172 | int line1, line2, col1, col2; | 174 | int line1, line2, col1, col2; |
173 | void mousePressEvent( QMouseEvent * ); | 175 | void mousePressEvent( QMouseEvent * ); |
174 | void mouseReleaseEvent( QMouseEvent * ); | 176 | void mouseReleaseEvent( QMouseEvent * ); |
175 | 177 | ||
176 | //public slots: | 178 | //public slots: |
177 | /* | 179 | /* |
178 | signals: | 180 | signals: |
179 | void notFound(); | 181 | void notFound(); |
180 | void searchWrapped(); | 182 | void searchWrapped(); |
181 | */ | 183 | */ |
182 | 184 | ||
183 | private: | 185 | private: |
184 | 186 | ||
185 | }; | 187 | }; |
186 | 188 | ||
187 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 189 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { |
188 | switch(e->button()) { | 190 | switch(e->button()) { |
189 | case RightButton: | 191 | case RightButton: |
190 | { //rediculous workaround for qt popup menu | 192 | { //rediculous workaround for qt popup menu |
191 | //and the hold right click mechanism | 193 | //and the hold right click mechanism |
192 | this->setSelection( line1, col1, line2, col2); | 194 | this->setSelection( line1, col1, line2, col2); |
193 | QMultiLineEdit::mousePressEvent( e ); | 195 | QMultiLineEdit::mousePressEvent( e ); |
194 | markIt = false; | 196 | markIt = false; |
195 | } | 197 | } |
196 | break; | 198 | break; |
197 | default: | 199 | default: |
198 | { | 200 | { |
199 | if(!markIt) { | 201 | if(!markIt) { |
200 | int line, col; | 202 | int line, col; |
201 | this->getCursorPosition(&line, &col); | 203 | this->getCursorPosition(&line, &col); |
202 | line1=line2=line; | 204 | line1=line2=line; |
203 | col1=col2=col; | 205 | col1=col2=col; |
204 | } | 206 | } |
205 | QMultiLineEdit::mousePressEvent( e ); | 207 | QMultiLineEdit::mousePressEvent( e ); |
206 | } | 208 | } |
207 | break; | 209 | break; |
208 | }; | 210 | }; |
209 | } | 211 | } |
210 | 212 | ||
211 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 213 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { |
212 | if(this->hasMarkedText()) { | 214 | if(this->hasMarkedText()) { |
213 | markIt = true; | 215 | markIt = true; |
214 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); | 216 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); |
215 | } else { | 217 | } else { |
216 | markIt = false; | 218 | markIt = false; |
217 | } | 219 | } |
218 | } | 220 | } |
219 | 221 | ||
220 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 222 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
221 | bool backwards ) | 223 | bool backwards ) |
222 | { | 224 | { |
223 | static bool wrap = false; | 225 | static bool wrap = false; |
224 | int line, col; | 226 | int line, col; |
225 | if ( wrap ) { | 227 | if ( wrap ) { |
226 | if ( !backwards ) | 228 | if ( !backwards ) |
227 | line = col = 0; | 229 | line = col = 0; |
228 | wrap = false; | 230 | wrap = false; |
229 | // emit searchWrapped(); | 231 | // emit searchWrapped(); |
230 | } else { | 232 | } else { |
231 | getCursorPosition( &line, &col ); | 233 | getCursorPosition( &line, &col ); |
232 | } | 234 | } |
233 | //ignore backwards for now.... | 235 | //ignore backwards for now.... |
234 | if ( !backwards ) { | 236 | if ( !backwards ) { |
235 | for ( ; ; ) { | 237 | for ( ; ; ) { |
236 | if ( line >= numLines() ) { | 238 | if ( line >= numLines() ) { |
237 | wrap = true; | 239 | wrap = true; |
238 | //emit notFound(); | 240 | //emit notFound(); |
239 | break; | 241 | break; |
240 | } | 242 | } |
241 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 243 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
242 | if ( findCol >= 0 ) { | 244 | if ( findCol >= 0 ) { |
243 | setCursorPosition( line, findCol, false ); | 245 | setCursorPosition( line, findCol, false ); |
244 | col = findCol + txt.length(); | 246 | col = findCol + txt.length(); |
245 | setCursorPosition( line, col, true ); | 247 | setCursorPosition( line, col, true ); |
246 | 248 | ||
247 | //found = true; | 249 | //found = true; |
248 | break; | 250 | break; |
249 | } | 251 | } |
250 | line++; | 252 | line++; |
251 | col = 0; | 253 | col = 0; |
252 | } | 254 | } |
253 | } | 255 | } |
254 | } | 256 | } |
255 | 257 | ||
256 | 258 | ||
257 | #else | 259 | #else |
258 | 260 | ||
259 | #error "Must make a QpeEditor that inherits QTextEdit" | 261 | #error "Must make a QpeEditor that inherits QTextEdit" |
260 | 262 | ||
261 | #endif | 263 | #endif |
262 | 264 | ||
263 | 265 | ||
264 | static const int nfontsizes = 6; | 266 | static const int nfontsizes = 6; |
265 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 267 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
266 | 268 | ||
267 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 269 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
268 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 270 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
269 | { | 271 | { |
270 | doc = 0; | 272 | doc = 0; |
271 | edited=false; | 273 | edited=false; |
272 | fromSetDocument=false; | 274 | fromSetDocument=false; |
273 | 275 | ||
274 | setToolBarsMovable( false ); | 276 | setToolBarsMovable( false ); |
275 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 277 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
276 | 278 | ||
277 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 279 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
278 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 280 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
279 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 281 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
280 | 282 | ||
281 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 283 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
282 | 284 | ||
283 | QPEToolBar *bar = new QPEToolBar( this ); | 285 | QPEToolBar *bar = new QPEToolBar( this ); |
284 | bar->setHorizontalStretchable( true ); | 286 | bar->setHorizontalStretchable( true ); |
285 | menu = bar; | 287 | menu = bar; |
286 | 288 | ||
287 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 289 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
288 | QPopupMenu *file = new QPopupMenu( this ); | 290 | QPopupMenu *file = new QPopupMenu( this ); |
289 | QPopupMenu *edit = new QPopupMenu( this ); | 291 | QPopupMenu *edit = new QPopupMenu( this ); |
290 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 292 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
291 | 293 | ||
292 | font = new QPopupMenu( this ); | 294 | font = new QPopupMenu( this ); |
293 | 295 | ||
294 | bar = new QPEToolBar( this ); | 296 | bar = new QPEToolBar( this ); |
295 | editBar = bar; | 297 | editBar = bar; |
296 | 298 | ||
297 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 299 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
298 | QString::null, 0, this, 0 ); | 300 | QString::null, 0, this, 0 ); |
299 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 301 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
300 | // a->addTo( bar ); | 302 | // a->addTo( bar ); |
301 | a->addTo( file ); | 303 | a->addTo( file ); |
302 | 304 | ||
303 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 305 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
304 | QString::null, 0, this, 0 ); | 306 | QString::null, 0, this, 0 ); |
305 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 307 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
306 | a->addTo( bar ); | 308 | a->addTo( bar ); |
307 | a->addTo( file ); | 309 | a->addTo( file ); |
308 | 310 | ||
309 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , | 311 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , |
310 | QString::null, 0, this, 0 ); | 312 | QString::null, 0, this, 0 ); |
311 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 313 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
312 | file->insertSeparator(); | 314 | file->insertSeparator(); |
313 | a->addTo( bar ); | 315 | a->addTo( bar ); |
314 | a->addTo( file ); | 316 | a->addTo( file ); |
315 | 317 | ||
316 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , | 318 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , |
317 | QString::null, 0, this, 0 ); | 319 | QString::null, 0, this, 0 ); |
318 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 320 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
319 | a->addTo( file ); | 321 | a->addTo( file ); |
320 | 322 | ||
321 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 323 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
322 | QString::null, 0, this, 0 ); | 324 | QString::null, 0, this, 0 ); |
323 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 325 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
324 | a->addTo( editBar ); | 326 | a->addTo( editBar ); |
325 | a->addTo( edit ); | 327 | a->addTo( edit ); |
326 | 328 | ||
327 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 329 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
328 | QString::null, 0, this, 0 ); | 330 | QString::null, 0, this, 0 ); |
329 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 331 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
330 | a->addTo( editBar ); | 332 | a->addTo( editBar ); |
331 | a->addTo( edit ); | 333 | a->addTo( edit ); |
332 | 334 | ||
333 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 335 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
334 | QString::null, 0, this, 0 ); | 336 | QString::null, 0, this, 0 ); |
335 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 337 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
336 | a->addTo( editBar ); | 338 | a->addTo( editBar ); |
337 | a->addTo( edit ); | 339 | a->addTo( edit ); |
338 | 340 | ||
339 | 341 | ||
340 | #ifndef QT_NO_CLIPBOARD | 342 | #ifndef QT_NO_CLIPBOARD |
341 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 343 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
342 | QString::null, 0, this, 0 ); | 344 | QString::null, 0, this, 0 ); |
343 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 345 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
344 | a->addTo( edit ); | 346 | a->addTo( edit ); |
345 | #endif | 347 | #endif |
346 | 348 | ||
347 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | 349 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), |
348 | QString::null, 0, this, 0 ); | 350 | QString::null, 0, this, 0 ); |
349 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 351 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
350 | edit->insertSeparator(); | 352 | edit->insertSeparator(); |
351 | a->addTo( bar ); | 353 | a->addTo( bar ); |
352 | a->addTo( edit ); | 354 | a->addTo( edit ); |
353 | 355 | ||
354 | 356 | ||
355 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 357 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
356 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 358 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
357 | zin->addTo( font ); | 359 | zin->addTo( font ); |
358 | 360 | ||
359 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 361 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
360 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 362 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
361 | zout->addTo( font ); | 363 | zout->addTo( font ); |
362 | 364 | ||
363 | font->insertSeparator(); | 365 | font->insertSeparator(); |
364 | 366 | ||
365 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 367 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
366 | 368 | ||
367 | font->insertSeparator(); | 369 | font->insertSeparator(); |
368 | font->insertItem(tr("Advanced Features"), advancedMenu); | 370 | font->insertItem(tr("Advanced Features"), advancedMenu); |
369 | 371 | ||
370 | QAction *wa = new QAction( tr("Wrap lines"), | 372 | QAction *wa = new QAction( tr("Wrap lines"), |
371 | QString::null, 0, this, 0 ); | 373 | QString::null, 0, this, 0 ); |
372 | connect( wa, SIGNAL( toggled(bool) ), | 374 | connect( wa, SIGNAL( toggled(bool) ), |
373 | this, SLOT( setWordWrap(bool) ) ); | 375 | this, SLOT( setWordWrap(bool) ) ); |
374 | wa->setToggleAction(true); | 376 | wa->setToggleAction(true); |
375 | wa->addTo( advancedMenu); | 377 | wa->addTo( advancedMenu); |
376 | 378 | ||
377 | nStart = new QAction( tr("Start with new file"), | 379 | nStart = new QAction( tr("Start with new file"), |
378 | QString::null, 0, this, 0 ); | 380 | QString::null, 0, this, 0 ); |
379 | connect( nStart, SIGNAL( toggled(bool) ), | 381 | connect( nStart, SIGNAL( toggled(bool) ), |
380 | this, SLOT( changeStartConfig(bool) ) ); | 382 | this, SLOT( changeStartConfig(bool) ) ); |
381 | nStart->setToggleAction(true); | 383 | nStart->setToggleAction(true); |
382 | nStart->addTo( advancedMenu ); | 384 | nStart->addTo( advancedMenu ); |
383 | nStart->setEnabled(false); | 385 | nStart->setEnabled(false); |
384 | 386 | ||
385 | nAdvanced = new QAction( tr("Prompt on Exit"), | 387 | nAdvanced = new QAction( tr("Prompt on Exit"), |
386 | QString::null, 0, this, 0 ); | 388 | QString::null, 0, this, 0 ); |
387 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 389 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
388 | this, SLOT( doPrompt(bool) ) ); | 390 | this, SLOT( doPrompt(bool) ) ); |
389 | nAdvanced->setToggleAction(true); | 391 | nAdvanced->setToggleAction(true); |
390 | nAdvanced->addTo( advancedMenu ); | 392 | nAdvanced->addTo( advancedMenu ); |
391 | 393 | ||
392 | desktopAction = new QAction( tr("Always open linked file"), | 394 | desktopAction = new QAction( tr("Always open linked file"), |
393 | QString::null, 0, this, 0 ); | 395 | QString::null, 0, this, 0 ); |
394 | connect( desktopAction, SIGNAL( toggled(bool) ), | 396 | connect( desktopAction, SIGNAL( toggled(bool) ), |
395 | this, SLOT( doDesktop(bool) ) ); | 397 | this, SLOT( doDesktop(bool) ) ); |
396 | desktopAction->setToggleAction(true); | 398 | desktopAction->setToggleAction(true); |
397 | desktopAction->addTo( advancedMenu); | 399 | desktopAction->addTo( advancedMenu); |
398 | 400 | ||
399 | filePermAction = new QAction( tr("File Permissions"), | 401 | filePermAction = new QAction( tr("File Permissions"), |
400 | QString::null, 0, this, 0 ); | 402 | QString::null, 0, this, 0 ); |
401 | connect( filePermAction, SIGNAL( toggled(bool) ), | 403 | connect( filePermAction, SIGNAL( toggled(bool) ), |
402 | this, SLOT( doFilePerms(bool) ) ); | 404 | this, SLOT( doFilePerms(bool) ) ); |
403 | filePermAction->setToggleAction(true); | 405 | filePermAction->setToggleAction(true); |
404 | filePermAction->addTo( advancedMenu); | 406 | filePermAction->addTo( advancedMenu); |
405 | 407 | ||
406 | searchBarAction = new QAction( tr("Search Bar Open"), | 408 | searchBarAction = new QAction( tr("Search Bar Open"), |
407 | QString::null, 0, this, 0 ); | 409 | QString::null, 0, this, 0 ); |
408 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 410 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
409 | this, SLOT( setSearchBar(bool) ) ); | 411 | this, SLOT( setSearchBar(bool) ) ); |
410 | searchBarAction->setToggleAction(true); | 412 | searchBarAction->setToggleAction(true); |
411 | searchBarAction->addTo( advancedMenu); | 413 | searchBarAction->addTo( advancedMenu); |
412 | 414 | ||
415 | nAutoSave = new QAction( tr("Auto Save 5 min."), | ||
416 | QString::null, 0, this, 0 ); | ||
417 | connect( nAutoSave, SIGNAL( toggled(bool) ), | ||
418 | this, SLOT( doTimer(bool) ) ); | ||
419 | nAutoSave->setToggleAction(true); | ||
420 | nAutoSave->addTo( advancedMenu); | ||
421 | |||
413 | 422 | ||
414 | font->insertSeparator(); | 423 | font->insertSeparator(); |
415 | 424 | ||
416 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 425 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
417 | 426 | ||
418 | mb->insertItem( tr( "File" ), file ); | 427 | mb->insertItem( tr( "File" ), file ); |
419 | mb->insertItem( tr( "Edit" ), edit ); | 428 | mb->insertItem( tr( "Edit" ), edit ); |
420 | mb->insertItem( tr( "View" ), font ); | 429 | mb->insertItem( tr( "View" ), font ); |
421 | 430 | ||
422 | searchBar = new QPEToolBar(this); | 431 | searchBar = new QPEToolBar(this); |
423 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 432 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
424 | 433 | ||
425 | searchBar->setHorizontalStretchable( true ); | 434 | searchBar->setHorizontalStretchable( true ); |
426 | 435 | ||
427 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 436 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
428 | searchBar->setStretchableWidget( searchEdit ); | 437 | searchBar->setStretchableWidget( searchEdit ); |
429 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 438 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
430 | this, SLOT( search() ) ); | 439 | this, SLOT( search() ) ); |
431 | 440 | ||
432 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 441 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
433 | QString::null, 0, this, 0 ); | 442 | QString::null, 0, this, 0 ); |
434 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 443 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
435 | a->addTo( searchBar ); | 444 | a->addTo( searchBar ); |
436 | a->addTo( edit ); | 445 | a->addTo( edit ); |
437 | 446 | ||
438 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 447 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
439 | QString::null, 0, this, 0 ); | 448 | QString::null, 0, this, 0 ); |
440 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 449 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
441 | a->addTo( searchBar ); | 450 | a->addTo( searchBar ); |
442 | 451 | ||
443 | edit->insertSeparator(); | 452 | edit->insertSeparator(); |
444 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 453 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
445 | QString::null, 0, this, 0 ); | 454 | QString::null, 0, this, 0 ); |
446 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 455 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
447 | a->addTo( edit ); | 456 | a->addTo( edit ); |
448 | 457 | ||
449 | searchBar->hide(); | 458 | searchBar->hide(); |
450 | 459 | ||
451 | editor = new QpeEditor( this ); | 460 | editor = new QpeEditor( this ); |
452 | setCentralWidget( editor ); | 461 | setCentralWidget( editor ); |
453 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 462 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
454 | connect( editor, SIGNAL( textChanged() ), | 463 | connect( editor, SIGNAL( textChanged() ), |
455 | this, SLOT( editorChanged() ) ); | 464 | this, SLOT( editorChanged() ) ); |
456 | 465 | ||
457 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 466 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
458 | 467 | ||
459 | Config cfg("TextEdit"); | 468 | Config cfg("TextEdit"); |
460 | cfg. setGroup ( "Font" ); | 469 | cfg. setGroup ( "Font" ); |
461 | 470 | ||
462 | QFont defaultFont = editor-> font ( ); | 471 | QFont defaultFont = editor-> font ( ); |
463 | 472 | ||
464 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 473 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
465 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 474 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
466 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 475 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
467 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 476 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
468 | 477 | ||
469 | defaultFont = QFont ( family, size, weight, italic ); | 478 | defaultFont = QFont ( family, size, weight, italic ); |
470 | editor-> setFont ( defaultFont ); | 479 | editor-> setFont ( defaultFont ); |
471 | 480 | ||
472 | // updateCaption(); | 481 | // updateCaption(); |
473 | 482 | ||
474 | cfg.setGroup ( "View" ); | 483 | cfg.setGroup ( "View" ); |
475 | 484 | ||
476 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 485 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
477 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 486 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
478 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 487 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
479 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 488 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
480 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 489 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
490 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | ||
481 | 491 | ||
482 | if(useSearchBar) searchBarAction->setOn(true); | 492 | if(useSearchBar) searchBarAction->setOn(true); |
483 | if(promptExit ) nAdvanced->setOn( true ); | 493 | if(promptExit) nAdvanced->setOn( true ); |
484 | if(openDesktop) desktopAction->setOn( true ); | 494 | if(openDesktop) desktopAction->setOn( true ); |
485 | if(filePerms) filePermAction->setOn( true ); | 495 | if(filePerms) filePermAction->setOn( true ); |
486 | if(startWithNew) nStart->setOn( true ); | 496 | if(startWithNew) nStart->setOn( true ); |
487 | 497 | if(featureAutoSave) nAutoSave->setOn(true); | |
498 | |||
499 | // { | ||
500 | // doTimer(true); | ||
501 | // } | ||
502 | |||
488 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 503 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
489 | wa-> setOn ( wrap ); | 504 | wa-> setOn ( wrap ); |
490 | setWordWrap ( wrap ); | 505 | setWordWrap ( wrap ); |
491 | 506 | ||
507 | ///////////////// | ||
492 | if( qApp->argc() > 1) { | 508 | if( qApp->argc() > 1) { |
493 | currentFileName=qApp->argv()[1]; | 509 | currentFileName=qApp->argv()[1]; |
494 | 510 | ||
495 | QFileInfo fi(currentFileName); | 511 | QFileInfo fi(currentFileName); |
496 | 512 | ||
497 | if(fi.baseName().left(1) == "") { | 513 | if(fi.baseName().left(1) == "") { |
498 | openDotFile(currentFileName); | 514 | openDotFile(currentFileName); |
499 | } else { | 515 | } else { |
500 | openFile(currentFileName); | 516 | openFile(currentFileName); |
501 | } | 517 | } |
502 | } else { | 518 | } else { |
503 | edited1=false; | 519 | edited1=false; |
504 | openDotFile(""); | 520 | openDotFile(""); |
505 | } | 521 | } |
506 | 522 | ||
507 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 523 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
508 | } | 524 | } |
509 | 525 | ||
510 | TextEdit::~TextEdit() { | 526 | TextEdit::~TextEdit() { |
511 | qWarning("textedit d'tor"); | 527 | qWarning("textedit d'tor"); |
512 | delete editor; | 528 | delete editor; |
513 | } | 529 | } |
514 | 530 | ||
515 | void TextEdit::closeEvent(QCloseEvent *) { | 531 | void TextEdit::closeEvent(QCloseEvent *) { |
516 | if( edited1 && promptExit) | 532 | if( edited1 && promptExit) |
517 | saveAs(); | 533 | { |
518 | qApp->quit(); | 534 | switch( savePrompt() ) |
535 | { | ||
536 | case 1: | ||
537 | { | ||
538 | saveAs(); | ||
539 | qApp->quit(); | ||
540 | } | ||
541 | break; | ||
542 | |||
543 | case 2: | ||
544 | { | ||
545 | qApp->quit(); | ||
546 | } | ||
547 | break; | ||
548 | |||
549 | case -1: | ||
550 | break; | ||
551 | }; | ||
552 | } | ||
553 | else | ||
554 | qApp->quit(); | ||
555 | |||
519 | } | 556 | } |
520 | 557 | ||
521 | void TextEdit::cleanUp() { | 558 | void TextEdit::cleanUp() { |
522 | 559 | ||
523 | Config cfg ( "TextEdit" ); | 560 | Config cfg ( "TextEdit" ); |
524 | cfg. setGroup ( "Font" ); | 561 | cfg. setGroup ( "Font" ); |
525 | QFont f = editor->font(); | 562 | QFont f = editor->font(); |
526 | cfg.writeEntry ( "Family", f. family ( )); | 563 | cfg.writeEntry ( "Family", f. family ( )); |
527 | cfg.writeEntry ( "Size", f. pointSize ( )); | 564 | cfg.writeEntry ( "Size", f. pointSize ( )); |
528 | cfg.writeEntry ( "Weight", f. weight ( )); | 565 | cfg.writeEntry ( "Weight", f. weight ( )); |
529 | cfg.writeEntry ( "Italic", f. italic ( )); | 566 | cfg.writeEntry ( "Italic", f. italic ( )); |
530 | 567 | ||
531 | cfg.setGroup ( "View" ); | 568 | cfg.setGroup ( "View" ); |
532 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); | 569 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); |
533 | cfg.writeEntry ( "FileView", viewSelection ); | 570 | cfg.writeEntry ( "FileView", viewSelection ); |
534 | 571 | ||
535 | cfg.writeEntry ( "PromptExit", promptExit ); | 572 | cfg.writeEntry ( "PromptExit", promptExit ); |
536 | cfg.writeEntry ( "OpenDesktop", openDesktop ); | 573 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
537 | cfg.writeEntry ( "FilePermissions", filePerms ); | 574 | cfg.writeEntry ( "FilePermissions", filePerms ); |
538 | cfg.writeEntry ( "SearchBar", useSearchBar ); | 575 | cfg.writeEntry ( "SearchBar", useSearchBar ); |
539 | cfg.writeEntry ( "startNew", startWithNew ); | 576 | cfg.writeEntry ( "startNew", startWithNew ); |
540 | 577 | ||
541 | } | 578 | } |
542 | 579 | ||
543 | 580 | ||
544 | void TextEdit::accept() { | 581 | void TextEdit::accept() { |
545 | if( edited1) | 582 | if( edited1) |
546 | saveAs(); | 583 | saveAs(); |
547 | qApp->quit(); | 584 | qApp->quit(); |
548 | } | 585 | } |
549 | 586 | ||
550 | void TextEdit::zoomIn() { | 587 | void TextEdit::zoomIn() { |
551 | setFontSize(editor->font().pointSize()+1,false); | 588 | setFontSize(editor->font().pointSize()+1,false); |
552 | } | 589 | } |
553 | 590 | ||
554 | void TextEdit::zoomOut() { | 591 | void TextEdit::zoomOut() { |
555 | setFontSize(editor->font().pointSize()-1,true); | 592 | setFontSize(editor->font().pointSize()-1,true); |
556 | } | 593 | } |
557 | 594 | ||
558 | 595 | ||
559 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 596 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
560 | int s=10; | 597 | int s=10; |
561 | for (int i=0; i<nfontsizes; i++) { | 598 | for (int i=0; i<nfontsizes; i++) { |
562 | if ( fontsize[i] == sz ) { | 599 | if ( fontsize[i] == sz ) { |
563 | s = sz; | 600 | s = sz; |
564 | break; | 601 | break; |
565 | } else if ( round_down_not_up ) { | 602 | } else if ( round_down_not_up ) { |
566 | if ( fontsize[i] < sz ) | 603 | if ( fontsize[i] < sz ) |
567 | s = fontsize[i]; | 604 | s = fontsize[i]; |
568 | } else { | 605 | } else { |
569 | if ( fontsize[i] > sz ) { | 606 | if ( fontsize[i] > sz ) { |
570 | s = fontsize[i]; | 607 | s = fontsize[i]; |
571 | break; | 608 | break; |
572 | } | 609 | } |
573 | } | 610 | } |
574 | } | 611 | } |
575 | 612 | ||
576 | QFont f = editor->font(); | 613 | QFont f = editor->font(); |
577 | f.setPointSize(s); | 614 | f.setPointSize(s); |
578 | editor->setFont(f); | 615 | editor->setFont(f); |
579 | 616 | ||
580 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 617 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
581 | zout->setEnabled(s != fontsize[0]); | 618 | zout->setEnabled(s != fontsize[0]); |
582 | } | 619 | } |
583 | 620 | ||
584 | void TextEdit::setBold(bool y) { | 621 | void TextEdit::setBold(bool y) { |
585 | QFont f = editor->font(); | 622 | QFont f = editor->font(); |
586 | f.setBold(y); | 623 | f.setBold(y); |
587 | editor->setFont(f); | 624 | editor->setFont(f); |
588 | } | 625 | } |
589 | 626 | ||
590 | void TextEdit::setItalic(bool y) { | 627 | void TextEdit::setItalic(bool y) { |
591 | QFont f = editor->font(); | 628 | QFont f = editor->font(); |
592 | f.setItalic(y); | 629 | f.setItalic(y); |
593 | editor->setFont(f); | 630 | editor->setFont(f); |
594 | } | 631 | } |
595 | 632 | ||
596 | void TextEdit::setWordWrap(bool y) { | 633 | void TextEdit::setWordWrap(bool y) { |
597 | bool state = editor->edited(); | 634 | bool state = editor->edited(); |
598 | QString captionStr = caption(); | 635 | QString captionStr = caption(); |
599 | bool b1 = edited1; | 636 | bool b1 = edited1; |
600 | bool b2 = edited; | 637 | bool b2 = edited; |
601 | 638 | ||
602 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 639 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
603 | editor->setEdited( state ); | 640 | editor->setEdited( state ); |
604 | edited1=b1; | 641 | edited1=b1; |
605 | edited=b2; | 642 | edited=b2; |
606 | setCaption(captionStr); | 643 | setCaption(captionStr); |
607 | } | 644 | } |
608 | 645 | ||
609 | void TextEdit::setSearchBar(bool b) { | 646 | void TextEdit::setSearchBar(bool b) { |
610 | useSearchBar=b; | 647 | useSearchBar=b; |
611 | Config cfg("TextEdit"); | 648 | Config cfg("TextEdit"); |
612 | cfg.setGroup("View"); | 649 | cfg.setGroup("View"); |
613 | cfg.writeEntry ( "SearchBar", b ); | 650 | cfg.writeEntry ( "SearchBar", b ); |
614 | searchBarAction->setOn(b); | 651 | searchBarAction->setOn(b); |
615 | if(b) | 652 | if(b) |
616 | searchBar->show(); | 653 | searchBar->show(); |
617 | else | 654 | else |
618 | searchBar->hide(); | 655 | searchBar->hide(); |
619 | editor->setFocus(); | 656 | editor->setFocus(); |
620 | } | 657 | } |
621 | 658 | ||
622 | void TextEdit::fileNew() { | 659 | void TextEdit::fileNew() { |
623 | // if( !bFromDocView ) { | 660 | // if( !bFromDocView ) { |
624 | // saveAs(); | 661 | // saveAs(); |
625 | // } | 662 | // } |
626 | newFile(DocLnk()); | 663 | newFile(DocLnk()); |
627 | } | 664 | } |
628 | 665 | ||
629 | void TextEdit::fileOpen() { | 666 | void TextEdit::fileOpen() { |
630 | QMap<QString, QStringList> map; | 667 | QMap<QString, QStringList> map; |
631 | map.insert(tr("All"), QStringList() ); | 668 | map.insert(tr("All"), QStringList() ); |
632 | QStringList text; | 669 | QStringList text; |
633 | text << "text/*"; | 670 | text << "text/*"; |
634 | map.insert(tr("Text"), text ); | 671 | map.insert(tr("Text"), text ); |
635 | text << "*"; | 672 | text << "*"; |
636 | map.insert(tr("All"), text ); | 673 | map.insert(tr("All"), text ); |
637 | QString str = OFileDialog::getOpenFileName( 2, | 674 | QString str = OFileDialog::getOpenFileName( 2, |
638 | QPEApplication::documentDir(), | 675 | QPEApplication::documentDir(), |
639 | QString::null, map); | 676 | QString::null, map); |
640 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 677 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
641 | openFile( str ); | 678 | openFile( str ); |
642 | else | 679 | else |
643 | updateCaption(); | 680 | updateCaption(); |
644 | } | 681 | } |
645 | 682 | ||
646 | void TextEdit::doSearchBar() { | 683 | void TextEdit::doSearchBar() { |
647 | if(!useSearchBar) | 684 | if(!useSearchBar) |
648 | searchBar->hide(); | 685 | searchBar->hide(); |
649 | else | 686 | else |
650 | searchBar->show(); | 687 | searchBar->show(); |
651 | } | 688 | } |
652 | 689 | ||
653 | #if 0 | 690 | #if 0 |
654 | void TextEdit::slotFind() { | 691 | void TextEdit::slotFind() { |
655 | FindDialog frmFind( tr("Text Editor"), this ); | 692 | FindDialog frmFind( tr("Text Editor"), this ); |
656 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 693 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
657 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 694 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
658 | 695 | ||
659 | //case sensitive, backwards, [category] | 696 | //case sensitive, backwards, [category] |
660 | 697 | ||
661 | connect( editor, SIGNAL(notFound()), | 698 | connect( editor, SIGNAL(notFound()), |
662 | &frmFind, SLOT(slotNotFound()) ); | 699 | &frmFind, SLOT(slotNotFound()) ); |
663 | connect( editor, SIGNAL(searchWrapped()), | 700 | connect( editor, SIGNAL(searchWrapped()), |
664 | &frmFind, SLOT(slotWrapAround()) ); | 701 | &frmFind, SLOT(slotWrapAround()) ); |
665 | 702 | ||
666 | frmFind.exec(); | 703 | frmFind.exec(); |
667 | 704 | ||
668 | 705 | ||
669 | } | 706 | } |
670 | #endif | 707 | #endif |
671 | 708 | ||
672 | void TextEdit::fileRevert() { | 709 | void TextEdit::fileRevert() { |
673 | clear(); | 710 | clear(); |
674 | fileOpen(); | 711 | fileOpen(); |
675 | } | 712 | } |
676 | 713 | ||
677 | void TextEdit::editCut() { | 714 | void TextEdit::editCut() { |
678 | #ifndef QT_NO_CLIPBOARD | 715 | #ifndef QT_NO_CLIPBOARD |
679 | editor->cut(); | 716 | editor->cut(); |
680 | #endif | 717 | #endif |
681 | } | 718 | } |
682 | 719 | ||
683 | void TextEdit::editCopy() { | 720 | void TextEdit::editCopy() { |
684 | #ifndef QT_NO_CLIPBOARD | 721 | #ifndef QT_NO_CLIPBOARD |
685 | editor->copy(); | 722 | editor->copy(); |
686 | #endif | 723 | #endif |
687 | } | 724 | } |
688 | 725 | ||
689 | void TextEdit::editPaste() { | 726 | void TextEdit::editPaste() { |
690 | #ifndef QT_NO_CLIPBOARD | 727 | #ifndef QT_NO_CLIPBOARD |
691 | editor->paste(); | 728 | editor->paste(); |
692 | #endif | 729 | #endif |
693 | } | 730 | } |
694 | 731 | ||
695 | void TextEdit::editFind() { | 732 | void TextEdit::editFind() { |
696 | searchBar->show(); | 733 | searchBar->show(); |
697 | searchEdit->setFocus(); | 734 | searchEdit->setFocus(); |
698 | } | 735 | } |
699 | 736 | ||
700 | void TextEdit::findNext() { | 737 | void TextEdit::findNext() { |
701 | editor->find( searchEdit->text(), false, false ); | 738 | editor->find( searchEdit->text(), false, false ); |
702 | 739 | ||
703 | } | 740 | } |
704 | 741 | ||
705 | void TextEdit::findClose() { | 742 | void TextEdit::findClose() { |
706 | searchBar->hide(); | 743 | searchBar->hide(); |
707 | } | 744 | } |
708 | 745 | ||
709 | void TextEdit::search() { | 746 | void TextEdit::search() { |
710 | editor->find( searchEdit->text(), false, false ); | 747 | editor->find( searchEdit->text(), false, false ); |
711 | } | 748 | } |
712 | 749 | ||
713 | void TextEdit::newFile( const DocLnk &f ) { | 750 | void TextEdit::newFile( const DocLnk &f ) { |
714 | DocLnk nf = f; | 751 | DocLnk nf = f; |
715 | nf.setType("text/plain"); | 752 | nf.setType("text/plain"); |
716 | clear(); | 753 | clear(); |
717 | setWState (WState_Reserved1 ); | 754 | setWState (WState_Reserved1 ); |
718 | editor->setFocus(); | 755 | editor->setFocus(); |
719 | doc = new DocLnk(nf); | 756 | doc = new DocLnk(nf); |
720 | currentFileName = "Unnamed"; | 757 | currentFileName = "Unnamed"; |
721 | qDebug("newFile "+currentFileName); | 758 | qDebug("newFile "+currentFileName); |
722 | updateCaption( currentFileName); | 759 | updateCaption( currentFileName); |
723 | // editor->setEdited( false); | 760 | // editor->setEdited( false); |
724 | } | 761 | } |
725 | 762 | ||
726 | void TextEdit::openDotFile( const QString &f ) { | 763 | void TextEdit::openDotFile( const QString &f ) { |
727 | if(!currentFileName.isEmpty()) { | 764 | if(!currentFileName.isEmpty()) { |
728 | currentFileName=f; | 765 | currentFileName=f; |
729 | 766 | ||
730 | qDebug("openFile dotfile " + currentFileName); | 767 | qDebug("openFile dotfile " + currentFileName); |
731 | QString txt; | 768 | QString txt; |
732 | QFile file(f); | 769 | QFile file(f); |
733 | file.open(IO_ReadWrite); | 770 | file.open(IO_ReadWrite); |
734 | QTextStream t(&file); | 771 | QTextStream t(&file); |
735 | while ( !t.atEnd()) { | 772 | while ( !t.atEnd()) { |
736 | txt+=t.readLine()+"\n"; | 773 | txt+=t.readLine()+"\n"; |
737 | } | 774 | } |
738 | editor->setText(txt); | 775 | editor->setText(txt); |
739 | editor->setEdited( false); | 776 | editor->setEdited( false); |
740 | edited1=false; | 777 | edited1=false; |
741 | edited=false; | 778 | edited=false; |
742 | 779 | ||
743 | 780 | ||
744 | } | 781 | } |
745 | updateCaption( currentFileName); | 782 | updateCaption( currentFileName); |
746 | } | 783 | } |
747 | 784 | ||
748 | void TextEdit::openFile( const QString &f ) { | 785 | void TextEdit::openFile( const QString &f ) { |
749 | qDebug("filename is "+ f); | 786 | qDebug("filename is "+ f); |
750 | QString filer; | 787 | QString filer; |
751 | QFileInfo fi( f); | 788 | QFileInfo fi( f); |
752 | // bFromDocView = true; | 789 | // bFromDocView = true; |
753 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) { | 790 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) { |
754 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 791 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
755 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> | 792 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> |
756 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | 793 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), |
757 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { | 794 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { |
758 | case 0: | 795 | case 0: |
759 | filer = f; | 796 | filer = f; |
760 | break; | 797 | break; |
761 | case 1: | 798 | case 1: |
762 | DocLnk sf(f); | 799 | DocLnk sf(f); |
763 | filer = sf.file(); | 800 | filer = sf.file(); |
764 | break; | 801 | break; |
765 | } | 802 | } |
766 | } else if(fi.baseName().left(1) == "") { | 803 | } else if(fi.baseName().left(1) == "") { |
767 | currentFileName=f; | 804 | currentFileName=f; |
768 | openDotFile(currentFileName); | 805 | openDotFile(currentFileName); |
769 | } else { | 806 | } else { |
770 | DocLnk sf(f); | 807 | DocLnk sf(f); |
771 | filer = sf.file(); | 808 | filer = sf.file(); |
772 | if(filer.right(1) == "/") | 809 | if(filer.right(1) == "/") |
773 | filer = f; | 810 | filer = f; |
774 | 811 | ||
775 | DocLnk nf; | 812 | DocLnk nf; |
776 | nf.setType("text/plain"); | 813 | nf.setType("text/plain"); |
777 | nf.setFile(filer); | 814 | nf.setFile(filer); |
778 | currentFileName=filer; | 815 | currentFileName=filer; |
779 | 816 | ||
780 | nf.setName(fi.baseName()); | 817 | nf.setName(fi.baseName()); |
781 | openFile(nf); | 818 | openFile(nf); |
782 | 819 | ||
783 | qDebug("openFile string "+currentFileName); | 820 | qDebug("openFile string "+currentFileName); |
784 | 821 | ||
785 | } | 822 | } |
786 | showEditTools(); | 823 | showEditTools(); |
787 | // Show filename in caption | 824 | // Show filename in caption |
788 | QString name = filer; | 825 | QString name = filer; |
789 | int sep = name.findRev( '/' ); | 826 | int sep = name.findRev( '/' ); |
790 | if ( sep > 0 ) | 827 | if ( sep > 0 ) |
791 | name = name.mid( sep+1 ); | 828 | name = name.mid( sep+1 ); |
792 | updateCaption( name ); | 829 | updateCaption( name ); |
793 | } | 830 | } |
794 | 831 | ||
795 | void TextEdit::openFile( const DocLnk &f ) { | 832 | void TextEdit::openFile( const DocLnk &f ) { |
796 | // clear(); | 833 | // clear(); |
797 | // bFromDocView = true; | 834 | // bFromDocView = true; |
798 | FileManager fm; | 835 | FileManager fm; |
799 | QString txt; | 836 | QString txt; |
800 | currentFileName=f.file(); | 837 | currentFileName=f.file(); |
801 | qDebug("openFile doclnk " + currentFileName); | 838 | qDebug("openFile doclnk " + currentFileName); |
802 | if ( !fm.loadFile( f, txt ) ) { | 839 | if ( !fm.loadFile( f, txt ) ) { |
803 | // ####### could be a new file | 840 | // ####### could be a new file |
804 | qDebug( "Cannot open file" ); | 841 | qDebug( "Cannot open file" ); |
805 | } | 842 | } |
806 | // fileNew(); | 843 | // fileNew(); |
807 | if ( doc ) | 844 | if ( doc ) |
808 | delete doc; | 845 | delete doc; |
809 | doc = new DocLnk(f); | 846 | doc = new DocLnk(f); |
810 | editor->setText(txt); | 847 | editor->setText(txt); |
811 | editor->setEdited( false); | 848 | editor->setEdited( false); |
812 | edited1=false; | 849 | edited1=false; |
813 | edited=false; | 850 | edited=false; |
814 | 851 | ||
815 | doc->setName(currentFileName); | 852 | doc->setName(currentFileName); |
816 | updateCaption(); | 853 | updateCaption(); |
854 | setTimer(); | ||
817 | } | 855 | } |
818 | 856 | ||
819 | void TextEdit::showEditTools() { | 857 | void TextEdit::showEditTools() { |
820 | menu->show(); | 858 | menu->show(); |
821 | editBar->show(); | 859 | editBar->show(); |
822 | if(!useSearchBar) | 860 | if(!useSearchBar) |
823 | searchBar->hide(); | 861 | searchBar->hide(); |
824 | else | 862 | else |
825 | searchBar->show(); | 863 | searchBar->show(); |
826 | setWState (WState_Reserved1 ); | 864 | setWState (WState_Reserved1 ); |
827 | } | 865 | } |
828 | 866 | ||
829 | /*! | 867 | /*! |
830 | unprompted save */ | 868 | unprompted save */ |
831 | bool TextEdit::save() { | 869 | bool TextEdit::save() { |
832 | qDebug("saveAsFile " + currentFileName); | 870 | qDebug("saveAsFile " + currentFileName); |
833 | if(currentFileName.isEmpty()) { | 871 | if(currentFileName.isEmpty()) { |
834 | saveAs(); | 872 | saveAs(); |
835 | return false; | 873 | return false; |
836 | } | 874 | } |
837 | QString file = doc->file(); | 875 | |
876 | QString file = doc->file(); | ||
838 | qDebug("saver file "+file); | 877 | qDebug("saver file "+file); |
839 | QString name= doc->name(); | 878 | QString name= doc->name(); |
840 | qDebug("File named "+name); | 879 | qDebug("File named "+name); |
841 | QString rt = editor->text(); | 880 | QString rt = editor->text(); |
842 | if( !rt.isEmpty() ) { | 881 | if( !rt.isEmpty() ) { |
843 | if(name.isEmpty()) { | 882 | if(name.isEmpty()) { |
844 | saveAs(); | 883 | saveAs(); |
845 | } else { | 884 | } else { |
846 | currentFileName= name ; | 885 | currentFileName= name ; |
847 | qDebug("saveFile "+currentFileName); | 886 | qDebug("saveFile "+currentFileName); |
848 | 887 | ||
849 | struct stat buf; | 888 | struct stat buf; |
850 | mode_t mode; | 889 | mode_t mode; |
851 | stat(file.latin1(), &buf); | 890 | stat(file.latin1(), &buf); |
852 | mode = buf.st_mode; | 891 | mode = buf.st_mode; |
853 | 892 | ||
854 | if(!fileIs) { | 893 | if(!fileIs) { |
855 | doc->setName( name); | 894 | doc->setName( name); |
856 | FileManager fm; | 895 | FileManager fm; |
857 | if ( !fm.saveFile( *doc, rt ) ) { | 896 | if ( !fm.saveFile( *doc, rt ) ) { |
858 | return false; | 897 | return false; |
859 | } | 898 | } |
860 | } else { | 899 | } else { |
861 | qDebug("regular save file"); | 900 | qDebug("regular save file"); |
862 | QFile f(file); | 901 | QFile f(file); |
863 | if( f.open(IO_WriteOnly)) { | 902 | if( f.open(IO_WriteOnly)) { |
864 | QCString crt = rt.utf8(); | 903 | QCString crt = rt.utf8(); |
865 | f.writeBlock(crt,crt.length()); | 904 | f.writeBlock(crt,crt.length()); |
866 | } else { | 905 | } else { |
867 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 906 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
868 | return false; | 907 | return false; |
869 | } | 908 | } |
870 | 909 | ||
871 | } | 910 | } |
872 | editor->setEdited( false); | 911 | editor->setEdited( false); |
873 | edited1=false; | 912 | edited1=false; |
874 | edited=false; | 913 | edited=false; |
875 | if(caption().left(1)=="*") | 914 | if(caption().left(1)=="*") |
876 | setCaption(caption().right(caption().length()-1)); | 915 | setCaption(caption().right(caption().length()-1)); |
877 | 916 | ||
878 | 917 | ||
879 | chmod( file.latin1(), mode); | 918 | chmod( file.latin1(), mode); |
880 | } | 919 | } |
881 | return true; | 920 | return true; |
882 | } | 921 | } |
883 | return false; | 922 | return false; |
884 | } | 923 | } |
885 | 924 | ||
886 | /*! | 925 | /*! |
887 | prompted save */ | 926 | prompted save */ |
888 | bool TextEdit::saveAs() { | 927 | bool TextEdit::saveAs() { |
928 | |||
889 | if(caption() == tr("Text Editor")) | 929 | if(caption() == tr("Text Editor")) |
890 | return false; | 930 | return false; |
891 | qDebug("saveAsFile " + currentFileName); | 931 | qDebug("saveAsFile " + currentFileName); |
892 | // case of nothing to save... | 932 | // case of nothing to save... |
893 | // if ( !doc && !currentFileName.isEmpty()) { | 933 | // if ( !doc && !currentFileName.isEmpty()) { |
894 | // //|| !bFromDocView) | 934 | // //|| !bFromDocView) |
895 | // qDebug("no doc"); | 935 | // qDebug("no doc"); |
896 | // return true; | 936 | // return true; |
897 | // } | 937 | // } |
898 | // if ( !editor->edited() ) { | 938 | // if ( !editor->edited() ) { |
899 | // delete doc; | 939 | // delete doc; |
900 | // doc = 0; | 940 | // doc = 0; |
901 | // return true; | 941 | // return true; |
902 | // } | 942 | // } |
903 | 943 | ||
904 | QString rt = editor->text(); | 944 | QString rt = editor->text(); |
905 | qDebug(currentFileName); | 945 | qDebug(currentFileName); |
906 | 946 | ||
907 | if( currentFileName.isEmpty() | 947 | if( currentFileName.isEmpty() |
908 | || currentFileName == tr("Unnamed") | 948 | || currentFileName == tr("Unnamed") |
909 | || currentFileName == tr("Text Editor")) { | 949 | || currentFileName == tr("Text Editor")) { |
910 | qDebug("do silly TT filename thing"); | 950 | qDebug("do silly TT filename thing"); |
911 | // if ( doc && doc->name().isEmpty() ) { | 951 | // if ( doc && doc->name().isEmpty() ) { |
912 | QString pt = rt.simplifyWhiteSpace(); | 952 | QString pt = rt.simplifyWhiteSpace(); |
913 | int i = pt.find( ' ' ); | 953 | int i = pt.find( ' ' ); |
914 | QString docname = pt; | 954 | QString docname = pt; |
915 | if ( i > 0 ) | 955 | if ( i > 0 ) |
916 | docname = pt.left( i ); | 956 | docname = pt.left( i ); |
917 | // remove "." at the beginning | 957 | // remove "." at the beginning |
918 | while( docname.startsWith( "." ) ) | 958 | while( docname.startsWith( "." ) ) |
919 | docname = docname.mid( 1 ); | 959 | docname = docname.mid( 1 ); |
920 | docname.replace( QRegExp("/"), "_" ); | 960 | docname.replace( QRegExp("/"), "_" ); |
921 | // cut the length. filenames longer than that | 961 | // cut the length. filenames longer than that |
922 | //don't make sense and something goes wrong when they get too long. | 962 | //don't make sense and something goes wrong when they get too long. |
923 | if ( docname.length() > 40 ) | 963 | if ( docname.length() > 40 ) |
924 | docname = docname.left(40); | 964 | docname = docname.left(40); |
925 | if ( docname.isEmpty() ) | 965 | if ( docname.isEmpty() ) |
926 | docname = tr("Unnamed"); | 966 | docname = tr("Unnamed"); |
927 | if(doc) doc->setName(docname); | 967 | if(doc) doc->setName(docname); |
928 | currentFileName=docname; | 968 | currentFileName=docname; |
929 | // } | 969 | // } |
930 | // else | 970 | // else |
931 | // qDebug("hmmmmmm"); | 971 | // qDebug("hmmmmmm"); |
932 | } | 972 | } |
933 | 973 | ||
934 | 974 | ||
935 | QMap<QString, QStringList> map; | 975 | QMap<QString, QStringList> map; |
936 | map.insert(tr("All"), QStringList() ); | 976 | map.insert(tr("All"), QStringList() ); |
937 | QStringList text; | 977 | QStringList text; |
938 | text << "text/*"; | 978 | text << "text/*"; |
939 | map.insert(tr("Text"), text ); | 979 | map.insert(tr("Text"), text ); |
940 | text << "*"; | 980 | text << "*"; |
941 | map.insert(tr("All"), text ); | 981 | map.insert(tr("All"), text ); |
942 | 982 | ||
943 | QFileInfo cuFi( currentFileName); | 983 | QFileInfo cuFi( currentFileName); |
944 | QString filee = cuFi.fileName(); | 984 | QString filee = cuFi.fileName(); |
945 | QString dire = cuFi.dirPath(); | 985 | QString dire = cuFi.dirPath(); |
946 | if(dire==".") | 986 | if(dire==".") |
947 | dire = QPEApplication::documentDir(); | 987 | dire = QPEApplication::documentDir(); |
948 | QString str = OFileDialog::getSaveFileName( 2, | 988 | QString str; |
949 | dire, | 989 | if( !featureAutoSave) |
950 | filee, map); | 990 | { |
951 | 991 | str = OFileDialog::getSaveFileName( 2, | |
992 | dire, | ||
993 | filee, map); | ||
994 | } | ||
995 | else | ||
996 | str=currentFileName; | ||
952 | if(!str.isEmpty()) { | 997 | if(!str.isEmpty()) { |
953 | QString fileNm=str; | 998 | QString fileNm=str; |
954 | 999 | ||
955 | qDebug("saving filename "+fileNm); | 1000 | qDebug("saving filename "+fileNm); |
956 | QFileInfo fi(fileNm); | 1001 | QFileInfo fi(fileNm); |
957 | currentFileName=fi.fileName(); | 1002 | currentFileName=fi.fileName(); |
958 | if(doc) | 1003 | if(doc) |
959 | // QString file = doc->file(); | 1004 | // QString file = doc->file(); |
960 | // doc->removeFiles(); | 1005 | // doc->removeFiles(); |
961 | delete doc; | 1006 | delete doc; |
962 | DocLnk nf; | 1007 | DocLnk nf; |
963 | nf.setType("text/plain"); | 1008 | nf.setType("text/plain"); |
964 | nf.setFile( fileNm); | 1009 | nf.setFile( fileNm); |
965 | doc = new DocLnk(nf); | 1010 | doc = new DocLnk(nf); |
966 | // editor->setText(rt); | 1011 | // editor->setText(rt); |
967 | qDebug("Saving file as "+currentFileName); | 1012 | qDebug("Saving file as "+currentFileName); |
968 | doc->setName( currentFileName); | 1013 | doc->setName( currentFileName); |
969 | updateCaption( currentFileName); | 1014 | updateCaption( currentFileName); |
970 | 1015 | ||
971 | FileManager fm; | 1016 | FileManager fm; |
972 | if ( !fm.saveFile( *doc, rt ) ) { | 1017 | if ( !fm.saveFile( *doc, rt ) ) { |
973 | return false; | 1018 | return false; |
974 | } | 1019 | } |
975 | 1020 | ||
976 | if( filePerms ) { | 1021 | if( filePerms ) { |
977 | filePermissions *filePerm; | 1022 | filePermissions *filePerm; |
978 | filePerm = new filePermissions(this, | 1023 | filePerm = new filePermissions(this, |
979 | tr("Permissions"),true, | 1024 | tr("Permissions"),true, |
980 | 0,(const QString &)fileNm); | 1025 | 0,(const QString &)fileNm); |
981 | filePerm->showMaximized(); | 1026 | filePerm->showMaximized(); |
982 | filePerm->exec(); | 1027 | filePerm->exec(); |
983 | 1028 | ||
984 | if( filePerm) | 1029 | if( filePerm) |
985 | delete filePerm; | 1030 | delete filePerm; |
986 | } | 1031 | } |
987 | // } | 1032 | // } |
988 | editor->setEdited( false); | 1033 | editor->setEdited( false); |
989 | edited1 = false; | 1034 | edited1 = false; |
990 | edited = false; | 1035 | edited = false; |
991 | if(caption().left(1)=="*") | 1036 | if(caption().left(1)=="*") |
992 | setCaption(caption().right(caption().length()-1)); | 1037 | setCaption(caption().right(caption().length()-1)); |
993 | 1038 | ||
994 | return true; | 1039 | return true; |
995 | } | 1040 | } |
996 | qDebug("returning false"); | 1041 | qDebug("returning false"); |
997 | return false; | 1042 | return false; |
998 | } //end saveAs | 1043 | } //end saveAs |
999 | 1044 | ||
1000 | void TextEdit::clear() { | 1045 | void TextEdit::clear() { |
1001 | delete doc; | 1046 | delete doc; |
1002 | doc = 0; | 1047 | doc = 0; |
1003 | editor->clear(); | 1048 | editor->clear(); |
1004 | } | 1049 | } |
1005 | 1050 | ||
1006 | void TextEdit::updateCaption( const QString &name ) { | 1051 | void TextEdit::updateCaption( const QString &name ) { |
1007 | 1052 | ||
1008 | if ( name.isEmpty() ) | 1053 | if ( name.isEmpty() ) |
1009 | setCaption( tr("Text Editor") ); | 1054 | setCaption( tr("Text Editor") ); |
1010 | else { | 1055 | else { |
1011 | QString s = name; | 1056 | QString s = name; |
1012 | if ( s.isNull() ) | 1057 | if ( s.isNull() ) |
1013 | s = doc->name(); | 1058 | s = doc->name(); |
1014 | if ( s.isEmpty() ) { | 1059 | if ( s.isEmpty() ) { |
1015 | s = tr( "Unnamed" ); | 1060 | s = tr( "Unnamed" ); |
1016 | currentFileName=s; | 1061 | currentFileName=s; |
1017 | } | 1062 | } |
1018 | // if(s.left(1) == "/") | 1063 | // if(s.left(1) == "/") |
1019 | // s = s.right(s.length()-1); | 1064 | // s = s.right(s.length()-1); |
1020 | setCaption( s + " - " + tr("Text Editor") ); | 1065 | setCaption( s + " - " + tr("Text Editor") ); |
1021 | } | 1066 | } |
1022 | } | 1067 | } |
1023 | 1068 | ||
1024 | void TextEdit::setDocument(const QString& fileref) { | 1069 | void TextEdit::setDocument(const QString& fileref) { |
1025 | if(fileref != "Unnamed") { | 1070 | if(fileref != "Unnamed") { |
1026 | currentFileName=fileref; | 1071 | currentFileName=fileref; |
1027 | qDebug("setDocument"); | 1072 | qDebug("setDocument"); |
1028 | QFileInfo fi(currentFileName); | 1073 | QFileInfo fi(currentFileName); |
1029 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); | 1074 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); |
1030 | if( (fi.baseName().left(1)).isEmpty() ) { | 1075 | if( (fi.baseName().left(1)).isEmpty() ) { |
1031 | openDotFile(currentFileName); | 1076 | openDotFile(currentFileName); |
1032 | 1077 | ||
1033 | } else { | 1078 | } else { |
1034 | qDebug("setDoc open"); | 1079 | qDebug("setDoc open"); |
1035 | bFromDocView = true; | 1080 | bFromDocView = true; |
1036 | openFile(fileref); | 1081 | openFile(fileref); |
1037 | editor->setEdited(true); | 1082 | editor->setEdited(true); |
1038 | edited1=false; | 1083 | edited1=false; |
1039 | edited=true; | 1084 | edited=true; |
1040 | // fromSetDocument=false; | 1085 | // fromSetDocument=false; |
1041 | // doSearchBar(); | 1086 | // doSearchBar(); |
1042 | } | 1087 | } |
1043 | } | 1088 | } |
1044 | updateCaption( currentFileName); | 1089 | updateCaption( currentFileName); |
1045 | } | 1090 | } |
1046 | 1091 | ||
1047 | void TextEdit::changeFont() { | 1092 | void TextEdit::changeFont() { |
1048 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 1093 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
1049 | d-> setCaption ( tr( "Choose font" )); | 1094 | d-> setCaption ( tr( "Choose font" )); |
1050 | QBoxLayout *lay = new QVBoxLayout ( d ); | 1095 | QBoxLayout *lay = new QVBoxLayout ( d ); |
1051 | OFontSelector *ofs = new OFontSelector ( true, d ); | 1096 | OFontSelector *ofs = new OFontSelector ( true, d ); |
1052 | lay-> addWidget ( ofs ); | 1097 | lay-> addWidget ( ofs ); |
1053 | ofs-> setSelectedFont ( editor-> font ( )); | 1098 | ofs-> setSelectedFont ( editor-> font ( )); |
1054 | 1099 | ||
1055 | d-> showMaximized ( ); | 1100 | d-> showMaximized ( ); |
1056 | if ( d-> exec ( ) == QDialog::Accepted ) | 1101 | if ( d-> exec ( ) == QDialog::Accepted ) |
1057 | editor-> setFont ( ofs-> selectedFont ( )); | 1102 | editor-> setFont ( ofs-> selectedFont ( )); |
1058 | delete d; | 1103 | delete d; |
1059 | 1104 | ||
1060 | } | 1105 | } |
1061 | 1106 | ||
1062 | void TextEdit::editDelete() { | 1107 | void TextEdit::editDelete() { |
1063 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 1108 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
1064 | tr("Do you really want<BR>to <B>delete</B> " | 1109 | tr("Do you really want<BR>to <B>delete</B> " |
1065 | "the current file\nfrom the disk?<BR>This is " | 1110 | "the current file\nfrom the disk?<BR>This is " |
1066 | "<B>irreversable!!</B>"), | 1111 | "<B>irreversable!!</B>"), |
1067 | tr("Yes"),tr("No"),0,0,1) ) { | 1112 | tr("Yes"),tr("No"),0,0,1) ) { |
1068 | case 0: | 1113 | case 0: |
1069 | if(doc) { | 1114 | if(doc) { |
1070 | doc->removeFiles(); | 1115 | doc->removeFiles(); |
1071 | clear(); | 1116 | clear(); |
1072 | setCaption( tr("Text Editor") ); | 1117 | setCaption( tr("Text Editor") ); |
1073 | } | 1118 | } |
1074 | break; | 1119 | break; |
1075 | case 1: | 1120 | case 1: |
1076 | // exit | 1121 | // exit |
1077 | break; | 1122 | break; |
1078 | }; | 1123 | }; |
1079 | } | 1124 | } |
1080 | 1125 | ||
1081 | void TextEdit::changeStartConfig( bool b ) { | 1126 | void TextEdit::changeStartConfig( bool b ) { |
1082 | startWithNew=b; | 1127 | startWithNew=b; |
1083 | Config cfg("TextEdit"); | 1128 | Config cfg("TextEdit"); |
1084 | cfg.setGroup("View"); | 1129 | cfg.setGroup("View"); |
1085 | cfg.writeEntry("startNew",b); | 1130 | cfg.writeEntry("startNew",b); |
1086 | update(); | 1131 | update(); |
1087 | } | 1132 | } |
1088 | 1133 | ||
1089 | void TextEdit::editorChanged() { | 1134 | void TextEdit::editorChanged() { |
1090 | // qDebug("editor changed"); | 1135 | // qDebug("editor changed"); |
1091 | if( /*editor->edited() &&*/ /*edited && */!edited1) { | 1136 | if( /*editor->edited() &&*/ /*edited && */!edited1) { |
1092 | setCaption( "*"+caption()); | 1137 | setCaption( "*"+caption()); |
1093 | edited1=true; | 1138 | edited1=true; |
1094 | } | 1139 | } |
1095 | edited=true; | 1140 | edited=true; |
1096 | } | 1141 | } |
1097 | 1142 | ||
1098 | void TextEdit::receive(const QCString&msg, const QByteArray &) { | 1143 | void TextEdit::receive(const QCString&msg, const QByteArray &) { |
1099 | qDebug("QCop "+msg); | 1144 | qDebug("QCop "+msg); |
1100 | if ( msg == "setDocument(QString)" ) { | 1145 | if ( msg == "setDocument(QString)" ) { |
1101 | qDebug("bugger all"); | 1146 | qDebug("bugger all"); |
1102 | 1147 | ||
1103 | } | 1148 | } |
1104 | 1149 | ||
1105 | } | 1150 | } |
1106 | 1151 | ||
1107 | void TextEdit::doAbout() { | 1152 | void TextEdit::doAbout() { |
1108 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" | 1153 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" |
1109 | "2000 Trolltech AS, and<BR>" | 1154 | "2000 Trolltech AS, and<BR>" |
1110 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" | 1155 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" |
1111 | "and is licensed under the GPL")); | 1156 | "and is licensed under the GPL")); |
1112 | } | 1157 | } |
1113 | 1158 | ||
1114 | void TextEdit::doPrompt(bool b) { | 1159 | void TextEdit::doPrompt(bool b) { |
1115 | promptExit=b; | 1160 | promptExit=b; |
1116 | Config cfg("TextEdit"); | 1161 | Config cfg("TextEdit"); |
1117 | cfg.setGroup ( "View" ); | 1162 | cfg.setGroup ( "View" ); |
1118 | cfg.writeEntry ( "PromptExit", b); | 1163 | cfg.writeEntry ( "PromptExit", b); |
1119 | } | 1164 | } |
1120 | 1165 | ||
1121 | void TextEdit::doDesktop(bool b) { | 1166 | void TextEdit::doDesktop(bool b) { |
1122 | openDesktop=b; | 1167 | openDesktop=b; |
1123 | Config cfg("TextEdit"); | 1168 | Config cfg("TextEdit"); |
1124 | cfg.setGroup ( "View" ); | 1169 | cfg.setGroup ( "View" ); |
1125 | cfg.writeEntry ( "OpenDesktop", b); | 1170 | cfg.writeEntry ( "OpenDesktop", b); |
1126 | } | 1171 | } |
1127 | 1172 | ||
1128 | void TextEdit::doFilePerms(bool b) { | 1173 | void TextEdit::doFilePerms(bool b) { |
1129 | filePerms=b; | 1174 | filePerms=b; |
1130 | Config cfg("TextEdit"); | 1175 | Config cfg("TextEdit"); |
1131 | cfg.setGroup ( "View" ); | 1176 | cfg.setGroup ( "View" ); |
1132 | cfg.writeEntry ( "FilePermissions", b); | 1177 | cfg.writeEntry ( "FilePermissions", b); |
1133 | } | 1178 | } |
1134 | 1179 | ||
1135 | void TextEdit::editPasteTimeDate() { | 1180 | void TextEdit::editPasteTimeDate() { |
1136 | #ifndef QT_NO_CLIPBOARD | 1181 | #ifndef QT_NO_CLIPBOARD |
1137 | QClipboard *cb = QApplication::clipboard(); | 1182 | QClipboard *cb = QApplication::clipboard(); |
1138 | QDateTime dt = QDateTime::currentDateTime(); | 1183 | QDateTime dt = QDateTime::currentDateTime(); |
1139 | cb->setText( dt.toString()); | 1184 | cb->setText( dt.toString()); |
1140 | editor->paste(); | 1185 | editor->paste(); |
1141 | #endif | 1186 | #endif |
1142 | } | 1187 | } |
1188 | |||
1189 | int TextEdit::savePrompt() | ||
1190 | { | ||
1191 | switch( QMessageBox::information( 0, (tr("Textedit")), | ||
1192 | (tr("Textedit detected\n" | ||
1193 | "you have unsaved changes\n" | ||
1194 | "Go ahead and save?\n")), | ||
1195 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) | ||
1196 | { | ||
1197 | case 0: | ||
1198 | { | ||
1199 | return 1; | ||
1200 | } | ||
1201 | break; | ||
1202 | |||
1203 | case 1: | ||
1204 | { | ||
1205 | return 2; | ||
1206 | } | ||
1207 | break; | ||
1208 | |||
1209 | case 2: | ||
1210 | { | ||
1211 | return -1; | ||
1212 | } | ||
1213 | break; | ||
1214 | }; | ||
1215 | |||
1216 | return 0; | ||
1217 | } | ||
1218 | |||
1219 | void TextEdit::timerCrank() | ||
1220 | { | ||
1221 | if(featureAutoSave) | ||
1222 | { | ||
1223 | if( edited1 ) | ||
1224 | { | ||
1225 | if(currentFileName.isEmpty()) | ||
1226 | { | ||
1227 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; | ||
1228 | saveAs(); | ||
1229 | } | ||
1230 | else | ||
1231 | { | ||
1232 | qDebug("autosave"); | ||
1233 | save(); | ||
1234 | } | ||
1235 | setTimer(); | ||
1236 | } | ||
1237 | } | ||
1238 | } | ||
1239 | |||
1240 | void TextEdit::doTimer(bool b) | ||
1241 | { | ||
1242 | Config cfg("TextEdit"); | ||
1243 | cfg.setGroup ( "View" ); | ||
1244 | cfg.writeEntry ( "autosave", b); | ||
1245 | featureAutoSave = b; | ||
1246 | nAutoSave->setOn(b); | ||
1247 | if(b) | ||
1248 | { | ||
1249 | qDebug("doTimer true"); | ||
1250 | setTimer(); | ||
1251 | } | ||
1252 | else | ||
1253 | qDebug("doTimer false"); | ||
1254 | } | ||
1255 | |||
1256 | void TextEdit::setTimer() | ||
1257 | { | ||
1258 | if(featureAutoSave) | ||
1259 | { | ||
1260 | qDebug("setting autosave"); | ||
1261 | QTimer *timer = new QTimer(this ); | ||
1262 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); | ||
1263 | timer->start( 30000/*0*/, true); //5 minutes | ||
1264 | } | ||
1265 | } | ||
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 9f16ebf..643ea68 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -1,132 +1,138 @@ | |||
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 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <opie/ofileselector.h> | 33 | #include <opie/ofileselector.h> |
34 | 34 | ||
35 | #include <qmainwindow.h> | 35 | #include <qmainwindow.h> |
36 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
37 | #include <qlist.h> | 37 | #include <qlist.h> |
38 | #include <qmap.h> | 38 | #include <qmap.h> |
39 | 39 | ||
40 | class QAction; | 40 | class QAction; |
41 | class QWidgetStack; | 41 | class QWidgetStack; |
42 | class QToolButton; | 42 | class QToolButton; |
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QToolBar; | 44 | class QToolBar; |
45 | class QLineEdit; | 45 | class QLineEdit; |
46 | class QAction; | 46 | class QAction; |
47 | class FileSelector; | 47 | class FileSelector; |
48 | class QpeEditor; | 48 | class QpeEditor; |
49 | class QPopupMenu; | 49 | class QPopupMenu; |
50 | class QTimer; | ||
50 | 51 | ||
51 | class TextEdit : public QMainWindow | 52 | class TextEdit : public QMainWindow |
52 | { | 53 | { |
53 | Q_OBJECT | 54 | Q_OBJECT |
54 | 55 | ||
55 | public: | 56 | public: |
56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 57 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
57 | ~TextEdit(); | 58 | ~TextEdit(); |
58 | 59 | ||
60 | protected: | ||
59 | QPopupMenu *font; | 61 | QPopupMenu *font; |
60 | QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction; | 62 | QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction, *nAutoSave; |
61 | bool edited, edited1; | 63 | bool edited, edited1; |
62 | void openFile( const QString & ); | 64 | void openFile( const QString & ); |
63 | QCopChannel * channel; | 65 | QCopChannel * channel; |
64 | public slots: | 66 | |
65 | void editorChanged(); | 67 | bool featureAutoSave; |
66 | void receive(const QCString&, const QByteArray&); | ||
67 | protected: | ||
68 | void closeEvent( QCloseEvent *e ); | 68 | void closeEvent( QCloseEvent *e ); |
69 | void doSearchBar(); | 69 | void doSearchBar(); |
70 | int savePrompt(); | ||
71 | void setTimer(); | ||
70 | private slots: | 72 | private slots: |
73 | void editorChanged(); | ||
74 | void receive(const QCString&, const QByteArray&); | ||
75 | void timerCrank(); | ||
76 | void doTimer(bool); | ||
71 | void editPasteTimeDate(); | 77 | void editPasteTimeDate(); |
72 | void doPrompt(bool); | 78 | void doPrompt(bool); |
73 | void doDesktop(bool); | 79 | void doDesktop(bool); |
74 | void doFilePerms(bool); | 80 | void doFilePerms(bool); |
75 | void doAbout(); | 81 | void doAbout(); |
76 | void setDocument(const QString&); | 82 | void setDocument(const QString&); |
77 | void changeFont(); | 83 | void changeFont(); |
78 | void fileNew(); | 84 | void fileNew(); |
79 | void fileRevert(); | 85 | void fileRevert(); |
80 | void fileOpen(); | 86 | void fileOpen(); |
81 | void changeStartConfig(bool); | 87 | void changeStartConfig(bool); |
82 | bool save(); | 88 | bool save(); |
83 | bool saveAs(); | 89 | bool saveAs(); |
84 | void cleanUp(); | 90 | void cleanUp(); |
85 | 91 | ||
86 | 92 | ||
87 | void editCut(); | 93 | void editCut(); |
88 | void editCopy(); | 94 | void editCopy(); |
89 | void editPaste(); | 95 | void editPaste(); |
90 | void editFind(); | 96 | void editFind(); |
91 | void editDelete(); | 97 | void editDelete(); |
92 | 98 | ||
93 | void findNext(); | 99 | void findNext(); |
94 | void findClose(); | 100 | void findClose(); |
95 | 101 | ||
96 | void search(); | 102 | void search(); |
97 | void accept(); | 103 | void accept(); |
98 | 104 | ||
99 | void newFile( const DocLnk & ); | 105 | void newFile( const DocLnk & ); |
100 | void openFile( const DocLnk & ); | 106 | void openFile( const DocLnk & ); |
101 | void showEditTools(); | 107 | void showEditTools(); |
102 | 108 | ||
103 | void zoomIn(); | 109 | void zoomIn(); |
104 | void zoomOut(); | 110 | void zoomOut(); |
105 | void setBold(bool y); | 111 | void setBold(bool y); |
106 | void setItalic(bool y); | 112 | void setItalic(bool y); |
107 | void setWordWrap(bool y); | 113 | void setWordWrap(bool y); |
108 | void setSearchBar(bool); | 114 | void setSearchBar(bool); |
109 | 115 | ||
110 | private: | 116 | private: |
111 | void openDotFile(const QString &); | 117 | void openDotFile(const QString &); |
112 | void colorChanged( const QColor &c ); | 118 | void colorChanged( const QColor &c ); |
113 | void clear(); | 119 | void clear(); |
114 | void updateCaption( const QString &name=QString::null ); | 120 | void updateCaption( const QString &name=QString::null ); |
115 | void setFontSize(int sz, bool round_down_not_up); | 121 | void setFontSize(int sz, bool round_down_not_up); |
116 | private: | 122 | private: |
117 | // fileSaver *fileSaveDlg; | 123 | // fileSaver *fileSaveDlg; |
118 | // fileBrowser *browseForFiles; | 124 | // fileBrowser *browseForFiles; |
119 | bool fromSetDocument; | 125 | bool fromSetDocument; |
120 | QpeEditor* editor; | 126 | QpeEditor* editor; |
121 | QToolBar *menu, *editBar, *searchBar; | 127 | QToolBar *menu, *editBar, *searchBar; |
122 | QPopupMenu *advancedMenu; | 128 | QPopupMenu *advancedMenu; |
123 | QLineEdit *searchEdit; | 129 | QLineEdit *searchEdit; |
124 | DocLnk *doc; | 130 | DocLnk *doc; |
125 | bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew; | 131 | bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew; |
126 | bool bFromDocView; | 132 | bool bFromDocView; |
127 | int viewSelection; | 133 | int viewSelection; |
128 | QAction *zin, *zout; | 134 | QAction *zin, *zout; |
129 | QString currentFileName; | 135 | QString currentFileName; |
130 | }; | 136 | }; |
131 | 137 | ||
132 | #endif | 138 | #endif |