-rw-r--r-- | core/apps/textedit/textedit.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 4cf1b07..e931f01 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -448,385 +448,385 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
448 | 448 | ||
449 | searchBar->hide(); | 449 | searchBar->hide(); |
450 | 450 | ||
451 | editor = new QpeEditor( this ); | 451 | editor = new QpeEditor( this ); |
452 | setCentralWidget( editor ); | 452 | setCentralWidget( editor ); |
453 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 453 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
454 | connect( editor, SIGNAL( textChanged() ), | 454 | connect( editor, SIGNAL( textChanged() ), |
455 | this, SLOT( editorChanged() ) ); | 455 | this, SLOT( editorChanged() ) ); |
456 | 456 | ||
457 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 457 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
458 | 458 | ||
459 | Config cfg("TextEdit"); | 459 | Config cfg("TextEdit"); |
460 | cfg. setGroup ( "Font" ); | 460 | cfg. setGroup ( "Font" ); |
461 | 461 | ||
462 | QFont defaultFont = editor-> font ( ); | 462 | QFont defaultFont = editor-> font ( ); |
463 | 463 | ||
464 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 464 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
465 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 465 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
466 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 466 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
467 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 467 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
468 | 468 | ||
469 | defaultFont = QFont ( family, size, weight, italic ); | 469 | defaultFont = QFont ( family, size, weight, italic ); |
470 | editor-> setFont ( defaultFont ); | 470 | editor-> setFont ( defaultFont ); |
471 | 471 | ||
472 | // updateCaption(); | 472 | // updateCaption(); |
473 | 473 | ||
474 | cfg.setGroup ( "View" ); | 474 | cfg.setGroup ( "View" ); |
475 | 475 | ||
476 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 476 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
477 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 477 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
478 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 478 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
479 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 479 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
480 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 480 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
481 | 481 | ||
482 | if(useSearchBar) searchBarAction->setOn(true); | 482 | if(useSearchBar) searchBarAction->setOn(true); |
483 | if(promptExit ) nAdvanced->setOn( true ); | 483 | if(promptExit ) nAdvanced->setOn( true ); |
484 | if(openDesktop) desktopAction->setOn( true ); | 484 | if(openDesktop) desktopAction->setOn( true ); |
485 | if(filePerms) filePermAction->setOn( true ); | 485 | if(filePerms) filePermAction->setOn( true ); |
486 | if(startWithNew) nStart->setOn( true ); | 486 | if(startWithNew) nStart->setOn( true ); |
487 | 487 | ||
488 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 488 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
489 | wa-> setOn ( wrap ); | 489 | wa-> setOn ( wrap ); |
490 | setWordWrap ( wrap ); | 490 | setWordWrap ( wrap ); |
491 | 491 | ||
492 | if( qApp->argc() > 1) { | 492 | if( qApp->argc() > 1) { |
493 | currentFileName=qApp->argv()[1]; | 493 | currentFileName=qApp->argv()[1]; |
494 | 494 | ||
495 | QFileInfo fi(currentFileName); | 495 | QFileInfo fi(currentFileName); |
496 | 496 | ||
497 | if(fi.baseName().left(1) == "") { | 497 | if(fi.baseName().left(1) == "") { |
498 | openDotFile(currentFileName); | 498 | openDotFile(currentFileName); |
499 | } else { | 499 | } else { |
500 | openFile(currentFileName); | 500 | openFile(currentFileName); |
501 | } | 501 | } |
502 | } else { | 502 | } else { |
503 | edited1=false; | 503 | edited1=false; |
504 | openDotFile(""); | 504 | openDotFile(""); |
505 | } | 505 | } |
506 | 506 | ||
507 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 507 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
508 | } | 508 | } |
509 | 509 | ||
510 | TextEdit::~TextEdit() { | 510 | TextEdit::~TextEdit() { |
511 | qWarning("textedit d'tor"); | 511 | qWarning("textedit d'tor"); |
512 | delete editor; | 512 | delete editor; |
513 | } | 513 | } |
514 | 514 | ||
515 | void TextEdit::closeEvent(QCloseEvent *) { | 515 | void TextEdit::closeEvent(QCloseEvent *) { |
516 | if( edited1 && promptExit) | 516 | if( edited1 && promptExit) |
517 | saveAs(); | 517 | saveAs(); |
518 | qApp->quit(); | 518 | qApp->quit(); |
519 | } | 519 | } |
520 | 520 | ||
521 | void TextEdit::cleanUp() { | 521 | void TextEdit::cleanUp() { |
522 | 522 | ||
523 | Config cfg ( "TextEdit" ); | 523 | Config cfg ( "TextEdit" ); |
524 | cfg. setGroup ( "Font" ); | 524 | cfg. setGroup ( "Font" ); |
525 | QFont f = editor->font(); | 525 | QFont f = editor->font(); |
526 | cfg.writeEntry ( "Family", f. family ( )); | 526 | cfg.writeEntry ( "Family", f. family ( )); |
527 | cfg.writeEntry ( "Size", f. pointSize ( )); | 527 | cfg.writeEntry ( "Size", f. pointSize ( )); |
528 | cfg.writeEntry ( "Weight", f. weight ( )); | 528 | cfg.writeEntry ( "Weight", f. weight ( )); |
529 | cfg.writeEntry ( "Italic", f. italic ( )); | 529 | cfg.writeEntry ( "Italic", f. italic ( )); |
530 | 530 | ||
531 | cfg.setGroup ( "View" ); | 531 | cfg.setGroup ( "View" ); |
532 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); | 532 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); |
533 | cfg.writeEntry ( "FileView", viewSelection ); | 533 | cfg.writeEntry ( "FileView", viewSelection ); |
534 | 534 | ||
535 | cfg.writeEntry ( "PromptExit", promptExit ); | 535 | cfg.writeEntry ( "PromptExit", promptExit ); |
536 | cfg.writeEntry ( "OpenDesktop", openDesktop ); | 536 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
537 | cfg.writeEntry ( "FilePermissions", filePerms ); | 537 | cfg.writeEntry ( "FilePermissions", filePerms ); |
538 | cfg.writeEntry ( "SearchBar", useSearchBar ); | 538 | cfg.writeEntry ( "SearchBar", useSearchBar ); |
539 | cfg.writeEntry ( "startNew", startWithNew ); | 539 | cfg.writeEntry ( "startNew", startWithNew ); |
540 | 540 | ||
541 | } | 541 | } |
542 | 542 | ||
543 | 543 | ||
544 | void TextEdit::accept() { | 544 | void TextEdit::accept() { |
545 | if( edited1) | 545 | if( edited1) |
546 | saveAs(); | 546 | saveAs(); |
547 | qApp->quit(); | 547 | qApp->quit(); |
548 | } | 548 | } |
549 | 549 | ||
550 | void TextEdit::zoomIn() { | 550 | void TextEdit::zoomIn() { |
551 | setFontSize(editor->font().pointSize()+1,false); | 551 | setFontSize(editor->font().pointSize()+1,false); |
552 | } | 552 | } |
553 | 553 | ||
554 | void TextEdit::zoomOut() { | 554 | void TextEdit::zoomOut() { |
555 | setFontSize(editor->font().pointSize()-1,true); | 555 | setFontSize(editor->font().pointSize()-1,true); |
556 | } | 556 | } |
557 | 557 | ||
558 | 558 | ||
559 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 559 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
560 | int s=10; | 560 | int s=10; |
561 | for (int i=0; i<nfontsizes; i++) { | 561 | for (int i=0; i<nfontsizes; i++) { |
562 | if ( fontsize[i] == sz ) { | 562 | if ( fontsize[i] == sz ) { |
563 | s = sz; | 563 | s = sz; |
564 | break; | 564 | break; |
565 | } else if ( round_down_not_up ) { | 565 | } else if ( round_down_not_up ) { |
566 | if ( fontsize[i] < sz ) | 566 | if ( fontsize[i] < sz ) |
567 | s = fontsize[i]; | 567 | s = fontsize[i]; |
568 | } else { | 568 | } else { |
569 | if ( fontsize[i] > sz ) { | 569 | if ( fontsize[i] > sz ) { |
570 | s = fontsize[i]; | 570 | s = fontsize[i]; |
571 | break; | 571 | break; |
572 | } | 572 | } |
573 | } | 573 | } |
574 | } | 574 | } |
575 | 575 | ||
576 | QFont f = editor->font(); | 576 | QFont f = editor->font(); |
577 | f.setPointSize(s); | 577 | f.setPointSize(s); |
578 | editor->setFont(f); | 578 | editor->setFont(f); |
579 | 579 | ||
580 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 580 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
581 | zout->setEnabled(s != fontsize[0]); | 581 | zout->setEnabled(s != fontsize[0]); |
582 | } | 582 | } |
583 | 583 | ||
584 | void TextEdit::setBold(bool y) { | 584 | void TextEdit::setBold(bool y) { |
585 | QFont f = editor->font(); | 585 | QFont f = editor->font(); |
586 | f.setBold(y); | 586 | f.setBold(y); |
587 | editor->setFont(f); | 587 | editor->setFont(f); |
588 | } | 588 | } |
589 | 589 | ||
590 | void TextEdit::setItalic(bool y) { | 590 | void TextEdit::setItalic(bool y) { |
591 | QFont f = editor->font(); | 591 | QFont f = editor->font(); |
592 | f.setItalic(y); | 592 | f.setItalic(y); |
593 | editor->setFont(f); | 593 | editor->setFont(f); |
594 | } | 594 | } |
595 | 595 | ||
596 | void TextEdit::setWordWrap(bool y) { | 596 | void TextEdit::setWordWrap(bool y) { |
597 | bool state = editor->edited(); | 597 | bool state = editor->edited(); |
598 | QString captionStr = caption(); | 598 | QString captionStr = caption(); |
599 | bool b1 = edited1; | 599 | bool b1 = edited1; |
600 | bool b2 = edited; | 600 | bool b2 = edited; |
601 | 601 | ||
602 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 602 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
603 | editor->setEdited( state ); | 603 | editor->setEdited( state ); |
604 | edited1=b1; | 604 | edited1=b1; |
605 | edited=b2; | 605 | edited=b2; |
606 | setCaption(captionStr); | 606 | setCaption(captionStr); |
607 | } | 607 | } |
608 | 608 | ||
609 | void TextEdit::setSearchBar(bool b) { | 609 | void TextEdit::setSearchBar(bool b) { |
610 | useSearchBar=b; | 610 | useSearchBar=b; |
611 | Config cfg("TextEdit"); | 611 | Config cfg("TextEdit"); |
612 | cfg.setGroup("View"); | 612 | cfg.setGroup("View"); |
613 | cfg.writeEntry ( "SearchBar", b ); | 613 | cfg.writeEntry ( "SearchBar", b ); |
614 | searchBarAction->setOn(b); | 614 | searchBarAction->setOn(b); |
615 | if(b) | 615 | if(b) |
616 | searchBar->show(); | 616 | searchBar->show(); |
617 | else | 617 | else |
618 | searchBar->hide(); | 618 | searchBar->hide(); |
619 | editor->setFocus(); | 619 | editor->setFocus(); |
620 | } | 620 | } |
621 | 621 | ||
622 | void TextEdit::fileNew() { | 622 | void TextEdit::fileNew() { |
623 | // if( !bFromDocView ) { | 623 | // if( !bFromDocView ) { |
624 | // saveAs(); | 624 | // saveAs(); |
625 | // } | 625 | // } |
626 | newFile(DocLnk()); | 626 | newFile(DocLnk()); |
627 | } | 627 | } |
628 | 628 | ||
629 | void TextEdit::fileOpen() { | 629 | void TextEdit::fileOpen() { |
630 | QMap<QString, QStringList> map; | 630 | QMap<QString, QStringList> map; |
631 | map.insert(tr("All"), QStringList() ); | 631 | map.insert(tr("All"), QStringList() ); |
632 | QStringList text; | 632 | QStringList text; |
633 | text << "text/*"; | 633 | text << "text/*"; |
634 | map.insert(tr("Text"), text ); | 634 | map.insert(tr("Text"), text ); |
635 | text << "*"; | 635 | text << "*"; |
636 | map.insert(tr("All"), text ); | 636 | map.insert(tr("All"), text ); |
637 | QString str = OFileDialog::getOpenFileName( 2, | 637 | QString str = OFileDialog::getOpenFileName( 2, |
638 | QPEApplication::documentDir(), | 638 | QPEApplication::documentDir(), |
639 | QString::null, map); | 639 | QString::null, map); |
640 | if( QFile(str).exists() && !QFileInfo(str).isDir() ) | 640 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
641 | openFile( str ); | 641 | openFile( str ); |
642 | else | 642 | else |
643 | updateCaption(); | 643 | updateCaption(); |
644 | } | 644 | } |
645 | 645 | ||
646 | void TextEdit::doSearchBar() { | 646 | void TextEdit::doSearchBar() { |
647 | if(!useSearchBar) | 647 | if(!useSearchBar) |
648 | searchBar->hide(); | 648 | searchBar->hide(); |
649 | else | 649 | else |
650 | searchBar->show(); | 650 | searchBar->show(); |
651 | } | 651 | } |
652 | 652 | ||
653 | #if 0 | 653 | #if 0 |
654 | void TextEdit::slotFind() { | 654 | void TextEdit::slotFind() { |
655 | FindDialog frmFind( tr("Text Editor"), this ); | 655 | FindDialog frmFind( tr("Text Editor"), this ); |
656 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 656 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
657 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 657 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
658 | 658 | ||
659 | //case sensitive, backwards, [category] | 659 | //case sensitive, backwards, [category] |
660 | 660 | ||
661 | connect( editor, SIGNAL(notFound()), | 661 | connect( editor, SIGNAL(notFound()), |
662 | &frmFind, SLOT(slotNotFound()) ); | 662 | &frmFind, SLOT(slotNotFound()) ); |
663 | connect( editor, SIGNAL(searchWrapped()), | 663 | connect( editor, SIGNAL(searchWrapped()), |
664 | &frmFind, SLOT(slotWrapAround()) ); | 664 | &frmFind, SLOT(slotWrapAround()) ); |
665 | 665 | ||
666 | frmFind.exec(); | 666 | frmFind.exec(); |
667 | 667 | ||
668 | 668 | ||
669 | } | 669 | } |
670 | #endif | 670 | #endif |
671 | 671 | ||
672 | void TextEdit::fileRevert() { | 672 | void TextEdit::fileRevert() { |
673 | clear(); | 673 | clear(); |
674 | fileOpen(); | 674 | fileOpen(); |
675 | } | 675 | } |
676 | 676 | ||
677 | void TextEdit::editCut() { | 677 | 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 | ||
683 | void TextEdit::editCopy() { | 683 | void 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 | ||
689 | void TextEdit::editPaste() { | 689 | void 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 | ||
695 | void TextEdit::editFind() { | 695 | void TextEdit::editFind() { |
696 | searchBar->show(); | 696 | searchBar->show(); |
697 | searchEdit->setFocus(); | 697 | searchEdit->setFocus(); |
698 | } | 698 | } |
699 | 699 | ||
700 | void TextEdit::findNext() { | 700 | void TextEdit::findNext() { |
701 | editor->find( searchEdit->text(), false, false ); | 701 | editor->find( searchEdit->text(), false, false ); |
702 | 702 | ||
703 | } | 703 | } |
704 | 704 | ||
705 | void TextEdit::findClose() { | 705 | void TextEdit::findClose() { |
706 | searchBar->hide(); | 706 | searchBar->hide(); |
707 | } | 707 | } |
708 | 708 | ||
709 | void TextEdit::search() { | 709 | void TextEdit::search() { |
710 | editor->find( searchEdit->text(), false, false ); | 710 | editor->find( searchEdit->text(), false, false ); |
711 | } | 711 | } |
712 | 712 | ||
713 | void TextEdit::newFile( const DocLnk &f ) { | 713 | void 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 | ||
726 | void TextEdit::openDotFile( const QString &f ) { | 726 | void 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 | ||
748 | void TextEdit::openFile( const QString &f ) { | 748 | void 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> |
756 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | 756 | file.<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 | 774 | ||
775 | DocLnk nf; | 775 | DocLnk nf; |
776 | nf.setType("text/plain"); | 776 | nf.setType("text/plain"); |
777 | nf.setFile(filer); | 777 | nf.setFile(filer); |
778 | currentFileName=filer; | 778 | currentFileName=filer; |
779 | 779 | ||
780 | nf.setName(fi.baseName()); | 780 | nf.setName(fi.baseName()); |
781 | openFile(nf); | 781 | openFile(nf); |
782 | 782 | ||
783 | qDebug("openFile string "+currentFileName); | 783 | qDebug("openFile string "+currentFileName); |
784 | 784 | ||
785 | } | 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 | ||
795 | void TextEdit::openFile( const DocLnk &f ) { | 795 | void 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 | ||
819 | void TextEdit::showEditTools() { | 819 | void 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 */ |
831 | bool TextEdit::save() { | 831 | bool TextEdit::save() { |
832 | qDebug("saveAsFile " + currentFileName); | 832 | qDebug("saveAsFile " + currentFileName); |