summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-02-18 15:02:33 (UTC)
committer llornkcor <llornkcor>2002-02-18 15:02:33 (UTC)
commita6266fb220a61c4904e24ebf31eeefab34362e59 (patch) (unidiff)
treeab1da9da25c4b5118935bc981fca62a8c72b6810
parent00f89d28e669140eb50f1f220c389f88fba1105c (diff)
downloadopie-a6266fb220a61c4904e24ebf31eeefab34362e59.zip
opie-a6266fb220a61c4904e24ebf31eeefab34362e59.tar.gz
opie-a6266fb220a61c4904e24ebf31eeefab34362e59.tar.bz2
added Save As (prompt user) and moved save (no prompt) functions there
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp23
-rw-r--r--core/apps/textedit/textedit.h2
2 files changed, 23 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 429c195..834971a 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -86,724 +86,743 @@ static char * filesave_xpm[] = {
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// 271//
272 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 272 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
273 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 273 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
274// a->addTo( bar ); 274// a->addTo( bar );
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 );
279 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
280 a->addTo( file );
281
278 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 282 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
279 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 283 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
280 a->addTo( editBar ); 284 a->addTo( editBar );
281 a->addTo( edit ); 285 a->addTo( edit );
282 286
283 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 287 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
284 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 288 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
285 a->addTo( editBar ); 289 a->addTo( editBar );
286 a->addTo( edit ); 290 a->addTo( edit );
287 291
288 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 292 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
289 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 293 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
290 a->addTo( editBar ); 294 a->addTo( editBar );
291 a->addTo( edit ); 295 a->addTo( edit );
292 296
293 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 297 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
294 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 298 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
295 edit->insertSeparator(); 299 edit->insertSeparator();
296 a->addTo( bar ); 300 a->addTo( bar );
297 a->addTo( edit ); 301 a->addTo( edit );
298 302
299 int defsize; 303 int defsize;
300 bool defb, defi, wrap; 304 bool defb, defi, wrap;
301 305
302 Config cfg("TextEdit"); 306 Config cfg("TextEdit");
303 cfg.setGroup("View"); 307 cfg.setGroup("View");
304 defsize = cfg.readNumEntry("FontSize",10); 308 defsize = cfg.readNumEntry("FontSize",10);
305 defb = cfg.readBoolEntry("Bold",FALSE); 309 defb = cfg.readBoolEntry("Bold",FALSE);
306 defi = cfg.readBoolEntry("Italic",FALSE); 310 defi = cfg.readBoolEntry("Italic",FALSE);
307 wrap = cfg.readBoolEntry("Wrap",TRUE); 311 wrap = cfg.readBoolEntry("Wrap",TRUE);
308 312
309 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 313 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
310 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 314 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
311 zin->addTo( font ); 315 zin->addTo( font );
312 316
313 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 317 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
314 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 318 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
315 zout->addTo( font ); 319 zout->addTo( font );
316 320
317 font->insertSeparator(); 321 font->insertSeparator();
318 322
319#if 0 323#if 0
320 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); 324 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 );
321 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); 325 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) );
322 ba->setToggleAction(TRUE); 326 ba->setToggleAction(TRUE);
323 ba->addTo( font ); 327 ba->addTo( font );
324 328
325 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); 329 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 );
326 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); 330 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) );
327 ia->setToggleAction(TRUE); 331 ia->setToggleAction(TRUE);
328 ia->addTo( font ); 332 ia->addTo( font );
329 333
330 ba->setOn(defb); 334 ba->setOn(defb);
331 ia->setOn(defi); 335 ia->setOn(defi);
332 336
333 font->insertSeparator(); 337 font->insertSeparator();
334#endif 338#endif
335 339
336 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 );
337 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 341 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
338 wa->setToggleAction(TRUE); 342 wa->setToggleAction(TRUE);
339 wa->addTo( font ); 343 wa->addTo( font );
340 344
341 font->insertSeparator(); 345 font->insertSeparator();
342 font->insertItem("Font", this, SLOT(changeFont()) ); 346 font->insertItem("Font", this, SLOT(changeFont()) );
343 347
344 mb->insertItem( tr( "File" ), file ); 348 mb->insertItem( tr( "File" ), file );
345 mb->insertItem( tr( "Edit" ), edit ); 349 mb->insertItem( tr( "Edit" ), edit );
346 mb->insertItem( tr( "View" ), font ); 350 mb->insertItem( tr( "View" ), font );
347 351
348 searchBar = new QPEToolBar(this); 352 searchBar = new QPEToolBar(this);
349 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 353 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
350 354
351 searchBar->setHorizontalStretchable( TRUE ); 355 searchBar->setHorizontalStretchable( TRUE );
352 356
353 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 357 searchEdit = new QLineEdit( searchBar, "searchEdit" );
354 searchBar->setStretchableWidget( searchEdit ); 358 searchBar->setStretchableWidget( searchEdit );
355 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 359 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
356 this, SLOT( search() ) ); 360 this, SLOT( search() ) );
357 361
358 362
359 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 );
360 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 364 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
361 a->addTo( searchBar ); 365 a->addTo( searchBar );
362 a->addTo( edit ); 366 a->addTo( edit );
363 367
364 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 );
365 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 369 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
366 a->addTo( searchBar ); 370 a->addTo( searchBar );
367 371
368 searchBar->hide(); 372 searchBar->hide();
369 373
370 editorStack = new QWidgetStack( this ); 374 editorStack = new QWidgetStack( this );
371 setCentralWidget( editorStack ); 375 setCentralWidget( editorStack );
372 376
373 searchVisible = FALSE; 377 searchVisible = FALSE;
374 378
375 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy 379 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy
376 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 380 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
377 connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 381 connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
378 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); 382 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) );
379// fileOpen(); 383// fileOpen();
380 384
381 editor = new QpeEditor( editorStack ); 385 editor = new QpeEditor( editorStack );
382 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 386 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
383 editorStack->addWidget( editor, get_unique_id() ); 387 editorStack->addWidget( editor, get_unique_id() );
384 388
385 resize( 200, 300 ); 389 resize( 200, 300 );
386 390
387// setFontSize(defsize,TRUE); 391// setFontSize(defsize,TRUE);
388 FontDatabase fdb; 392 FontDatabase fdb;
389 QFont defaultFont=editor->font(); 393 QFont defaultFont=editor->font();
390 QFontInfo fontInfo(defaultFont); 394 QFontInfo fontInfo(defaultFont);
391 395
392 cfg.setGroup("Font"); 396 cfg.setGroup("Font");
393 QString family = cfg.readEntry("Family", fontInfo.family()); 397 QString family = cfg.readEntry("Family", fontInfo.family());
394 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 398 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
395 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 399 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
396 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 400 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
397 401
398 defaultFont = fdb.font(family,style,i_size,charSet); 402 defaultFont = fdb.font(family,style,i_size,charSet);
399 editor->setFont( defaultFont); 403 editor->setFont( defaultFont);
400 404
401 wa->setOn(wrap); 405 wa->setOn(wrap);
402 updateCaption(); 406 updateCaption();
403 if( qApp->argc() > 1 ) { 407 if( qApp->argc() > 1 ) {
404 for (int i=1;i< qApp->argc();i++) { 408 for (int i=1;i< qApp->argc();i++) {
405 QString tmp; 409 QString tmp;
406 currentFileName = tmp.sprintf("%s",qApp->argv()[i]); 410 currentFileName = tmp.sprintf("%s",qApp->argv()[i]);
407 qDebug(currentFileName); 411 qDebug(currentFileName);
408 setDocument( currentFileName ); 412 setDocument( currentFileName );
409 } 413 }
410 } 414 }
411 else 415 else
412 fileNew(); 416 fileNew();
413} 417}
414 418
415TextEdit::~TextEdit() 419TextEdit::~TextEdit()
416{ 420{
417 save(); 421 saveAs();
418 422
419 Config cfg("TextEdit"); 423 Config cfg("TextEdit");
420 cfg.setGroup("View"); 424 cfg.setGroup("View");
421 QFont f = editor->font(); 425 QFont f = editor->font();
422 cfg.writeEntry("FontSize",f.pointSize()); 426 cfg.writeEntry("FontSize",f.pointSize());
423 cfg.writeEntry("Bold",f.bold()); 427 cfg.writeEntry("Bold",f.bold());
424 cfg.writeEntry("Italic",f.italic()); 428 cfg.writeEntry("Italic",f.italic());
425 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 429 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
426} 430}
427 431
428void TextEdit::zoomIn() 432void TextEdit::zoomIn()
429{ 433{
430 setFontSize(editor->font().pointSize()+1,FALSE); 434 setFontSize(editor->font().pointSize()+1,FALSE);
431} 435}
432 436
433void TextEdit::zoomOut() 437void TextEdit::zoomOut()
434{ 438{
435 setFontSize(editor->font().pointSize()-1,TRUE); 439 setFontSize(editor->font().pointSize()-1,TRUE);
436} 440}
437 441
438 442
439void TextEdit::setFontSize(int sz, bool round_down_not_up) 443void TextEdit::setFontSize(int sz, bool round_down_not_up)
440{ 444{
441 int s=10; 445 int s=10;
442 for (int i=0; i<nfontsizes; i++) { 446 for (int i=0; i<nfontsizes; i++) {
443 if ( fontsize[i] == sz ) { 447 if ( fontsize[i] == sz ) {
444 s = sz; 448 s = sz;
445 break; 449 break;
446 } else if ( round_down_not_up ) { 450 } else if ( round_down_not_up ) {
447 if ( fontsize[i] < sz ) 451 if ( fontsize[i] < sz )
448 s = fontsize[i]; 452 s = fontsize[i];
449 } else { 453 } else {
450 if ( fontsize[i] > sz ) { 454 if ( fontsize[i] > sz ) {
451 s = fontsize[i]; 455 s = fontsize[i];
452 break; 456 break;
453 } 457 }
454 } 458 }
455 } 459 }
456 460
457 QFont f = editor->font(); 461 QFont f = editor->font();
458 f.setPointSize(s); 462 f.setPointSize(s);
459 editor->setFont(f); 463 editor->setFont(f);
460 464
461 zin->setEnabled(s != fontsize[nfontsizes-1]); 465 zin->setEnabled(s != fontsize[nfontsizes-1]);
462 zout->setEnabled(s != fontsize[0]); 466 zout->setEnabled(s != fontsize[0]);
463} 467}
464 468
465void TextEdit::setBold(bool y) 469void TextEdit::setBold(bool y)
466{ 470{
467 QFont f = editor->font(); 471 QFont f = editor->font();
468 f.setBold(y); 472 f.setBold(y);
469 editor->setFont(f); 473 editor->setFont(f);
470} 474}
471 475
472void TextEdit::setItalic(bool y) 476void TextEdit::setItalic(bool y)
473{ 477{
474 QFont f = editor->font(); 478 QFont f = editor->font();
475 f.setItalic(y); 479 f.setItalic(y);
476 editor->setFont(f); 480 editor->setFont(f);
477} 481}
478 482
479void TextEdit::setWordWrap(bool y) 483void TextEdit::setWordWrap(bool y)
480{ 484{
481 bool state = editor->edited(); 485 bool state = editor->edited();
482 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 486 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
483 editor->setEdited( state ); 487 editor->setEdited( state );
484} 488}
485 489
486void TextEdit::fileNew() 490void TextEdit::fileNew()
487{ 491{
488 if( !bFromDocView ) { 492 if( !bFromDocView ) {
489 save(); 493 saveAs();
490 } 494 }
491 newFile(DocLnk()); 495 newFile(DocLnk());
492} 496}
493 497
494void TextEdit::fileOpen() 498void TextEdit::fileOpen()
495{ 499{
496// if ( !save() ) { 500// if ( !save() ) {
497// if ( QMessageBox::critical( this, tr( "Out of space" ), 501// if ( QMessageBox::critical( this, tr( "Out of space" ),
498// tr( "Text Editor was unable to\n" 502// tr( "Text Editor was unable to\n"
499// "save your changes.\n" 503// "save your changes.\n"
500// "Free some space and try again.\n" 504// "Free some space and try again.\n"
501// "\nContinue anyway?" ), 505// "\nContinue anyway?" ),
502// QMessageBox::Yes|QMessageBox::Escape, 506// QMessageBox::Yes|QMessageBox::Escape,
503// QMessageBox::No|QMessageBox::Default ) 507// QMessageBox::No|QMessageBox::Default )
504// != QMessageBox::Yes ) 508// != QMessageBox::Yes )
505// return; 509// return;
506// else { 510// else {
507// delete doc; 511// delete doc;
508// doc = 0; 512// doc = 0;
509// } 513// }
510// } 514// }
511 menu->hide(); 515 menu->hide();
512 editBar->hide(); 516 editBar->hide();
513 searchBar->hide(); 517 searchBar->hide();
514 clearWState (WState_Reserved1 ); 518 clearWState (WState_Reserved1 );
515 editorStack->raiseWidget( fileSelector ); 519 editorStack->raiseWidget( fileSelector );
516 fileSelector->reread(); 520 fileSelector->reread();
517 updateCaption(currentFileName); 521 updateCaption(currentFileName);
518} 522}
519 523
520void TextEdit::newFileOpen() 524void TextEdit::newFileOpen()
521{ 525{
522 fileBrowser *browseForFiles; 526 fileBrowser *browseForFiles;
523 browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); 527 browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*");
524 if( browseForFiles->exec()!= 0 ) { 528 if( browseForFiles->exec()!= 0 ) {
525 QString selFile= browseForFiles->selectedFileName; 529 QString selFile= browseForFiles->selectedFileName;
526 QStringList fileList=browseForFiles->fileList; 530 QStringList fileList=browseForFiles->fileList;
527 qDebug(selFile); 531 qDebug(selFile);
528 QStringList::ConstIterator f; 532 QStringList::ConstIterator f;
529 QString fileTemp; 533 QString fileTemp;
530 for ( f = fileList.begin(); f != fileList.end(); f++ ) { 534 for ( f = fileList.begin(); f != fileList.end(); f++ ) {
531 fileTemp = *f; 535 fileTemp = *f;
532 fileTemp.right( fileTemp.length()-5); 536 fileTemp.right( fileTemp.length()-5);
533 QString fileName = fileTemp; 537 QString fileName = fileTemp;
534 if( fileName != "Unnamed" || fileName != "Empty Text" ) { 538 if( fileName != "Unnamed" || fileName != "Empty Text" ) {
535 currentFileName = fileName; 539 currentFileName = fileName;
536// qDebug("please open "+currentFileName); 540// qDebug("please open "+currentFileName);
537 openFile(fileName ); 541 openFile(fileName );
538 } 542 }
539 } 543 }
540 } 544 }
541 delete browseForFiles; 545 delete browseForFiles;
542 546
543} 547}
544 548
545#if 0 549#if 0
546void TextEdit::slotFind() 550void TextEdit::slotFind()
547{ 551{
548 FindDialog frmFind( "Text Editor", this ); 552 FindDialog frmFind( "Text Editor", this );
549 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 553 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
550 editor, SLOT(slotDoFind( const QString&,bool,bool))); 554 editor, SLOT(slotDoFind( const QString&,bool,bool)));
551 555
552 //case sensitive, backwards, [category] 556 //case sensitive, backwards, [category]
553 557
554 connect( editor, SIGNAL(notFound()), 558 connect( editor, SIGNAL(notFound()),
555 &frmFind, SLOT(slotNotFound()) ); 559 &frmFind, SLOT(slotNotFound()) );
556 connect( editor, SIGNAL(searchWrapped()), 560 connect( editor, SIGNAL(searchWrapped()),
557 &frmFind, SLOT(slotWrapAround()) ); 561 &frmFind, SLOT(slotWrapAround()) );
558 562
559 frmFind.exec(); 563 frmFind.exec();
560 564
561 565
562} 566}
563#endif 567#endif
564 568
565void TextEdit::fileRevert() 569void TextEdit::fileRevert()
566{ 570{
567 clear(); 571 clear();
568 fileOpen(); 572 fileOpen();
569} 573}
570 574
571void TextEdit::editCut() 575void TextEdit::editCut()
572{ 576{
573#ifndef QT_NO_CLIPBOARD 577#ifndef QT_NO_CLIPBOARD
574 editor->cut(); 578 editor->cut();
575#endif 579#endif
576} 580}
577 581
578void TextEdit::editCopy() 582void TextEdit::editCopy()
579{ 583{
580#ifndef QT_NO_CLIPBOARD 584#ifndef QT_NO_CLIPBOARD
581 editor->copy(); 585 editor->copy();
582#endif 586#endif
583} 587}
584 588
585void TextEdit::editPaste() 589void TextEdit::editPaste()
586{ 590{
587#ifndef QT_NO_CLIPBOARD 591#ifndef QT_NO_CLIPBOARD
588 editor->paste(); 592 editor->paste();
589#endif 593#endif
590} 594}
591 595
592void TextEdit::editFind() 596void TextEdit::editFind()
593{ 597{
594 searchBar->show(); 598 searchBar->show();
595 searchVisible = TRUE; 599 searchVisible = TRUE;
596 searchEdit->setFocus(); 600 searchEdit->setFocus();
597} 601}
598 602
599void TextEdit::findNext() 603void TextEdit::findNext()
600{ 604{
601 editor->find( searchEdit->text(), FALSE, FALSE ); 605 editor->find( searchEdit->text(), FALSE, FALSE );
602 606
603} 607}
604 608
605void TextEdit::findClose() 609void TextEdit::findClose()
606{ 610{
607 searchVisible = FALSE; 611 searchVisible = FALSE;
608 searchBar->hide(); 612 searchBar->hide();
609} 613}
610 614
611void TextEdit::search() 615void TextEdit::search()
612{ 616{
613 editor->find( searchEdit->text(), FALSE, FALSE ); 617 editor->find( searchEdit->text(), FALSE, FALSE );
614} 618}
615 619
616void TextEdit::newFile( const DocLnk &f ) 620void TextEdit::newFile( const DocLnk &f )
617{ 621{
618 DocLnk nf = f; 622 DocLnk nf = f;
619 nf.setType("text/plain"); 623 nf.setType("text/plain");
620 clear(); 624 clear();
621 editorStack->raiseWidget( editor ); 625 editorStack->raiseWidget( editor );
622 setWState (WState_Reserved1 ); 626 setWState (WState_Reserved1 );
623 editor->setFocus(); 627 editor->setFocus();
624 doc = new DocLnk(nf); 628 doc = new DocLnk(nf);
625// updateCaption(); 629// updateCaption();
626} 630}
627 631
628void TextEdit::openFile( const QString &f ) 632void TextEdit::openFile( const QString &f )
629{ 633{
630 bFromDocView = TRUE; 634 bFromDocView = TRUE;
631 DocLnk nf; 635 DocLnk nf;
632 nf.setType("text/plain"); 636 nf.setType("text/plain");
633 nf.setFile(f); 637 nf.setFile(f);
634 openFile(nf); 638 openFile(nf);
635 showEditTools(); 639 showEditTools();
636 // Show filename in caption 640 // Show filename in caption
637 QString name = f; 641 QString name = f;
638 int sep = name.findRev( '/' ); 642 int sep = name.findRev( '/' );
639 if ( sep > 0 ) 643 if ( sep > 0 )
640 name = name.mid( sep+1 ); 644 name = name.mid( sep+1 );
641 updateCaption( name ); 645 updateCaption( name );
642} 646}
643 647
644void TextEdit::openFile( const DocLnk &f ) 648void TextEdit::openFile( const DocLnk &f )
645{ 649{
646// clear(); 650// clear();
647 bFromDocView = TRUE; 651 bFromDocView = TRUE;
648 FileManager fm; 652 FileManager fm;
649 QString txt; 653 QString txt;
650 if ( !fm.loadFile( f, txt ) ) { 654 if ( !fm.loadFile( f, txt ) ) {
651 // ####### could be a new file 655 // ####### could be a new file
652 qDebug( "Cannot open file" ); 656 qDebug( "Cannot open file" );
653 657
654 //return; 658 //return;
655 } 659 }
656 660
657 fileNew(); 661 fileNew();
658 if ( doc ) 662 if ( doc )
659 delete doc; 663 delete doc;
660 doc = new DocLnk(f); 664 doc = new DocLnk(f);
661 editor->setText(txt); 665 editor->setText(txt);
662 editor->setEdited(FALSE); 666 editor->setEdited(FALSE);
663 updateCaption(currentFileName); 667 updateCaption(currentFileName);
664} 668}
665 669
666void TextEdit::showEditTools() 670void TextEdit::showEditTools()
667{ 671{
668// if ( !doc ) 672// if ( !doc )
669// close(); 673// close();
670// clear(); 674// clear();
671 fileSelector->hide(); 675 fileSelector->hide();
672 menu->show(); 676 menu->show();
673 editBar->show(); 677 editBar->show();
674 if ( searchVisible ) 678 if ( searchVisible )
675 searchBar->show(); 679 searchBar->show();
676// updateCaption(); 680// updateCaption();
677 editorStack->raiseWidget( editor ); 681 editorStack->raiseWidget( editor );
678 setWState (WState_Reserved1 ); 682 setWState (WState_Reserved1 );
679} 683}
680 684
681bool TextEdit::save() 685bool TextEdit::save()
682{ 686{
687 QString rt = editor->text();
688 doc->setName( currentFileName);
689 FileManager fm;
690 if ( !fm.saveFile( *doc, rt ) ) {
691 return false;
692 }
693 delete doc;
694 doc = 0;
695 editor->setEdited( false );
696 return true;
697
698}
699
700bool TextEdit::saveAs()
701{
683 // case of nothing to save... 702 // case of nothing to save...
684 if ( !doc || !bFromDocView) 703 if ( !doc || !bFromDocView)
685 return true; 704 return true;
686 if ( !editor->edited() ) { 705 if ( !editor->edited() ) {
687 delete doc; 706 delete doc;
688 doc = 0; 707 doc = 0;
689 return true; 708 return true;
690 } 709 }
691 710
692 QString rt = editor->text(); 711 QString rt = editor->text();
693 qDebug(currentFileName); 712 qDebug(currentFileName);
694 713
695 if( currentFileName.isEmpty() || currentFileName == "Unnamed") { 714 if( currentFileName.isEmpty() || currentFileName == "Unnamed") {
696 715
697 if ( doc->name().isEmpty() ) { 716 if ( doc->name().isEmpty() ) {
698 QString pt = rt.simplifyWhiteSpace(); 717 QString pt = rt.simplifyWhiteSpace();
699 int i = pt.find( ' ' ); 718 int i = pt.find( ' ' );
700 QString docname = pt; 719 QString docname = pt;
701 if ( i > 0 ) 720 if ( i > 0 )
702 docname = pt.left( i ); 721 docname = pt.left( i );
703 // remove "." at the beginning 722 // remove "." at the beginning
704 while( docname.startsWith( "." ) ) 723 while( docname.startsWith( "." ) )
705 docname = docname.mid( 1 ); 724 docname = docname.mid( 1 );
706 docname.replace( QRegExp("/"), "_" ); 725 docname.replace( QRegExp("/"), "_" );
707 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 726 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
708 if ( docname.length() > 40 ) 727 if ( docname.length() > 40 )
709 docname = docname.left(40); 728 docname = docname.left(40);
710 if ( docname.isEmpty() ) 729 if ( docname.isEmpty() )
711 docname = "Empty Text"; 730 docname = "Empty Text";
712 doc->setName(docname); 731 doc->setName(docname);
713 currentFileName=docname; 732 currentFileName=docname;
714 } 733 }
715 } 734 }
716 735
717 fileSaver *fileSaveDlg; 736 fileSaver *fileSaveDlg;
718 fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); 737 fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName);
719 if( fileSaveDlg->exec() != 0 ) { 738 if( fileSaveDlg->exec() != 0 ) {
720 QString fileNm=fileSaveDlg->selectedFileName; 739 QString fileNm=fileSaveDlg->selectedFileName;
721 qDebug("save filename "+fileNm); 740 qDebug("save filename "+fileNm);
722 doc->setName(fileNm); 741 doc->setName(fileNm);
723 updateCaption(fileNm); 742 updateCaption(fileNm);
724 } 743 }
725 delete fileSaveDlg; 744 delete fileSaveDlg;
726 745
727 FileManager fm; 746 FileManager fm;
728 if ( !fm.saveFile( *doc, rt ) ) { 747 if ( !fm.saveFile( *doc, rt ) ) {
729 return false; 748 return false;
730 } 749 }
731 delete doc; 750 delete doc;
732 doc = 0; 751 doc = 0;
733 editor->setEdited( false ); 752 editor->setEdited( false );
734 return true; 753 return true;
735} 754}
736 755
737void TextEdit::clear() 756void TextEdit::clear()
738{ 757{
739 delete doc; 758 delete doc;
740 doc = 0; 759 doc = 0;
741 editor->clear(); 760 editor->clear();
742} 761}
743 762
744void TextEdit::updateCaption( const QString &name ) 763void TextEdit::updateCaption( const QString &name )
745{ 764{
746 if ( !doc ) 765 if ( !doc )
747 setCaption( tr("Text Editor") ); 766 setCaption( tr("Text Editor") );
748 else { 767 else {
749 QString s = name; 768 QString s = name;
750 if ( s.isNull() ) 769 if ( s.isNull() )
751 s = doc->name(); 770 s = doc->name();
752 if ( s.isEmpty() ) { 771 if ( s.isEmpty() ) {
753 s = tr( "Unnamed" ); 772 s = tr( "Unnamed" );
754 currentFileName=s; 773 currentFileName=s;
755 } 774 }
756 setCaption( s + " - " + tr("Text Editor") ); 775 setCaption( s + " - " + tr("Text Editor") );
757 } 776 }
758} 777}
759 778
760void TextEdit::setDocument(const QString& fileref) 779void TextEdit::setDocument(const QString& fileref)
761{ 780{
762 bFromDocView = TRUE; 781 bFromDocView = TRUE;
763 openFile(DocLnk(fileref)); 782 openFile(DocLnk(fileref));
764// showEditTools(); 783// showEditTools();
765} 784}
766 785
767void TextEdit::closeEvent( QCloseEvent *e ) 786void TextEdit::closeEvent( QCloseEvent *e )
768{ 787{
769 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { 788 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) {
770 e->ignore(); 789 e->ignore();
771 repaint(); 790 repaint();
772// fileRevert(); 791// fileRevert();
773 792
774 } else { 793 } else {
775 bFromDocView = FALSE; 794 bFromDocView = FALSE;
776 e->accept(); 795 e->accept();
777 } 796 }
778} 797}
779 798
780void TextEdit::accept() 799void TextEdit::accept()
781{ 800{
782 close(); 801 close();
783// fileOpen(); //godamn thats obnoxious! lemme out!!! 802// fileOpen(); //godamn thats obnoxious! lemme out!!!
784} 803}
785 804
786void TextEdit::changeFont() { 805void TextEdit::changeFont() {
787 FontDatabase fdb; 806 FontDatabase fdb;
788 QFont defaultFont=editor->font(); 807 QFont defaultFont=editor->font();
789 QFontInfo fontInfo(defaultFont); 808 QFontInfo fontInfo(defaultFont);
790 Config cfg("TextEdit"); 809 Config cfg("TextEdit");
791 cfg.setGroup("Font"); 810 cfg.setGroup("Font");
792 QString family = cfg.readEntry("Family", fontInfo.family()); 811 QString family = cfg.readEntry("Family", fontInfo.family());
793 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 812 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
794 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 813 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
795 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 814 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
796 815
797 defaultFont = fdb.font(family,style,i_size,charSet); 816 defaultFont = fdb.font(family,style,i_size,charSet);
798 817
799 FontDialog *fontDlg; 818 FontDialog *fontDlg;
800 fontDlg=new FontDialog(this,"FontDialog",TRUE); 819 fontDlg=new FontDialog(this,"FontDialog",TRUE);
801 820
802 fontDlg->exec(); 821 fontDlg->exec();
803 822
804 QFont myFont=fontDlg->selectedFont; 823 QFont myFont=fontDlg->selectedFont;
805 editor->setFont( myFont); 824 editor->setFont( myFont);
806 delete fontDlg; 825 delete fontDlg;
807 826
808} 827}
809 828
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index 4bfb260..f9eb241 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -1,105 +1,107 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// additions made by L.J. Potter Sun 02-17-2002 22:27:46 20// additions made by L.J. Potter Sun 02-17-2002 22:27:46
21 21
22#ifndef TEXTEDIT_H 22#ifndef TEXTEDIT_H
23#define TEXTEDIT_H 23#define TEXTEDIT_H
24 24
25#define QTEXTEDIT_OPEN_API 25#define QTEXTEDIT_OPEN_API
26 26
27#include <qpe/filemanager.h> 27#include <qpe/filemanager.h>
28 28
29#include <qmainwindow.h> 29#include <qmainwindow.h>
30#include <qmultilineedit.h> 30#include <qmultilineedit.h>
31#include <qlist.h> 31#include <qlist.h>
32#include <qmap.h> 32#include <qmap.h>
33 33
34class QWidgetStack; 34class QWidgetStack;
35class QToolButton; 35class QToolButton;
36class QPopupMenu; 36class QPopupMenu;
37class QToolBar; 37class QToolBar;
38class QLineEdit; 38class QLineEdit;
39class QAction; 39class QAction;
40class FileSelector; 40class FileSelector;
41class QpeEditor; 41class QpeEditor;
42 42
43class TextEdit : public QMainWindow 43class TextEdit : public QMainWindow
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 46
47public: 47public:
48 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 48 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
49 ~TextEdit(); 49 ~TextEdit();
50 50
51 void openFile( const QString & ); 51 void openFile( const QString & );
52 52
53protected: 53protected:
54 void closeEvent( QCloseEvent *e ); 54 void closeEvent( QCloseEvent *e );
55 55
56private slots: 56private slots:
57 void setDocument(const QString&); 57 void setDocument(const QString&);
58 void changeFont(); 58 void changeFont();
59 void fileNew(); 59 void fileNew();
60 void fileRevert(); 60 void fileRevert();
61 void fileOpen(); 61 void fileOpen();
62 void newFileOpen(); 62 void newFileOpen();
63 bool save(); 63 bool save();
64 bool saveAs();
65
64 66
65 void editCut(); 67 void editCut();
66 void editCopy(); 68 void editCopy();
67 void editPaste(); 69 void editPaste();
68 void editFind(); 70 void editFind();
69 71
70 void findNext(); 72 void findNext();
71 void findClose(); 73 void findClose();
72 74
73 void search(); 75 void search();
74 void accept(); 76 void accept();
75 77
76 void newFile( const DocLnk & ); 78 void newFile( const DocLnk & );
77 void openFile( const DocLnk & ); 79 void openFile( const DocLnk & );
78 void showEditTools(); 80 void showEditTools();
79 81
80 void zoomIn(); 82 void zoomIn();
81 void zoomOut(); 83 void zoomOut();
82 void setBold(bool y); 84 void setBold(bool y);
83 void setItalic(bool y); 85 void setItalic(bool y);
84 void setWordWrap(bool y); 86 void setWordWrap(bool y);
85 87
86private: 88private:
87 void colorChanged( const QColor &c ); 89 void colorChanged( const QColor &c );
88 void clear(); 90 void clear();
89 void updateCaption( const QString &name=QString::null ); 91 void updateCaption( const QString &name=QString::null );
90 void setFontSize(int sz, bool round_down_not_up); 92 void setFontSize(int sz, bool round_down_not_up);
91 93
92private: 94private:
93 QWidgetStack *editorStack; 95 QWidgetStack *editorStack;
94 FileSelector *fileSelector; 96 FileSelector *fileSelector;
95 QpeEditor* editor; 97 QpeEditor* editor;
96 QToolBar *menu, *editBar, *searchBar; 98 QToolBar *menu, *editBar, *searchBar;
97 QLineEdit *searchEdit; 99 QLineEdit *searchEdit;
98 DocLnk *doc; 100 DocLnk *doc;
99 bool searchVisible; 101 bool searchVisible;
100 bool bFromDocView; 102 bool bFromDocView;
101 QAction *zin, *zout; 103 QAction *zin, *zout;
102 QString currentFileName; 104 QString currentFileName;
103}; 105};
104 106
105#endif 107#endif