-rw-r--r-- | core/apps/textedit/textedit.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index f99f259..c1f74bb 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -714,97 +714,98 @@ void TextEdit::openFile( const DocLnk &f ) | |||
714 | doc->setName(currentFileName); | 714 | doc->setName(currentFileName); |
715 | updateCaption(); | 715 | updateCaption(); |
716 | } | 716 | } |
717 | 717 | ||
718 | void TextEdit::showEditTools() | 718 | void TextEdit::showEditTools() |
719 | { | 719 | { |
720 | // if ( !doc ) | 720 | // if ( !doc ) |
721 | // close(); | 721 | // close(); |
722 | // clear(); | 722 | // clear(); |
723 | menu->show(); | 723 | menu->show(); |
724 | editBar->show(); | 724 | editBar->show(); |
725 | if ( searchVisible ) | 725 | if ( searchVisible ) |
726 | searchBar->show(); | 726 | searchBar->show(); |
727 | // updateCaption(); | 727 | // updateCaption(); |
728 | setWState (WState_Reserved1 ); | 728 | setWState (WState_Reserved1 ); |
729 | } | 729 | } |
730 | 730 | ||
731 | /*! | 731 | /*! |
732 | unprompted save */ | 732 | unprompted save */ |
733 | bool TextEdit::save() | 733 | bool TextEdit::save() |
734 | { | 734 | { |
735 | QString file = doc->file(); | 735 | QString file = doc->file(); |
736 | qDebug("saver file "+file); | 736 | qDebug("saver file "+file); |
737 | QString name= doc->name(); | 737 | QString name= doc->name(); |
738 | qDebug("File named "+name); | 738 | qDebug("File named "+name); |
739 | QString rt = editor->text(); | 739 | QString rt = editor->text(); |
740 | if( !rt.isEmpty() ) { | 740 | if( !rt.isEmpty() ) { |
741 | if(name.isEmpty()) { | 741 | if(name.isEmpty()) { |
742 | saveAs(); | 742 | saveAs(); |
743 | } else { | 743 | } else { |
744 | currentFileName= name ; | 744 | currentFileName= name ; |
745 | qDebug("saveFile "+currentFileName); | 745 | qDebug("saveFile "+currentFileName); |
746 | 746 | ||
747 | struct stat buf; | 747 | struct stat buf; |
748 | mode_t mode; | 748 | mode_t mode; |
749 | stat(file.latin1(), &buf); | 749 | stat(file.latin1(), &buf); |
750 | mode = buf.st_mode; | 750 | mode = buf.st_mode; |
751 | 751 | ||
752 | if(!fileIs) { | 752 | if(!fileIs) { |
753 | doc->setName( name); | 753 | doc->setName( name); |
754 | FileManager fm; | 754 | FileManager fm; |
755 | if ( !fm.saveFile( *doc, rt ) ) { | 755 | if ( !fm.saveFile( *doc, rt ) ) { |
756 | return false; | 756 | return false; |
757 | } | 757 | } |
758 | } else { | 758 | } else { |
759 | qDebug("regular save file"); | 759 | qDebug("regular save file"); |
760 | QFile f(file); | 760 | QFile f(file); |
761 | if( f.open(IO_WriteOnly)) { | 761 | if( f.open(IO_WriteOnly)) { |
762 | f.writeBlock(rt,rt.length()); | 762 | QCString crt = rt.utf8(); |
763 | f.writeBlock(crt,crt.length()); | ||
763 | } else { | 764 | } else { |
764 | QMessageBox::message("Text Edit","Write Failed"); | 765 | QMessageBox::message("Text Edit","Write Failed"); |
765 | return false; | 766 | return false; |
766 | } | 767 | } |
767 | 768 | ||
768 | } | 769 | } |
769 | editor->setEdited( FALSE); | 770 | editor->setEdited( FALSE); |
770 | edited1=FALSE; | 771 | edited1=FALSE; |
771 | edited=FALSE; | 772 | edited=FALSE; |
772 | if(caption().left(1)=="*") | 773 | if(caption().left(1)=="*") |
773 | setCaption(caption().right(caption().length()-1)); | 774 | setCaption(caption().right(caption().length()-1)); |
774 | 775 | ||
775 | 776 | ||
776 | chmod( file.latin1(), mode); | 777 | chmod( file.latin1(), mode); |
777 | } | 778 | } |
778 | return true; | 779 | return true; |
779 | } | 780 | } |
780 | return false; | 781 | return false; |
781 | } | 782 | } |
782 | 783 | ||
783 | /*! | 784 | /*! |
784 | prompted save */ | 785 | prompted save */ |
785 | bool TextEdit::saveAs() | 786 | bool TextEdit::saveAs() |
786 | { | 787 | { |
787 | // qDebug("saveAsFile "+currentFileName); | 788 | // qDebug("saveAsFile "+currentFileName); |
788 | // case of nothing to save... | 789 | // case of nothing to save... |
789 | if ( !doc )//|| !bFromDocView) | 790 | if ( !doc )//|| !bFromDocView) |
790 | { | 791 | { |
791 | qDebug("no doc"); | 792 | qDebug("no doc"); |
792 | return true; | 793 | return true; |
793 | } | 794 | } |
794 | if ( !editor->edited() ) { | 795 | if ( !editor->edited() ) { |
795 | delete doc; | 796 | delete doc; |
796 | doc = 0; | 797 | doc = 0; |
797 | return true; | 798 | return true; |
798 | } | 799 | } |
799 | 800 | ||
800 | QString rt = editor->text(); | 801 | QString rt = editor->text(); |
801 | qDebug(currentFileName); | 802 | qDebug(currentFileName); |
802 | 803 | ||
803 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { | 804 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { |
804 | qDebug("do silly TT filename thing"); | 805 | qDebug("do silly TT filename thing"); |
805 | if ( doc->name().isEmpty() ) { | 806 | if ( doc->name().isEmpty() ) { |
806 | QString pt = rt.simplifyWhiteSpace(); | 807 | QString pt = rt.simplifyWhiteSpace(); |
807 | int i = pt.find( ' ' ); | 808 | int i = pt.find( ' ' ); |
808 | QString docname = pt; | 809 | QString docname = pt; |
809 | if ( i > 0 ) | 810 | if ( i > 0 ) |
810 | docname = pt.left( i ); | 811 | docname = pt.left( i ); |