summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-12-25 15:30:40 (UTC)
committer llornkcor <llornkcor>2002-12-25 15:30:40 (UTC)
commitce5af9d00edb805f4c1115d5a461dae7210cb218 (patch) (unidiff)
tree5fdd75447a787144d8ba53ef0f5e19bcf44f70d4
parent1cb75c721b69459494cb599730a96bbc1ddc0f65 (diff)
downloadopie-ce5af9d00edb805f4c1115d5a461dae7210cb218.zip
opie-ce5af9d00edb805f4c1115d5a461dae7210cb218.tar.gz
opie-ce5af9d00edb805f4c1115d5a461dae7210cb218.tar.bz2
fix dotfiles - again
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index dc0d61b..9ef423c 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -678,204 +678,204 @@ void TextEdit::editCut() {
678#ifndef QT_NO_CLIPBOARD 678#ifndef QT_NO_CLIPBOARD
679 editor->cut(); 679 editor->cut();
680#endif 680#endif
681} 681}
682 682
683void TextEdit::editCopy() { 683void TextEdit::editCopy() {
684#ifndef QT_NO_CLIPBOARD 684#ifndef QT_NO_CLIPBOARD
685 editor->copy(); 685 editor->copy();
686#endif 686#endif
687} 687}
688 688
689void TextEdit::editPaste() { 689void TextEdit::editPaste() {
690#ifndef QT_NO_CLIPBOARD 690#ifndef QT_NO_CLIPBOARD
691 editor->paste(); 691 editor->paste();
692#endif 692#endif
693} 693}
694 694
695void TextEdit::editFind() { 695void TextEdit::editFind() {
696 searchBar->show(); 696 searchBar->show();
697 searchEdit->setFocus(); 697 searchEdit->setFocus();
698} 698}
699 699
700void TextEdit::findNext() { 700void TextEdit::findNext() {
701 editor->find( searchEdit->text(), false, false ); 701 editor->find( searchEdit->text(), false, false );
702 702
703} 703}
704 704
705void TextEdit::findClose() { 705void TextEdit::findClose() {
706 searchBar->hide(); 706 searchBar->hide();
707} 707}
708 708
709void TextEdit::search() { 709void TextEdit::search() {
710 editor->find( searchEdit->text(), false, false ); 710 editor->find( searchEdit->text(), false, false );
711} 711}
712 712
713void TextEdit::newFile( const DocLnk &f ) { 713void TextEdit::newFile( const DocLnk &f ) {
714 DocLnk nf = f; 714 DocLnk nf = f;
715 nf.setType("text/plain"); 715 nf.setType("text/plain");
716 clear(); 716 clear();
717 setWState (WState_Reserved1 ); 717 setWState (WState_Reserved1 );
718 editor->setFocus(); 718 editor->setFocus();
719 doc = new DocLnk(nf); 719 doc = new DocLnk(nf);
720 currentFileName = "Unnamed"; 720 currentFileName = "Unnamed";
721 qDebug("newFile "+currentFileName); 721 qDebug("newFile "+currentFileName);
722 updateCaption( currentFileName); 722 updateCaption( currentFileName);
723// editor->setEdited( false); 723// editor->setEdited( false);
724} 724}
725 725
726void TextEdit::openDotFile( const QString &f ) { 726void TextEdit::openDotFile( const QString &f ) {
727 if(!currentFileName.isEmpty()) { 727 if(!currentFileName.isEmpty()) {
728 currentFileName=f; 728 currentFileName=f;
729 729
730 qDebug("openFile dotfile " + currentFileName); 730 qDebug("openFile dotfile " + currentFileName);
731 QString txt; 731 QString txt;
732 QFile file(f); 732 QFile file(f);
733 file.open(IO_ReadWrite); 733 file.open(IO_ReadWrite);
734 QTextStream t(&file); 734 QTextStream t(&file);
735 while ( !t.atEnd()) { 735 while ( !t.atEnd()) {
736 txt+=t.readLine()+"\n"; 736 txt+=t.readLine()+"\n";
737 } 737 }
738 editor->setText(txt); 738 editor->setText(txt);
739 editor->setEdited( false); 739 editor->setEdited( false);
740 edited1=false; 740 edited1=false;
741 edited=false; 741 edited=false;
742 742
743 743
744 } 744 }
745 updateCaption( currentFileName); 745 updateCaption( currentFileName);
746} 746}
747 747
748void TextEdit::openFile( const QString &f ) { 748void TextEdit::openFile( const QString &f ) {
749 qDebug("filename is "+ f); 749 qDebug("filename is "+ f);
750 QString filer; 750 QString filer;
751 QFileInfo fi( f); 751 QFileInfo fi( f);
752// bFromDocView = true; 752// bFromDocView = true;
753 if(f.find(".desktop",0,true) != -1 && !openDesktop ) { 753 if(f.find(".desktop",0,true) != -1 && !openDesktop ) {
754 switch ( QMessageBox::warning(this,tr("Text Editor"), 754 switch ( QMessageBox::warning(this,tr("Text Editor"),
755 tr("Text Editor has detected<BR>you selected a <B>.desktop</B> 755 tr("Text Editor has detected<BR>you selected a <B>.desktop</B>
756file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), 756file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
757 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 757 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
758 case 0: 758 case 0:
759 filer = f; 759 filer = f;
760 break; 760 break;
761 case 1: 761 case 1:
762 DocLnk sf(f); 762 DocLnk sf(f);
763 filer = sf.file(); 763 filer = sf.file();
764 break; 764 break;
765 } 765 }
766 } else if(fi.baseName().left(1) == "") { 766 } else if(fi.baseName().left(1) == "") {
767 currentFileName=f; 767 currentFileName=f;
768 openDotFile(currentFileName); 768 openDotFile(currentFileName);
769 } else { 769 } else {
770 DocLnk sf(f); 770 DocLnk sf(f);
771 filer = sf.file(); 771 filer = sf.file();
772 if(filer.right(1) == "/") 772 if(filer.right(1) == "/")
773 filer = f; 773 filer = f;
774 }
775 774
776 DocLnk nf; 775 DocLnk nf;
777 nf.setType("text/plain"); 776 nf.setType("text/plain");
778 nf.setFile(filer); 777 nf.setFile(filer);
779 currentFileName=filer; 778 currentFileName=filer;
780 779
781 nf.setName(fi.baseName()); 780 nf.setName(fi.baseName());
782 openFile(nf); 781 openFile(nf);
783 782
784 qDebug("openFile string "+currentFileName); 783 qDebug("openFile string "+currentFileName);
785 784
785 }
786 showEditTools(); 786 showEditTools();
787 // Show filename in caption 787 // Show filename in caption
788 QString name = filer; 788 QString name = filer;
789 int sep = name.findRev( '/' ); 789 int sep = name.findRev( '/' );
790 if ( sep > 0 ) 790 if ( sep > 0 )
791 name = name.mid( sep+1 ); 791 name = name.mid( sep+1 );
792 updateCaption( name ); 792 updateCaption( name );
793} 793}
794 794
795void TextEdit::openFile( const DocLnk &f ) { 795void TextEdit::openFile( const DocLnk &f ) {
796// clear(); 796// clear();
797// bFromDocView = true; 797// bFromDocView = true;
798 FileManager fm; 798 FileManager fm;
799 QString txt; 799 QString txt;
800 currentFileName=f.file(); 800 currentFileName=f.file();
801 qDebug("openFile doclnk " + currentFileName); 801 qDebug("openFile doclnk " + currentFileName);
802 if ( !fm.loadFile( f, txt ) ) { 802 if ( !fm.loadFile( f, txt ) ) {
803 // ####### could be a new file 803 // ####### could be a new file
804 qDebug( "Cannot open file" ); 804 qDebug( "Cannot open file" );
805 } 805 }
806// fileNew(); 806// fileNew();
807 if ( doc ) 807 if ( doc )
808 delete doc; 808 delete doc;
809 doc = new DocLnk(f); 809 doc = new DocLnk(f);
810 editor->setText(txt); 810 editor->setText(txt);
811 editor->setEdited( false); 811 editor->setEdited( false);
812 edited1=false; 812 edited1=false;
813 edited=false; 813 edited=false;
814 814
815 doc->setName(currentFileName); 815 doc->setName(currentFileName);
816 updateCaption(); 816 updateCaption();
817} 817}
818 818
819void TextEdit::showEditTools() { 819void TextEdit::showEditTools() {
820 menu->show(); 820 menu->show();
821 editBar->show(); 821 editBar->show();
822 if(!useSearchBar) 822 if(!useSearchBar)
823 searchBar->hide(); 823 searchBar->hide();
824 else 824 else
825 searchBar->show(); 825 searchBar->show();
826 setWState (WState_Reserved1 ); 826 setWState (WState_Reserved1 );
827} 827}
828 828
829/*! 829/*!
830 unprompted save */ 830 unprompted save */
831bool TextEdit::save() { 831bool TextEdit::save() {
832 qDebug("saveAsFile " + currentFileName); 832 qDebug("saveAsFile " + currentFileName);
833 if(currentFileName.isEmpty()) { 833 if(currentFileName.isEmpty()) {
834 saveAs(); 834 saveAs();
835 return false; 835 return false;
836 } 836 }
837 QString file = doc->file(); 837 QString file = doc->file();
838 qDebug("saver file "+file); 838 qDebug("saver file "+file);
839 QString name= doc->name(); 839 QString name= doc->name();
840 qDebug("File named "+name); 840 qDebug("File named "+name);
841 QString rt = editor->text(); 841 QString rt = editor->text();
842 if( !rt.isEmpty() ) { 842 if( !rt.isEmpty() ) {
843 if(name.isEmpty()) { 843 if(name.isEmpty()) {
844 saveAs(); 844 saveAs();
845 } else { 845 } else {
846 currentFileName= name ; 846 currentFileName= name ;
847 qDebug("saveFile "+currentFileName); 847 qDebug("saveFile "+currentFileName);
848 848
849 struct stat buf; 849 struct stat buf;
850 mode_t mode; 850 mode_t mode;
851 stat(file.latin1(), &buf); 851 stat(file.latin1(), &buf);
852 mode = buf.st_mode; 852 mode = buf.st_mode;
853 853
854 if(!fileIs) { 854 if(!fileIs) {
855 doc->setName( name); 855 doc->setName( name);
856 FileManager fm; 856 FileManager fm;
857 if ( !fm.saveFile( *doc, rt ) ) { 857 if ( !fm.saveFile( *doc, rt ) ) {
858 return false; 858 return false;
859 } 859 }
860 } else { 860 } else {
861 qDebug("regular save file"); 861 qDebug("regular save file");
862 QFile f(file); 862 QFile f(file);
863 if( f.open(IO_WriteOnly)) { 863 if( f.open(IO_WriteOnly)) {
864 QCString crt = rt.utf8(); 864 QCString crt = rt.utf8();
865 f.writeBlock(crt,crt.length()); 865 f.writeBlock(crt,crt.length());
866 } else { 866 } else {
867 QMessageBox::message(tr("Text Edit"),tr("Write Failed")); 867 QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
868 return false; 868 return false;
869 } 869 }
870 870
871 } 871 }
872 editor->setEdited( false); 872 editor->setEdited( false);
873 edited1=false; 873 edited1=false;
874 edited=false; 874 edited=false;
875 if(caption().left(1)=="*") 875 if(caption().left(1)=="*")
876 setCaption(caption().right(caption().length()-1)); 876 setCaption(caption().right(caption().length()-1));
877 877
878 878
879 chmod( file.latin1(), mode); 879 chmod( file.latin1(), mode);
880 } 880 }
881 return true; 881 return true;