-rw-r--r-- | core/apps/textedit/textedit.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index dc0d61b..9ef423c 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -710,140 +710,140 @@ void TextEdit::search() { | |||
710 | editor->find( searchEdit->text(), false, false ); | 710 | editor->find( searchEdit->text(), false, false ); |
711 | } | 711 | } |
712 | 712 | ||
713 | void TextEdit::newFile( const DocLnk &f ) { | 713 | void TextEdit::newFile( const DocLnk &f ) { |
714 | DocLnk nf = f; | 714 | DocLnk nf = f; |
715 | nf.setType("text/plain"); | 715 | nf.setType("text/plain"); |
716 | clear(); | 716 | clear(); |
717 | setWState (WState_Reserved1 ); | 717 | setWState (WState_Reserved1 ); |
718 | editor->setFocus(); | 718 | editor->setFocus(); |
719 | doc = new DocLnk(nf); | 719 | doc = new DocLnk(nf); |
720 | currentFileName = "Unnamed"; | 720 | currentFileName = "Unnamed"; |
721 | qDebug("newFile "+currentFileName); | 721 | qDebug("newFile "+currentFileName); |
722 | updateCaption( currentFileName); | 722 | updateCaption( currentFileName); |
723 | // editor->setEdited( false); | 723 | // editor->setEdited( false); |
724 | } | 724 | } |
725 | 725 | ||
726 | void TextEdit::openDotFile( const QString &f ) { | 726 | void TextEdit::openDotFile( const QString &f ) { |
727 | if(!currentFileName.isEmpty()) { | 727 | if(!currentFileName.isEmpty()) { |
728 | currentFileName=f; | 728 | currentFileName=f; |
729 | 729 | ||
730 | qDebug("openFile dotfile " + currentFileName); | 730 | qDebug("openFile dotfile " + currentFileName); |
731 | QString txt; | 731 | QString txt; |
732 | QFile file(f); | 732 | QFile file(f); |
733 | file.open(IO_ReadWrite); | 733 | file.open(IO_ReadWrite); |
734 | QTextStream t(&file); | 734 | QTextStream t(&file); |
735 | while ( !t.atEnd()) { | 735 | while ( !t.atEnd()) { |
736 | txt+=t.readLine()+"\n"; | 736 | txt+=t.readLine()+"\n"; |
737 | } | 737 | } |
738 | editor->setText(txt); | 738 | editor->setText(txt); |
739 | editor->setEdited( false); | 739 | editor->setEdited( false); |
740 | edited1=false; | 740 | edited1=false; |
741 | edited=false; | 741 | edited=false; |
742 | 742 | ||
743 | 743 | ||
744 | } | 744 | } |
745 | updateCaption( currentFileName); | 745 | updateCaption( currentFileName); |
746 | } | 746 | } |
747 | 747 | ||
748 | void TextEdit::openFile( const QString &f ) { | 748 | void TextEdit::openFile( const QString &f ) { |
749 | qDebug("filename is "+ f); | 749 | qDebug("filename is "+ f); |
750 | QString filer; | 750 | QString filer; |
751 | QFileInfo fi( f); | 751 | QFileInfo fi( f); |
752 | // bFromDocView = true; | 752 | // bFromDocView = true; |
753 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) { | 753 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) { |
754 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 754 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
755 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> | 755 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> |
756 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | 756 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), |
757 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { | 757 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { |
758 | case 0: | 758 | case 0: |
759 | filer = f; | 759 | filer = f; |
760 | break; | 760 | break; |
761 | case 1: | 761 | case 1: |
762 | DocLnk sf(f); | 762 | DocLnk sf(f); |
763 | filer = sf.file(); | 763 | filer = sf.file(); |
764 | break; | 764 | break; |
765 | } | 765 | } |
766 | } else if(fi.baseName().left(1) == "") { | 766 | } else if(fi.baseName().left(1) == "") { |
767 | currentFileName=f; | 767 | currentFileName=f; |
768 | openDotFile(currentFileName); | 768 | openDotFile(currentFileName); |
769 | } else { | 769 | } else { |
770 | DocLnk sf(f); | 770 | DocLnk sf(f); |
771 | filer = sf.file(); | 771 | filer = sf.file(); |
772 | if(filer.right(1) == "/") | 772 | if(filer.right(1) == "/") |
773 | filer = f; | 773 | filer = f; |
774 | } | ||
775 | 774 | ||
776 | DocLnk nf; | 775 | DocLnk nf; |
777 | nf.setType("text/plain"); | 776 | nf.setType("text/plain"); |
778 | nf.setFile(filer); | 777 | nf.setFile(filer); |
779 | currentFileName=filer; | 778 | currentFileName=filer; |
780 | 779 | ||
781 | nf.setName(fi.baseName()); | 780 | nf.setName(fi.baseName()); |
782 | openFile(nf); | 781 | openFile(nf); |
783 | 782 | ||
784 | qDebug("openFile string "+currentFileName); | 783 | qDebug("openFile string "+currentFileName); |
785 | 784 | ||
785 | } | ||
786 | showEditTools(); | 786 | showEditTools(); |
787 | // Show filename in caption | 787 | // Show filename in caption |
788 | QString name = filer; | 788 | QString name = filer; |
789 | int sep = name.findRev( '/' ); | 789 | int sep = name.findRev( '/' ); |
790 | if ( sep > 0 ) | 790 | if ( sep > 0 ) |
791 | name = name.mid( sep+1 ); | 791 | name = name.mid( sep+1 ); |
792 | updateCaption( name ); | 792 | updateCaption( name ); |
793 | } | 793 | } |
794 | 794 | ||
795 | void TextEdit::openFile( const DocLnk &f ) { | 795 | void TextEdit::openFile( const DocLnk &f ) { |
796 | // clear(); | 796 | // clear(); |
797 | // bFromDocView = true; | 797 | // bFromDocView = true; |
798 | FileManager fm; | 798 | FileManager fm; |
799 | QString txt; | 799 | QString txt; |
800 | currentFileName=f.file(); | 800 | currentFileName=f.file(); |
801 | qDebug("openFile doclnk " + currentFileName); | 801 | qDebug("openFile doclnk " + currentFileName); |
802 | if ( !fm.loadFile( f, txt ) ) { | 802 | if ( !fm.loadFile( f, txt ) ) { |
803 | // ####### could be a new file | 803 | // ####### could be a new file |
804 | qDebug( "Cannot open file" ); | 804 | qDebug( "Cannot open file" ); |
805 | } | 805 | } |
806 | // fileNew(); | 806 | // fileNew(); |
807 | if ( doc ) | 807 | if ( doc ) |
808 | delete doc; | 808 | delete doc; |
809 | doc = new DocLnk(f); | 809 | doc = new DocLnk(f); |
810 | editor->setText(txt); | 810 | editor->setText(txt); |
811 | editor->setEdited( false); | 811 | editor->setEdited( false); |
812 | edited1=false; | 812 | edited1=false; |
813 | edited=false; | 813 | edited=false; |
814 | 814 | ||
815 | doc->setName(currentFileName); | 815 | doc->setName(currentFileName); |
816 | updateCaption(); | 816 | updateCaption(); |
817 | } | 817 | } |
818 | 818 | ||
819 | void TextEdit::showEditTools() { | 819 | void TextEdit::showEditTools() { |
820 | menu->show(); | 820 | menu->show(); |
821 | editBar->show(); | 821 | editBar->show(); |
822 | if(!useSearchBar) | 822 | if(!useSearchBar) |
823 | searchBar->hide(); | 823 | searchBar->hide(); |
824 | else | 824 | else |
825 | searchBar->show(); | 825 | searchBar->show(); |
826 | setWState (WState_Reserved1 ); | 826 | setWState (WState_Reserved1 ); |
827 | } | 827 | } |
828 | 828 | ||
829 | /*! | 829 | /*! |
830 | unprompted save */ | 830 | unprompted save */ |
831 | bool TextEdit::save() { | 831 | bool TextEdit::save() { |
832 | qDebug("saveAsFile " + currentFileName); | 832 | qDebug("saveAsFile " + currentFileName); |
833 | if(currentFileName.isEmpty()) { | 833 | if(currentFileName.isEmpty()) { |
834 | saveAs(); | 834 | saveAs(); |
835 | return false; | 835 | return false; |
836 | } | 836 | } |
837 | QString file = doc->file(); | 837 | QString file = doc->file(); |
838 | qDebug("saver file "+file); | 838 | qDebug("saver file "+file); |
839 | QString name= doc->name(); | 839 | QString name= doc->name(); |
840 | qDebug("File named "+name); | 840 | qDebug("File named "+name); |
841 | QString rt = editor->text(); | 841 | QString rt = editor->text(); |
842 | if( !rt.isEmpty() ) { | 842 | if( !rt.isEmpty() ) { |
843 | if(name.isEmpty()) { | 843 | if(name.isEmpty()) { |
844 | saveAs(); | 844 | saveAs(); |
845 | } else { | 845 | } else { |
846 | currentFileName= name ; | 846 | currentFileName= name ; |
847 | qDebug("saveFile "+currentFileName); | 847 | qDebug("saveFile "+currentFileName); |
848 | 848 | ||
849 | struct stat buf; | 849 | struct stat buf; |