summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 21bf4b3..6f96574 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -573,260 +573,257 @@ void TextEdit::fileOpen() {
573 QMap<QString, QStringList> map; 573 QMap<QString, QStringList> map;
574 map.insert(tr("All"), QStringList() ); 574 map.insert(tr("All"), QStringList() );
575 QStringList text; 575 QStringList text;
576 text << "text/*"; 576 text << "text/*";
577 map.insert(tr("Text"), text ); 577 map.insert(tr("Text"), text );
578 text << "*"; 578 text << "*";
579 map.insert(tr("All"), text ); 579 map.insert(tr("All"), text );
580 QString str = OFileDialog::getOpenFileName( 2, 580 QString str = OFileDialog::getOpenFileName( 2,
581 dir , 581 dir ,
582 QString::null, map); 582 QString::null, map);
583 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 583 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
584 { 584 {
585 cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); 585 cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false));
586 openFile( str ); 586 openFile( str );
587 } 587 }
588 else 588 else
589 updateCaption(); 589 updateCaption();
590} 590}
591 591
592void TextEdit::doSearchBar() { 592void TextEdit::doSearchBar() {
593 if(!useSearchBar) 593 if(!useSearchBar)
594 searchBar->hide(); 594 searchBar->hide();
595 else 595 else
596 searchBar->show(); 596 searchBar->show();
597} 597}
598 598
599#if 0 599#if 0
600void TextEdit::slotFind() { 600void TextEdit::slotFind() {
601 FindDialog frmFind( tr("Text Editor"), this ); 601 FindDialog frmFind( tr("Text Editor"), this );
602 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 602 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
603 editor, SLOT(slotDoFind( const QString&,bool,bool))); 603 editor, SLOT(slotDoFind( const QString&,bool,bool)));
604 604
605 //case sensitive, backwards, [category] 605 //case sensitive, backwards, [category]
606 606
607 connect( editor, SIGNAL(notFound()), 607 connect( editor, SIGNAL(notFound()),
608 &frmFind, SLOT(slotNotFound()) ); 608 &frmFind, SLOT(slotNotFound()) );
609 connect( editor, SIGNAL(searchWrapped()), 609 connect( editor, SIGNAL(searchWrapped()),
610 &frmFind, SLOT(slotWrapAround()) ); 610 &frmFind, SLOT(slotWrapAround()) );
611 611
612 frmFind.exec(); 612 frmFind.exec();
613 613
614 614
615} 615}
616#endif 616#endif
617 617
618void TextEdit::fileRevert() { 618void TextEdit::fileRevert() {
619 clear(); 619 clear();
620 fileOpen(); 620 fileOpen();
621} 621}
622 622
623void TextEdit::editCut() { 623void TextEdit::editCut() {
624#ifndef QT_NO_CLIPBOARD 624#ifndef QT_NO_CLIPBOARD
625 editor->cut(); 625 editor->cut();
626#endif 626#endif
627} 627}
628 628
629void TextEdit::editCopy() { 629void TextEdit::editCopy() {
630#ifndef QT_NO_CLIPBOARD 630#ifndef QT_NO_CLIPBOARD
631 editor->copy(); 631 editor->copy();
632#endif 632#endif
633} 633}
634 634
635void TextEdit::editPaste() { 635void TextEdit::editPaste() {
636#ifndef QT_NO_CLIPBOARD 636#ifndef QT_NO_CLIPBOARD
637 editor->paste(); 637 editor->paste();
638#endif 638#endif
639} 639}
640 640
641void TextEdit::editFind() { 641void TextEdit::editFind() {
642 searchBar->show(); 642 searchBar->show();
643 searchEdit->setFocus(); 643 searchEdit->setFocus();
644} 644}
645 645
646void TextEdit::findNext() { 646void TextEdit::findNext() {
647 editor->find( searchEdit->text(), false, false ); 647 editor->find( searchEdit->text(), false, false );
648 648
649} 649}
650 650
651void TextEdit::findClose() { 651void TextEdit::findClose() {
652 searchBar->hide(); 652 searchBar->hide();
653} 653}
654 654
655void TextEdit::search() { 655void TextEdit::search() {
656 editor->find( searchEdit->text(), false, false ); 656 editor->find( searchEdit->text(), false, false );
657} 657}
658 658
659void TextEdit::newFile( const DocLnk &f ) { 659void TextEdit::newFile( const DocLnk &f ) {
660 DocLnk nf = f; 660 DocLnk nf = f;
661 nf.setType("text/plain"); 661 nf.setType("text/plain");
662 clear(); 662 clear();
663 setWState (WState_Reserved1 ); 663 setWState (WState_Reserved1 );
664 editor->setFocus(); 664 editor->setFocus();
665 doc = new DocLnk(nf); 665 doc = new DocLnk(nf);
666 currentFileName = "Unnamed"; 666 currentFileName = "Unnamed";
667 qDebug("newFile "+currentFileName); 667 qDebug("newFile "+currentFileName);
668 updateCaption( currentFileName); 668 updateCaption( currentFileName);
669// editor->setEdited( false); 669// editor->setEdited( false);
670} 670}
671 671
672void TextEdit::openDotFile( const QString &f ) { 672void TextEdit::openDotFile( const QString &f ) {
673 if(!currentFileName.isEmpty()) { 673 if(!currentFileName.isEmpty()) {
674 currentFileName=f; 674 currentFileName=f;
675 675
676 qDebug("openFile dotfile " + currentFileName); 676 qDebug("openFile dotfile " + currentFileName);
677 QString txt; 677 QString txt;
678 QFile file(f); 678 QFile file(f);
679 file.open(IO_ReadWrite); 679 file.open(IO_ReadWrite);
680 QTextStream t(&file); 680 QTextStream t(&file);
681 while ( !t.atEnd()) { 681 while ( !t.atEnd()) {
682 txt+=t.readLine()+"\n"; 682 txt+=t.readLine()+"\n";
683 } 683 }
684 editor->setText(txt); 684 editor->setText(txt);
685 editor->setEdited( false); 685 editor->setEdited( false);
686 edited1=false; 686 edited1=false;
687 edited=false; 687 edited=false;
688 688
689 689
690 } 690 }
691 updateCaption( currentFileName); 691 updateCaption( currentFileName);
692} 692}
693 693
694void TextEdit::openFile( const QString &f ) { 694void TextEdit::openFile( const QString &f ) {
695 qDebug("filename is "+ f); 695 qDebug("filename is "+ f);
696 QString filer; 696 QString filer;
697 QFileInfo fi( f); 697 QFileInfo fi( f);
698// bFromDocView = true; 698// bFromDocView = true;
699 if(f.find(".desktop",0,true) != -1 && !openDesktop ) 699 if(f.find(".desktop",0,true) != -1 && !openDesktop )
700 { 700 {
701 switch ( QMessageBox::warning(this,tr("Text Editor"), 701 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) )
702 tr("Text Editor has detected<BR>you selected a <B>.desktop</B>
703file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
704 tr(".desktop File"),tr("Linked Document"),0,1,1) )
705 { 702 {
706 case 0: //desktop 703 case 0: //desktop
707 filer = f; 704 filer = f;
708 break; 705 break;
709 case 1: //linked 706 case 1: //linked
710 DocLnk sf(f); 707 DocLnk sf(f);
711 filer = sf.file(); 708 filer = sf.file();
712 break; 709 break;
713 }; 710 };
714 } 711 }
715 else if(fi.baseName().left(1) == "") 712 else if(fi.baseName().left(1) == "")
716 { 713 {
717 qDebug("opening dotfile"); 714 qDebug("opening dotfile");
718 currentFileName=f; 715 currentFileName=f;
719 openDotFile(currentFileName); 716 openDotFile(currentFileName);
720 return; 717 return;
721 } 718 }
722 else 719 else
723 { 720 {
724 DocLnk sf(f); 721 DocLnk sf(f);
725 filer = sf.file(); 722 filer = sf.file();
726 if(filer.right(1) == "/") 723 if(filer.right(1) == "/")
727 filer = f; 724 filer = f;
728 } 725 }
729 726
730 DocLnk nf; 727 DocLnk nf;
731 nf.setType("text/plain"); 728 nf.setType("text/plain");
732 nf.setFile(filer); 729 nf.setFile(filer);
733 currentFileName=filer; 730 currentFileName=filer;
734 731
735 nf.setName(fi.baseName()); 732 nf.setName(fi.baseName());
736 openFile(nf); 733 openFile(nf);
737 734
738 qDebug("openFile string "+currentFileName); 735 qDebug("openFile string "+currentFileName);
739 736
740 showEditTools(); 737 showEditTools();
741 // Show filename in caption 738 // Show filename in caption
742 QString name = filer; 739 QString name = filer;
743 int sep = name.findRev( '/' ); 740 int sep = name.findRev( '/' );
744 if ( sep > 0 ) 741 if ( sep > 0 )
745 name = name.mid( sep+1 ); 742 name = name.mid( sep+1 );
746 updateCaption( name ); 743 updateCaption( name );
747} 744}
748 745
749void TextEdit::openFile( const DocLnk &f ) { 746void TextEdit::openFile( const DocLnk &f ) {
750// clear(); 747// clear();
751// bFromDocView = true; 748// bFromDocView = true;
752 FileManager fm; 749 FileManager fm;
753 QString txt; 750 QString txt;
754 currentFileName=f.file(); 751 currentFileName=f.file();
755 qDebug("openFile doclnk " + currentFileName); 752 qDebug("openFile doclnk " + currentFileName);
756 if ( !fm.loadFile( f, txt ) ) { 753 if ( !fm.loadFile( f, txt ) ) {
757 // ####### could be a new file 754 // ####### could be a new file
758 qDebug( "Cannot open file" ); 755 qDebug( "Cannot open file" );
759 } 756 }
760// fileNew(); 757// fileNew();
761 if ( doc ) 758 if ( doc )
762 delete doc; 759 delete doc;
763 doc = new DocLnk(f); 760 doc = new DocLnk(f);
764 editor->setText(txt); 761 editor->setText(txt);
765 editor->setEdited( false); 762 editor->setEdited( false);
766 edited1=false; 763 edited1=false;
767 edited=false; 764 edited=false;
768 765
769 doc->setName(currentFileName); 766 doc->setName(currentFileName);
770 updateCaption(); 767 updateCaption();
771 setTimer(); 768 setTimer();
772} 769}
773 770
774void TextEdit::showEditTools() { 771void TextEdit::showEditTools() {
775 menu->show(); 772 menu->show();
776 editBar->show(); 773 editBar->show();
777 if(!useSearchBar) 774 if(!useSearchBar)
778 searchBar->hide(); 775 searchBar->hide();
779 else 776 else
780 searchBar->show(); 777 searchBar->show();
781 setWState (WState_Reserved1 ); 778 setWState (WState_Reserved1 );
782} 779}
783 780
784/*! 781/*!
785 unprompted save */ 782 unprompted save */
786bool TextEdit::save() { 783bool TextEdit::save() {
787 qDebug("saveAsFile " + currentFileName); 784 qDebug("saveAsFile " + currentFileName);
788 if(currentFileName.isEmpty()) { 785 if(currentFileName.isEmpty()) {
789 saveAs(); 786 saveAs();
790 return false; 787 return false;
791 } 788 }
792 789
793 QString file = doc->file(); 790 QString file = doc->file();
794 qDebug("saver file "+file); 791 qDebug("saver file "+file);
795 QString name= doc->name(); 792 QString name= doc->name();
796 qDebug("File named "+name); 793 qDebug("File named "+name);
797 QString rt = editor->text(); 794 QString rt = editor->text();
798 if( !rt.isEmpty() ) { 795 if( !rt.isEmpty() ) {
799 if(name.isEmpty()) { 796 if(name.isEmpty()) {
800 saveAs(); 797 saveAs();
801 } else { 798 } else {
802 currentFileName= name ; 799 currentFileName= name ;
803 qDebug("saveFile "+currentFileName); 800 qDebug("saveFile "+currentFileName);
804 801
805 struct stat buf; 802 struct stat buf;
806 mode_t mode; 803 mode_t mode;
807 stat(file.latin1(), &buf); 804 stat(file.latin1(), &buf);
808 mode = buf.st_mode; 805 mode = buf.st_mode;
809 806
810 if(!fileIs) { 807 if(!fileIs) {
811 doc->setName( name); 808 doc->setName( name);
812 FileManager fm; 809 FileManager fm;
813 if ( !fm.saveFile( *doc, rt ) ) { 810 if ( !fm.saveFile( *doc, rt ) ) {
814 return false; 811 return false;
815 } 812 }
816 } else { 813 } else {
817 qDebug("regular save file"); 814 qDebug("regular save file");
818 QFile f(file); 815 QFile f(file);
819 if( f.open(IO_WriteOnly)) { 816 if( f.open(IO_WriteOnly)) {
820 QCString crt = rt.utf8(); 817 QCString crt = rt.utf8();
821 f.writeBlock(crt,crt.length()); 818 f.writeBlock(crt,crt.length());
822 } else { 819 } else {
823 QMessageBox::message(tr("Text Edit"),tr("Write Failed")); 820 QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
824 return false; 821 return false;
825 } 822 }
826 823
827 } 824 }
828 editor->setEdited( false); 825 editor->setEdited( false);
829 edited1=false; 826 edited1=false;
830 edited=false; 827 edited=false;
831 if(caption().left(1)=="*") 828 if(caption().left(1)=="*")
832 setCaption(caption().right(caption().length()-1)); 829 setCaption(caption().right(caption().length()-1));