-rw-r--r-- | core/apps/textedit/textedit.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index f38ea53..e3b8361 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -755,107 +755,114 @@ bool TextEdit::save() { | |||
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() |
788 | || currentFileName == tr("Unnamed") | ||
789 | || currentFileName == tr("Text Editor")) { | ||
788 | // qDebug("do silly TT filename thing"); | 790 | // qDebug("do silly TT filename thing"); |
789 | if ( doc->name().isEmpty() ) { | 791 | if ( doc->name().isEmpty() ) { |
790 | QString pt = rt.simplifyWhiteSpace(); | 792 | QString pt = rt.simplifyWhiteSpace(); |
791 | int i = pt.find( ' ' ); | 793 | int i = pt.find( ' ' ); |
792 | QString docname = pt; | 794 | QString docname = pt; |
793 | if ( i > 0 ) | 795 | if ( i > 0 ) |
794 | docname = pt.left( i ); | 796 | docname = pt.left( i ); |
795 | // remove "." at the beginning | 797 | // remove "." at the beginning |
796 | while( docname.startsWith( "." ) ) | 798 | while( docname.startsWith( "." ) ) |
797 | docname = docname.mid( 1 ); | 799 | docname = docname.mid( 1 ); |
798 | docname.replace( QRegExp("/"), "_" ); | 800 | docname.replace( QRegExp("/"), "_" ); |
799 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 801 | // cut the length. filenames longer than that |
802 | //don't make sense and something goes wrong when they get too long. | ||
800 | if ( docname.length() > 40 ) | 803 | if ( docname.length() > 40 ) |
801 | docname = docname.left(40); | 804 | docname = docname.left(40); |
802 | if ( docname.isEmpty() ) | 805 | if ( docname.isEmpty() ) |
803 | docname = tr("Unnamed"); | 806 | docname = tr("Unnamed"); |
804 | doc->setName(docname); | 807 | doc->setName(docname); |
805 | currentFileName=docname; | 808 | currentFileName=docname; |
806 | } | 809 | } |
807 | } | 810 | } |
808 | 811 | ||
809 | QMap<QString, QStringList> map; | 812 | QMap<QString, QStringList> map; |
810 | map.insert(tr("All"), QStringList() ); | 813 | map.insert(tr("All"), QStringList() ); |
811 | QStringList text; | 814 | QStringList text; |
812 | text << "text/*"; | 815 | text << "text/*"; |
813 | map.insert(tr("Text"), text ); | 816 | map.insert(tr("Text"), text ); |
814 | text << "*"; | 817 | text << "*"; |
815 | map.insert(tr("All"), text ); | 818 | map.insert(tr("All"), text ); |
816 | 819 | // if(currentFileName | |
817 | QString str = OFileDialog::getSaveFileName( 2,QPEApplication::documentDir(), QString::null, map); | 820 | QString str = OFileDialog::getSaveFileName( 2, |
821 | QPEApplication::documentDir(), | ||
822 | currentFileName, map); | ||
818 | 823 | ||
819 | if(!str.isEmpty() ) { | 824 | if(!str.isEmpty() ) { |
820 | QString fileNm=str; | 825 | QString fileNm=str; |
821 | 826 | ||
822 | qDebug("saving filename "+fileNm); | 827 | qDebug("saving filename "+fileNm); |
823 | QFileInfo fi(fileNm); | 828 | QFileInfo fi(fileNm); |
824 | currentFileName=fi.fileName(); | 829 | currentFileName=fi.fileName(); |
825 | if(doc) { | 830 | if(doc) { |
826 | // QString file = doc->file(); | 831 | // QString file = doc->file(); |
827 | // doc->removeFiles(); | 832 | // doc->removeFiles(); |
828 | delete doc; | 833 | delete doc; |
829 | DocLnk nf; | 834 | DocLnk nf; |
830 | nf.setType("text/plain"); | 835 | nf.setType("text/plain"); |
831 | nf.setFile( fileNm); | 836 | nf.setFile( fileNm); |
832 | doc = new DocLnk(nf); | 837 | doc = new DocLnk(nf); |
833 | // editor->setText(rt); | 838 | // editor->setText(rt); |
834 | // qDebug("openFile doclnk "+currentFileName); | 839 | // qDebug("openFile doclnk "+currentFileName); |
835 | doc->setName( currentFileName); | 840 | doc->setName( currentFileName); |
836 | updateCaption( currentFileName); | 841 | updateCaption( currentFileName); |
837 | 842 | ||
838 | FileManager fm; | 843 | FileManager fm; |
839 | if ( !fm.saveFile( *doc, rt ) ) { | 844 | if ( !fm.saveFile( *doc, rt ) ) { |
840 | return false; | 845 | return false; |
841 | } | 846 | } |
842 | 847 | ||
843 | if( filePerms ) { | 848 | if( filePerms ) { |
844 | filePermissions *filePerm; | 849 | filePermissions *filePerm; |
845 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); | 850 | filePerm = new filePermissions(this, |
851 | tr("Permissions"),true, | ||
852 | 0,(const QString &)fileNm); | ||
846 | filePerm->showMaximized(); | 853 | filePerm->showMaximized(); |
847 | filePerm->exec(); | 854 | filePerm->exec(); |
848 | 855 | ||
849 | if( filePerm) | 856 | if( filePerm) |
850 | delete filePerm; | 857 | delete filePerm; |
851 | } | 858 | } |
852 | } | 859 | } |
853 | editor->setEdited( false); | 860 | editor->setEdited( false); |
854 | edited1 = false; | 861 | edited1 = false; |
855 | edited = false; | 862 | edited = false; |
856 | if(caption().left(1)=="*") | 863 | if(caption().left(1)=="*") |
857 | setCaption(caption().right(caption().length()-1)); | 864 | setCaption(caption().right(caption().length()-1)); |
858 | 865 | ||
859 | return true; | 866 | return true; |
860 | } | 867 | } |
861 | qDebug("returning false"); | 868 | qDebug("returning false"); |