author | ar <ar> | 2004-10-16 23:11:36 (UTC) |
---|---|---|
committer | ar <ar> | 2004-10-16 23:11:36 (UTC) |
commit | 1deb4b9d09fcb0eddd8425de7d66e8919e1e0d32 (patch) (unidiff) | |
tree | db323920bf4258d8afc1e0af722b968b2a520b9e | |
parent | 5fb6ed213aa8b4b1101082671f57db45d7b10d01 (diff) | |
download | opie-1deb4b9d09fcb0eddd8425de7d66e8919e1e0d32.zip opie-1deb4b9d09fcb0eddd8425de7d66e8919e1e0d32.tar.gz opie-1deb4b9d09fcb0eddd8425de7d66e8919e1e0d32.tar.bz2 |
- BugFix: clear currentFileName in SaveAs when the user abort.
otherwise it crashs when user try to save after aborted saveas action
-rw-r--r-- | core/apps/textedit/textedit.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 1d0df6a..571df27 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -764,384 +764,385 @@ void TextEdit::openFile( const DocLnk &f ) { | |||
764 | 764 | ||
765 | void TextEdit::showEditTools() { | 765 | void TextEdit::showEditTools() { |
766 | menu->show(); | 766 | menu->show(); |
767 | editBar->show(); | 767 | editBar->show(); |
768 | if(!useSearchBar) | 768 | if(!useSearchBar) |
769 | searchBar->hide(); | 769 | searchBar->hide(); |
770 | else | 770 | else |
771 | searchBar->show(); | 771 | searchBar->show(); |
772 | setWState (WState_Reserved1 ); | 772 | setWState (WState_Reserved1 ); |
773 | } | 773 | } |
774 | 774 | ||
775 | /*! | 775 | /*! |
776 | unprompted save */ | 776 | unprompted save */ |
777 | bool TextEdit::save() { | 777 | bool TextEdit::save() { |
778 | QString name, file; | 778 | QString name, file; |
779 | odebug << "saveAsFile " + currentFileName << oendl; | 779 | odebug << "saveAsFile " + currentFileName << oendl; |
780 | if(currentFileName.isEmpty()) { | 780 | if(currentFileName.isEmpty()) { |
781 | saveAs(); | 781 | saveAs(); |
782 | return false; | 782 | return false; |
783 | } | 783 | } |
784 | name = currentFileName; | 784 | name = currentFileName; |
785 | if(doc) { | 785 | if(doc) { |
786 | file = doc->file(); | 786 | file = doc->file(); |
787 | odebug << "saver file "+file << oendl; | 787 | odebug << "saver file "+file << oendl; |
788 | name = doc->name(); | 788 | name = doc->name(); |
789 | odebug << "File named "+name << oendl; | 789 | odebug << "File named "+name << oendl; |
790 | } else { | 790 | } else { |
791 | name = file = currentFileName; | 791 | name = file = currentFileName; |
792 | } | 792 | } |
793 | 793 | ||
794 | QString rt = editor->text(); | 794 | QString rt = editor->text(); |
795 | if( !rt.isEmpty() ) { | 795 | if( !rt.isEmpty() ) { |
796 | if(name.isEmpty()) { | 796 | if(name.isEmpty()) { |
797 | saveAs(); | 797 | saveAs(); |
798 | } else { | 798 | } else { |
799 | currentFileName = name; | 799 | currentFileName = name; |
800 | odebug << "saveFile "+currentFileName << oendl; | 800 | odebug << "saveFile "+currentFileName << oendl; |
801 | 801 | ||
802 | struct stat buf; | 802 | struct stat buf; |
803 | mode_t mode; | 803 | mode_t mode; |
804 | stat(file.latin1(), &buf); | 804 | stat(file.latin1(), &buf); |
805 | mode = buf.st_mode; | 805 | mode = buf.st_mode; |
806 | 806 | ||
807 | if(!fileIs) { | 807 | if(!fileIs) { |
808 | doc->setName( name); | 808 | doc->setName( name); |
809 | FileManager fm; | 809 | FileManager fm; |
810 | if ( !fm.saveFile( *doc, rt ) ) { | 810 | if ( !fm.saveFile( *doc, rt ) ) { |
811 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 811 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
812 | return false; | 812 | return false; |
813 | } | 813 | } |
814 | } else { | 814 | } else { |
815 | odebug << "regular save file" << oendl; | 815 | odebug << "regular save file" << oendl; |
816 | QFile f(file); | 816 | QFile f(file); |
817 | if( f.open(IO_WriteOnly)) { | 817 | if( f.open(IO_WriteOnly)) { |
818 | QCString crt = rt.utf8(); | 818 | QCString crt = rt.utf8(); |
819 | f.writeBlock(crt,crt.length()); | 819 | f.writeBlock(crt,crt.length()); |
820 | } else { | 820 | } else { |
821 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 821 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
822 | return false; | 822 | return false; |
823 | } | 823 | } |
824 | 824 | ||
825 | } | 825 | } |
826 | editor->setEdited( false); | 826 | editor->setEdited( false); |
827 | edited1=false; | 827 | edited1=false; |
828 | edited=false; | 828 | edited=false; |
829 | if(caption().left(1)=="*") | 829 | if(caption().left(1)=="*") |
830 | setCaption(caption().right(caption().length()-1)); | 830 | setCaption(caption().right(caption().length()-1)); |
831 | 831 | ||
832 | 832 | ||
833 | chmod( file.latin1(), mode); | 833 | chmod( file.latin1(), mode); |
834 | } | 834 | } |
835 | return true; | 835 | return true; |
836 | } | 836 | } |
837 | return false; | 837 | return false; |
838 | } | 838 | } |
839 | 839 | ||
840 | /*! | 840 | /*! |
841 | prompted save */ | 841 | prompted save */ |
842 | bool TextEdit::saveAs() { | 842 | bool TextEdit::saveAs() { |
843 | 843 | ||
844 | if(caption() == tr("Text Editor")) | 844 | if(caption() == tr("Text Editor")) |
845 | return false; | 845 | return false; |
846 | odebug << "saveAsFile " + currentFileName << oendl; | 846 | odebug << "saveAsFile " + currentFileName << oendl; |
847 | // case of nothing to save... | 847 | // case of nothing to save... |
848 | // if ( !doc && !currentFileName.isEmpty()) { | 848 | // if ( !doc && !currentFileName.isEmpty()) { |
849 | // //|| !bFromDocView) | 849 | // //|| !bFromDocView) |
850 | // odebug << "no doc" << oendl; | 850 | // odebug << "no doc" << oendl; |
851 | // return true; | 851 | // return true; |
852 | // } | 852 | // } |
853 | // if ( !editor->edited() ) { | 853 | // if ( !editor->edited() ) { |
854 | // delete doc; | 854 | // delete doc; |
855 | // doc = 0; | 855 | // doc = 0; |
856 | // return true; | 856 | // return true; |
857 | // } | 857 | // } |
858 | 858 | ||
859 | QString rt = editor->text(); | 859 | QString rt = editor->text(); |
860 | odebug << currentFileName << oendl; | 860 | odebug << currentFileName << oendl; |
861 | 861 | ||
862 | if( currentFileName.isEmpty() | 862 | if( currentFileName.isEmpty() |
863 | || currentFileName == tr("Unnamed") | 863 | || currentFileName == tr("Unnamed") |
864 | || currentFileName == tr("Text Editor")) { | 864 | || currentFileName == tr("Text Editor")) { |
865 | odebug << "do silly TT filename thing" << oendl; | 865 | odebug << "do silly TT filename thing" << oendl; |
866 | // if ( doc && doc->name().isEmpty() ) { | 866 | // if ( doc && doc->name().isEmpty() ) { |
867 | QString pt = rt.simplifyWhiteSpace(); | 867 | QString pt = rt.simplifyWhiteSpace(); |
868 | int i = pt.find( ' ' ); | 868 | int i = pt.find( ' ' ); |
869 | QString docname = pt; | 869 | QString docname = pt; |
870 | if ( i > 0 ) | 870 | if ( i > 0 ) |
871 | docname = pt.left( i ); | 871 | docname = pt.left( i ); |
872 | // remove "." at the beginning | 872 | // remove "." at the beginning |
873 | while( docname.startsWith( "." ) ) | 873 | while( docname.startsWith( "." ) ) |
874 | docname = docname.mid( 1 ); | 874 | docname = docname.mid( 1 ); |
875 | docname.replace( QRegExp("/"), "_" ); | 875 | docname.replace( QRegExp("/"), "_" ); |
876 | // cut the length. filenames longer than that | 876 | // cut the length. filenames longer than that |
877 | //don't make sense and something goes wrong when they get too long. | 877 | //don't make sense and something goes wrong when they get too long. |
878 | if ( docname.length() > 40 ) | 878 | if ( docname.length() > 40 ) |
879 | docname = docname.left(40); | 879 | docname = docname.left(40); |
880 | if ( docname.isEmpty() ) | 880 | if ( docname.isEmpty() ) |
881 | docname = tr("Unnamed"); | 881 | docname = tr("Unnamed"); |
882 | if(doc) doc->setName(docname); | 882 | if(doc) doc->setName(docname); |
883 | currentFileName=docname; | 883 | currentFileName=docname; |
884 | // } | 884 | // } |
885 | // else | 885 | // else |
886 | // odebug << "hmmmmmm" << oendl; | 886 | // odebug << "hmmmmmm" << oendl; |
887 | } | 887 | } |
888 | 888 | ||
889 | 889 | ||
890 | QMap<QString, QStringList> map; | 890 | QMap<QString, QStringList> map; |
891 | map.insert(tr("All"), QStringList() ); | 891 | map.insert(tr("All"), QStringList() ); |
892 | QStringList text; | 892 | QStringList text; |
893 | text << "text/*"; | 893 | text << "text/*"; |
894 | map.insert(tr("Text"), text ); | 894 | map.insert(tr("Text"), text ); |
895 | text << "*"; | 895 | text << "*"; |
896 | map.insert(tr("All"), text ); | 896 | map.insert(tr("All"), text ); |
897 | 897 | ||
898 | QFileInfo cuFi( currentFileName); | 898 | QFileInfo cuFi( currentFileName); |
899 | QString filee = cuFi.fileName(); | 899 | QString filee = cuFi.fileName(); |
900 | QString dire = cuFi.dirPath(); | 900 | QString dire = cuFi.dirPath(); |
901 | if(dire==".") | 901 | if(dire==".") |
902 | dire = QPEApplication::documentDir(); | 902 | dire = QPEApplication::documentDir(); |
903 | QString str; | 903 | QString str; |
904 | if( !featureAutoSave) { | 904 | if( !featureAutoSave) { |
905 | str = OFileDialog::getSaveFileName( 2, | 905 | str = OFileDialog::getSaveFileName( 2, |
906 | dire, | 906 | dire, |
907 | filee, map); | 907 | filee, map); |
908 | } else | 908 | } else |
909 | str=currentFileName; | 909 | str=currentFileName; |
910 | 910 | ||
911 | if(!str.isEmpty()) { | 911 | if(!str.isEmpty()) { |
912 | QString fileNm=str; | 912 | QString fileNm=str; |
913 | 913 | ||
914 | odebug << "saving filename "+fileNm << oendl; | 914 | odebug << "saving filename "+fileNm << oendl; |
915 | QFileInfo fi(fileNm); | 915 | QFileInfo fi(fileNm); |
916 | currentFileName=fi.fileName(); | 916 | currentFileName=fi.fileName(); |
917 | if(doc) | 917 | if(doc) |
918 | // QString file = doc->file(); | 918 | // QString file = doc->file(); |
919 | // doc->removeFiles(); | 919 | // doc->removeFiles(); |
920 | delete doc; | 920 | delete doc; |
921 | DocLnk nf; | 921 | DocLnk nf; |
922 | nf.setType("text/plain"); | 922 | nf.setType("text/plain"); |
923 | nf.setFile( fileNm); | 923 | nf.setFile( fileNm); |
924 | doc = new DocLnk(nf); | 924 | doc = new DocLnk(nf); |
925 | // editor->setText(rt); | 925 | // editor->setText(rt); |
926 | odebug << "Saving file as "+currentFileName << oendl; | 926 | odebug << "Saving file as "+currentFileName << oendl; |
927 | doc->setName( currentFileName); | 927 | doc->setName( currentFileName); |
928 | updateCaption( currentFileName); | 928 | updateCaption( currentFileName); |
929 | 929 | ||
930 | FileManager fm; | 930 | FileManager fm; |
931 | if ( !fm.saveFile( *doc, rt ) ) { | 931 | if ( !fm.saveFile( *doc, rt ) ) { |
932 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 932 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
933 | return false; | 933 | return false; |
934 | } | 934 | } |
935 | 935 | ||
936 | if( filePerms ) { | 936 | if( filePerms ) { |
937 | filePermissions *filePerm; | 937 | filePermissions *filePerm; |
938 | filePerm = new filePermissions(this, | 938 | filePerm = new filePermissions(this, |
939 | tr("Permissions"),true, | 939 | tr("Permissions"),true, |
940 | 0,(const QString &)fileNm); | 940 | 0,(const QString &)fileNm); |
941 | QPEApplication::execDialog( filePerm ); | 941 | QPEApplication::execDialog( filePerm ); |
942 | 942 | ||
943 | if( filePerm) | 943 | if( filePerm) |
944 | delete filePerm; | 944 | delete filePerm; |
945 | } | 945 | } |
946 | // } | 946 | // } |
947 | editor->setEdited( false); | 947 | editor->setEdited( false); |
948 | edited1 = false; | 948 | edited1 = false; |
949 | edited = false; | 949 | edited = false; |
950 | if(caption().left(1)=="*") | 950 | if(caption().left(1)=="*") |
951 | setCaption(caption().right(caption().length()-1)); | 951 | setCaption(caption().right(caption().length()-1)); |
952 | 952 | ||
953 | return true; | 953 | return true; |
954 | } | 954 | } |
955 | odebug << "returning false" << oendl; | 955 | odebug << "returning false" << oendl; |
956 | currentFileName = ""; | ||
956 | return false; | 957 | return false; |
957 | } //end saveAs | 958 | } //end saveAs |
958 | 959 | ||
959 | void TextEdit::clear() { | 960 | void TextEdit::clear() { |
960 | delete doc; | 961 | delete doc; |
961 | doc = 0; | 962 | doc = 0; |
962 | editor->clear(); | 963 | editor->clear(); |
963 | } | 964 | } |
964 | 965 | ||
965 | void TextEdit::updateCaption( const QString &name ) { | 966 | void TextEdit::updateCaption( const QString &name ) { |
966 | 967 | ||
967 | if ( name.isEmpty() ) | 968 | if ( name.isEmpty() ) |
968 | setCaption( tr("Text Editor") ); | 969 | setCaption( tr("Text Editor") ); |
969 | else { | 970 | else { |
970 | QString s = name; | 971 | QString s = name; |
971 | if ( s.isNull() ) | 972 | if ( s.isNull() ) |
972 | s = doc->name(); | 973 | s = doc->name(); |
973 | if ( s.isEmpty() ) { | 974 | if ( s.isEmpty() ) { |
974 | s = tr( "Unnamed" ); | 975 | s = tr( "Unnamed" ); |
975 | currentFileName=s; | 976 | currentFileName=s; |
976 | } | 977 | } |
977 | // if(s.left(1) == "/") | 978 | // if(s.left(1) == "/") |
978 | // s = s.right(s.length()-1); | 979 | // s = s.right(s.length()-1); |
979 | setCaption( tr("%1 - Text Editor").arg( s ) ); | 980 | setCaption( tr("%1 - Text Editor").arg( s ) ); |
980 | } | 981 | } |
981 | } | 982 | } |
982 | 983 | ||
983 | void TextEdit::setDocument(const QString& fileref) { | 984 | void TextEdit::setDocument(const QString& fileref) { |
984 | if(fileref != "Unnamed") { | 985 | if(fileref != "Unnamed") { |
985 | currentFileName=fileref; | 986 | currentFileName=fileref; |
986 | odebug << "setDocument" << oendl; | 987 | odebug << "setDocument" << oendl; |
987 | QFileInfo fi(currentFileName); | 988 | QFileInfo fi(currentFileName); |
988 | odebug << "basename:"+fi.baseName()+": current filenmame "+currentFileName << oendl; | 989 | odebug << "basename:"+fi.baseName()+": current filenmame "+currentFileName << oendl; |
989 | if( (fi.baseName().left(1)).isEmpty() ) { | 990 | if( (fi.baseName().left(1)).isEmpty() ) { |
990 | openDotFile(currentFileName); | 991 | openDotFile(currentFileName); |
991 | 992 | ||
992 | } else { | 993 | } else { |
993 | odebug << "setDoc open" << oendl; | 994 | odebug << "setDoc open" << oendl; |
994 | bFromDocView = true; | 995 | bFromDocView = true; |
995 | openFile(fileref); | 996 | openFile(fileref); |
996 | editor->setEdited(true); | 997 | editor->setEdited(true); |
997 | edited1=false; | 998 | edited1=false; |
998 | edited=true; | 999 | edited=true; |
999 | // fromSetDocument=false; | 1000 | // fromSetDocument=false; |
1000 | // doSearchBar(); | 1001 | // doSearchBar(); |
1001 | } | 1002 | } |
1002 | } | 1003 | } |
1003 | updateCaption( currentFileName); | 1004 | updateCaption( currentFileName); |
1004 | } | 1005 | } |
1005 | 1006 | ||
1006 | void TextEdit::changeFont() { | 1007 | void TextEdit::changeFont() { |
1007 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 1008 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
1008 | d-> setCaption ( tr( "Choose font" )); | 1009 | d-> setCaption ( tr( "Choose font" )); |
1009 | QBoxLayout *lay = new QVBoxLayout ( d ); | 1010 | QBoxLayout *lay = new QVBoxLayout ( d ); |
1010 | OFontSelector *ofs = new OFontSelector ( true, d ); | 1011 | OFontSelector *ofs = new OFontSelector ( true, d ); |
1011 | lay-> addWidget ( ofs ); | 1012 | lay-> addWidget ( ofs ); |
1012 | ofs-> setSelectedFont ( editor-> font ( )); | 1013 | ofs-> setSelectedFont ( editor-> font ( )); |
1013 | 1014 | ||
1014 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) | 1015 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) |
1015 | editor-> setFont ( ofs-> selectedFont ( )); | 1016 | editor-> setFont ( ofs-> selectedFont ( )); |
1016 | delete d; | 1017 | delete d; |
1017 | 1018 | ||
1018 | } | 1019 | } |
1019 | 1020 | ||
1020 | void TextEdit::editDelete() { | 1021 | void TextEdit::editDelete() { |
1021 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 1022 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
1022 | tr("Do you really want<BR>to <B>delete</B> " | 1023 | tr("Do you really want<BR>to <B>delete</B> " |
1023 | "the current file\nfrom the disk?<BR>This is " | 1024 | "the current file\nfrom the disk?<BR>This is " |
1024 | "<B>irreversable!</B>"), | 1025 | "<B>irreversable!</B>"), |
1025 | tr("Yes"),tr("No"),0,0,1) ) { | 1026 | tr("Yes"),tr("No"),0,0,1) ) { |
1026 | case 0: | 1027 | case 0: |
1027 | if(doc) { | 1028 | if(doc) { |
1028 | doc->removeFiles(); | 1029 | doc->removeFiles(); |
1029 | clear(); | 1030 | clear(); |
1030 | setCaption( tr("Text Editor") ); | 1031 | setCaption( tr("Text Editor") ); |
1031 | } | 1032 | } |
1032 | break; | 1033 | break; |
1033 | case 1: | 1034 | case 1: |
1034 | // exit | 1035 | // exit |
1035 | break; | 1036 | break; |
1036 | }; | 1037 | }; |
1037 | } | 1038 | } |
1038 | 1039 | ||
1039 | void TextEdit::changeStartConfig( bool b ) { | 1040 | void TextEdit::changeStartConfig( bool b ) { |
1040 | startWithNew=b; | 1041 | startWithNew=b; |
1041 | Config cfg("TextEdit"); | 1042 | Config cfg("TextEdit"); |
1042 | cfg.setGroup("View"); | 1043 | cfg.setGroup("View"); |
1043 | cfg.writeEntry("startNew",b); | 1044 | cfg.writeEntry("startNew",b); |
1044 | update(); | 1045 | update(); |
1045 | } | 1046 | } |
1046 | 1047 | ||
1047 | void TextEdit::editorChanged() { | 1048 | void TextEdit::editorChanged() { |
1048 | // odebug << "editor changed" << oendl; | 1049 | // odebug << "editor changed" << oendl; |
1049 | if( /*editor->edited() &&*/ /*edited && */!edited1) { | 1050 | if( /*editor->edited() &&*/ /*edited && */!edited1) { |
1050 | setCaption( "*"+caption()); | 1051 | setCaption( "*"+caption()); |
1051 | edited1=true; | 1052 | edited1=true; |
1052 | } | 1053 | } |
1053 | edited=true; | 1054 | edited=true; |
1054 | } | 1055 | } |
1055 | 1056 | ||
1056 | void TextEdit::receive(const QCString&msg, const QByteArray &) { | 1057 | void TextEdit::receive(const QCString&msg, const QByteArray &) { |
1057 | odebug << "QCop "+msg << oendl; | 1058 | odebug << "QCop "+msg << oendl; |
1058 | if ( msg == "setDocument(QString)" ) { | 1059 | if ( msg == "setDocument(QString)" ) { |
1059 | odebug << "bugger all" << oendl; | 1060 | odebug << "bugger all" << oendl; |
1060 | 1061 | ||
1061 | } | 1062 | } |
1062 | 1063 | ||
1063 | } | 1064 | } |
1064 | 1065 | ||
1065 | void TextEdit::doAbout() { | 1066 | void TextEdit::doAbout() { |
1066 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" | 1067 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" |
1067 | "2000 Trolltech AS, and<BR>" | 1068 | "2000 Trolltech AS, and<BR>" |
1068 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" | 1069 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" |
1069 | "and is licensed under the GPL")); | 1070 | "and is licensed under the GPL")); |
1070 | } | 1071 | } |
1071 | 1072 | ||
1072 | void TextEdit::doPrompt(bool b) { | 1073 | void TextEdit::doPrompt(bool b) { |
1073 | promptExit=b; | 1074 | promptExit=b; |
1074 | Config cfg("TextEdit"); | 1075 | Config cfg("TextEdit"); |
1075 | cfg.setGroup ( "View" ); | 1076 | cfg.setGroup ( "View" ); |
1076 | cfg.writeEntry ( "PromptExit", b); | 1077 | cfg.writeEntry ( "PromptExit", b); |
1077 | } | 1078 | } |
1078 | 1079 | ||
1079 | void TextEdit::doDesktop(bool b) { | 1080 | void TextEdit::doDesktop(bool b) { |
1080 | openDesktop=b; | 1081 | openDesktop=b; |
1081 | Config cfg("TextEdit"); | 1082 | Config cfg("TextEdit"); |
1082 | cfg.setGroup ( "View" ); | 1083 | cfg.setGroup ( "View" ); |
1083 | cfg.writeEntry ( "OpenDesktop", b); | 1084 | cfg.writeEntry ( "OpenDesktop", b); |
1084 | } | 1085 | } |
1085 | 1086 | ||
1086 | void TextEdit::doFilePerms(bool b) { | 1087 | void TextEdit::doFilePerms(bool b) { |
1087 | filePerms=b; | 1088 | filePerms=b; |
1088 | Config cfg("TextEdit"); | 1089 | Config cfg("TextEdit"); |
1089 | cfg.setGroup ( "View" ); | 1090 | cfg.setGroup ( "View" ); |
1090 | cfg.writeEntry ( "FilePermissions", b); | 1091 | cfg.writeEntry ( "FilePermissions", b); |
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | void TextEdit::editPasteTimeDate() { | 1094 | void TextEdit::editPasteTimeDate() { |
1094 | #ifndef QT_NO_CLIPBOARD | 1095 | #ifndef QT_NO_CLIPBOARD |
1095 | QClipboard *cb = QApplication::clipboard(); | 1096 | QClipboard *cb = QApplication::clipboard(); |
1096 | QDateTime dt = QDateTime::currentDateTime(); | 1097 | QDateTime dt = QDateTime::currentDateTime(); |
1097 | cb->setText( dt.toString()); | 1098 | cb->setText( dt.toString()); |
1098 | editor->paste(); | 1099 | editor->paste(); |
1099 | #endif | 1100 | #endif |
1100 | } | 1101 | } |
1101 | 1102 | ||
1102 | int TextEdit::savePrompt() | 1103 | int TextEdit::savePrompt() |
1103 | { | 1104 | { |
1104 | switch( QMessageBox::information( 0, (tr("Textedit")), | 1105 | switch( QMessageBox::information( 0, (tr("Textedit")), |
1105 | (tr("Textedit detected\n" | 1106 | (tr("Textedit detected\n" |
1106 | "you have unsaved changes\n" | 1107 | "you have unsaved changes\n" |
1107 | "Go ahead and save?\n")), | 1108 | "Go ahead and save?\n")), |
1108 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) | 1109 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) |
1109 | { | 1110 | { |
1110 | case 0: | 1111 | case 0: |
1111 | { | 1112 | { |
1112 | return 1; | 1113 | return 1; |
1113 | } | 1114 | } |
1114 | break; | 1115 | break; |
1115 | 1116 | ||
1116 | case 1: | 1117 | case 1: |
1117 | { | 1118 | { |
1118 | return 2; | 1119 | return 2; |
1119 | } | 1120 | } |
1120 | break; | 1121 | break; |
1121 | 1122 | ||
1122 | case 2: | 1123 | case 2: |
1123 | { | 1124 | { |
1124 | return -1; | 1125 | return -1; |
1125 | } | 1126 | } |
1126 | break; | 1127 | break; |
1127 | }; | 1128 | }; |
1128 | 1129 | ||
1129 | return 0; | 1130 | return 0; |
1130 | } | 1131 | } |
1131 | 1132 | ||
1132 | void TextEdit::timerCrank() | 1133 | void TextEdit::timerCrank() |
1133 | { | 1134 | { |
1134 | if(featureAutoSave && edited1) | 1135 | if(featureAutoSave && edited1) |
1135 | { | 1136 | { |
1136 | if(currentFileName.isEmpty()) | 1137 | if(currentFileName.isEmpty()) |
1137 | { | 1138 | { |
1138 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; | 1139 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; |
1139 | saveAs(); | 1140 | saveAs(); |
1140 | } | 1141 | } |
1141 | else | 1142 | else |
1142 | { | 1143 | { |
1143 | // odebug << "autosave" << oendl; | 1144 | // odebug << "autosave" << oendl; |
1144 | save(); | 1145 | save(); |
1145 | } | 1146 | } |
1146 | setTimer(); | 1147 | setTimer(); |
1147 | } | 1148 | } |