-rw-r--r-- | core/apps/textedit/textedit.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 35f9d3c..209c5de 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -446,193 +446,193 @@ void TextEdit::cleanUp() { | |||
446 | 446 | ||
447 | Config cfg ( "TextEdit" ); | 447 | Config cfg ( "TextEdit" ); |
448 | cfg. setGroup ( "Font" ); | 448 | cfg. setGroup ( "Font" ); |
449 | QFont f = editor->font(); | 449 | QFont f = editor->font(); |
450 | cfg. writeEntry ( "Family", f. family ( )); | 450 | cfg. writeEntry ( "Family", f. family ( )); |
451 | cfg. writeEntry ( "Size", f. pointSize ( )); | 451 | cfg. writeEntry ( "Size", f. pointSize ( )); |
452 | cfg. writeEntry ( "Weight", f. weight ( )); | 452 | cfg. writeEntry ( "Weight", f. weight ( )); |
453 | cfg. writeEntry ( "Italic", f. italic ( )); | 453 | cfg. writeEntry ( "Italic", f. italic ( )); |
454 | 454 | ||
455 | cfg. setGroup ( "View" ); | 455 | cfg. setGroup ( "View" ); |
456 | cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); | 456 | cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); |
457 | cfg. writeEntry ( "FileView", viewSelection ); | 457 | cfg. writeEntry ( "FileView", viewSelection ); |
458 | 458 | ||
459 | cfg. writeEntry ( "PromptExit", promptExit ); | 459 | cfg. writeEntry ( "PromptExit", promptExit ); |
460 | cfg. writeEntry ( "OpenDesktop", openDesktop ); | 460 | cfg. writeEntry ( "OpenDesktop", openDesktop ); |
461 | cfg. writeEntry ( "FilePermissions", filePerms ); | 461 | cfg. writeEntry ( "FilePermissions", filePerms ); |
462 | } | 462 | } |
463 | 463 | ||
464 | 464 | ||
465 | void TextEdit::accept() { | 465 | void TextEdit::accept() { |
466 | if( edited1) | 466 | if( edited1) |
467 | saveAs(); | 467 | saveAs(); |
468 | exit(0); | 468 | exit(0); |
469 | } | 469 | } |
470 | 470 | ||
471 | void TextEdit::zoomIn() { | 471 | void TextEdit::zoomIn() { |
472 | setFontSize(editor->font().pointSize()+1,FALSE); | 472 | setFontSize(editor->font().pointSize()+1,FALSE); |
473 | } | 473 | } |
474 | 474 | ||
475 | void TextEdit::zoomOut() { | 475 | void TextEdit::zoomOut() { |
476 | setFontSize(editor->font().pointSize()-1,TRUE); | 476 | setFontSize(editor->font().pointSize()-1,TRUE); |
477 | } | 477 | } |
478 | 478 | ||
479 | 479 | ||
480 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 480 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
481 | int s=10; | 481 | int s=10; |
482 | for (int i=0; i<nfontsizes; i++) { | 482 | for (int i=0; i<nfontsizes; i++) { |
483 | if ( fontsize[i] == sz ) { | 483 | if ( fontsize[i] == sz ) { |
484 | s = sz; | 484 | s = sz; |
485 | break; | 485 | break; |
486 | } else if ( round_down_not_up ) { | 486 | } else if ( round_down_not_up ) { |
487 | if ( fontsize[i] < sz ) | 487 | if ( fontsize[i] < sz ) |
488 | s = fontsize[i]; | 488 | s = fontsize[i]; |
489 | } else { | 489 | } else { |
490 | if ( fontsize[i] > sz ) { | 490 | if ( fontsize[i] > sz ) { |
491 | s = fontsize[i]; | 491 | s = fontsize[i]; |
492 | break; | 492 | break; |
493 | } | 493 | } |
494 | } | 494 | } |
495 | } | 495 | } |
496 | 496 | ||
497 | QFont f = editor->font(); | 497 | QFont f = editor->font(); |
498 | f.setPointSize(s); | 498 | f.setPointSize(s); |
499 | editor->setFont(f); | 499 | editor->setFont(f); |
500 | 500 | ||
501 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 501 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
502 | zout->setEnabled(s != fontsize[0]); | 502 | zout->setEnabled(s != fontsize[0]); |
503 | } | 503 | } |
504 | 504 | ||
505 | void TextEdit::setBold(bool y) { | 505 | void TextEdit::setBold(bool y) { |
506 | QFont f = editor->font(); | 506 | QFont f = editor->font(); |
507 | f.setBold(y); | 507 | f.setBold(y); |
508 | editor->setFont(f); | 508 | editor->setFont(f); |
509 | } | 509 | } |
510 | 510 | ||
511 | void TextEdit::setItalic(bool y) { | 511 | void TextEdit::setItalic(bool y) { |
512 | QFont f = editor->font(); | 512 | QFont f = editor->font(); |
513 | f.setItalic(y); | 513 | f.setItalic(y); |
514 | editor->setFont(f); | 514 | editor->setFont(f); |
515 | } | 515 | } |
516 | 516 | ||
517 | void TextEdit::setWordWrap(bool y) { | 517 | void TextEdit::setWordWrap(bool y) { |
518 | bool state = editor->edited(); | 518 | bool state = editor->edited(); |
519 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 519 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
520 | editor->setEdited( state ); | 520 | editor->setEdited( state ); |
521 | } | 521 | } |
522 | 522 | ||
523 | void TextEdit::fileNew() { | 523 | void TextEdit::fileNew() { |
524 | // if( !bFromDocView ) { | 524 | // if( !bFromDocView ) { |
525 | // saveAs(); | 525 | // saveAs(); |
526 | // } | 526 | // } |
527 | newFile(DocLnk()); | 527 | newFile(DocLnk()); |
528 | } | 528 | } |
529 | 529 | ||
530 | void TextEdit::fileOpen() { | 530 | void TextEdit::fileOpen() { |
531 | Config cfg("TextEdit"); | 531 | Config cfg("TextEdit"); |
532 | cfg.setGroup("View"); | 532 | cfg.setGroup("View"); |
533 | // bool b=FALSE; | 533 | // bool b=FALSE; |
534 | 534 | ||
535 | QMap<QString, QStringList> map; | 535 | QMap<QString, QStringList> map; |
536 | map.insert(tr("All"), QStringList() ); | 536 | map.insert(tr("All"), QStringList() ); |
537 | QStringList text; | 537 | QStringList text; |
538 | text << "text/*"; | 538 | text << "text/*"; |
539 | map.insert(tr("Text"), text ); | 539 | map.insert(tr("Text"), text ); |
540 | text << "*"; | 540 | text << "*"; |
541 | map.insert(tr("All"), text ); | 541 | map.insert(tr("All"), text ); |
542 | QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map); | 542 | QString str = OFileDialog::getOpenFileName( 2, QPEApplication::documentDir(), QString::null, map); |
543 | if(!str.isEmpty() ) | 543 | if(!str.isEmpty() ) |
544 | openFile( str ); | 544 | openFile( str ); |
545 | 545 | ||
546 | } | 546 | } |
547 | 547 | ||
548 | void TextEdit::doSearchBar() { | 548 | void TextEdit::doSearchBar() { |
549 | Config cfg("TextEdit"); | 549 | Config cfg("TextEdit"); |
550 | cfg.setGroup("View"); | 550 | cfg.setGroup("View"); |
551 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 551 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
552 | searchBar->hide(); | 552 | searchBar->hide(); |
553 | } | 553 | } |
554 | 554 | ||
555 | #if 0 | 555 | #if 0 |
556 | void TextEdit::slotFind() { | 556 | void TextEdit::slotFind() { |
557 | FindDialog frmFind( tr("Text Editor"), this ); | 557 | FindDialog frmFind( tr("Text Editor"), this ); |
558 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 558 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
559 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 559 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
560 | 560 | ||
561 | //case sensitive, backwards, [category] | 561 | //case sensitive, backwards, [category] |
562 | 562 | ||
563 | connect( editor, SIGNAL(notFound()), | 563 | connect( editor, SIGNAL(notFound()), |
564 | &frmFind, SLOT(slotNotFound()) ); | 564 | &frmFind, SLOT(slotNotFound()) ); |
565 | connect( editor, SIGNAL(searchWrapped()), | 565 | connect( editor, SIGNAL(searchWrapped()), |
566 | &frmFind, SLOT(slotWrapAround()) ); | 566 | &frmFind, SLOT(slotWrapAround()) ); |
567 | 567 | ||
568 | frmFind.exec(); | 568 | frmFind.exec(); |
569 | 569 | ||
570 | 570 | ||
571 | } | 571 | } |
572 | #endif | 572 | #endif |
573 | 573 | ||
574 | void TextEdit::fileRevert() { | 574 | void TextEdit::fileRevert() { |
575 | clear(); | 575 | clear(); |
576 | fileOpen(); | 576 | fileOpen(); |
577 | } | 577 | } |
578 | 578 | ||
579 | void TextEdit::editCut() { | 579 | void TextEdit::editCut() { |
580 | #ifndef QT_NO_CLIPBOARD | 580 | #ifndef QT_NO_CLIPBOARD |
581 | editor->cut(); | 581 | editor->cut(); |
582 | #endif | 582 | #endif |
583 | } | 583 | } |
584 | 584 | ||
585 | void TextEdit::editCopy() { | 585 | void TextEdit::editCopy() { |
586 | #ifndef QT_NO_CLIPBOARD | 586 | #ifndef QT_NO_CLIPBOARD |
587 | editor->copy(); | 587 | editor->copy(); |
588 | #endif | 588 | #endif |
589 | } | 589 | } |
590 | 590 | ||
591 | void TextEdit::editPaste() { | 591 | void TextEdit::editPaste() { |
592 | #ifndef QT_NO_CLIPBOARD | 592 | #ifndef QT_NO_CLIPBOARD |
593 | editor->paste(); | 593 | editor->paste(); |
594 | #endif | 594 | #endif |
595 | } | 595 | } |
596 | 596 | ||
597 | void TextEdit::editFind() { | 597 | void TextEdit::editFind() { |
598 | searchBar->show(); | 598 | searchBar->show(); |
599 | searchVisible = TRUE; | 599 | searchVisible = TRUE; |
600 | searchEdit->setFocus(); | 600 | searchEdit->setFocus(); |
601 | Config cfg("TextEdit"); | 601 | Config cfg("TextEdit"); |
602 | cfg.setGroup("View"); | 602 | cfg.setGroup("View"); |
603 | cfg.writeEntry("SearchBar","Opened"); | 603 | cfg.writeEntry("SearchBar","Opened"); |
604 | 604 | ||
605 | } | 605 | } |
606 | 606 | ||
607 | void TextEdit::findNext() { | 607 | void TextEdit::findNext() { |
608 | editor->find( searchEdit->text(), FALSE, FALSE ); | 608 | editor->find( searchEdit->text(), FALSE, FALSE ); |
609 | 609 | ||
610 | } | 610 | } |
611 | 611 | ||
612 | void TextEdit::findClose() { | 612 | void TextEdit::findClose() { |
613 | searchVisible = FALSE; | 613 | searchVisible = FALSE; |
614 | searchBar->hide(); | 614 | searchBar->hide(); |
615 | Config cfg("TextEdit"); | 615 | Config cfg("TextEdit"); |
616 | cfg.setGroup("View"); | 616 | cfg.setGroup("View"); |
617 | cfg.writeEntry("SearchBar","Closed"); | 617 | cfg.writeEntry("SearchBar","Closed"); |
618 | cfg.write(); | 618 | cfg.write(); |
619 | } | 619 | } |
620 | 620 | ||
621 | void TextEdit::search() { | 621 | void TextEdit::search() { |
622 | editor->find( searchEdit->text(), FALSE, FALSE ); | 622 | editor->find( searchEdit->text(), FALSE, FALSE ); |
623 | } | 623 | } |
624 | 624 | ||
625 | void TextEdit::newFile( const DocLnk &f ) { | 625 | void TextEdit::newFile( const DocLnk &f ) { |
626 | DocLnk nf = f; | 626 | DocLnk nf = f; |
627 | nf.setType("text/plain"); | 627 | nf.setType("text/plain"); |
628 | clear(); | 628 | clear(); |
629 | setWState (WState_Reserved1 ); | 629 | setWState (WState_Reserved1 ); |
630 | editor->setFocus(); | 630 | editor->setFocus(); |
631 | doc = new DocLnk(nf); | 631 | doc = new DocLnk(nf); |
632 | currentFileName = "Unnamed"; | 632 | currentFileName = "Unnamed"; |
633 | qDebug("newFile "+currentFileName); | 633 | qDebug("newFile "+currentFileName); |
634 | updateCaption( currentFileName); | 634 | updateCaption( currentFileName); |
635 | // editor->setEdited( FALSE); | 635 | // editor->setEdited( FALSE); |
636 | } | 636 | } |
637 | 637 | ||
638 | void TextEdit::openFile( const QString &f ) { | 638 | void TextEdit::openFile( const QString &f ) { |
@@ -721,193 +721,193 @@ bool TextEdit::save() { | |||
721 | QString name= doc->name(); | 721 | QString name= doc->name(); |
722 | qDebug("File named "+name); | 722 | qDebug("File named "+name); |
723 | QString rt = editor->text(); | 723 | QString rt = editor->text(); |
724 | if( !rt.isEmpty() ) { | 724 | if( !rt.isEmpty() ) { |
725 | if(name.isEmpty()) { | 725 | if(name.isEmpty()) { |
726 | saveAs(); | 726 | saveAs(); |
727 | } else { | 727 | } else { |
728 | currentFileName= name ; | 728 | currentFileName= name ; |
729 | qDebug("saveFile "+currentFileName); | 729 | qDebug("saveFile "+currentFileName); |
730 | 730 | ||
731 | struct stat buf; | 731 | struct stat buf; |
732 | mode_t mode; | 732 | mode_t mode; |
733 | stat(file.latin1(), &buf); | 733 | stat(file.latin1(), &buf); |
734 | mode = buf.st_mode; | 734 | mode = buf.st_mode; |
735 | 735 | ||
736 | if(!fileIs) { | 736 | if(!fileIs) { |
737 | doc->setName( name); | 737 | doc->setName( name); |
738 | FileManager fm; | 738 | FileManager fm; |
739 | if ( !fm.saveFile( *doc, rt ) ) { | 739 | if ( !fm.saveFile( *doc, rt ) ) { |
740 | return false; | 740 | return false; |
741 | } | 741 | } |
742 | } else { | 742 | } else { |
743 | qDebug("regular save file"); | 743 | qDebug("regular save file"); |
744 | QFile f(file); | 744 | QFile f(file); |
745 | if( f.open(IO_WriteOnly)) { | 745 | if( f.open(IO_WriteOnly)) { |
746 | QCString crt = rt.utf8(); | 746 | QCString crt = rt.utf8(); |
747 | f.writeBlock(crt,crt.length()); | 747 | f.writeBlock(crt,crt.length()); |
748 | } else { | 748 | } else { |
749 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 749 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
750 | return false; | 750 | return false; |
751 | } | 751 | } |
752 | 752 | ||
753 | } | 753 | } |
754 | editor->setEdited( FALSE); | 754 | editor->setEdited( FALSE); |
755 | edited1=FALSE; | 755 | edited1=FALSE; |
756 | edited=FALSE; | 756 | edited=FALSE; |
757 | if(caption().left(1)=="*") | 757 | if(caption().left(1)=="*") |
758 | setCaption(caption().right(caption().length()-1)); | 758 | setCaption(caption().right(caption().length()-1)); |
759 | 759 | ||
760 | 760 | ||
761 | chmod( file.latin1(), mode); | 761 | chmod( file.latin1(), mode); |
762 | } | 762 | } |
763 | return true; | 763 | return true; |
764 | } | 764 | } |
765 | return false; | 765 | return false; |
766 | } | 766 | } |
767 | 767 | ||
768 | /*! | 768 | /*! |
769 | prompted save */ | 769 | prompted save */ |
770 | bool TextEdit::saveAs() { | 770 | bool TextEdit::saveAs() { |
771 | qDebug("saveAsFile "+currentFileName); | 771 | qDebug("saveAsFile "+currentFileName); |
772 | // case of nothing to save... | 772 | // case of nothing to save... |
773 | if ( !doc ) { | 773 | if ( !doc ) { |
774 | //|| !bFromDocView) | 774 | //|| !bFromDocView) |
775 | qDebug("no doc"); | 775 | qDebug("no doc"); |
776 | return true; | 776 | return true; |
777 | } | 777 | } |
778 | if ( !editor->edited() ) { | 778 | if ( !editor->edited() ) { |
779 | delete doc; | 779 | delete doc; |
780 | doc = 0; | 780 | doc = 0; |
781 | return true; | 781 | return true; |
782 | } | 782 | } |
783 | 783 | ||
784 | QString rt = editor->text(); | 784 | QString rt = editor->text(); |
785 | qDebug(currentFileName); | 785 | qDebug(currentFileName); |
786 | 786 | ||
787 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { | 787 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { |
788 | // qDebug("do silly TT filename thing"); | 788 | // qDebug("do silly TT filename thing"); |
789 | if ( doc->name().isEmpty() ) { | 789 | if ( doc->name().isEmpty() ) { |
790 | QString pt = rt.simplifyWhiteSpace(); | 790 | QString pt = rt.simplifyWhiteSpace(); |
791 | int i = pt.find( ' ' ); | 791 | int i = pt.find( ' ' ); |
792 | QString docname = pt; | 792 | QString docname = pt; |
793 | if ( i > 0 ) | 793 | if ( i > 0 ) |
794 | docname = pt.left( i ); | 794 | docname = pt.left( i ); |
795 | // remove "." at the beginning | 795 | // remove "." at the beginning |
796 | while( docname.startsWith( "." ) ) | 796 | while( docname.startsWith( "." ) ) |
797 | docname = docname.mid( 1 ); | 797 | docname = docname.mid( 1 ); |
798 | docname.replace( QRegExp("/"), "_" ); | 798 | docname.replace( QRegExp("/"), "_" ); |
799 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 799 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
800 | if ( docname.length() > 40 ) | 800 | if ( docname.length() > 40 ) |
801 | docname = docname.left(40); | 801 | docname = docname.left(40); |
802 | if ( docname.isEmpty() ) | 802 | if ( docname.isEmpty() ) |
803 | docname = tr("Unnamed"); | 803 | docname = tr("Unnamed"); |
804 | doc->setName(docname); | 804 | doc->setName(docname); |
805 | currentFileName=docname; | 805 | currentFileName=docname; |
806 | } | 806 | } |
807 | } | 807 | } |
808 | 808 | ||
809 | QMap<QString, QStringList> map; | 809 | QMap<QString, QStringList> map; |
810 | map.insert(tr("All"), QStringList() ); | 810 | map.insert(tr("All"), QStringList() ); |
811 | QStringList text; | 811 | QStringList text; |
812 | text << "text/*"; | 812 | text << "text/*"; |
813 | map.insert(tr("Text"), text ); | 813 | map.insert(tr("Text"), text ); |
814 | text << "*"; | 814 | text << "*"; |
815 | map.insert(tr("All"), text ); | 815 | map.insert(tr("All"), text ); |
816 | 816 | ||
817 | QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map); | 817 | QString str = OFileDialog::getSaveFileName( 2,QPEApplication::documentDir(), QString::null, map); |
818 | 818 | ||
819 | if(!str.isEmpty() ) { | 819 | if(!str.isEmpty() ) { |
820 | QString fileNm=str; | 820 | QString fileNm=str; |
821 | 821 | ||
822 | qDebug("saving filename "+fileNm); | 822 | qDebug("saving filename "+fileNm); |
823 | QFileInfo fi(fileNm); | 823 | QFileInfo fi(fileNm); |
824 | currentFileName=fi.fileName(); | 824 | currentFileName=fi.fileName(); |
825 | if(doc) { | 825 | if(doc) { |
826 | // QString file = doc->file(); | 826 | // QString file = doc->file(); |
827 | // doc->removeFiles(); | 827 | // doc->removeFiles(); |
828 | delete doc; | 828 | delete doc; |
829 | DocLnk nf; | 829 | DocLnk nf; |
830 | nf.setType("text/plain"); | 830 | nf.setType("text/plain"); |
831 | nf.setFile( fileNm); | 831 | nf.setFile( fileNm); |
832 | doc = new DocLnk(nf); | 832 | doc = new DocLnk(nf); |
833 | // editor->setText(rt); | 833 | // editor->setText(rt); |
834 | // qDebug("openFile doclnk "+currentFileName); | 834 | // qDebug("openFile doclnk "+currentFileName); |
835 | doc->setName( currentFileName); | 835 | doc->setName( currentFileName); |
836 | updateCaption( currentFileName); | 836 | updateCaption( currentFileName); |
837 | 837 | ||
838 | FileManager fm; | 838 | FileManager fm; |
839 | if ( !fm.saveFile( *doc, rt ) ) { | 839 | if ( !fm.saveFile( *doc, rt ) ) { |
840 | return false; | 840 | return false; |
841 | } | 841 | } |
842 | 842 | ||
843 | if( filePerms ) { | 843 | if( filePerms ) { |
844 | filePermissions *filePerm; | 844 | filePermissions *filePerm; |
845 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); | 845 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); |
846 | filePerm->showMaximized(); | 846 | filePerm->showMaximized(); |
847 | filePerm->exec(); | 847 | filePerm->exec(); |
848 | 848 | ||
849 | if( filePerm) | 849 | if( filePerm) |
850 | delete filePerm; | 850 | delete filePerm; |
851 | } | 851 | } |
852 | } | 852 | } |
853 | editor->setEdited( false); | 853 | editor->setEdited( false); |
854 | edited1 = false; | 854 | edited1 = false; |
855 | edited = false; | 855 | edited = false; |
856 | if(caption().left(1)=="*") | 856 | if(caption().left(1)=="*") |
857 | setCaption(caption().right(caption().length()-1)); | 857 | setCaption(caption().right(caption().length()-1)); |
858 | 858 | ||
859 | return true; | 859 | return true; |
860 | } | 860 | } |
861 | qDebug("returning false"); | 861 | qDebug("returning false"); |
862 | return false; | 862 | return false; |
863 | } //end saveAs | 863 | } //end saveAs |
864 | 864 | ||
865 | void TextEdit::clear() { | 865 | void TextEdit::clear() { |
866 | delete doc; | 866 | delete doc; |
867 | doc = 0; | 867 | doc = 0; |
868 | editor->clear(); | 868 | editor->clear(); |
869 | } | 869 | } |
870 | 870 | ||
871 | void TextEdit::updateCaption( const QString &name ) { | 871 | void TextEdit::updateCaption( const QString &name ) { |
872 | if ( !doc ) | 872 | if ( !doc ) |
873 | setCaption( tr("Text Editor") ); | 873 | setCaption( tr("Text Editor") ); |
874 | else { | 874 | else { |
875 | QString s = name; | 875 | QString s = name; |
876 | if ( s.isNull() ) | 876 | if ( s.isNull() ) |
877 | s = doc->name(); | 877 | s = doc->name(); |
878 | if ( s.isEmpty() ) { | 878 | if ( s.isEmpty() ) { |
879 | s = tr( "Unnamed" ); | 879 | s = tr( "Unnamed" ); |
880 | currentFileName=s; | 880 | currentFileName=s; |
881 | } | 881 | } |
882 | if(s.left(1) == "/") | 882 | if(s.left(1) == "/") |
883 | s = s.right(s.length()-1); | 883 | s = s.right(s.length()-1); |
884 | setCaption( s + " - " + tr("Text Editor") ); | 884 | setCaption( s + " - " + tr("Text Editor") ); |
885 | } | 885 | } |
886 | } | 886 | } |
887 | 887 | ||
888 | void TextEdit::setDocument(const QString& fileref) { | 888 | void TextEdit::setDocument(const QString& fileref) { |
889 | bFromDocView = TRUE; | 889 | bFromDocView = TRUE; |
890 | openFile(fileref); | 890 | openFile(fileref); |
891 | editor->setEdited(TRUE); | 891 | editor->setEdited(TRUE); |
892 | edited1=FALSE; | 892 | edited1=FALSE; |
893 | edited=TRUE; | 893 | edited=TRUE; |
894 | doSearchBar(); | 894 | doSearchBar(); |
895 | } | 895 | } |
896 | 896 | ||
897 | void TextEdit::closeEvent( QCloseEvent *e ) { | 897 | void TextEdit::closeEvent( QCloseEvent *e ) { |
898 | bFromDocView = FALSE; | 898 | bFromDocView = FALSE; |
899 | e->accept(); | 899 | e->accept(); |
900 | } | 900 | } |
901 | 901 | ||
902 | void TextEdit::changeFont() { | 902 | void TextEdit::changeFont() { |
903 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 903 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
904 | d-> setCaption ( tr( "Choose font" )); | 904 | d-> setCaption ( tr( "Choose font" )); |
905 | QBoxLayout *lay = new QVBoxLayout ( d ); | 905 | QBoxLayout *lay = new QVBoxLayout ( d ); |
906 | OFontSelector *ofs = new OFontSelector ( true, d ); | 906 | OFontSelector *ofs = new OFontSelector ( true, d ); |
907 | lay-> addWidget ( ofs ); | 907 | lay-> addWidget ( ofs ); |
908 | ofs-> setSelectedFont ( editor-> font ( )); | 908 | ofs-> setSelectedFont ( editor-> font ( )); |
909 | 909 | ||
910 | d-> showMaximized ( ); | 910 | d-> showMaximized ( ); |
911 | if ( d-> exec ( ) == QDialog::Accepted ) | 911 | if ( d-> exec ( ) == QDialog::Accepted ) |
912 | editor-> setFont ( ofs-> selectedFont ( )); | 912 | editor-> setFont ( ofs-> selectedFont ( )); |
913 | delete d; | 913 | delete d; |