-rw-r--r-- | core/apps/textedit/textedit.cpp | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 21bf4b3..6f96574 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -605,196 +605,193 @@ void TextEdit::slotFind() { | |||
605 | //case sensitive, backwards, [category] | 605 | //case sensitive, backwards, [category] |
606 | 606 | ||
607 | connect( editor, SIGNAL(notFound()), | 607 | connect( editor, SIGNAL(notFound()), |
608 | &frmFind, SLOT(slotNotFound()) ); | 608 | &frmFind, SLOT(slotNotFound()) ); |
609 | connect( editor, SIGNAL(searchWrapped()), | 609 | connect( editor, SIGNAL(searchWrapped()), |
610 | &frmFind, SLOT(slotWrapAround()) ); | 610 | &frmFind, SLOT(slotWrapAround()) ); |
611 | 611 | ||
612 | frmFind.exec(); | 612 | frmFind.exec(); |
613 | 613 | ||
614 | 614 | ||
615 | } | 615 | } |
616 | #endif | 616 | #endif |
617 | 617 | ||
618 | void TextEdit::fileRevert() { | 618 | void TextEdit::fileRevert() { |
619 | clear(); | 619 | clear(); |
620 | fileOpen(); | 620 | fileOpen(); |
621 | } | 621 | } |
622 | 622 | ||
623 | void TextEdit::editCut() { | 623 | void TextEdit::editCut() { |
624 | #ifndef QT_NO_CLIPBOARD | 624 | #ifndef QT_NO_CLIPBOARD |
625 | editor->cut(); | 625 | editor->cut(); |
626 | #endif | 626 | #endif |
627 | } | 627 | } |
628 | 628 | ||
629 | void TextEdit::editCopy() { | 629 | void TextEdit::editCopy() { |
630 | #ifndef QT_NO_CLIPBOARD | 630 | #ifndef QT_NO_CLIPBOARD |
631 | editor->copy(); | 631 | editor->copy(); |
632 | #endif | 632 | #endif |
633 | } | 633 | } |
634 | 634 | ||
635 | void TextEdit::editPaste() { | 635 | void TextEdit::editPaste() { |
636 | #ifndef QT_NO_CLIPBOARD | 636 | #ifndef QT_NO_CLIPBOARD |
637 | editor->paste(); | 637 | editor->paste(); |
638 | #endif | 638 | #endif |
639 | } | 639 | } |
640 | 640 | ||
641 | void TextEdit::editFind() { | 641 | void TextEdit::editFind() { |
642 | searchBar->show(); | 642 | searchBar->show(); |
643 | searchEdit->setFocus(); | 643 | searchEdit->setFocus(); |
644 | } | 644 | } |
645 | 645 | ||
646 | void TextEdit::findNext() { | 646 | void TextEdit::findNext() { |
647 | editor->find( searchEdit->text(), false, false ); | 647 | editor->find( searchEdit->text(), false, false ); |
648 | 648 | ||
649 | } | 649 | } |
650 | 650 | ||
651 | void TextEdit::findClose() { | 651 | void TextEdit::findClose() { |
652 | searchBar->hide(); | 652 | searchBar->hide(); |
653 | } | 653 | } |
654 | 654 | ||
655 | void TextEdit::search() { | 655 | void TextEdit::search() { |
656 | editor->find( searchEdit->text(), false, false ); | 656 | editor->find( searchEdit->text(), false, false ); |
657 | } | 657 | } |
658 | 658 | ||
659 | void TextEdit::newFile( const DocLnk &f ) { | 659 | void TextEdit::newFile( const DocLnk &f ) { |
660 | DocLnk nf = f; | 660 | DocLnk nf = f; |
661 | nf.setType("text/plain"); | 661 | nf.setType("text/plain"); |
662 | clear(); | 662 | clear(); |
663 | setWState (WState_Reserved1 ); | 663 | setWState (WState_Reserved1 ); |
664 | editor->setFocus(); | 664 | editor->setFocus(); |
665 | doc = new DocLnk(nf); | 665 | doc = new DocLnk(nf); |
666 | currentFileName = "Unnamed"; | 666 | currentFileName = "Unnamed"; |
667 | qDebug("newFile "+currentFileName); | 667 | qDebug("newFile "+currentFileName); |
668 | updateCaption( currentFileName); | 668 | updateCaption( currentFileName); |
669 | // editor->setEdited( false); | 669 | // editor->setEdited( false); |
670 | } | 670 | } |
671 | 671 | ||
672 | void TextEdit::openDotFile( const QString &f ) { | 672 | void TextEdit::openDotFile( const QString &f ) { |
673 | if(!currentFileName.isEmpty()) { | 673 | if(!currentFileName.isEmpty()) { |
674 | currentFileName=f; | 674 | currentFileName=f; |
675 | 675 | ||
676 | qDebug("openFile dotfile " + currentFileName); | 676 | qDebug("openFile dotfile " + currentFileName); |
677 | QString txt; | 677 | QString txt; |
678 | QFile file(f); | 678 | QFile file(f); |
679 | file.open(IO_ReadWrite); | 679 | file.open(IO_ReadWrite); |
680 | QTextStream t(&file); | 680 | QTextStream t(&file); |
681 | while ( !t.atEnd()) { | 681 | while ( !t.atEnd()) { |
682 | txt+=t.readLine()+"\n"; | 682 | txt+=t.readLine()+"\n"; |
683 | } | 683 | } |
684 | editor->setText(txt); | 684 | editor->setText(txt); |
685 | editor->setEdited( false); | 685 | editor->setEdited( false); |
686 | edited1=false; | 686 | edited1=false; |
687 | edited=false; | 687 | edited=false; |
688 | 688 | ||
689 | 689 | ||
690 | } | 690 | } |
691 | updateCaption( currentFileName); | 691 | updateCaption( currentFileName); |
692 | } | 692 | } |
693 | 693 | ||
694 | void TextEdit::openFile( const QString &f ) { | 694 | void TextEdit::openFile( const QString &f ) { |
695 | qDebug("filename is "+ f); | 695 | qDebug("filename is "+ f); |
696 | QString filer; | 696 | QString filer; |
697 | QFileInfo fi( f); | 697 | QFileInfo fi( f); |
698 | // bFromDocView = true; | 698 | // bFromDocView = true; |
699 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 699 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
700 | { | 700 | { |
701 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 701 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) |
702 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> | ||
703 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | ||
704 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) | ||
705 | { | 702 | { |
706 | case 0: //desktop | 703 | case 0: //desktop |
707 | filer = f; | 704 | filer = f; |
708 | break; | 705 | break; |
709 | case 1: //linked | 706 | case 1: //linked |
710 | DocLnk sf(f); | 707 | DocLnk sf(f); |
711 | filer = sf.file(); | 708 | filer = sf.file(); |
712 | break; | 709 | break; |
713 | }; | 710 | }; |
714 | } | 711 | } |
715 | else if(fi.baseName().left(1) == "") | 712 | else if(fi.baseName().left(1) == "") |
716 | { | 713 | { |
717 | qDebug("opening dotfile"); | 714 | qDebug("opening dotfile"); |
718 | currentFileName=f; | 715 | currentFileName=f; |
719 | openDotFile(currentFileName); | 716 | openDotFile(currentFileName); |
720 | return; | 717 | return; |
721 | } | 718 | } |
722 | else | 719 | else |
723 | { | 720 | { |
724 | DocLnk sf(f); | 721 | DocLnk sf(f); |
725 | filer = sf.file(); | 722 | filer = sf.file(); |
726 | if(filer.right(1) == "/") | 723 | if(filer.right(1) == "/") |
727 | filer = f; | 724 | filer = f; |
728 | } | 725 | } |
729 | 726 | ||
730 | DocLnk nf; | 727 | DocLnk nf; |
731 | nf.setType("text/plain"); | 728 | nf.setType("text/plain"); |
732 | nf.setFile(filer); | 729 | nf.setFile(filer); |
733 | currentFileName=filer; | 730 | currentFileName=filer; |
734 | 731 | ||
735 | nf.setName(fi.baseName()); | 732 | nf.setName(fi.baseName()); |
736 | openFile(nf); | 733 | openFile(nf); |
737 | 734 | ||
738 | qDebug("openFile string "+currentFileName); | 735 | qDebug("openFile string "+currentFileName); |
739 | 736 | ||
740 | showEditTools(); | 737 | showEditTools(); |
741 | // Show filename in caption | 738 | // Show filename in caption |
742 | QString name = filer; | 739 | QString name = filer; |
743 | int sep = name.findRev( '/' ); | 740 | int sep = name.findRev( '/' ); |
744 | if ( sep > 0 ) | 741 | if ( sep > 0 ) |
745 | name = name.mid( sep+1 ); | 742 | name = name.mid( sep+1 ); |
746 | updateCaption( name ); | 743 | updateCaption( name ); |
747 | } | 744 | } |
748 | 745 | ||
749 | void TextEdit::openFile( const DocLnk &f ) { | 746 | void TextEdit::openFile( const DocLnk &f ) { |
750 | // clear(); | 747 | // clear(); |
751 | // bFromDocView = true; | 748 | // bFromDocView = true; |
752 | FileManager fm; | 749 | FileManager fm; |
753 | QString txt; | 750 | QString txt; |
754 | currentFileName=f.file(); | 751 | currentFileName=f.file(); |
755 | qDebug("openFile doclnk " + currentFileName); | 752 | qDebug("openFile doclnk " + currentFileName); |
756 | if ( !fm.loadFile( f, txt ) ) { | 753 | if ( !fm.loadFile( f, txt ) ) { |
757 | // ####### could be a new file | 754 | // ####### could be a new file |
758 | qDebug( "Cannot open file" ); | 755 | qDebug( "Cannot open file" ); |
759 | } | 756 | } |
760 | // fileNew(); | 757 | // fileNew(); |
761 | if ( doc ) | 758 | if ( doc ) |
762 | delete doc; | 759 | delete doc; |
763 | doc = new DocLnk(f); | 760 | doc = new DocLnk(f); |
764 | editor->setText(txt); | 761 | editor->setText(txt); |
765 | editor->setEdited( false); | 762 | editor->setEdited( false); |
766 | edited1=false; | 763 | edited1=false; |
767 | edited=false; | 764 | edited=false; |
768 | 765 | ||
769 | doc->setName(currentFileName); | 766 | doc->setName(currentFileName); |
770 | updateCaption(); | 767 | updateCaption(); |
771 | setTimer(); | 768 | setTimer(); |
772 | } | 769 | } |
773 | 770 | ||
774 | void TextEdit::showEditTools() { | 771 | void TextEdit::showEditTools() { |
775 | menu->show(); | 772 | menu->show(); |
776 | editBar->show(); | 773 | editBar->show(); |
777 | if(!useSearchBar) | 774 | if(!useSearchBar) |
778 | searchBar->hide(); | 775 | searchBar->hide(); |
779 | else | 776 | else |
780 | searchBar->show(); | 777 | searchBar->show(); |
781 | setWState (WState_Reserved1 ); | 778 | setWState (WState_Reserved1 ); |
782 | } | 779 | } |
783 | 780 | ||
784 | /*! | 781 | /*! |
785 | unprompted save */ | 782 | unprompted save */ |
786 | bool TextEdit::save() { | 783 | bool TextEdit::save() { |
787 | qDebug("saveAsFile " + currentFileName); | 784 | qDebug("saveAsFile " + currentFileName); |
788 | if(currentFileName.isEmpty()) { | 785 | if(currentFileName.isEmpty()) { |
789 | saveAs(); | 786 | saveAs(); |
790 | return false; | 787 | return false; |
791 | } | 788 | } |
792 | 789 | ||
793 | QString file = doc->file(); | 790 | QString file = doc->file(); |
794 | qDebug("saver file "+file); | 791 | qDebug("saver file "+file); |
795 | QString name= doc->name(); | 792 | QString name= doc->name(); |
796 | qDebug("File named "+name); | 793 | qDebug("File named "+name); |
797 | QString rt = editor->text(); | 794 | QString rt = editor->text(); |
798 | if( !rt.isEmpty() ) { | 795 | if( !rt.isEmpty() ) { |
799 | if(name.isEmpty()) { | 796 | if(name.isEmpty()) { |
800 | saveAs(); | 797 | saveAs(); |