summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index c1f74bb..ccc43fa 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -257,513 +257,518 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
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 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 );
298 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 298 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
299 edit->insertSeparator(); 299 edit->insertSeparator();
300 a->addTo( bar ); 300 a->addTo( bar );
301 a->addTo( edit ); 301 a->addTo( edit );
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(tr("Font"), this, SLOT(changeFont()) ); 346 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
347 347
348 font->insertSeparator(); 348 font->insertSeparator();
349 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); 349 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 );
350 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); 350 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) );
351 nStart->setToggleAction(TRUE); 351 nStart->setToggleAction(TRUE);
352 nStart->addTo( font ); 352 nStart->addTo( font );
353 font->insertSeparator(); 353 font->insertSeparator();
354 font->insertItem(tr("About"), this, SLOT( doAbout()) ); 354 font->insertItem(tr("About"), this, SLOT( doAbout()) );
355 355
356 mb->insertItem( tr( "File" ), file ); 356 mb->insertItem( tr( "File" ), file );
357 mb->insertItem( tr( "Edit" ), edit ); 357 mb->insertItem( tr( "Edit" ), edit );
358 mb->insertItem( tr( "View" ), font ); 358 mb->insertItem( tr( "View" ), font );
359 359
360 searchBar = new QPEToolBar(this); 360 searchBar = new QPEToolBar(this);
361 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 361 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
362 362
363 searchBar->setHorizontalStretchable( TRUE ); 363 searchBar->setHorizontalStretchable( TRUE );
364 364
365 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 365 searchEdit = new QLineEdit( searchBar, "searchEdit" );
366 searchBar->setStretchableWidget( searchEdit ); 366 searchBar->setStretchableWidget( searchEdit );
367 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 367 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
368 this, SLOT( search() ) ); 368 this, SLOT( search() ) );
369 369
370 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 370 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
371 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 371 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
372 a->addTo( searchBar ); 372 a->addTo( searchBar );
373 a->addTo( edit ); 373 a->addTo( edit );
374 374
375 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 375 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
376 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 376 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
377 a->addTo( searchBar ); 377 a->addTo( searchBar );
378 378
379 edit->insertSeparator(); 379 edit->insertSeparator();
380 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 380 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
381 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 381 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
382 a->addTo( edit ); 382 a->addTo( edit );
383 383
384 searchBar->hide(); 384 searchBar->hide();
385 385
386 editor = new QpeEditor( this ); 386 editor = new QpeEditor( this );
387 setCentralWidget( editor ); 387 setCentralWidget( editor );
388 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 388 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
389 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); 389 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
390 390
391// resize( 200, 300 ); 391// resize( 200, 300 );
392 392
393// setFontSize(defsize,TRUE); 393// setFontSize(defsize,TRUE);
394 FontDatabase fdb; 394 FontDatabase fdb;
395 QFont defaultFont=editor->font(); 395 QFont defaultFont=editor->font();
396 QFontInfo fontInfo(defaultFont); 396 QFontInfo fontInfo(defaultFont);
397 397
398 cfg.setGroup("Font"); 398 cfg.setGroup("Font");
399 QString family = cfg.readEntry("Family", fontInfo.family()); 399 QString family = cfg.readEntry("Family", fontInfo.family());
400 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 400 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
401 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 401 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
402 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 402 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
403 403
404 defaultFont = fdb.font(family,style,i_size,charSet); 404 defaultFont = fdb.font(family,style,i_size,charSet);
405 editor->setFont( defaultFont); 405 editor->setFont( defaultFont);
406 406
407 wa->setOn(wrap); 407 wa->setOn(wrap);
408 updateCaption(); 408 updateCaption();
409 409
410 cfg.setGroup("View"); 410 cfg.setGroup("View");
411 if(cfg.readEntry("startNew","TRUE") == "TRUE") { 411 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
412 nStart->setOn(TRUE); 412 nStart->setOn(TRUE);
413 fileNew(); 413 fileNew();
414 } else { 414 } else {
415 fileOpen(); 415 fileOpen();
416 } 416 }
417 417
418 viewSelection = cfg.readNumEntry( "FileView", 0 ); 418 viewSelection = cfg.readNumEntry( "FileView", 0 );
419} 419}
420 420
421void TextEdit::cleanUp() 421void TextEdit::cleanUp()
422{ 422{
423// save(); 423// save();
424 Config cfg("TextEdit"); 424 Config cfg("TextEdit");
425 cfg.setGroup("View"); 425 cfg.setGroup("View");
426 QFont f = editor->font(); 426 QFont f = editor->font();
427 cfg.writeEntry("FontSize",f.pointSize()); 427 cfg.writeEntry("FontSize",f.pointSize());
428 cfg.writeEntry("Bold",f.bold()); 428 cfg.writeEntry("Bold",f.bold());
429 cfg.writeEntry("Italic",f.italic()); 429 cfg.writeEntry("Italic",f.italic());
430 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 430 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
431 cfg.writeEntry( "FileView", viewSelection ); 431 cfg.writeEntry( "FileView", viewSelection );
432 432
433} 433}
434 434
435TextEdit::~TextEdit() 435TextEdit::~TextEdit()
436{ 436{
437} 437}
438 438
439void TextEdit::zoomIn() 439void TextEdit::zoomIn()
440{ 440{
441 setFontSize(editor->font().pointSize()+1,FALSE); 441 setFontSize(editor->font().pointSize()+1,FALSE);
442} 442}
443 443
444void TextEdit::zoomOut() 444void TextEdit::zoomOut()
445{ 445{
446 setFontSize(editor->font().pointSize()-1,TRUE); 446 setFontSize(editor->font().pointSize()-1,TRUE);
447} 447}
448 448
449 449
450void TextEdit::setFontSize(int sz, bool round_down_not_up) 450void TextEdit::setFontSize(int sz, bool round_down_not_up)
451{ 451{
452 int s=10; 452 int s=10;
453 for (int i=0; i<nfontsizes; i++) { 453 for (int i=0; i<nfontsizes; i++) {
454 if ( fontsize[i] == sz ) { 454 if ( fontsize[i] == sz ) {
455 s = sz; 455 s = sz;
456 break; 456 break;
457 } else if ( round_down_not_up ) { 457 } else if ( round_down_not_up ) {
458 if ( fontsize[i] < sz ) 458 if ( fontsize[i] < sz )
459 s = fontsize[i]; 459 s = fontsize[i];
460 } else { 460 } else {
461 if ( fontsize[i] > sz ) { 461 if ( fontsize[i] > sz ) {
462 s = fontsize[i]; 462 s = fontsize[i];
463 break; 463 break;
464 } 464 }
465 } 465 }
466 } 466 }
467 467
468 QFont f = editor->font(); 468 QFont f = editor->font();
469 f.setPointSize(s); 469 f.setPointSize(s);
470 editor->setFont(f); 470 editor->setFont(f);
471 471
472 zin->setEnabled(s != fontsize[nfontsizes-1]); 472 zin->setEnabled(s != fontsize[nfontsizes-1]);
473 zout->setEnabled(s != fontsize[0]); 473 zout->setEnabled(s != fontsize[0]);
474} 474}
475 475
476void TextEdit::setBold(bool y) 476void TextEdit::setBold(bool y)
477{ 477{
478 QFont f = editor->font(); 478 QFont f = editor->font();
479 f.setBold(y); 479 f.setBold(y);
480 editor->setFont(f); 480 editor->setFont(f);
481} 481}
482 482
483void TextEdit::setItalic(bool y) 483void TextEdit::setItalic(bool y)
484{ 484{
485 QFont f = editor->font(); 485 QFont f = editor->font();
486 f.setItalic(y); 486 f.setItalic(y);
487 editor->setFont(f); 487 editor->setFont(f);
488} 488}
489 489
490void TextEdit::setWordWrap(bool y) 490void TextEdit::setWordWrap(bool y)
491{ 491{
492 bool state = editor->edited(); 492 bool state = editor->edited();
493 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 493 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
494 editor->setEdited( state ); 494 editor->setEdited( state );
495} 495}
496 496
497void TextEdit::fileNew() 497void TextEdit::fileNew()
498{ 498{
499// if( !bFromDocView ) { 499// if( !bFromDocView ) {
500// saveAs(); 500// saveAs();
501// } 501// }
502 newFile(DocLnk()); 502 newFile(DocLnk());
503} 503}
504 504
505void TextEdit::fileOpen() 505void TextEdit::fileOpen()
506{ 506{
507 Config cfg("TextEdit"); 507 Config cfg("TextEdit");
508 cfg.setGroup("View"); 508 cfg.setGroup("View");
509 bool b=FALSE; 509 bool b=FALSE;
510// if(cfg.readEntry("useOldFileDialog") == "TRUE") 510// if(cfg.readEntry("useOldFileDialog") == "TRUE")
511// b=TRUE; 511// b=TRUE;
512// if(!b) { 512// if(!b) {
513 QString str = OFileDialog::getOpenFileName( 2,"/");//,"", "*", this ); 513 QMap<QString, QStringList> map;
514 map.insert(tr("All"), QStringList() );
515 QStringList text;
516 text << "text/*";
517 map.insert(tr("Text"), text );
518 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map);//,"", "*", this );
514 if(!str.isEmpty() ) 519 if(!str.isEmpty() )
515 openFile( str ); 520 openFile( str );
516// } else { 521// } else {
517// QString str; 522// QString str;
518// browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "*"); // 523// browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "*"); //
519// browseForFiles->setFileView( viewSelection ); 524// browseForFiles->setFileView( viewSelection );
520// browseForFiles->showMaximized(); 525// browseForFiles->showMaximized();
521// // if( result != -1 ) 526// // if( result != -1 )
522 527
523// if( browseForFiles->exec() != -1 ) { 528// if( browseForFiles->exec() != -1 ) {
524// QString selFile = browseForFiles->selectedFileName; 529// QString selFile = browseForFiles->selectedFileName;
525// QStringList fileList = browseForFiles->fileList; 530// QStringList fileList = browseForFiles->fileList;
526// qDebug(selFile); 531// qDebug(selFile);
527// QStringList::ConstIterator f; 532// QStringList::ConstIterator f;
528// QString fileTemp; 533// QString fileTemp;
529// for ( f = fileList.begin(); f != fileList.end(); f++ ) { 534// for ( f = fileList.begin(); f != fileList.end(); f++ ) {
530// fileTemp = *f; 535// fileTemp = *f;
531// fileTemp.right( fileTemp.length()-5); 536// fileTemp.right( fileTemp.length()-5);
532// QString fileName = fileTemp; 537// QString fileName = fileTemp;
533// if( fileName != "Unnamed" || fileName != "Empty Text" ) { 538// if( fileName != "Unnamed" || fileName != "Empty Text" ) {
534// currentFileName = fileName; 539// currentFileName = fileName;
535// qDebug("please open "+currentFileName); 540// qDebug("please open "+currentFileName);
536// openFile(currentFileName ); 541// openFile(currentFileName );
537// } 542// }
538// } 543// }
539// viewSelection = browseForFiles->SelectionCombo->currentItem(); 544// viewSelection = browseForFiles->SelectionCombo->currentItem();
540// } 545// }
541// delete browseForFiles; 546// delete browseForFiles;
542// editor->setEdited( FALSE); 547// editor->setEdited( FALSE);
543// edited1=FALSE; 548// edited1=FALSE;
544// edited=FALSE; 549// edited=FALSE;
545// if(caption().left(1)=="*") 550// if(caption().left(1)=="*")
546// setCaption(caption().right(caption().length()-1)); 551// setCaption(caption().right(caption().length()-1));
547// doSearchBar(); 552// doSearchBar();
548// } 553// }
549 554
550} 555}
551 556
552void TextEdit::doSearchBar() 557void TextEdit::doSearchBar()
553{ 558{
554 Config cfg("TextEdit"); 559 Config cfg("TextEdit");
555 cfg.setGroup("View"); 560 cfg.setGroup("View");
556 if(cfg.readEntry("SearchBar","Closed") != "Opened") 561 if(cfg.readEntry("SearchBar","Closed") != "Opened")
557 searchBar->hide(); 562 searchBar->hide();
558} 563}
559 564
560#if 0 565#if 0
561void TextEdit::slotFind() 566void TextEdit::slotFind()
562{ 567{
563 FindDialog frmFind( tr("Text Editor"), this ); 568 FindDialog frmFind( tr("Text Editor"), this );
564 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 569 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
565 editor, SLOT(slotDoFind( const QString&,bool,bool))); 570 editor, SLOT(slotDoFind( const QString&,bool,bool)));
566 571
567 //case sensitive, backwards, [category] 572 //case sensitive, backwards, [category]
568 573
569 connect( editor, SIGNAL(notFound()), 574 connect( editor, SIGNAL(notFound()),
570 &frmFind, SLOT(slotNotFound()) ); 575 &frmFind, SLOT(slotNotFound()) );
571 connect( editor, SIGNAL(searchWrapped()), 576 connect( editor, SIGNAL(searchWrapped()),
572 &frmFind, SLOT(slotWrapAround()) ); 577 &frmFind, SLOT(slotWrapAround()) );
573 578
574 frmFind.exec(); 579 frmFind.exec();
575 580
576 581
577} 582}
578#endif 583#endif
579 584
580void TextEdit::fileRevert() 585void TextEdit::fileRevert()
581{ 586{
582 clear(); 587 clear();
583 fileOpen(); 588 fileOpen();
584} 589}
585 590
586void TextEdit::editCut() 591void TextEdit::editCut()
587{ 592{
588#ifndef QT_NO_CLIPBOARD 593#ifndef QT_NO_CLIPBOARD
589 editor->cut(); 594 editor->cut();
590#endif 595#endif
591} 596}
592 597
593void TextEdit::editCopy() 598void TextEdit::editCopy()
594{ 599{
595#ifndef QT_NO_CLIPBOARD 600#ifndef QT_NO_CLIPBOARD
596 editor->copy(); 601 editor->copy();
597#endif 602#endif
598} 603}
599 604
600void TextEdit::editPaste() 605void TextEdit::editPaste()
601{ 606{
602#ifndef QT_NO_CLIPBOARD 607#ifndef QT_NO_CLIPBOARD
603 editor->paste(); 608 editor->paste();
604#endif 609#endif
605} 610}
606 611
607void TextEdit::editFind() 612void TextEdit::editFind()
608{ 613{
609 searchBar->show(); 614 searchBar->show();
610 searchVisible = TRUE; 615 searchVisible = TRUE;
611 searchEdit->setFocus(); 616 searchEdit->setFocus();
612 Config cfg("TextEdit"); 617 Config cfg("TextEdit");
613 cfg.setGroup("View"); 618 cfg.setGroup("View");
614 cfg.writeEntry("SearchBar","Opened"); 619 cfg.writeEntry("SearchBar","Opened");
615 620
616} 621}
617 622
618void TextEdit::findNext() 623void TextEdit::findNext()
619{ 624{
620 editor->find( searchEdit->text(), FALSE, FALSE ); 625 editor->find( searchEdit->text(), FALSE, FALSE );
621 626
622} 627}
623 628
624void TextEdit::findClose() 629void TextEdit::findClose()
625{ 630{
626 searchVisible = FALSE; 631 searchVisible = FALSE;
627 searchBar->hide(); 632 searchBar->hide();
628 Config cfg("TextEdit"); 633 Config cfg("TextEdit");
629 cfg.setGroup("View"); 634 cfg.setGroup("View");
630 cfg.writeEntry("SearchBar","Closed"); 635 cfg.writeEntry("SearchBar","Closed");
631 cfg.write(); 636 cfg.write();
632} 637}
633 638
634void TextEdit::search() 639void TextEdit::search()
635{ 640{
636 editor->find( searchEdit->text(), FALSE, FALSE ); 641 editor->find( searchEdit->text(), FALSE, FALSE );
637} 642}
638 643
639void TextEdit::newFile( const DocLnk &f ) 644void TextEdit::newFile( const DocLnk &f )
640{ 645{
641 DocLnk nf = f; 646 DocLnk nf = f;
642 nf.setType("text/plain"); 647 nf.setType("text/plain");
643 clear(); 648 clear();
644 setWState (WState_Reserved1 ); 649 setWState (WState_Reserved1 );
645 editor->setFocus(); 650 editor->setFocus();
646 doc = new DocLnk(nf); 651 doc = new DocLnk(nf);
647 currentFileName = "Unnamed"; 652 currentFileName = "Unnamed";
648 qDebug("newFile "+currentFileName); 653 qDebug("newFile "+currentFileName);
649 updateCaption( currentFileName); 654 updateCaption( currentFileName);
650// editor->setEdited( FALSE); 655// editor->setEdited( FALSE);
651} 656}
652 657
653void TextEdit::openFile( const QString &f ) 658void TextEdit::openFile( const QString &f )
654{ 659{
655 qDebug("filename is "+ f); 660 qDebug("filename is "+ f);
656 QString filer; 661 QString filer;
657// bFromDocView = TRUE; 662// bFromDocView = TRUE;
658 if(f.find(".desktop",0,TRUE) != -1) { 663 if(f.find(".desktop",0,TRUE) != -1) {
659 switch ( QMessageBox::warning(this,tr("Text Editor"), 664 switch ( QMessageBox::warning(this,tr("Text Editor"),
660 tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), 665 tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"),
661 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 666 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
662 case 0: 667 case 0:
663 filer = f; 668 filer = f;
664 break; 669 break;
665 case 1: 670 case 1:
666 DocLnk sf(f); 671 DocLnk sf(f);
667 filer = sf.file(); 672 filer = sf.file();
668 break; 673 break;
669 } 674 }
670 } else { 675 } else {
671 filer = f; 676 filer = f;
672 fileIs = TRUE; 677 fileIs = TRUE;
673 } 678 }
674 679
675 DocLnk nf; 680 DocLnk nf;
676 nf.setType("text/plain"); 681 nf.setType("text/plain");
677 nf.setFile(filer); 682 nf.setFile(filer);
678 currentFileName=filer; 683 currentFileName=filer;
679 QFileInfo fi( currentFileName); 684 QFileInfo fi( currentFileName);
680 nf.setName(fi.baseName()); 685 nf.setName(fi.baseName());
681 qDebug("openFile string "+currentFileName); 686 qDebug("openFile string "+currentFileName);
682 687
683 openFile(nf); 688 openFile(nf);
684 showEditTools(); 689 showEditTools();
685 // Show filename in caption 690 // Show filename in caption
686 QString name = filer; 691 QString name = filer;
687 int sep = name.findRev( '/' ); 692 int sep = name.findRev( '/' );
688 if ( sep > 0 ) 693 if ( sep > 0 )
689 name = name.mid( sep+1 ); 694 name = name.mid( sep+1 );
690 updateCaption( name ); 695 updateCaption( name );
691} 696}
692 697
693void TextEdit::openFile( const DocLnk &f ) 698void TextEdit::openFile( const DocLnk &f )
694{ 699{
695// clear(); 700// clear();
696// bFromDocView = TRUE; 701// bFromDocView = TRUE;
697 FileManager fm; 702 FileManager fm;
698 QString txt; 703 QString txt;
699 currentFileName=f.file(); 704 currentFileName=f.file();
700 qDebug("openFile doclnk " + currentFileName); 705 qDebug("openFile doclnk " + currentFileName);
701 if ( !fm.loadFile( f, txt ) ) { 706 if ( !fm.loadFile( f, txt ) ) {
702 // ####### could be a new file 707 // ####### could be a new file
703 qDebug( "Cannot open file" ); 708 qDebug( "Cannot open file" );
704 } 709 }
705// fileNew(); 710// fileNew();
706 if ( doc ) 711 if ( doc )
707 delete doc; 712 delete doc;
708 doc = new DocLnk(f); 713 doc = new DocLnk(f);
709 editor->setText(txt); 714 editor->setText(txt);
710 editor->setEdited( FALSE); 715 editor->setEdited( FALSE);
711 edited1=FALSE; 716 edited1=FALSE;
712 edited=FALSE; 717 edited=FALSE;
713 718
714 doc->setName(currentFileName); 719 doc->setName(currentFileName);
715 updateCaption(); 720 updateCaption();
716} 721}
717 722
718void TextEdit::showEditTools() 723void TextEdit::showEditTools()
719{ 724{
720// if ( !doc ) 725// if ( !doc )
721// close(); 726// close();
722// clear(); 727// clear();
723 menu->show(); 728 menu->show();
724 editBar->show(); 729 editBar->show();
725 if ( searchVisible ) 730 if ( searchVisible )
726 searchBar->show(); 731 searchBar->show();
727// updateCaption(); 732// updateCaption();
728 setWState (WState_Reserved1 ); 733 setWState (WState_Reserved1 );
729} 734}
730 735
731/*! 736/*!
732 unprompted save */ 737 unprompted save */
733bool TextEdit::save() 738bool TextEdit::save()
734{ 739{
735 QString file = doc->file(); 740 QString file = doc->file();
736 qDebug("saver file "+file); 741 qDebug("saver file "+file);
737 QString name= doc->name(); 742 QString name= doc->name();
738 qDebug("File named "+name); 743 qDebug("File named "+name);
739 QString rt = editor->text(); 744 QString rt = editor->text();
740 if( !rt.isEmpty() ) { 745 if( !rt.isEmpty() ) {
741 if(name.isEmpty()) { 746 if(name.isEmpty()) {
742 saveAs(); 747 saveAs();
743 } else { 748 } else {
744 currentFileName= name ; 749 currentFileName= name ;
745 qDebug("saveFile "+currentFileName); 750 qDebug("saveFile "+currentFileName);
746 751
747 struct stat buf; 752 struct stat buf;
748 mode_t mode; 753 mode_t mode;
749 stat(file.latin1(), &buf); 754 stat(file.latin1(), &buf);
750 mode = buf.st_mode; 755 mode = buf.st_mode;
751 756
752 if(!fileIs) { 757 if(!fileIs) {
753 doc->setName( name); 758 doc->setName( name);
754 FileManager fm; 759 FileManager fm;
755 if ( !fm.saveFile( *doc, rt ) ) { 760 if ( !fm.saveFile( *doc, rt ) ) {
756 return false; 761 return false;
757 } 762 }
758 } else { 763 } else {
759 qDebug("regular save file"); 764 qDebug("regular save file");
760 QFile f(file); 765 QFile f(file);
761 if( f.open(IO_WriteOnly)) { 766 if( f.open(IO_WriteOnly)) {
762 QCString crt = rt.utf8(); 767 QCString crt = rt.utf8();
763 f.writeBlock(crt,crt.length()); 768 f.writeBlock(crt,crt.length());
764 } else { 769 } else {
765 QMessageBox::message("Text Edit","Write Failed"); 770 QMessageBox::message("Text Edit","Write Failed");
766 return false; 771 return false;
767 } 772 }
768 773
769 } 774 }