-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 0af18da..9e6ba8d 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -771,129 +771,129 @@ bool TextEdit::saveAs() | |||
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 | ||
854 | void TextEdit::clear() | 854 | void 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 | ||
861 | void TextEdit::updateCaption( const QString &name ) | 861 | void 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 | ||
879 | void TextEdit::setDocument(const QString& fileref) | 879 | void 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 | ||
889 | void TextEdit::closeEvent( QCloseEvent *e ) | 889 | void TextEdit::closeEvent( QCloseEvent *e ) |
890 | { | 890 | { |
891 | bFromDocView = FALSE; | 891 | bFromDocView = FALSE; |
892 | e->accept(); | 892 | e->accept(); |
893 | } | 893 | } |
894 | 894 | ||
895 | void TextEdit::accept() | 895 | void TextEdit::accept() |
896 | { | 896 | { |
897 | //if(caption() !="Unnamed") | 897 | //if(caption() !="Unnamed") |
898 | if(edited1) | 898 | if(edited1) |
899 | saveAs(); | 899 | saveAs(); |