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