-rw-r--r-- | core/apps/textedit/textedit.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 759e440..61beac5 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -622,107 +622,108 @@ void TextEdit::editCopy() { | |||
622 | editor->copy(); | 622 | editor->copy(); |
623 | #endif | 623 | #endif |
624 | } | 624 | } |
625 | 625 | ||
626 | void TextEdit::editPaste() { | 626 | void TextEdit::editPaste() { |
627 | #ifndef QT_NO_CLIPBOARD | 627 | #ifndef QT_NO_CLIPBOARD |
628 | editor->paste(); | 628 | editor->paste(); |
629 | #endif | 629 | #endif |
630 | } | 630 | } |
631 | 631 | ||
632 | void TextEdit::editFind() { | 632 | void TextEdit::editFind() { |
633 | searchBar->show(); | 633 | searchBar->show(); |
634 | searchEdit->setFocus(); | 634 | searchEdit->setFocus(); |
635 | } | 635 | } |
636 | 636 | ||
637 | void TextEdit::findNext() { | 637 | void TextEdit::findNext() { |
638 | editor->find( searchEdit->text(), false, false ); | 638 | editor->find( searchEdit->text(), false, false ); |
639 | 639 | ||
640 | } | 640 | } |
641 | 641 | ||
642 | void TextEdit::findClose() { | 642 | void TextEdit::findClose() { |
643 | searchBar->hide(); | 643 | searchBar->hide(); |
644 | } | 644 | } |
645 | 645 | ||
646 | void TextEdit::search() { | 646 | void TextEdit::search() { |
647 | editor->find( searchEdit->text(), false, false ); | 647 | editor->find( searchEdit->text(), false, false ); |
648 | } | 648 | } |
649 | 649 | ||
650 | void TextEdit::newFile( const DocLnk &f ) { | 650 | void TextEdit::newFile( const DocLnk &f ) { |
651 | DocLnk nf = f; | 651 | DocLnk nf = f; |
652 | nf.setType("text/plain"); | 652 | nf.setType("text/plain"); |
653 | clear(); | 653 | clear(); |
654 | setWState (WState_Reserved1 ); | 654 | setWState (WState_Reserved1 ); |
655 | editor->setFocus(); | 655 | editor->setFocus(); |
656 | doc = new DocLnk(nf); | 656 | doc = new DocLnk(nf); |
657 | currentFileName = "Unnamed"; | 657 | currentFileName = "Unnamed"; |
658 | odebug << "newFile "+currentFileName << oendl; | 658 | odebug << "newFile "+currentFileName << oendl; |
659 | updateCaption( currentFileName); | 659 | updateCaption( currentFileName); |
660 | // editor->setEdited( false); | 660 | // editor->setEdited( false); |
661 | } | 661 | } |
662 | 662 | ||
663 | void TextEdit::openDotFile( const QString &f ) { | 663 | void TextEdit::openDotFile( const QString &f ) { |
664 | if(!currentFileName.isEmpty()) { | 664 | if(!currentFileName.isEmpty()) { |
665 | currentFileName=f; | 665 | currentFileName=f; |
666 | 666 | ||
667 | odebug << "openFile dotfile " + currentFileName << oendl; | 667 | odebug << "openFile dotfile " + currentFileName << oendl; |
668 | QString txt; | 668 | QString txt; |
669 | QFile file(f); | 669 | QFile file(f); |
670 | file.open(IO_ReadWrite); | 670 | if (!file.open(IO_ReadWrite)) |
671 | owarn << "Failed to open file " << file.name() << oendl; | ||
672 | else { | ||
671 | QTextStream t(&file); | 673 | QTextStream t(&file); |
672 | while ( !t.atEnd()) { | 674 | while ( !t.atEnd()) { |
673 | txt+=t.readLine()+"\n"; | 675 | txt+=t.readLine()+"\n"; |
674 | } | 676 | } |
675 | editor->setText(txt); | 677 | editor->setText(txt); |
676 | editor->setEdited( false); | 678 | editor->setEdited( false); |
677 | edited1=false; | 679 | edited1=false; |
678 | edited=false; | 680 | edited=false; |
679 | 681 | } | |
680 | |||
681 | } | 682 | } |
682 | updateCaption( currentFileName); | 683 | updateCaption( currentFileName); |
683 | } | 684 | } |
684 | 685 | ||
685 | void TextEdit::openFile( const QString &f ) { | 686 | void TextEdit::openFile( const QString &f ) { |
686 | odebug << "filename is "+ f << oendl; | 687 | odebug << "filename is "+ f << oendl; |
687 | QString filer; | 688 | QString filer; |
688 | QFileInfo fi( f); | 689 | QFileInfo fi( f); |
689 | // bFromDocView = true; | 690 | // bFromDocView = true; |
690 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 691 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
691 | { | 692 | { |
692 | 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) ) | 693 | 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) ) |
693 | { | 694 | { |
694 | case 0: //desktop | 695 | case 0: //desktop |
695 | filer = f; | 696 | filer = f; |
696 | break; | 697 | break; |
697 | case 1: //linked | 698 | case 1: //linked |
698 | DocLnk sf(f); | 699 | DocLnk sf(f); |
699 | filer = sf.file(); | 700 | filer = sf.file(); |
700 | break; | 701 | break; |
701 | }; | 702 | }; |
702 | } | 703 | } |
703 | else if(fi.baseName().left(1) == "") | 704 | else if(fi.baseName().left(1) == "") |
704 | { | 705 | { |
705 | odebug << "opening dotfile" << oendl; | 706 | odebug << "opening dotfile" << oendl; |
706 | currentFileName=f; | 707 | currentFileName=f; |
707 | openDotFile(currentFileName); | 708 | openDotFile(currentFileName); |
708 | return; | 709 | return; |
709 | } | 710 | } |
710 | /* | 711 | /* |
711 | * The problem is a file where Config(f).isValid() and it does not | 712 | * The problem is a file where Config(f).isValid() and it does not |
712 | * end with .desktop will be treated as desktop file | 713 | * end with .desktop will be treated as desktop file |
713 | */ | 714 | */ |
714 | else if (f.find(".desktop",0,true) != -1 ) | 715 | else if (f.find(".desktop",0,true) != -1 ) |
715 | { | 716 | { |
716 | DocLnk sf(f); | 717 | DocLnk sf(f); |
717 | filer = sf.file(); | 718 | filer = sf.file(); |
718 | if(filer.right(1) == "/") | 719 | if(filer.right(1) == "/") |
719 | filer = f; | 720 | filer = f; |
720 | 721 | ||
721 | } | 722 | } |
722 | else | 723 | else |
723 | filer = f; | 724 | filer = f; |
724 | 725 | ||
725 | DocLnk nf; | 726 | DocLnk nf; |
726 | nf.setType("text/plain"); | 727 | nf.setType("text/plain"); |
727 | nf.setFile(filer); | 728 | nf.setFile(filer); |
728 | currentFileName=filer; | 729 | currentFileName=filer; |