summaryrefslogtreecommitdiff
path: root/core/apps/textedit
Unidiff
Diffstat (limited to 'core/apps/textedit') (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 2f59ede..019ffee 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -600,193 +600,193 @@ void TextEdit::findNext()
600{ 600{
601 editor->find( searchEdit->text(), FALSE, FALSE ); 601 editor->find( searchEdit->text(), FALSE, FALSE );
602 602
603} 603}
604 604
605void TextEdit::findClose() 605void TextEdit::findClose()
606{ 606{
607 searchVisible = FALSE; 607 searchVisible = FALSE;
608 searchBar->hide(); 608 searchBar->hide();
609} 609}
610 610
611void TextEdit::search() 611void TextEdit::search()
612{ 612{
613 editor->find( searchEdit->text(), FALSE, FALSE ); 613 editor->find( searchEdit->text(), FALSE, FALSE );
614} 614}
615 615
616void TextEdit::newFile( const DocLnk &f ) 616void TextEdit::newFile( const DocLnk &f )
617{ 617{
618 DocLnk nf = f; 618 DocLnk nf = f;
619 nf.setType("text/plain"); 619 nf.setType("text/plain");
620 clear(); 620 clear();
621 editorStack->raiseWidget( editor ); 621 editorStack->raiseWidget( editor );
622 setWState (WState_Reserved1 ); 622 setWState (WState_Reserved1 );
623 editor->setFocus(); 623 editor->setFocus();
624 doc = new DocLnk(nf); 624 doc = new DocLnk(nf);
625 qDebug("newFile "+currentFileName); 625 qDebug("newFile "+currentFileName);
626 updateCaption(currentFileName); 626 updateCaption(currentFileName);
627} 627}
628 628
629void TextEdit::openFile( const QString &f ) 629void TextEdit::openFile( const QString &f )
630{ 630{
631 bFromDocView = TRUE; 631 bFromDocView = TRUE;
632 DocLnk nf; 632 DocLnk nf;
633 nf.setType("text/plain"); 633 nf.setType("text/plain");
634 nf.setFile(f); 634 nf.setFile(f);
635 currentFileName=f; 635 currentFileName=f;
636 qDebug("openFile string"+currentFileName); 636 qDebug("openFile string"+currentFileName);
637 637
638 openFile(nf); 638 openFile(nf);
639 showEditTools(); 639 showEditTools();
640 // Show filename in caption 640 // Show filename in caption
641 QString name = f; 641 QString name = f;
642 int sep = name.findRev( '/' ); 642 int sep = name.findRev( '/' );
643 if ( sep > 0 ) 643 if ( sep > 0 )
644 name = name.mid( sep+1 ); 644 name = name.mid( sep+1 );
645 updateCaption( name ); 645 updateCaption( name );
646} 646}
647 647
648void TextEdit::openFile( const DocLnk &f ) 648void TextEdit::openFile( const DocLnk &f )
649{ 649{
650// clear(); 650// clear();
651 bFromDocView = TRUE; 651 bFromDocView = TRUE;
652 FileManager fm; 652 FileManager fm;
653 QString txt; 653 QString txt;
654 currentFileName=f.name(); 654 currentFileName=f.name();
655 qDebug("openFile doclnk " + currentFileName); 655 qDebug("openFile doclnk " + currentFileName);
656 if ( !fm.loadFile( f, txt ) ) { 656 if ( !fm.loadFile( f, txt ) ) {
657 // ####### could be a new file 657 // ####### could be a new file
658 qDebug( "Cannot open file" ); 658 qDebug( "Cannot open file" );
659 659
660 //return; 660 //return;
661 } 661 }
662 662
663 fileNew(); 663 fileNew();
664 if ( doc ) 664 if ( doc )
665 delete doc; 665 delete doc;
666 doc = new DocLnk(f); 666 doc = new DocLnk(f);
667 editor->setText(txt); 667 editor->setText(txt);
668 editor->setEdited( false); 668 editor->setEdited( false);
669 qDebug("openFile doclnk "+currentFileName); 669 qDebug("openFile doclnk "+currentFileName);
670 doc->setName(currentFileName); 670 doc->setName(currentFileName);
671 updateCaption(); 671 updateCaption();
672} 672}
673 673
674void TextEdit::showEditTools() 674void TextEdit::showEditTools()
675{ 675{
676// if ( !doc ) 676// if ( !doc )
677// close(); 677// close();
678// clear(); 678// clear();
679 fileSelector->hide(); 679 fileSelector->hide();
680 menu->show(); 680 menu->show();
681 editBar->show(); 681 editBar->show();
682 if ( searchVisible ) 682 if ( searchVisible )
683 searchBar->show(); 683 searchBar->show();
684// updateCaption(); 684// updateCaption();
685 editorStack->raiseWidget( editor ); 685 editorStack->raiseWidget( editor );
686 setWState (WState_Reserved1 ); 686 setWState (WState_Reserved1 );
687} 687}
688 688
689/*! 689/*!
690 unprompted save */ 690 unprompted save */
691bool TextEdit::save() 691bool TextEdit::save()
692{ 692{
693 QString file = doc->file(); 693 QString file = doc->file();
694 QString name= doc->name(); 694 QString name= doc->name();
695 QString rt = editor->text(); 695 QString rt = editor->text();
696 currentFileName= file ; 696 currentFileName= name ;
697 qDebug("saveFile "+currentFileName); 697 qDebug("saveFile "+currentFileName);
698 698
699 doc->setName( name); 699 doc->setName( name);
700 FileManager fm; 700 FileManager fm;
701 if ( !fm.saveFile( *doc, rt ) ) { 701 if ( !fm.saveFile( *doc, rt ) ) {
702 return false; 702 return false;
703 } 703 }
704// if(doc) 704// if(doc)
705// delete doc; 705// delete doc;
706// doc = 0; 706// doc = 0;
707 editor->setEdited( false ); 707 editor->setEdited( false );
708 return true; 708 return true;
709} 709}
710 710
711/*! 711/*!
712 prompted save */ 712 prompted save */
713bool TextEdit::saveAs() 713bool TextEdit::saveAs()
714{ 714{
715 qDebug("saveAsFile "+currentFileName); 715 qDebug("saveAsFile "+currentFileName);
716 716
717 // case of nothing to save... /// there's always something to save 717 // case of nothing to save... /// there's always something to save
718// if ( !doc )//|| !bFromDocView) 718// if ( !doc )//|| !bFromDocView)
719// { 719// {
720// qDebug("no doc"); 720// qDebug("no doc");
721// return true; 721// return true;
722// } 722// }
723 if ( !editor->edited() ) { 723 if ( !editor->edited() ) {
724 delete doc; 724 delete doc;
725 doc = 0; 725 doc = 0;
726 return true; 726 return true;
727 } 727 }
728 728
729 QString rt = editor->text(); 729 QString rt = editor->text();
730 qDebug(currentFileName); 730 qDebug(currentFileName);
731 731
732 if( currentFileName.isEmpty() || currentFileName == "Unnamed") { 732 if( currentFileName.isEmpty() || currentFileName == "Unnamed") {
733 qDebug("do silly TT filename thing"); 733 qDebug("do silly TT filename thing");
734 if ( doc->name().isEmpty() ) { 734 if ( doc->name().isEmpty() ) {
735 QString pt = rt.simplifyWhiteSpace(); 735 QString pt = rt.simplifyWhiteSpace();
736 int i = pt.find( ' ' ); 736 int i = pt.find( ' ' );
737 QString docname = pt; 737 QString docname = pt;
738 if ( i > 0 ) 738 if ( i > 0 )
739 docname = pt.left( i ); 739 docname = pt.left( i );
740 // remove "." at the beginning 740 // remove "." at the beginning
741 while( docname.startsWith( "." ) ) 741 while( docname.startsWith( "." ) )
742 docname = docname.mid( 1 ); 742 docname = docname.mid( 1 );
743 docname.replace( QRegExp("/"), "_" ); 743 docname.replace( QRegExp("/"), "_" );
744 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 744 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
745 if ( docname.length() > 40 ) 745 if ( docname.length() > 40 )
746 docname = docname.left(40); 746 docname = docname.left(40);
747 if ( docname.isEmpty() ) 747 if ( docname.isEmpty() )
748 docname = "Unnamed"; 748 docname = "Unnamed";
749 doc->setName(docname); 749 doc->setName(docname);
750 currentFileName=docname; 750 currentFileName=docname;
751 } 751 }
752 } 752 }
753 753
754 fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); 754 fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName);
755 qDebug("wanna save filename "+currentFileName); 755 qDebug("wanna save filename "+currentFileName);
756 fileSaveDlg->exec(); 756 fileSaveDlg->exec();
757 if( fileSaveDlg->result() == 1 ) { 757 if( fileSaveDlg->result() == 1 ) {
758 QString fileNm=fileSaveDlg->selectedFileName; 758 QString fileNm=fileSaveDlg->selectedFileName;
759 qDebug("saving filename "+fileNm); 759 qDebug("saving filename "+fileNm);
760 QFileInfo fi(fileNm); 760 QFileInfo fi(fileNm);
761 currentFileName=fi.fileName(); 761 currentFileName=fi.fileName();
762 if(doc) { 762 if(doc) {
763 qDebug("doclnk exists"); 763 qDebug("doclnk exists");
764// QString file = doc->file(); 764// QString file = doc->file();
765// doc->removeFiles(); 765// doc->removeFiles();
766 delete doc; 766 delete doc;
767 DocLnk nf; 767 DocLnk nf;
768 nf.setType("text/plain"); 768 nf.setType("text/plain");
769 nf.setFile( fileNm); 769 nf.setFile( fileNm);
770 doc = new DocLnk(nf); 770 doc = new DocLnk(nf);
771// editor->setText(rt); 771// editor->setText(rt);
772 qDebug("openFile doclnk "+currentFileName); 772 qDebug("openFile doclnk "+currentFileName);
773 } 773 }
774 doc->setName( currentFileName); 774 doc->setName( currentFileName);
775 updateCaption( currentFileName); 775 updateCaption( currentFileName);
776 776
777 FileManager fm; 777 FileManager fm;
778 if ( !fm.saveFile( *doc, rt ) ) { 778 if ( !fm.saveFile( *doc, rt ) ) {
779 return false; 779 return false;
780 } 780 }
781// delete doc; 781// delete doc;
782// doc = 0; 782// doc = 0;
783 editor->setEdited( false ); 783 editor->setEdited( false );
784 } 784 }
785 if(fileSaveDlg) 785 if(fileSaveDlg)
786 delete fileSaveDlg; 786 delete fileSaveDlg;
787 return true; 787 return true;
788} 788}
789 789
790void TextEdit::clear() 790void TextEdit::clear()
791{ 791{
792 delete doc; 792 delete doc;