author | bipolar <bipolar> | 2002-03-06 00:58:32 (UTC) |
---|---|---|
committer | bipolar <bipolar> | 2002-03-06 00:58:32 (UTC) |
commit | 406bed0f501ea131ba31dbdecdde8c1fe8b15806 (patch) (unidiff) | |
tree | 11f375b25df3534e7d8ecd4120ee2df53a9791d3 | |
parent | fcb139a744cfe6c9521962595f15cd8369251c56 (diff) | |
download | opie-406bed0f501ea131ba31dbdecdde8c1fe8b15806.zip opie-406bed0f501ea131ba31dbdecdde8c1fe8b15806.tar.gz opie-406bed0f501ea131ba31dbdecdde8c1fe8b15806.tar.bz2 |
ljp: fixed setDocument opening the .desktop file and not the file it points too
-rw-r--r-- | core/apps/textedit/textedit.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index f138572..0f19da9 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -739,161 +739,164 @@ bool TextEdit::saveAs() | |||
739 | 739 | ||
740 | QString rt = editor->text(); | 740 | QString rt = editor->text(); |
741 | qDebug(currentFileName); | 741 | qDebug(currentFileName); |
742 | 742 | ||
743 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { | 743 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { |
744 | qDebug("do silly TT filename thing"); | 744 | qDebug("do silly TT filename thing"); |
745 | if ( doc->name().isEmpty() ) { | 745 | if ( doc->name().isEmpty() ) { |
746 | QString pt = rt.simplifyWhiteSpace(); | 746 | QString pt = rt.simplifyWhiteSpace(); |
747 | int i = pt.find( ' ' ); | 747 | int i = pt.find( ' ' ); |
748 | QString docname = pt; | 748 | QString docname = pt; |
749 | if ( i > 0 ) | 749 | if ( i > 0 ) |
750 | docname = pt.left( i ); | 750 | docname = pt.left( i ); |
751 | // remove "." at the beginning | 751 | // remove "." at the beginning |
752 | while( docname.startsWith( "." ) ) | 752 | while( docname.startsWith( "." ) ) |
753 | docname = docname.mid( 1 ); | 753 | docname = docname.mid( 1 ); |
754 | docname.replace( QRegExp("/"), "_" ); | 754 | docname.replace( QRegExp("/"), "_" ); |
755 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 755 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
756 | if ( docname.length() > 40 ) | 756 | if ( docname.length() > 40 ) |
757 | docname = docname.left(40); | 757 | docname = docname.left(40); |
758 | if ( docname.isEmpty() ) | 758 | if ( docname.isEmpty() ) |
759 | docname = "Unnamed"; | 759 | docname = "Unnamed"; |
760 | doc->setName(docname); | 760 | doc->setName(docname); |
761 | currentFileName=docname; | 761 | currentFileName=docname; |
762 | } | 762 | } |
763 | } | 763 | } |
764 | 764 | ||
765 | 765 | ||
766 | fileSaveDlg=new fileSaver(this,"Save File",TRUE, 0, currentFileName); | 766 | fileSaveDlg=new fileSaver(this,"Save File",TRUE, 0, currentFileName); |
767 | qDebug("wanna save filename "+currentFileName); | 767 | qDebug("wanna save filename "+currentFileName); |
768 | fileSaveDlg->exec(); | 768 | fileSaveDlg->exec(); |
769 | if( fileSaveDlg->result() == 1 ) { | 769 | if( fileSaveDlg->result() == 1 ) { |
770 | QString fileNm=fileSaveDlg->selectedFileName; | 770 | QString fileNm=fileSaveDlg->selectedFileName; |
771 | qDebug("saving filename "+fileNm); | 771 | qDebug("saving filename "+fileNm); |
772 | QFileInfo fi(fileNm); | 772 | QFileInfo fi(fileNm); |
773 | currentFileName=fi.fileName(); | 773 | currentFileName=fi.fileName(); |
774 | if(doc) { | 774 | if(doc) { |
775 | qDebug("doclnk exists"); | 775 | qDebug("doclnk exists"); |
776 | // QString file = doc->file(); | 776 | // QString file = doc->file(); |
777 | // doc->removeFiles(); | 777 | // doc->removeFiles(); |
778 | delete doc; | 778 | delete doc; |
779 | DocLnk nf; | 779 | DocLnk nf; |
780 | nf.setType("text/plain"); | 780 | nf.setType("text/plain"); |
781 | nf.setFile( fileNm); | 781 | nf.setFile( fileNm); |
782 | doc = new DocLnk(nf); | 782 | doc = new DocLnk(nf); |
783 | // editor->setText(rt); | 783 | // editor->setText(rt); |
784 | qDebug("openFile doclnk "+currentFileName); | 784 | qDebug("openFile doclnk "+currentFileName); |
785 | doc->setName( currentFileName); | 785 | doc->setName( currentFileName); |
786 | updateCaption( currentFileName); | 786 | updateCaption( currentFileName); |
787 | 787 | ||
788 | FileManager fm; | 788 | FileManager fm; |
789 | if ( !fm.saveFile( *doc, rt ) ) { | 789 | if ( !fm.saveFile( *doc, rt ) ) { |
790 | return false; | 790 | return false; |
791 | } | 791 | } |
792 | if( fileSaveDlg->filePermCheck->isChecked() ) { | 792 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
793 | filePermissions *filePerm; | 793 | filePermissions *filePerm; |
794 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); | 794 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); |
795 | filePerm->exec(); | 795 | filePerm->exec(); |
796 | editor->setEdited( false ); | 796 | editor->setEdited( false ); |
797 | if( filePerm) | 797 | if( filePerm) |
798 | delete filePerm; | 798 | delete filePerm; |
799 | } | 799 | } |
800 | } | 800 | } |
801 | } | 801 | } |
802 | 802 | ||
803 | if(fileSaveDlg) | 803 | if(fileSaveDlg) |
804 | delete fileSaveDlg; | 804 | delete fileSaveDlg; |
805 | return true; | 805 | return true; |
806 | } | 806 | } |
807 | 807 | ||
808 | void TextEdit::clear() | 808 | void TextEdit::clear() |
809 | { | 809 | { |
810 | delete doc; | 810 | delete doc; |
811 | doc = 0; | 811 | doc = 0; |
812 | editor->clear(); | 812 | editor->clear(); |
813 | } | 813 | } |
814 | 814 | ||
815 | void TextEdit::updateCaption( const QString &name ) | 815 | void TextEdit::updateCaption( const QString &name ) |
816 | { | 816 | { |
817 | if ( !doc ) | 817 | if ( !doc ) |
818 | setCaption( tr("Text Editor") ); | 818 | setCaption( tr("Text Editor") ); |
819 | else { | 819 | else { |
820 | QString s = name; | 820 | QString s = name; |
821 | if ( s.isNull() ) | 821 | if ( s.isNull() ) |
822 | s = doc->name(); | 822 | s = doc->name(); |
823 | if ( s.isEmpty() ) { | 823 | if ( s.isEmpty() ) { |
824 | s = tr( "Unnamed" ); | 824 | s = tr( "Unnamed" ); |
825 | currentFileName=s; | 825 | currentFileName=s; |
826 | } | 826 | } |
827 | 827 | ||
828 | setCaption( s + " - " + tr("Text Editor") ); | 828 | setCaption( s + " - " + tr("Text Editor") ); |
829 | } | 829 | } |
830 | } | 830 | } |
831 | 831 | ||
832 | void TextEdit::setDocument(const QString& fileref) | 832 | void TextEdit::setDocument(const QString& fileref) |
833 | { | 833 | { |
834 | bFromDocView = TRUE; | 834 | bFromDocView = TRUE; |
835 | qDebug("setDocument "+fileref); | ||
836 | bFromDocView = TRUE; | ||
837 | if(fileref.find(".desktop",0,TRUE) == -1) { | ||
835 | openFile(fileref); | 838 | openFile(fileref); |
836 | // bFromDocView = TRUE; | 839 | } else { |
837 | // openFile(DocLnk(fileref)); | 840 | openFile(DocLnk(fileref)); |
838 | // showEditTools(); | 841 | } |
839 | } | 842 | } |
840 | 843 | ||
841 | void TextEdit::closeEvent( QCloseEvent *e ) | 844 | void TextEdit::closeEvent( QCloseEvent *e ) |
842 | { | 845 | { |
843 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { | 846 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { |
844 | e->ignore(); | 847 | e->ignore(); |
845 | repaint(); | 848 | repaint(); |
846 | // fileRevert(); | 849 | // fileRevert(); |
847 | 850 | ||
848 | } else { | 851 | } else { |
849 | bFromDocView = FALSE; | 852 | bFromDocView = FALSE; |
850 | e->accept(); | 853 | e->accept(); |
851 | } | 854 | } |
852 | } | 855 | } |
853 | 856 | ||
854 | void TextEdit::accept() | 857 | void TextEdit::accept() |
855 | { | 858 | { |
856 | save(); | 859 | save(); |
857 | close(); | 860 | close(); |
858 | // fileOpen(); //godamn thats obnoxious! lemme out!!! | 861 | // fileOpen(); //godamn thats obnoxious! lemme out!!! |
859 | } | 862 | } |
860 | 863 | ||
861 | void TextEdit::changeFont() { | 864 | void TextEdit::changeFont() { |
862 | FontDatabase fdb; | 865 | FontDatabase fdb; |
863 | QFont defaultFont=editor->font(); | 866 | QFont defaultFont=editor->font(); |
864 | QFontInfo fontInfo(defaultFont); | 867 | QFontInfo fontInfo(defaultFont); |
865 | Config cfg("TextEdit"); | 868 | Config cfg("TextEdit"); |
866 | cfg.setGroup("Font"); | 869 | cfg.setGroup("Font"); |
867 | QString family = cfg.readEntry("Family", fontInfo.family()); | 870 | QString family = cfg.readEntry("Family", fontInfo.family()); |
868 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 871 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
869 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 872 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
870 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 873 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
871 | 874 | ||
872 | defaultFont = fdb.font(family,style,i_size,charSet); | 875 | defaultFont = fdb.font(family,style,i_size,charSet); |
873 | 876 | ||
874 | FontDialog *fontDlg; | 877 | FontDialog *fontDlg; |
875 | fontDlg=new FontDialog(this,"FontDialog",TRUE); | 878 | fontDlg=new FontDialog(this,"FontDialog",TRUE); |
876 | 879 | ||
877 | fontDlg->exec(); | 880 | fontDlg->exec(); |
878 | 881 | ||
879 | QFont myFont=fontDlg->selectedFont; | 882 | QFont myFont=fontDlg->selectedFont; |
880 | editor->setFont( myFont); | 883 | editor->setFont( myFont); |
881 | delete fontDlg; | 884 | delete fontDlg; |
882 | 885 | ||
883 | } | 886 | } |
884 | 887 | ||
885 | void TextEdit::editDelete() | 888 | void TextEdit::editDelete() |
886 | { | 889 | { |
887 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { | 890 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { |
888 | case 0: | 891 | case 0: |
889 | if(doc) { | 892 | if(doc) { |
890 | doc->removeFiles(); | 893 | doc->removeFiles(); |
891 | clear(); | 894 | clear(); |
892 | setCaption( tr("Text Editor") ); | 895 | setCaption( tr("Text Editor") ); |
893 | } | 896 | } |
894 | break; | 897 | break; |
895 | case 1: | 898 | case 1: |
896 | // exit | 899 | // exit |
897 | break; | 900 | break; |
898 | }; | 901 | }; |
899 | } | 902 | } |