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