summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp24
-rw-r--r--core/apps/textedit/textedit.h1
2 files changed, 23 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 9e6ba8d..107695a 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,706 +1,717 @@
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 "filePermissions.h" 23#include "filePermissions.h"
24#include "fontDialog.h" 24#include "fontDialog.h"
25 25
26#include <opie/ofileselector.h> 26#include <opie/ofileselector.h>
27#include <opie/ofiledialog.h> 27#include <opie/ofiledialog.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/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39 39
40#include <qdatetime.h>
41#include <qclipboard.h>
40#include <qstringlist.h> 42#include <qstringlist.h>
41#include <qaction.h> 43#include <qaction.h>
42#include <qcolordialog.h> 44#include <qcolordialog.h>
43#include <qfileinfo.h> 45#include <qfileinfo.h>
44#include <qlineedit.h> 46#include <qlineedit.h>
45#include <qmessagebox.h> 47#include <qmessagebox.h>
46#include <qobjectlist.h> 48#include <qobjectlist.h>
47#include <qpopupmenu.h> 49#include <qpopupmenu.h>
48#include <qspinbox.h> 50#include <qspinbox.h>
49#include <qtoolbutton.h> 51#include <qtoolbutton.h>
50#include <qwidgetstack.h> 52#include <qwidgetstack.h>
51#include <qcheckbox.h> 53#include <qcheckbox.h>
52#include <qcombo.h> 54#include <qcombo.h>
55
53#include <unistd.h> 56#include <unistd.h>
54#include <sys/stat.h> 57#include <sys/stat.h>
55
56#include <stdlib.h> //getenv 58#include <stdlib.h> //getenv
59
60
57/* XPM */ 61/* XPM */
58static char * filesave_xpm[] = { 62static char * filesave_xpm[] = {
59"16 16 78 1", 63"16 16 78 1",
60" c None", 64" c None",
61". c #343434", 65". c #343434",
62"+ c #A0A0A0", 66"+ c #A0A0A0",
63"@ c #565656", 67"@ c #565656",
64"# c #9E9E9E", 68"# c #9E9E9E",
65"$ c #525252", 69"$ c #525252",
66"% c #929292", 70"% c #929292",
67"& c #676767", 71"& c #676767",
68"* c #848484", 72"* c #848484",
69"= c #666666", 73"= c #666666",
70"- c #D8D8D8", 74"- c #D8D8D8",
71"; c #FFFFFF", 75"; c #FFFFFF",
72"> c #DBDBDB", 76"> c #DBDBDB",
73", c #636363", 77", c #636363",
74"' c #989898", 78"' c #989898",
75") c #2D2D2D", 79") c #2D2D2D",
76"! c #909090", 80"! c #909090",
77"~ c #AEAEAE", 81"~ c #AEAEAE",
78"{ c #EAEAEA", 82"{ c #EAEAEA",
79"] c #575757", 83"] c #575757",
80"^ c #585858", 84"^ c #585858",
81"/ c #8A8A8A", 85"/ c #8A8A8A",
82"( c #828282", 86"( c #828282",
83"_ c #6F6F6F", 87"_ c #6F6F6F",
84": c #C9C9C9", 88": c #C9C9C9",
85"< c #050505", 89"< c #050505",
86"[ c #292929", 90"[ c #292929",
87"} c #777777", 91"} c #777777",
88"| c #616161", 92"| c #616161",
89"1 c #3A3A3A", 93"1 c #3A3A3A",
90"2 c #BEBEBE", 94"2 c #BEBEBE",
91"3 c #2C2C2C", 95"3 c #2C2C2C",
92"4 c #7C7C7C", 96"4 c #7C7C7C",
93"5 c #F6F6F6", 97"5 c #F6F6F6",
94"6 c #FCFCFC", 98"6 c #FCFCFC",
95"7 c #6B6B6B", 99"7 c #6B6B6B",
96"8 c #959595", 100"8 c #959595",
97"9 c #4F4F4F", 101"9 c #4F4F4F",
98"0 c #808080", 102"0 c #808080",
99"a c #767676", 103"a c #767676",
100"b c #818181", 104"b c #818181",
101"c c #B8B8B8", 105"c c #B8B8B8",
102"d c #FBFBFB", 106"d c #FBFBFB",
103"e c #F9F9F9", 107"e c #F9F9F9",
104"f c #CCCCCC", 108"f c #CCCCCC",
105"g c #030303", 109"g c #030303",
106"h c #737373", 110"h c #737373",
107"i c #7A7A7A", 111"i c #7A7A7A",
108"j c #7E7E7E", 112"j c #7E7E7E",
109"k c #6A6A6A", 113"k c #6A6A6A",
110"l c #FAFAFA", 114"l c #FAFAFA",
111"m c #505050", 115"m c #505050",
112"n c #9D9D9D", 116"n c #9D9D9D",
113"o c #333333", 117"o c #333333",
114"p c #7B7B7B", 118"p c #7B7B7B",
115"q c #787878", 119"q c #787878",
116"r c #696969", 120"r c #696969",
117"s c #494949", 121"s c #494949",
118"t c #555555", 122"t c #555555",
119"u c #949494", 123"u c #949494",
120"v c #E6E6E6", 124"v c #E6E6E6",
121"w c #424242", 125"w c #424242",
122"x c #515151", 126"x c #515151",
123"y c #535353", 127"y c #535353",
124"z c #3E3E3E", 128"z c #3E3E3E",
125"A c #D4D4D4", 129"A c #D4D4D4",
126"B c #0C0C0C", 130"B c #0C0C0C",
127"C c #353535", 131"C c #353535",
128"D c #474747", 132"D c #474747",
129"E c #ECECEC", 133"E c #ECECEC",
130"F c #919191", 134"F c #919191",
131"G c #7D7D7D", 135"G c #7D7D7D",
132"H c #000000", 136"H c #000000",
133"I c #404040", 137"I c #404040",
134"J c #858585", 138"J c #858585",
135"K c #323232", 139"K c #323232",
136"L c #D0D0D0", 140"L c #D0D0D0",
137"M c #1C1C1C", 141"M c #1C1C1C",
138" ...+ ", 142" ...+ ",
139" @#$%&..+ ", 143" @#$%&..+ ",
140" .*=-;;>,..+ ", 144" .*=-;;>,..+ ",
141" ')!~;;;;;;{]..", 145" ')!~;;;;;;{]..",
142" ^/(-;;;;;;;_:<", 146" ^/(-;;;;;;;_:<",
143" [}|;;;;;;;{12$", 147" [}|;;;;;;;{12$",
144" #34-55;;;;678$+", 148" #34-55;;;;678$+",
145" 90ab=c;dd;e1fg ", 149" 90ab=c;dd;e1fg ",
146" [ahij((kbl0mn$ ", 150" [ahij((kbl0mn$ ",
147" op^q^^7r&]s/$+ ", 151" op^q^^7r&]s/$+ ",
148"@btu;vbwxy]zAB ", 152"@btu;vbwxy]zAB ",
149"CzDEvEv;;DssF$ ", 153"CzDEvEv;;DssF$ ",
150"G.H{E{E{IxsJ$+ ", 154"G.H{E{E{IxsJ$+ ",
151" +...vEKxzLM ", 155" +...vEKxzLM ",
152" +...z]n$ ", 156" +...z]n$ ",
153" +... "}; 157" +... "};
154 158
155 159
156#if QT_VERSION < 300 160#if QT_VERSION < 300
157 161
158class QpeEditor : public QMultiLineEdit 162class QpeEditor : public QMultiLineEdit
159{ 163{
160 // Q_OBJECT 164 // Q_OBJECT
161public: 165public:
162 QpeEditor( QWidget *parent, const char * name = 0 ) 166 QpeEditor( QWidget *parent, const char * name = 0 )
163 : QMultiLineEdit( parent, name ) 167 : QMultiLineEdit( parent, name )
164 { 168 {
165 clearTableFlags(); 169 clearTableFlags();
166 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 170 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
167 } 171 }
168 172
169 void find( const QString &txt, bool caseSensitive, 173 void find( const QString &txt, bool caseSensitive,
170 bool backwards ); 174 bool backwards );
171//public slots: 175//public slots:
172 /* 176 /*
173signals: 177signals:
174 void notFound(); 178 void notFound();
175 void searchWrapped(); 179 void searchWrapped();
176 */ 180 */
177 181
178private: 182private:
179 183
180}; 184};
181 185
182 186
183void QpeEditor::find ( const QString &txt, bool caseSensitive, 187void QpeEditor::find ( const QString &txt, bool caseSensitive,
184 bool backwards ) 188 bool backwards )
185{ 189{
186 static bool wrap = FALSE; 190 static bool wrap = FALSE;
187 int line, col; 191 int line, col;
188 if ( wrap ) { 192 if ( wrap ) {
189 if ( !backwards ) 193 if ( !backwards )
190 line = col = 0; 194 line = col = 0;
191 wrap = FALSE; 195 wrap = FALSE;
192 // emit searchWrapped(); 196 // emit searchWrapped();
193 } else { 197 } else {
194 getCursorPosition( &line, &col ); 198 getCursorPosition( &line, &col );
195 } 199 }
196 //ignore backwards for now.... 200 //ignore backwards for now....
197 if ( !backwards ) { 201 if ( !backwards ) {
198 for ( ; ; ) { 202 for ( ; ; ) {
199 if ( line >= numLines() ) { 203 if ( line >= numLines() ) {
200 wrap = TRUE; 204 wrap = TRUE;
201 //emit notFound(); 205 //emit notFound();
202 break; 206 break;
203 } 207 }
204 int findCol = getString( line )->find( txt, col, caseSensitive ); 208 int findCol = getString( line )->find( txt, col, caseSensitive );
205 if ( findCol >= 0 ) { 209 if ( findCol >= 0 ) {
206 setCursorPosition( line, findCol, FALSE ); 210 setCursorPosition( line, findCol, FALSE );
207 col = findCol + txt.length(); 211 col = findCol + txt.length();
208 setCursorPosition( line, col, TRUE ); 212 setCursorPosition( line, col, TRUE );
209 213
210 //found = TRUE; 214 //found = TRUE;
211 break; 215 break;
212 } 216 }
213 line++; 217 line++;
214 col = 0; 218 col = 0;
215 } 219 }
216 220
217 } 221 }
218 222
219} 223}
220 224
221 225
222#else 226#else
223 227
224#error "Must make a QpeEditor that inherits QTextEdit" 228#error "Must make a QpeEditor that inherits QTextEdit"
225 229
226#endif 230#endif
227 231
228 232
229static const int nfontsizes = 6; 233static const int nfontsizes = 6;
230static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 234static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
231 235
232TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 236TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
233 : QMainWindow( parent, name, f ), bFromDocView( FALSE ) 237 : QMainWindow( parent, name, f ), bFromDocView( FALSE )
234{ 238{
235 doc = 0; 239 doc = 0;
236 edited=FALSE; 240 edited=FALSE;
237 edited1=FALSE; 241 edited1=FALSE;
238 setToolBarsMovable( FALSE ); 242 setToolBarsMovable( FALSE );
239 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 243 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
240 244
241 channel = new QCopChannel( "QPE/Application/textedit", this ); 245 channel = new QCopChannel( "QPE/Application/textedit", this );
242 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 246 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
243 this, SLOT(receive(const QCString&, const QByteArray&)) ); 247 this, SLOT(receive(const QCString&, const QByteArray&)) );
244 248
245 setIcon( Resource::loadPixmap( "TextEditor" ) ); 249 setIcon( Resource::loadPixmap( "TextEditor" ) );
246 250
247 QPEToolBar *bar = new QPEToolBar( this ); 251 QPEToolBar *bar = new QPEToolBar( this );
248 bar->setHorizontalStretchable( TRUE ); 252 bar->setHorizontalStretchable( TRUE );
249 menu = bar; 253 menu = bar;
250 254
251 QPEMenuBar *mb = new QPEMenuBar( bar ); 255 QPEMenuBar *mb = new QPEMenuBar( bar );
252 QPopupMenu *file = new QPopupMenu( this ); 256 QPopupMenu *file = new QPopupMenu( this );
253 QPopupMenu *edit = new QPopupMenu( this ); 257 QPopupMenu *edit = new QPopupMenu( this );
254 font = new QPopupMenu( this ); 258 font = new QPopupMenu( this );
255 259
256 bar = new QPEToolBar( this ); 260 bar = new QPEToolBar( this );
257 editBar = bar; 261 editBar = bar;
258 262
259 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 263 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
260 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 264 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
261 a->addTo( bar ); 265 a->addTo( bar );
262 a->addTo( file ); 266 a->addTo( file );
263 267
264 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 268 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
265 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 269 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
266 a->addTo( bar ); 270 a->addTo( bar );
267 a->addTo( file ); 271 a->addTo( file );
268 272
269 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 273 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
270 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 274 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
271 file->insertSeparator(); 275 file->insertSeparator();
272 a->addTo( file ); 276 a->addTo( file );
273 277
274 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 278 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
275 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 279 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
276 a->addTo( file ); 280 a->addTo( file );
277 281
278 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 282 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
279 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 283 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
280 a->addTo( editBar ); 284 a->addTo( editBar );
281 a->addTo( edit ); 285 a->addTo( edit );
282 286
283 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 287 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
284 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 288 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
285 a->addTo( editBar ); 289 a->addTo( editBar );
286 a->addTo( edit ); 290 a->addTo( edit );
287 291
288 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 292 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
289 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 293 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
290 a->addTo( editBar ); 294 a->addTo( editBar );
291 a->addTo( edit ); 295 a->addTo( edit );
292 296
297
298#ifndef QT_NO_CLIPBOARD
299 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
300 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
301 a->addTo( edit );
302#endif
303
293 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 304 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
294 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 305 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
295 edit->insertSeparator(); 306 edit->insertSeparator();
296 a->addTo( bar ); 307 a->addTo( bar );
297 a->addTo( edit ); 308 a->addTo( edit );
298 309
299 int defsize; 310 int defsize;
300 bool defb, defi, wrap; 311 bool defb, defi, wrap;
301 312
302 Config cfg("TextEdit"); 313 Config cfg("TextEdit");
303 cfg.setGroup("View"); 314 cfg.setGroup("View");
304 defsize = cfg.readNumEntry("FontSize",10); 315 defsize = cfg.readNumEntry("FontSize",10);
305 defb = cfg.readBoolEntry("Bold",FALSE); 316 defb = cfg.readBoolEntry("Bold",FALSE);
306 defi = cfg.readBoolEntry("Italic",FALSE); 317 defi = cfg.readBoolEntry("Italic",FALSE);
307 wrap = cfg.readBoolEntry("Wrap",TRUE); 318 wrap = cfg.readBoolEntry("Wrap",TRUE);
308 319
309 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 320 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
310 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 321 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
311 zin->addTo( font ); 322 zin->addTo( font );
312 323
313 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 324 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
314 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 325 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
315 zout->addTo( font ); 326 zout->addTo( font );
316 327
317 font->insertSeparator(); 328 font->insertSeparator();
318 329
319#if 0 330#if 0
320 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); 331 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 );
321 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); 332 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) );
322 ba->setToggleAction(TRUE); 333 ba->setToggleAction(TRUE);
323 ba->addTo( font ); 334 ba->addTo( font );
324 335
325 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); 336 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 );
326 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); 337 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) );
327 ia->setToggleAction(TRUE); 338 ia->setToggleAction(TRUE);
328 ia->addTo( font ); 339 ia->addTo( font );
329 340
330 ba->setOn(defb); 341 ba->setOn(defb);
331 ia->setOn(defi); 342 ia->setOn(defi);
332 343
333 font->insertSeparator(); 344 font->insertSeparator();
334#endif 345#endif
335 346
336 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); 347 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 );
337 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 348 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
338 wa->setToggleAction(TRUE); 349 wa->setToggleAction(TRUE);
339 wa->addTo( font ); 350 wa->addTo( font );
340 351
341 font->insertSeparator(); 352 font->insertSeparator();
342 font->insertItem(tr("Font"), this, SLOT(changeFont()) ); 353 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
343 354
344 font->insertSeparator(); 355 font->insertSeparator();
345 356
346 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); 357 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 );
347 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); 358 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) );
348 nStart->setToggleAction(TRUE); 359 nStart->setToggleAction(TRUE);
349 nStart->addTo( font ); 360 nStart->addTo( font );
350 361
351 nAdvanced = new QAction( tr("Advanced features"), QString::null, 0, this, 0 ); 362 nAdvanced = new QAction( tr("Advanced features"), QString::null, 0, this, 0 );
352 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doAdvanced(bool) ) ); 363 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doAdvanced(bool) ) );
353 nAdvanced->setToggleAction(TRUE); 364 nAdvanced->setToggleAction(TRUE);
354 nAdvanced->addTo( font ); 365 nAdvanced->addTo( font );
355 if(cfg.readBoolEntry("AdvancedFeatures")) 366 if(cfg.readBoolEntry("AdvancedFeatures"))
356 nAdvanced->setOn(TRUE); 367 nAdvanced->setOn(TRUE);
357 font->insertSeparator(); 368 font->insertSeparator();
358 369
359 font->insertItem(tr("About"), this, SLOT( doAbout()) ); 370 font->insertItem(tr("About"), this, SLOT( doAbout()) );
360 371
361 mb->insertItem( tr( "File" ), file ); 372 mb->insertItem( tr( "File" ), file );
362 mb->insertItem( tr( "Edit" ), edit ); 373 mb->insertItem( tr( "Edit" ), edit );
363 mb->insertItem( tr( "View" ), font ); 374 mb->insertItem( tr( "View" ), font );
364 375
365 searchBar = new QPEToolBar(this); 376 searchBar = new QPEToolBar(this);
366 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 377 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
367 378
368 searchBar->setHorizontalStretchable( TRUE ); 379 searchBar->setHorizontalStretchable( TRUE );
369 380
370 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 381 searchEdit = new QLineEdit( searchBar, "searchEdit" );
371 searchBar->setStretchableWidget( searchEdit ); 382 searchBar->setStretchableWidget( searchEdit );
372 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 383 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
373 this, SLOT( search() ) ); 384 this, SLOT( search() ) );
374 385
375 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 386 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
376 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 387 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
377 a->addTo( searchBar ); 388 a->addTo( searchBar );
378 a->addTo( edit ); 389 a->addTo( edit );
379 390
380 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 391 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
381 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 392 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
382 a->addTo( searchBar ); 393 a->addTo( searchBar );
383 394
384 edit->insertSeparator(); 395 edit->insertSeparator();
385 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 396 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
386 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 397 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
387 a->addTo( edit ); 398 a->addTo( edit );
388 399
389 searchBar->hide(); 400 searchBar->hide();
390 401
391 editor = new QpeEditor( this ); 402 editor = new QpeEditor( this );
392 setCentralWidget( editor ); 403 setCentralWidget( editor );
393 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 404 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
394 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); 405 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
395 406
396// resize( 200, 300 ); 407// resize( 200, 300 );
397 408
398// setFontSize(defsize,TRUE); 409// setFontSize(defsize,TRUE);
399 FontDatabase fdb; 410 FontDatabase fdb;
400 QFont defaultFont=editor->font(); 411 QFont defaultFont=editor->font();
401 QFontInfo fontInfo(defaultFont); 412 QFontInfo fontInfo(defaultFont);
402 413
403 cfg.setGroup("Font"); 414 cfg.setGroup("Font");
404 QString family = cfg.readEntry("Family", fontInfo.family()); 415 QString family = cfg.readEntry("Family", fontInfo.family());
405 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 416 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
406 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 417 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
407 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 418 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
408 419
409 defaultFont = fdb.font(family,style,i_size,charSet); 420 defaultFont = fdb.font(family,style,i_size,charSet);
410 editor->setFont( defaultFont); 421 editor->setFont( defaultFont);
411 422
412 wa->setOn(wrap); 423 wa->setOn(wrap);
413 updateCaption(); 424 updateCaption();
414 425
415 cfg.setGroup("View"); 426 cfg.setGroup("View");
416 if(cfg.readEntry("startNew","TRUE") == "TRUE") { 427 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
417 nStart->setOn(TRUE); 428 nStart->setOn(TRUE);
418 fileNew(); 429 fileNew();
419 } else { 430 } else {
420 fileOpen(); 431 fileOpen();
421 } 432 }
422 433
423 viewSelection = cfg.readNumEntry( "FileView", 0 ); 434 viewSelection = cfg.readNumEntry( "FileView", 0 );
424} 435}
425 436
426void TextEdit::cleanUp() 437void TextEdit::cleanUp()
427{ 438{
428// save(); 439// save();
429 Config cfg("TextEdit"); 440 Config cfg("TextEdit");
430 cfg.setGroup("View"); 441 cfg.setGroup("View");
431 QFont f = editor->font(); 442 QFont f = editor->font();
432 cfg.writeEntry("FontSize",f.pointSize()); 443 cfg.writeEntry("FontSize",f.pointSize());
433 cfg.writeEntry("Bold",f.bold()); 444 cfg.writeEntry("Bold",f.bold());
434 cfg.writeEntry("Italic",f.italic()); 445 cfg.writeEntry("Italic",f.italic());
435 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 446 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
436 cfg.writeEntry( "FileView", viewSelection ); 447 cfg.writeEntry( "FileView", viewSelection );
437 448
438} 449}
439 450
440TextEdit::~TextEdit() 451TextEdit::~TextEdit()
441{ 452{
442} 453}
443 454
444void TextEdit::zoomIn() 455void TextEdit::zoomIn()
445{ 456{
446 setFontSize(editor->font().pointSize()+1,FALSE); 457 setFontSize(editor->font().pointSize()+1,FALSE);
447} 458}
448 459
449void TextEdit::zoomOut() 460void TextEdit::zoomOut()
450{ 461{
451 setFontSize(editor->font().pointSize()-1,TRUE); 462 setFontSize(editor->font().pointSize()-1,TRUE);
452} 463}
453 464
454 465
455void TextEdit::setFontSize(int sz, bool round_down_not_up) 466void TextEdit::setFontSize(int sz, bool round_down_not_up)
456{ 467{
457 int s=10; 468 int s=10;
458 for (int i=0; i<nfontsizes; i++) { 469 for (int i=0; i<nfontsizes; i++) {
459 if ( fontsize[i] == sz ) { 470 if ( fontsize[i] == sz ) {
460 s = sz; 471 s = sz;
461 break; 472 break;
462 } else if ( round_down_not_up ) { 473 } else if ( round_down_not_up ) {
463 if ( fontsize[i] < sz ) 474 if ( fontsize[i] < sz )
464 s = fontsize[i]; 475 s = fontsize[i];
465 } else { 476 } else {
466 if ( fontsize[i] > sz ) { 477 if ( fontsize[i] > sz ) {
467 s = fontsize[i]; 478 s = fontsize[i];
468 break; 479 break;
469 } 480 }
470 } 481 }
471 } 482 }
472 483
473 QFont f = editor->font(); 484 QFont f = editor->font();
474 f.setPointSize(s); 485 f.setPointSize(s);
475 editor->setFont(f); 486 editor->setFont(f);
476 487
477 zin->setEnabled(s != fontsize[nfontsizes-1]); 488 zin->setEnabled(s != fontsize[nfontsizes-1]);
478 zout->setEnabled(s != fontsize[0]); 489 zout->setEnabled(s != fontsize[0]);
479} 490}
480 491
481void TextEdit::setBold(bool y) 492void TextEdit::setBold(bool y)
482{ 493{
483 QFont f = editor->font(); 494 QFont f = editor->font();
484 f.setBold(y); 495 f.setBold(y);
485 editor->setFont(f); 496 editor->setFont(f);
486} 497}
487 498
488void TextEdit::setItalic(bool y) 499void TextEdit::setItalic(bool y)
489{ 500{
490 QFont f = editor->font(); 501 QFont f = editor->font();
491 f.setItalic(y); 502 f.setItalic(y);
492 editor->setFont(f); 503 editor->setFont(f);
493} 504}
494 505
495void TextEdit::setWordWrap(bool y) 506void TextEdit::setWordWrap(bool y)
496{ 507{
497 bool state = editor->edited(); 508 bool state = editor->edited();
498 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 509 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
499 editor->setEdited( state ); 510 editor->setEdited( state );
500} 511}
501 512
502void TextEdit::fileNew() 513void TextEdit::fileNew()
503{ 514{
504// if( !bFromDocView ) { 515// if( !bFromDocView ) {
505// saveAs(); 516// saveAs();
506// } 517// }
507 newFile(DocLnk()); 518 newFile(DocLnk());
508} 519}
509 520
510void TextEdit::fileOpen() 521void TextEdit::fileOpen()
511{ 522{
512 Config cfg("TextEdit"); 523 Config cfg("TextEdit");
513 cfg.setGroup("View"); 524 cfg.setGroup("View");
514 bool b=FALSE; 525 // bool b=FALSE;
515 526
516 QMap<QString, QStringList> map; 527 QMap<QString, QStringList> map;
517 map.insert(tr("All"), QStringList() ); 528 map.insert(tr("All"), QStringList() );
518 QStringList text; 529 QStringList text;
519 text << "text/*"; 530 text << "text/*";
520 map.insert(tr("Text"), text ); 531 map.insert(tr("Text"), text );
521 text << "*"; 532 text << "*";
522 map.insert(tr("All"), text ); 533 map.insert(tr("All"), text );
523 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map); 534 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map);
524 if(!str.isEmpty() ) 535 if(!str.isEmpty() )
525 openFile( str ); 536 openFile( str );
526 537
527} 538}
528 539
529void TextEdit::doSearchBar() 540void TextEdit::doSearchBar()
530{ 541{
531 Config cfg("TextEdit"); 542 Config cfg("TextEdit");
532 cfg.setGroup("View"); 543 cfg.setGroup("View");
533 if(cfg.readEntry("SearchBar","Closed") != "Opened") 544 if(cfg.readEntry("SearchBar","Closed") != "Opened")
534 searchBar->hide(); 545 searchBar->hide();
535} 546}
536 547
537#if 0 548#if 0
538void TextEdit::slotFind() 549void TextEdit::slotFind()
539{ 550{
540 FindDialog frmFind( tr("Text Editor"), this ); 551 FindDialog frmFind( tr("Text Editor"), this );
541 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 552 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
542 editor, SLOT(slotDoFind( const QString&,bool,bool))); 553 editor, SLOT(slotDoFind( const QString&,bool,bool)));
543 554
544 //case sensitive, backwards, [category] 555 //case sensitive, backwards, [category]
545 556
546 connect( editor, SIGNAL(notFound()), 557 connect( editor, SIGNAL(notFound()),
547 &frmFind, SLOT(slotNotFound()) ); 558 &frmFind, SLOT(slotNotFound()) );
548 connect( editor, SIGNAL(searchWrapped()), 559 connect( editor, SIGNAL(searchWrapped()),
549 &frmFind, SLOT(slotWrapAround()) ); 560 &frmFind, SLOT(slotWrapAround()) );
550 561
551 frmFind.exec(); 562 frmFind.exec();
552 563
553 564
554} 565}
555#endif 566#endif
556 567
557void TextEdit::fileRevert() 568void TextEdit::fileRevert()
558{ 569{
559 clear(); 570 clear();
560 fileOpen(); 571 fileOpen();
561} 572}
562 573
563void TextEdit::editCut() 574void TextEdit::editCut()
564{ 575{
565#ifndef QT_NO_CLIPBOARD 576#ifndef QT_NO_CLIPBOARD
566 editor->cut(); 577 editor->cut();
567#endif 578#endif
568} 579}
569 580
570void TextEdit::editCopy() 581void TextEdit::editCopy()
571{ 582{
572#ifndef QT_NO_CLIPBOARD 583#ifndef QT_NO_CLIPBOARD
573 editor->copy(); 584 editor->copy();
574#endif 585#endif
575} 586}
576 587
577void TextEdit::editPaste() 588void TextEdit::editPaste()
578{ 589{
579#ifndef QT_NO_CLIPBOARD 590#ifndef QT_NO_CLIPBOARD
580 editor->paste(); 591 editor->paste();
581#endif 592#endif
582} 593}
583 594
584void TextEdit::editFind() 595void TextEdit::editFind()
585{ 596{
586 searchBar->show(); 597 searchBar->show();
587 searchVisible = TRUE; 598 searchVisible = TRUE;
588 searchEdit->setFocus(); 599 searchEdit->setFocus();
589 Config cfg("TextEdit"); 600 Config cfg("TextEdit");
590 cfg.setGroup("View"); 601 cfg.setGroup("View");
591 cfg.writeEntry("SearchBar","Opened"); 602 cfg.writeEntry("SearchBar","Opened");
592 603
593} 604}
594 605
595void TextEdit::findNext() 606void TextEdit::findNext()
596{ 607{
597 editor->find( searchEdit->text(), FALSE, FALSE ); 608 editor->find( searchEdit->text(), FALSE, FALSE );
598 609
599} 610}
600 611
601void TextEdit::findClose() 612void TextEdit::findClose()
602{ 613{
603 searchVisible = FALSE; 614 searchVisible = FALSE;
604 searchBar->hide(); 615 searchBar->hide();
605 Config cfg("TextEdit"); 616 Config cfg("TextEdit");
606 cfg.setGroup("View"); 617 cfg.setGroup("View");
607 cfg.writeEntry("SearchBar","Closed"); 618 cfg.writeEntry("SearchBar","Closed");
608 cfg.write(); 619 cfg.write();
609} 620}
610 621
611void TextEdit::search() 622void TextEdit::search()
612{ 623{
613 editor->find( searchEdit->text(), FALSE, FALSE ); 624 editor->find( searchEdit->text(), FALSE, FALSE );
614} 625}
615 626
616void TextEdit::newFile( const DocLnk &f ) 627void TextEdit::newFile( const DocLnk &f )
617{ 628{
618 DocLnk nf = f; 629 DocLnk nf = f;
619 nf.setType("text/plain"); 630 nf.setType("text/plain");
620 clear(); 631 clear();
621 setWState (WState_Reserved1 ); 632 setWState (WState_Reserved1 );
622 editor->setFocus(); 633 editor->setFocus();
623 doc = new DocLnk(nf); 634 doc = new DocLnk(nf);
624 currentFileName = "Unnamed"; 635 currentFileName = "Unnamed";
625 qDebug("newFile "+currentFileName); 636 qDebug("newFile "+currentFileName);
626 updateCaption( currentFileName); 637 updateCaption( currentFileName);
627// editor->setEdited( FALSE); 638// editor->setEdited( FALSE);
628} 639}
629 640
630void TextEdit::openFile( const QString &f ) 641void TextEdit::openFile( const QString &f )
631{ 642{
632 qDebug("filename is "+ f); 643 qDebug("filename is "+ f);
633 QString filer; 644 QString filer;
634// bFromDocView = TRUE; 645// bFromDocView = TRUE;
635 if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) { 646 if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) {
636 switch ( QMessageBox::warning(this,tr("Text Editor"), 647 switch ( QMessageBox::warning(this,tr("Text Editor"),
637 tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), 648 tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"),
638 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 649 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
639 case 0: 650 case 0:
640 filer = f; 651 filer = f;
641 break; 652 break;
642 case 1: 653 case 1:
643 DocLnk sf(f); 654 DocLnk sf(f);
644 filer = sf.file(); 655 filer = sf.file();
645 break; 656 break;
646 } 657 }
647 } else { 658 } else {
648 filer = f; 659 filer = f;
649 fileIs = TRUE; 660 fileIs = TRUE;
650 } 661 }
651 662
652 DocLnk nf; 663 DocLnk nf;
653 nf.setType("text/plain"); 664 nf.setType("text/plain");
654 nf.setFile(filer); 665 nf.setFile(filer);
655 currentFileName=filer; 666 currentFileName=filer;
656 QFileInfo fi( currentFileName); 667 QFileInfo fi( currentFileName);
657 nf.setName(fi.baseName()); 668 nf.setName(fi.baseName());
658 qDebug("openFile string "+currentFileName); 669 qDebug("openFile string "+currentFileName);
659 670
660 openFile(nf); 671 openFile(nf);
661 showEditTools(); 672 showEditTools();
662 // Show filename in caption 673 // Show filename in caption
663 QString name = filer; 674 QString name = filer;
664 int sep = name.findRev( '/' ); 675 int sep = name.findRev( '/' );
665 if ( sep > 0 ) 676 if ( sep > 0 )
666 name = name.mid( sep+1 ); 677 name = name.mid( sep+1 );
667 updateCaption( name ); 678 updateCaption( name );
668} 679}
669 680
670void TextEdit::openFile( const DocLnk &f ) 681void TextEdit::openFile( const DocLnk &f )
671{ 682{
672// clear(); 683// clear();
673// bFromDocView = TRUE; 684// bFromDocView = TRUE;
674 FileManager fm; 685 FileManager fm;
675 QString txt; 686 QString txt;
676 currentFileName=f.file(); 687 currentFileName=f.file();
677 qDebug("openFile doclnk " + currentFileName); 688 qDebug("openFile doclnk " + currentFileName);
678 if ( !fm.loadFile( f, txt ) ) { 689 if ( !fm.loadFile( f, txt ) ) {
679 // ####### could be a new file 690 // ####### could be a new file
680 qDebug( "Cannot open file" ); 691 qDebug( "Cannot open file" );
681 } 692 }
682// fileNew(); 693// fileNew();
683 if ( doc ) 694 if ( doc )
684 delete doc; 695 delete doc;
685 doc = new DocLnk(f); 696 doc = new DocLnk(f);
686 editor->setText(txt); 697 editor->setText(txt);
687 editor->setEdited( FALSE); 698 editor->setEdited( FALSE);
688 edited1=FALSE; 699 edited1=FALSE;
689 edited=FALSE; 700 edited=FALSE;
690 701
691 doc->setName(currentFileName); 702 doc->setName(currentFileName);
692 updateCaption(); 703 updateCaption();
693} 704}
694 705
695void TextEdit::showEditTools() 706void TextEdit::showEditTools()
696{ 707{
697// if ( !doc ) 708// if ( !doc )
698// close(); 709// close();
699// clear(); 710// clear();
700 menu->show(); 711 menu->show();
701 editBar->show(); 712 editBar->show();
702 if ( searchVisible ) 713 if ( searchVisible )
703 searchBar->show(); 714 searchBar->show();
704// updateCaption(); 715// updateCaption();
705 setWState (WState_Reserved1 ); 716 setWState (WState_Reserved1 );
706} 717}
@@ -793,192 +804,201 @@ bool TextEdit::saveAs()
793 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 804 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
794 if ( docname.length() > 40 ) 805 if ( docname.length() > 40 )
795 docname = docname.left(40); 806 docname = docname.left(40);
796 if ( docname.isEmpty() ) 807 if ( docname.isEmpty() )
797 docname = tr("Unnamed"); 808 docname = tr("Unnamed");
798 doc->setName(docname); 809 doc->setName(docname);
799 currentFileName=docname; 810 currentFileName=docname;
800 } 811 }
801 } 812 }
802 813
803 QMap<QString, QStringList> map; 814 QMap<QString, QStringList> map;
804 map.insert(tr("All"), QStringList() ); 815 map.insert(tr("All"), QStringList() );
805 QStringList text; 816 QStringList text;
806 text << "text/*"; 817 text << "text/*";
807 map.insert(tr("Text"), text ); 818 map.insert(tr("Text"), text );
808 text << "*"; 819 text << "*";
809 map.insert(tr("All"), text ); 820 map.insert(tr("All"), text );
810 QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map); 821 QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map);
811 if(!str.isEmpty() ) { 822 if(!str.isEmpty() ) {
812 QString fileNm=str; 823 QString fileNm=str;
813 824
814 qDebug("saving filename "+fileNm); 825 qDebug("saving filename "+fileNm);
815 QFileInfo fi(fileNm); 826 QFileInfo fi(fileNm);
816 currentFileName=fi.fileName(); 827 currentFileName=fi.fileName();
817 if(doc) { 828 if(doc) {
818// QString file = doc->file(); 829// QString file = doc->file();
819// doc->removeFiles(); 830// doc->removeFiles();
820 delete doc; 831 delete doc;
821 DocLnk nf; 832 DocLnk nf;
822 nf.setType("text/plain"); 833 nf.setType("text/plain");
823 nf.setFile( fileNm); 834 nf.setFile( fileNm);
824 doc = new DocLnk(nf); 835 doc = new DocLnk(nf);
825// editor->setText(rt); 836// editor->setText(rt);
826// qDebug("openFile doclnk "+currentFileName); 837// qDebug("openFile doclnk "+currentFileName);
827 doc->setName( currentFileName); 838 doc->setName( currentFileName);
828 updateCaption( currentFileName); 839 updateCaption( currentFileName);
829 840
830 FileManager fm; 841 FileManager fm;
831 if ( !fm.saveFile( *doc, rt ) ) { 842 if ( !fm.saveFile( *doc, rt ) ) {
832 return false; 843 return false;
833 } 844 }
834 845
835 if( useAdvancedFeatures ) { 846 if( useAdvancedFeatures ) {
836 filePermissions *filePerm; 847 filePermissions *filePerm;
837 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); 848 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm);
838 filePerm->exec(); 849 filePerm->exec();
839 850
840 if( filePerm) 851 if( filePerm)
841 delete filePerm; 852 delete filePerm;
842 } 853 }
843 } 854 }
844 } 855 }
845 editor->setEdited(TRUE); 856 editor->setEdited(TRUE);
846 edited1=FALSE; 857 edited1=FALSE;
847 edited=TRUE; 858 edited=TRUE;
848 if(caption().left(1)=="*") 859 if(caption().left(1)=="*")
849 setCaption(caption().right(caption().length()-1)); 860 setCaption(caption().right(caption().length()-1));
850 861
851 return true; 862 return true;
852} //end saveAs 863} //end saveAs
853 864
854void TextEdit::clear() 865void TextEdit::clear()
855{ 866{
856 delete doc; 867 delete doc;
857 doc = 0; 868 doc = 0;
858 editor->clear(); 869 editor->clear();
859} 870}
860 871
861void TextEdit::updateCaption( const QString &name ) 872void TextEdit::updateCaption( const QString &name )
862{ 873{
863 if ( !doc ) 874 if ( !doc )
864 setCaption( tr("Text Editor") ); 875 setCaption( tr("Text Editor") );
865 else { 876 else {
866 QString s = name; 877 QString s = name;
867 if ( s.isNull() ) 878 if ( s.isNull() )
868 s = doc->name(); 879 s = doc->name();
869 if ( s.isEmpty() ) { 880 if ( s.isEmpty() ) {
870 s = tr( "Unnamed" ); 881 s = tr( "Unnamed" );
871 currentFileName=s; 882 currentFileName=s;
872 } 883 }
873 if(s.left(1) == "/") 884 if(s.left(1) == "/")
874 s = s.right(s.length()-1); 885 s = s.right(s.length()-1);
875 setCaption( s + " - " + tr("Text Editor") ); 886 setCaption( s + " - " + tr("Text Editor") );
876 } 887 }
877} 888}
878 889
879void TextEdit::setDocument(const QString& fileref) 890void TextEdit::setDocument(const QString& fileref)
880{ 891{
881 bFromDocView = TRUE; 892 bFromDocView = TRUE;
882 openFile(fileref); 893 openFile(fileref);
883 editor->setEdited(TRUE); 894 editor->setEdited(TRUE);
884 edited1=FALSE; 895 edited1=FALSE;
885 edited=TRUE; 896 edited=TRUE;
886 doSearchBar(); 897 doSearchBar();
887} 898}
888 899
889void TextEdit::closeEvent( QCloseEvent *e ) 900void TextEdit::closeEvent( QCloseEvent *e )
890{ 901{
891 bFromDocView = FALSE; 902 bFromDocView = FALSE;
892 e->accept(); 903 e->accept();
893} 904}
894 905
895void TextEdit::accept() 906void TextEdit::accept()
896 { 907 {
897 //if(caption() !="Unnamed") 908 //if(caption() !="Unnamed")
898 if(edited1) 909 if(edited1)
899 saveAs(); 910 saveAs();
900 exit(0); 911 exit(0);
901 912
902} 913}
903 914
904void TextEdit::changeFont() { 915void TextEdit::changeFont() {
905 FontDatabase fdb; 916 FontDatabase fdb;
906 QFont defaultFont=editor->font(); 917 QFont defaultFont=editor->font();
907 QFontInfo fontInfo(defaultFont); 918 QFontInfo fontInfo(defaultFont);
908 Config cfg("TextEdit"); 919 Config cfg("TextEdit");
909 cfg.setGroup("Font"); 920 cfg.setGroup("Font");
910 QString family = cfg.readEntry("Family", fontInfo.family()); 921 QString family = cfg.readEntry("Family", fontInfo.family());
911 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 922 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
912 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 923 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
913 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 924 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
914 925
915 defaultFont = fdb.font(family,style,i_size,charSet); 926 defaultFont = fdb.font(family,style,i_size,charSet);
916 927
917 FontDialog *fontDlg; 928 FontDialog *fontDlg;
918 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); 929 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE);
919 930
920 fontDlg->exec(); 931 fontDlg->exec();
921 932
922 QFont myFont=fontDlg->selectedFont; 933 QFont myFont=fontDlg->selectedFont;
923 editor->setFont( myFont); 934 editor->setFont( myFont);
924 delete fontDlg; 935 delete fontDlg;
925 936
926} 937}
927 938
928void TextEdit::editDelete() 939void TextEdit::editDelete()
929{ 940{
930 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) { 941 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) {
931 case 0: 942 case 0:
932 if(doc) { 943 if(doc) {
933 doc->removeFiles(); 944 doc->removeFiles();
934 clear(); 945 clear();
935 setCaption( tr("Text Editor") ); 946 setCaption( tr("Text Editor") );
936 } 947 }
937 break; 948 break;
938 case 1: 949 case 1:
939 // exit 950 // exit
940 break; 951 break;
941 }; 952 };
942} 953}
943 954
944void TextEdit::changeStartConfig( bool b ) { 955void TextEdit::changeStartConfig( bool b ) {
945 956
946 Config cfg("TextEdit"); 957 Config cfg("TextEdit");
947 cfg.setGroup("View"); 958 cfg.setGroup("View");
948 if(b) { 959 if(b) {
949 qDebug("bool"); 960 qDebug("bool");
950 cfg.writeEntry("startNew","TRUE"); 961 cfg.writeEntry("startNew","TRUE");
951 } else { 962 } else {
952 cfg.writeEntry("startNew","FALSE"); 963 cfg.writeEntry("startNew","FALSE");
953 } 964 }
954 update(); 965 update();
955} 966}
956 967
957void TextEdit::editorChanged() { 968void TextEdit::editorChanged() {
958 if(editor->edited() && edited && !edited1) { 969 if(editor->edited() && edited && !edited1) {
959 setCaption( "*"+caption()); 970 setCaption( "*"+caption());
960 edited1=TRUE; 971 edited1=TRUE;
961 } 972 }
962 edited=TRUE; 973 edited=TRUE;
963} 974}
964 975
965void TextEdit::receive(const QCString&msg, const QByteArray&) { 976void TextEdit::receive(const QCString&msg, const QByteArray&) {
966 qDebug("QCop "+msg); 977 qDebug("QCop "+msg);
967 if ( msg == "setDocument(QString)" ) { 978 if ( msg == "setDocument(QString)" ) {
968 qDebug("bugger all"); 979 qDebug("bugger all");
969 } 980 }
970 981
971} 982}
972void TextEdit::doAbout() { 983void TextEdit::doAbout() {
973 QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" 984 QMessageBox::about(0,"Text Edit","Text Edit is copyright\n"
974 "2000 Trolltech AS, and\n" 985 "2000 Trolltech AS, and\n"
975 "2002 by L.J.Potter \nljp@llornkcor.com\n" 986 "2002 by L.J.Potter \nljp@llornkcor.com\n"
976 "and is licensed under the GPL"); 987 "and is licensed under the GPL");
977} 988}
978 989
979void TextEdit::doAdvanced(bool b) { 990void TextEdit::doAdvanced(bool b) {
980 useAdvancedFeatures=b; 991 useAdvancedFeatures=b;
981 Config cfg("TextEdit"); 992 Config cfg("TextEdit");
982 cfg.setGroup("View"); 993 cfg.setGroup("View");
983 cfg.writeEntry("AdvancedFeatures",b); 994 cfg.writeEntry("AdvancedFeatures",b);
984} 995}
996
997void TextEdit::editPasteTimeDate() {
998#ifndef QT_NO_CLIPBOARD
999 QClipboard *cb = QApplication::clipboard();
1000 QDateTime dt = QDateTime::currentDateTime();
1001 cb->setText( dt.toString());
1002 editor->paste();
1003#endif
1004}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index aec6427..a2badaa 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -1,127 +1,128 @@
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
40class QAction; 40class QAction;
41class QWidgetStack; 41class QWidgetStack;
42class QToolButton; 42class QToolButton;
43class QPopupMenu; 43class QPopupMenu;
44class QToolBar; 44class QToolBar;
45class QLineEdit; 45class QLineEdit;
46class QAction; 46class QAction;
47class FileSelector; 47class FileSelector;
48class QpeEditor; 48class QpeEditor;
49class QPopupMenu; 49class QPopupMenu;
50 50
51class TextEdit : public QMainWindow 51class TextEdit : public QMainWindow
52{ 52{
53 Q_OBJECT 53 Q_OBJECT
54 54
55public: 55public:
56 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 56 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
57 ~TextEdit(); 57 ~TextEdit();
58 58
59 QPopupMenu *font; 59 QPopupMenu *font;
60 QAction *nStart, *nFileDlgOpt, *nAdvanced; 60 QAction *nStart, *nFileDlgOpt, *nAdvanced;
61 bool edited, edited1; 61 bool edited, edited1;
62 void openFile( const QString & ); 62 void openFile( const QString & );
63 QCopChannel * channel; 63 QCopChannel * channel;
64public slots: 64public slots:
65 void editorChanged(); 65 void editorChanged();
66void receive(const QCString&, const QByteArray&); 66void receive(const QCString&, const QByteArray&);
67protected: 67protected:
68 bool fileIs, useAdvancedFeatures; 68 bool fileIs, useAdvancedFeatures;
69 void closeEvent( QCloseEvent *e ); 69 void closeEvent( QCloseEvent *e );
70 void doSearchBar(); 70 void doSearchBar();
71private slots: 71private slots:
72 void editPasteTimeDate();
72 void doAdvanced(bool); 73 void doAdvanced(bool);
73 void doAbout(); 74 void doAbout();
74 void setDocument(const QString&); 75 void setDocument(const QString&);
75 void changeFont(); 76 void changeFont();
76 void fileNew(); 77 void fileNew();
77 void fileRevert(); 78 void fileRevert();
78 void fileOpen(); 79 void fileOpen();
79 void changeStartConfig(bool); 80 void changeStartConfig(bool);
80 bool save(); 81 bool save();
81 bool saveAs(); 82 bool saveAs();
82 void cleanUp(); 83 void cleanUp();
83 84
84 85
85 void editCut(); 86 void editCut();
86 void editCopy(); 87 void editCopy();
87 void editPaste(); 88 void editPaste();
88 void editFind(); 89 void editFind();
89 void editDelete(); 90 void editDelete();
90 91
91 void findNext(); 92 void findNext();
92 void findClose(); 93 void findClose();
93 94
94 void search(); 95 void search();
95 void accept(); 96 void accept();
96 97
97 void newFile( const DocLnk & ); 98 void newFile( const DocLnk & );
98 void openFile( const DocLnk & ); 99 void openFile( const DocLnk & );
99 void showEditTools(); 100 void showEditTools();
100 101
101 void zoomIn(); 102 void zoomIn();
102 void zoomOut(); 103 void zoomOut();
103 void setBold(bool y); 104 void setBold(bool y);
104 void setItalic(bool y); 105 void setItalic(bool y);
105 void setWordWrap(bool y); 106 void setWordWrap(bool y);
106 107
107private: 108private:
108 void colorChanged( const QColor &c ); 109 void colorChanged( const QColor &c );
109 void clear(); 110 void clear();
110 void updateCaption( const QString &name=QString::null ); 111 void updateCaption( const QString &name=QString::null );
111 void setFontSize(int sz, bool round_down_not_up); 112 void setFontSize(int sz, bool round_down_not_up);
112 113
113private: 114private:
114// fileSaver *fileSaveDlg; 115// fileSaver *fileSaveDlg;
115// fileBrowser *browseForFiles; 116// fileBrowser *browseForFiles;
116 QpeEditor* editor; 117 QpeEditor* editor;
117 QToolBar *menu, *editBar, *searchBar; 118 QToolBar *menu, *editBar, *searchBar;
118 QLineEdit *searchEdit; 119 QLineEdit *searchEdit;
119 DocLnk *doc; 120 DocLnk *doc;
120 bool searchVisible; 121 bool searchVisible;
121 bool bFromDocView; 122 bool bFromDocView;
122 int viewSelection; 123 int viewSelection;
123 QAction *zin, *zout; 124 QAction *zin, *zout;
124 QString currentFileName; 125 QString currentFileName;
125}; 126};
126 127
127#endif 128#endif