summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-20 03:08:24 (UTC)
committer llornkcor <llornkcor>2002-07-20 03:08:24 (UTC)
commitcd03e9a352b7f37f3df45a089dd1eba9eefb9f05 (patch) (unidiff)
treefe7ea2902786f46d0af6aedaf9d247b4962f36d0
parentc42e3e2485c545beedd482115927bff7d1bf65a2 (diff)
downloadopie-cd03e9a352b7f37f3df45a089dd1eba9eefb9f05.zip
opie-cd03e9a352b7f37f3df45a089dd1eba9eefb9f05.tar.gz
opie-cd03e9a352b7f37f3df45a089dd1eba9eefb9f05.tar.bz2
spelling error
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 0af18da..9e6ba8d 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -451,534 +451,534 @@ void TextEdit::zoomOut()
451 setFontSize(editor->font().pointSize()-1,TRUE); 451 setFontSize(editor->font().pointSize()-1,TRUE);
452} 452}
453 453
454 454
455void TextEdit::setFontSize(int sz, bool round_down_not_up) 455void TextEdit::setFontSize(int sz, bool round_down_not_up)
456{ 456{
457 int s=10; 457 int s=10;
458 for (int i=0; i<nfontsizes; i++) { 458 for (int i=0; i<nfontsizes; i++) {
459 if ( fontsize[i] == sz ) { 459 if ( fontsize[i] == sz ) {
460 s = sz; 460 s = sz;
461 break; 461 break;
462 } else if ( round_down_not_up ) { 462 } else if ( round_down_not_up ) {
463 if ( fontsize[i] < sz ) 463 if ( fontsize[i] < sz )
464 s = fontsize[i]; 464 s = fontsize[i];
465 } else { 465 } else {
466 if ( fontsize[i] > sz ) { 466 if ( fontsize[i] > sz ) {
467 s = fontsize[i]; 467 s = fontsize[i];
468 break; 468 break;
469 } 469 }
470 } 470 }
471 } 471 }
472 472
473 QFont f = editor->font(); 473 QFont f = editor->font();
474 f.setPointSize(s); 474 f.setPointSize(s);
475 editor->setFont(f); 475 editor->setFont(f);
476 476
477 zin->setEnabled(s != fontsize[nfontsizes-1]); 477 zin->setEnabled(s != fontsize[nfontsizes-1]);
478 zout->setEnabled(s != fontsize[0]); 478 zout->setEnabled(s != fontsize[0]);
479} 479}
480 480
481void TextEdit::setBold(bool y) 481void TextEdit::setBold(bool y)
482{ 482{
483 QFont f = editor->font(); 483 QFont f = editor->font();
484 f.setBold(y); 484 f.setBold(y);
485 editor->setFont(f); 485 editor->setFont(f);
486} 486}
487 487
488void TextEdit::setItalic(bool y) 488void TextEdit::setItalic(bool y)
489{ 489{
490 QFont f = editor->font(); 490 QFont f = editor->font();
491 f.setItalic(y); 491 f.setItalic(y);
492 editor->setFont(f); 492 editor->setFont(f);
493} 493}
494 494
495void TextEdit::setWordWrap(bool y) 495void TextEdit::setWordWrap(bool y)
496{ 496{
497 bool state = editor->edited(); 497 bool state = editor->edited();
498 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 498 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
499 editor->setEdited( state ); 499 editor->setEdited( state );
500} 500}
501 501
502void TextEdit::fileNew() 502void TextEdit::fileNew()
503{ 503{
504// if( !bFromDocView ) { 504// if( !bFromDocView ) {
505// saveAs(); 505// saveAs();
506// } 506// }
507 newFile(DocLnk()); 507 newFile(DocLnk());
508} 508}
509 509
510void TextEdit::fileOpen() 510void TextEdit::fileOpen()
511{ 511{
512 Config cfg("TextEdit"); 512 Config cfg("TextEdit");
513 cfg.setGroup("View"); 513 cfg.setGroup("View");
514 bool b=FALSE; 514 bool b=FALSE;
515 515
516 QMap<QString, QStringList> map; 516 QMap<QString, QStringList> map;
517 map.insert(tr("All"), QStringList() ); 517 map.insert(tr("All"), QStringList() );
518 QStringList text; 518 QStringList text;
519 text << "text/*"; 519 text << "text/*";
520 map.insert(tr("Text"), text ); 520 map.insert(tr("Text"), text );
521 text << "*"; 521 text << "*";
522 map.insert(tr("All"), text ); 522 map.insert(tr("All"), text );
523 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map); 523 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map);
524 if(!str.isEmpty() ) 524 if(!str.isEmpty() )
525 openFile( str ); 525 openFile( str );
526 526
527} 527}
528 528
529void TextEdit::doSearchBar() 529void TextEdit::doSearchBar()
530{ 530{
531 Config cfg("TextEdit"); 531 Config cfg("TextEdit");
532 cfg.setGroup("View"); 532 cfg.setGroup("View");
533 if(cfg.readEntry("SearchBar","Closed") != "Opened") 533 if(cfg.readEntry("SearchBar","Closed") != "Opened")
534 searchBar->hide(); 534 searchBar->hide();
535} 535}
536 536
537#if 0 537#if 0
538void TextEdit::slotFind() 538void TextEdit::slotFind()
539{ 539{
540 FindDialog frmFind( tr("Text Editor"), this ); 540 FindDialog frmFind( tr("Text Editor"), this );
541 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 541 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
542 editor, SLOT(slotDoFind( const QString&,bool,bool))); 542 editor, SLOT(slotDoFind( const QString&,bool,bool)));
543 543
544 //case sensitive, backwards, [category] 544 //case sensitive, backwards, [category]
545 545
546 connect( editor, SIGNAL(notFound()), 546 connect( editor, SIGNAL(notFound()),
547 &frmFind, SLOT(slotNotFound()) ); 547 &frmFind, SLOT(slotNotFound()) );
548 connect( editor, SIGNAL(searchWrapped()), 548 connect( editor, SIGNAL(searchWrapped()),
549 &frmFind, SLOT(slotWrapAround()) ); 549 &frmFind, SLOT(slotWrapAround()) );
550 550
551 frmFind.exec(); 551 frmFind.exec();
552 552
553 553
554} 554}
555#endif 555#endif
556 556
557void TextEdit::fileRevert() 557void TextEdit::fileRevert()
558{ 558{
559 clear(); 559 clear();
560 fileOpen(); 560 fileOpen();
561} 561}
562 562
563void TextEdit::editCut() 563void TextEdit::editCut()
564{ 564{
565#ifndef QT_NO_CLIPBOARD 565#ifndef QT_NO_CLIPBOARD
566 editor->cut(); 566 editor->cut();
567#endif 567#endif
568} 568}
569 569
570void TextEdit::editCopy() 570void TextEdit::editCopy()
571{ 571{
572#ifndef QT_NO_CLIPBOARD 572#ifndef QT_NO_CLIPBOARD
573 editor->copy(); 573 editor->copy();
574#endif 574#endif
575} 575}
576 576
577void TextEdit::editPaste() 577void TextEdit::editPaste()
578{ 578{
579#ifndef QT_NO_CLIPBOARD 579#ifndef QT_NO_CLIPBOARD
580 editor->paste(); 580 editor->paste();
581#endif 581#endif
582} 582}
583 583
584void TextEdit::editFind() 584void TextEdit::editFind()
585{ 585{
586 searchBar->show(); 586 searchBar->show();
587 searchVisible = TRUE; 587 searchVisible = TRUE;
588 searchEdit->setFocus(); 588 searchEdit->setFocus();
589 Config cfg("TextEdit"); 589 Config cfg("TextEdit");
590 cfg.setGroup("View"); 590 cfg.setGroup("View");
591 cfg.writeEntry("SearchBar","Opened"); 591 cfg.writeEntry("SearchBar","Opened");
592 592
593} 593}
594 594
595void TextEdit::findNext() 595void TextEdit::findNext()
596{ 596{
597 editor->find( searchEdit->text(), FALSE, FALSE ); 597 editor->find( searchEdit->text(), FALSE, FALSE );
598 598
599} 599}
600 600
601void TextEdit::findClose() 601void TextEdit::findClose()
602{ 602{
603 searchVisible = FALSE; 603 searchVisible = FALSE;
604 searchBar->hide(); 604 searchBar->hide();
605 Config cfg("TextEdit"); 605 Config cfg("TextEdit");
606 cfg.setGroup("View"); 606 cfg.setGroup("View");
607 cfg.writeEntry("SearchBar","Closed"); 607 cfg.writeEntry("SearchBar","Closed");
608 cfg.write(); 608 cfg.write();
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 setWState (WState_Reserved1 ); 621 setWState (WState_Reserved1 );
622 editor->setFocus(); 622 editor->setFocus();
623 doc = new DocLnk(nf); 623 doc = new DocLnk(nf);
624 currentFileName = "Unnamed"; 624 currentFileName = "Unnamed";
625 qDebug("newFile "+currentFileName); 625 qDebug("newFile "+currentFileName);
626 updateCaption( currentFileName); 626 updateCaption( currentFileName);
627// editor->setEdited( FALSE); 627// editor->setEdited( FALSE);
628} 628}
629 629
630void TextEdit::openFile( const QString &f ) 630void TextEdit::openFile( const QString &f )
631{ 631{
632 qDebug("filename is "+ f); 632 qDebug("filename is "+ f);
633 QString filer; 633 QString filer;
634// bFromDocView = TRUE; 634// bFromDocView = TRUE;
635 if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) { 635 if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) {
636 switch ( QMessageBox::warning(this,tr("Text Editor"), 636 switch ( QMessageBox::warning(this,tr("Text Editor"),
637 tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), 637 tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"),
638 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 638 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
639 case 0: 639 case 0:
640 filer = f; 640 filer = f;
641 break; 641 break;
642 case 1: 642 case 1:
643 DocLnk sf(f); 643 DocLnk sf(f);
644 filer = sf.file(); 644 filer = sf.file();
645 break; 645 break;
646 } 646 }
647 } else { 647 } else {
648 filer = f; 648 filer = f;
649 fileIs = TRUE; 649 fileIs = TRUE;
650 } 650 }
651 651
652 DocLnk nf; 652 DocLnk nf;
653 nf.setType("text/plain"); 653 nf.setType("text/plain");
654 nf.setFile(filer); 654 nf.setFile(filer);
655 currentFileName=filer; 655 currentFileName=filer;
656 QFileInfo fi( currentFileName); 656 QFileInfo fi( currentFileName);
657 nf.setName(fi.baseName()); 657 nf.setName(fi.baseName());
658 qDebug("openFile string "+currentFileName); 658 qDebug("openFile string "+currentFileName);
659 659
660 openFile(nf); 660 openFile(nf);
661 showEditTools(); 661 showEditTools();
662 // Show filename in caption 662 // Show filename in caption
663 QString name = filer; 663 QString name = filer;
664 int sep = name.findRev( '/' ); 664 int sep = name.findRev( '/' );
665 if ( sep > 0 ) 665 if ( sep > 0 )
666 name = name.mid( sep+1 ); 666 name = name.mid( sep+1 );
667 updateCaption( name ); 667 updateCaption( name );
668} 668}
669 669
670void TextEdit::openFile( const DocLnk &f ) 670void TextEdit::openFile( const DocLnk &f )
671{ 671{
672// clear(); 672// clear();
673// bFromDocView = TRUE; 673// bFromDocView = TRUE;
674 FileManager fm; 674 FileManager fm;
675 QString txt; 675 QString txt;
676 currentFileName=f.file(); 676 currentFileName=f.file();
677 qDebug("openFile doclnk " + currentFileName); 677 qDebug("openFile doclnk " + currentFileName);
678 if ( !fm.loadFile( f, txt ) ) { 678 if ( !fm.loadFile( f, txt ) ) {
679 // ####### could be a new file 679 // ####### could be a new file
680 qDebug( "Cannot open file" ); 680 qDebug( "Cannot open file" );
681 } 681 }
682// fileNew(); 682// fileNew();
683 if ( doc ) 683 if ( doc )
684 delete doc; 684 delete doc;
685 doc = new DocLnk(f); 685 doc = new DocLnk(f);
686 editor->setText(txt); 686 editor->setText(txt);
687 editor->setEdited( FALSE); 687 editor->setEdited( FALSE);
688 edited1=FALSE; 688 edited1=FALSE;
689 edited=FALSE; 689 edited=FALSE;
690 690
691 doc->setName(currentFileName); 691 doc->setName(currentFileName);
692 updateCaption(); 692 updateCaption();
693} 693}
694 694
695void TextEdit::showEditTools() 695void TextEdit::showEditTools()
696{ 696{
697// if ( !doc ) 697// if ( !doc )
698// close(); 698// close();
699// clear(); 699// clear();
700 menu->show(); 700 menu->show();
701 editBar->show(); 701 editBar->show();
702 if ( searchVisible ) 702 if ( searchVisible )
703 searchBar->show(); 703 searchBar->show();
704// updateCaption(); 704// updateCaption();
705 setWState (WState_Reserved1 ); 705 setWState (WState_Reserved1 );
706} 706}
707 707
708/*! 708/*!
709 unprompted save */ 709 unprompted save */
710bool TextEdit::save() 710bool TextEdit::save()
711{ 711{
712 QString file = doc->file(); 712 QString file = doc->file();
713 qDebug("saver file "+file); 713 qDebug("saver file "+file);
714 QString name= doc->name(); 714 QString name= doc->name();
715 qDebug("File named "+name); 715 qDebug("File named "+name);
716 QString rt = editor->text(); 716 QString rt = editor->text();
717 if( !rt.isEmpty() ) { 717 if( !rt.isEmpty() ) {
718 if(name.isEmpty()) { 718 if(name.isEmpty()) {
719 saveAs(); 719 saveAs();
720 } else { 720 } else {
721 currentFileName= name ; 721 currentFileName= name ;
722 qDebug("saveFile "+currentFileName); 722 qDebug("saveFile "+currentFileName);
723 723
724 struct stat buf; 724 struct stat buf;
725 mode_t mode; 725 mode_t mode;
726 stat(file.latin1(), &buf); 726 stat(file.latin1(), &buf);
727 mode = buf.st_mode; 727 mode = buf.st_mode;
728 728
729 if(!fileIs) { 729 if(!fileIs) {
730 doc->setName( name); 730 doc->setName( name);
731 FileManager fm; 731 FileManager fm;
732 if ( !fm.saveFile( *doc, rt ) ) { 732 if ( !fm.saveFile( *doc, rt ) ) {
733 return false; 733 return false;
734 } 734 }
735 } else { 735 } else {
736 qDebug("regular save file"); 736 qDebug("regular save file");
737 QFile f(file); 737 QFile f(file);
738 if( f.open(IO_WriteOnly)) { 738 if( f.open(IO_WriteOnly)) {
739 QCString crt = rt.utf8(); 739 QCString crt = rt.utf8();
740 f.writeBlock(crt,crt.length()); 740 f.writeBlock(crt,crt.length());
741 } else { 741 } else {
742 QMessageBox::message("Text Edit","Write Failed"); 742 QMessageBox::message("Text Edit","Write Failed");
743 return false; 743 return false;
744 } 744 }
745 745
746 } 746 }
747 editor->setEdited( FALSE); 747 editor->setEdited( FALSE);
748 edited1=FALSE; 748 edited1=FALSE;
749 edited=FALSE; 749 edited=FALSE;
750 if(caption().left(1)=="*") 750 if(caption().left(1)=="*")
751 setCaption(caption().right(caption().length()-1)); 751 setCaption(caption().right(caption().length()-1));
752 752
753 753
754 chmod( file.latin1(), mode); 754 chmod( file.latin1(), mode);
755 } 755 }
756 return true; 756 return true;
757 } 757 }
758 return false; 758 return false;
759} 759}
760 760
761/*! 761/*!
762 prompted save */ 762 prompted save */
763bool TextEdit::saveAs() 763bool TextEdit::saveAs()
764{ 764{
765// qDebug("saveAsFile "+currentFileName); 765// qDebug("saveAsFile "+currentFileName);
766 // case of nothing to save... 766 // case of nothing to save...
767 if ( !doc )//|| !bFromDocView) 767 if ( !doc )//|| !bFromDocView)
768 { 768 {
769 qDebug("no doc"); 769 qDebug("no doc");
770 return true; 770 return true;
771 } 771 }
772 if ( !editor->edited() ) { 772 if ( !editor->edited() ) {
773 delete doc; 773 delete doc;
774 doc = 0; 774 doc = 0;
775 return true; 775 return true;
776 } 776 }
777 777
778 QString rt = editor->text(); 778 QString rt = editor->text();
779 qDebug(currentFileName); 779 qDebug(currentFileName);
780 780
781 if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { 781 if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) {
782 qDebug("do silly TT filename thing"); 782 qDebug("do silly TT filename thing");
783 if ( doc->name().isEmpty() ) { 783 if ( doc->name().isEmpty() ) {
784 QString pt = rt.simplifyWhiteSpace(); 784 QString pt = rt.simplifyWhiteSpace();
785 int i = pt.find( ' ' ); 785 int i = pt.find( ' ' );
786 QString docname = pt; 786 QString docname = pt;
787 if ( i > 0 ) 787 if ( i > 0 )
788 docname = pt.left( i ); 788 docname = pt.left( i );
789 // remove "." at the beginning 789 // remove "." at the beginning
790 while( docname.startsWith( "." ) ) 790 while( docname.startsWith( "." ) )
791 docname = docname.mid( 1 ); 791 docname = docname.mid( 1 );
792 docname.replace( QRegExp("/"), "_" ); 792 docname.replace( QRegExp("/"), "_" );
793 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 793 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
794 if ( docname.length() > 40 ) 794 if ( docname.length() > 40 )
795 docname = docname.left(40); 795 docname = docname.left(40);
796 if ( docname.isEmpty() ) 796 if ( docname.isEmpty() )
797 docname = tr("Unnamed"); 797 docname = tr("Unnamed");
798 doc->setName(docname); 798 doc->setName(docname);
799 currentFileName=docname; 799 currentFileName=docname;
800 } 800 }
801 } 801 }
802 802
803 QMap<QString, QStringList> map; 803 QMap<QString, QStringList> map;
804 map.insert(tr("All"), QStringList() ); 804 map.insert(tr("All"), QStringList() );
805 QStringList text; 805 QStringList text;
806 text << "text/*"; 806 text << "text/*";
807 map.insert(tr("Text"), text ); 807 map.insert(tr("Text"), text );
808 text << "*"; 808 text << "*";
809 map.insert(tr("All"), text ); 809 map.insert(tr("All"), text );
810 QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map); 810 QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map);
811 if(!str.isEmpty() ) { 811 if(!str.isEmpty() ) {
812 QString fileNm=str; 812 QString fileNm=str;
813 813
814 qDebug("saving filename "+fileNm); 814 qDebug("saving filename "+fileNm);
815 QFileInfo fi(fileNm); 815 QFileInfo fi(fileNm);
816 currentFileName=fi.fileName(); 816 currentFileName=fi.fileName();
817 if(doc) { 817 if(doc) {
818// QString file = doc->file(); 818// QString file = doc->file();
819// doc->removeFiles(); 819// doc->removeFiles();
820 delete doc; 820 delete doc;
821 DocLnk nf; 821 DocLnk nf;
822 nf.setType("text/plain"); 822 nf.setType("text/plain");
823 nf.setFile( fileNm); 823 nf.setFile( fileNm);
824 doc = new DocLnk(nf); 824 doc = new DocLnk(nf);
825// editor->setText(rt); 825// editor->setText(rt);
826// qDebug("openFile doclnk "+currentFileName); 826// qDebug("openFile doclnk "+currentFileName);
827 doc->setName( currentFileName); 827 doc->setName( currentFileName);
828 updateCaption( currentFileName); 828 updateCaption( currentFileName);
829 829
830 FileManager fm; 830 FileManager fm;
831 if ( !fm.saveFile( *doc, rt ) ) { 831 if ( !fm.saveFile( *doc, rt ) ) {
832 return false; 832 return false;
833 } 833 }
834 834
835 if( useAdvancedFfeatures ) { 835 if( useAdvancedFeatures ) {
836 filePermissions *filePerm; 836 filePermissions *filePerm;
837 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); 837 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm);
838 filePerm->exec(); 838 filePerm->exec();
839 839
840 if( filePerm) 840 if( filePerm)
841 delete filePerm; 841 delete filePerm;
842 } 842 }
843 } 843 }
844 } 844 }
845 editor->setEdited(TRUE); 845 editor->setEdited(TRUE);
846 edited1=FALSE; 846 edited1=FALSE;
847 edited=TRUE; 847 edited=TRUE;
848 if(caption().left(1)=="*") 848 if(caption().left(1)=="*")
849 setCaption(caption().right(caption().length()-1)); 849 setCaption(caption().right(caption().length()-1));
850 850
851 return true; 851 return true;
852} //end saveAs 852} //end saveAs
853 853
854void TextEdit::clear() 854void TextEdit::clear()
855{ 855{
856 delete doc; 856 delete doc;
857 doc = 0; 857 doc = 0;
858 editor->clear(); 858 editor->clear();
859} 859}
860 860
861void TextEdit::updateCaption( const QString &name ) 861void TextEdit::updateCaption( const QString &name )
862{ 862{
863 if ( !doc ) 863 if ( !doc )
864 setCaption( tr("Text Editor") ); 864 setCaption( tr("Text Editor") );
865 else { 865 else {
866 QString s = name; 866 QString s = name;
867 if ( s.isNull() ) 867 if ( s.isNull() )
868 s = doc->name(); 868 s = doc->name();
869 if ( s.isEmpty() ) { 869 if ( s.isEmpty() ) {
870 s = tr( "Unnamed" ); 870 s = tr( "Unnamed" );
871 currentFileName=s; 871 currentFileName=s;
872 } 872 }
873 if(s.left(1) == "/") 873 if(s.left(1) == "/")
874 s = s.right(s.length()-1); 874 s = s.right(s.length()-1);
875 setCaption( s + " - " + tr("Text Editor") ); 875 setCaption( s + " - " + tr("Text Editor") );
876 } 876 }
877} 877}
878 878
879void TextEdit::setDocument(const QString& fileref) 879void TextEdit::setDocument(const QString& fileref)
880{ 880{
881 bFromDocView = TRUE; 881 bFromDocView = TRUE;
882 openFile(fileref); 882 openFile(fileref);
883 editor->setEdited(TRUE); 883 editor->setEdited(TRUE);
884 edited1=FALSE; 884 edited1=FALSE;
885 edited=TRUE; 885 edited=TRUE;
886 doSearchBar(); 886 doSearchBar();
887} 887}
888 888
889void TextEdit::closeEvent( QCloseEvent *e ) 889void TextEdit::closeEvent( QCloseEvent *e )
890{ 890{
891 bFromDocView = FALSE; 891 bFromDocView = FALSE;
892 e->accept(); 892 e->accept();
893} 893}
894 894
895void TextEdit::accept() 895void TextEdit::accept()
896 { 896 {
897 //if(caption() !="Unnamed") 897 //if(caption() !="Unnamed")
898 if(edited1) 898 if(edited1)
899 saveAs(); 899 saveAs();
900 exit(0); 900 exit(0);
901 901
902} 902}
903 903
904void TextEdit::changeFont() { 904void TextEdit::changeFont() {
905 FontDatabase fdb; 905 FontDatabase fdb;
906 QFont defaultFont=editor->font(); 906 QFont defaultFont=editor->font();
907 QFontInfo fontInfo(defaultFont); 907 QFontInfo fontInfo(defaultFont);
908 Config cfg("TextEdit"); 908 Config cfg("TextEdit");
909 cfg.setGroup("Font"); 909 cfg.setGroup("Font");
910 QString family = cfg.readEntry("Family", fontInfo.family()); 910 QString family = cfg.readEntry("Family", fontInfo.family());
911 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 911 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
912 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 912 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
913 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 913 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
914 914
915 defaultFont = fdb.font(family,style,i_size,charSet); 915 defaultFont = fdb.font(family,style,i_size,charSet);
916 916
917 FontDialog *fontDlg; 917 FontDialog *fontDlg;
918 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); 918 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE);
919 919
920 fontDlg->exec(); 920 fontDlg->exec();
921 921
922 QFont myFont=fontDlg->selectedFont; 922 QFont myFont=fontDlg->selectedFont;
923 editor->setFont( myFont); 923 editor->setFont( myFont);
924 delete fontDlg; 924 delete fontDlg;
925 925
926} 926}
927 927
928void TextEdit::editDelete() 928void TextEdit::editDelete()
929{ 929{
930 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) { 930 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) {
931 case 0: 931 case 0:
932 if(doc) { 932 if(doc) {
933 doc->removeFiles(); 933 doc->removeFiles();
934 clear(); 934 clear();
935 setCaption( tr("Text Editor") ); 935 setCaption( tr("Text Editor") );
936 } 936 }
937 break; 937 break;
938 case 1: 938 case 1:
939 // exit 939 // exit
940 break; 940 break;
941 }; 941 };
942} 942}
943 943
944void TextEdit::changeStartConfig( bool b ) { 944void TextEdit::changeStartConfig( bool b ) {
945 945
946 Config cfg("TextEdit"); 946 Config cfg("TextEdit");
947 cfg.setGroup("View"); 947 cfg.setGroup("View");
948 if(b) { 948 if(b) {
949 qDebug("bool"); 949 qDebug("bool");
950 cfg.writeEntry("startNew","TRUE"); 950 cfg.writeEntry("startNew","TRUE");
951 } else { 951 } else {
952 cfg.writeEntry("startNew","FALSE"); 952 cfg.writeEntry("startNew","FALSE");
953 } 953 }
954 update(); 954 update();
955} 955}
956 956
957void TextEdit::editorChanged() { 957void TextEdit::editorChanged() {
958 if(editor->edited() && edited && !edited1) { 958 if(editor->edited() && edited && !edited1) {
959 setCaption( "*"+caption()); 959 setCaption( "*"+caption());
960 edited1=TRUE; 960 edited1=TRUE;
961 } 961 }
962 edited=TRUE; 962 edited=TRUE;
963} 963}
964 964
965void TextEdit::receive(const QCString&msg, const QByteArray&) { 965void TextEdit::receive(const QCString&msg, const QByteArray&) {
966 qDebug("QCop "+msg); 966 qDebug("QCop "+msg);
967 if ( msg == "setDocument(QString)" ) { 967 if ( msg == "setDocument(QString)" ) {
968 qDebug("bugger all"); 968 qDebug("bugger all");
969 } 969 }
970 970
971} 971}
972void TextEdit::doAbout() { 972void TextEdit::doAbout() {
973 QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" 973 QMessageBox::about(0,"Text Edit","Text Edit is copyright\n"
974 "2000 Trolltech AS, and\n" 974 "2000 Trolltech AS, and\n"
975 "2002 by L.J.Potter \nljp@llornkcor.com\n" 975 "2002 by L.J.Potter \nljp@llornkcor.com\n"
976 "and is licensed under the GPL"); 976 "and is licensed under the GPL");
977} 977}
978 978
979void TextEdit::doAdvanced(bool b) { 979void TextEdit::doAdvanced(bool b) {
980 useAdvancedFeatures=b; 980 useAdvancedFeatures=b;
981 Config cfg("TextEdit"); 981 Config cfg("TextEdit");
982 cfg.setGroup("View"); 982 cfg.setGroup("View");
983 cfg.writeEntry("AdvancedFeatures",b); 983 cfg.writeEntry("AdvancedFeatures",b);
984} 984}