-rw-r--r-- | core/apps/textedit/textedit.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 834bd8c..18402d4 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -456,99 +456,96 @@ void TextEdit::setFontSize(int sz, bool round_down_not_up) | |||
456 | s = fontsize[i]; | 456 | s = fontsize[i]; |
457 | } else { | 457 | } else { |
458 | if ( fontsize[i] > sz ) { | 458 | if ( fontsize[i] > sz ) { |
459 | s = fontsize[i]; | 459 | s = fontsize[i]; |
460 | break; | 460 | break; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | } | 463 | } |
464 | 464 | ||
465 | QFont f = editor->font(); | 465 | QFont f = editor->font(); |
466 | f.setPointSize(s); | 466 | f.setPointSize(s); |
467 | editor->setFont(f); | 467 | editor->setFont(f); |
468 | 468 | ||
469 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 469 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
470 | zout->setEnabled(s != fontsize[0]); | 470 | zout->setEnabled(s != fontsize[0]); |
471 | } | 471 | } |
472 | 472 | ||
473 | void TextEdit::setBold(bool y) | 473 | void TextEdit::setBold(bool y) |
474 | { | 474 | { |
475 | QFont f = editor->font(); | 475 | QFont f = editor->font(); |
476 | f.setBold(y); | 476 | f.setBold(y); |
477 | editor->setFont(f); | 477 | editor->setFont(f); |
478 | } | 478 | } |
479 | 479 | ||
480 | void TextEdit::setItalic(bool y) | 480 | void TextEdit::setItalic(bool y) |
481 | { | 481 | { |
482 | QFont f = editor->font(); | 482 | QFont f = editor->font(); |
483 | f.setItalic(y); | 483 | f.setItalic(y); |
484 | editor->setFont(f); | 484 | editor->setFont(f); |
485 | } | 485 | } |
486 | 486 | ||
487 | void TextEdit::setWordWrap(bool y) | 487 | void TextEdit::setWordWrap(bool y) |
488 | { | 488 | { |
489 | bool state = editor->edited(); | 489 | bool state = editor->edited(); |
490 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 490 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
491 | editor->setEdited( state ); | 491 | editor->setEdited( state ); |
492 | } | 492 | } |
493 | 493 | ||
494 | void TextEdit::fileNew() | 494 | void TextEdit::fileNew() |
495 | { | 495 | { |
496 | // if( !bFromDocView ) { | 496 | // if( !bFromDocView ) { |
497 | // saveAs(); | 497 | // saveAs(); |
498 | // } | 498 | // } |
499 | newFile(DocLnk()); | 499 | newFile(DocLnk()); |
500 | } | 500 | } |
501 | 501 | ||
502 | void TextEdit::fileOpen() | 502 | void TextEdit::fileOpen() |
503 | { | 503 | { |
504 | // OFileSelector *fileSelector; | ||
505 | // fileSelector = new OFileSelector( this, 1,1,"/","", "text/*"); | ||
506 | //fileSelector->showMaximized(); | ||
507 | QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this ); | 504 | QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this ); |
508 | if(!str.isEmpty() ) | 505 | if(!str.isEmpty() ) |
509 | openFile( str ); | 506 | openFile( str ); |
510 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // | 507 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // |
511 | // browseForFiles->setFileView( viewSelection ); | 508 | // browseForFiles->setFileView( viewSelection ); |
512 | // browseForFiles->showMaximized(); | 509 | // browseForFiles->showMaximized(); |
513 | // // if( result != -1 ) | 510 | // // if( result != -1 ) |
514 | 511 | ||
515 | // if( browseForFiles->exec() != -1 ) { | 512 | // if( browseForFiles->exec() != -1 ) { |
516 | // QString selFile = browseForFiles->selectedFileName; | 513 | // QString selFile = browseForFiles->selectedFileName; |
517 | // QStringList fileList = browseForFiles->fileList; | 514 | // QStringList fileList = browseForFiles->fileList; |
518 | // qDebug(selFile); | 515 | // qDebug(selFile); |
519 | // QStringList::ConstIterator f; | 516 | // QStringList::ConstIterator f; |
520 | // QString fileTemp; | 517 | // QString fileTemp; |
521 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 518 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
522 | // fileTemp = *f; | 519 | // fileTemp = *f; |
523 | // fileTemp.right( fileTemp.length()-5); | 520 | // fileTemp.right( fileTemp.length()-5); |
524 | // QString fileName = fileTemp; | 521 | // QString fileName = fileTemp; |
525 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 522 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
526 | // currentFileName = fileName; | 523 | // currentFileName = fileName; |
527 | // qDebug("please open "+currentFileName); | 524 | // qDebug("please open "+currentFileName); |
528 | // openFile(str ); | 525 | // openFile(str ); |
529 | // } | 526 | // } |
530 | // } | 527 | // } |
531 | // viewSelection = browseForFiles->SelectionCombo->currentItem(); | 528 | // viewSelection = browseForFiles->SelectionCombo->currentItem(); |
532 | // } | 529 | // } |
533 | // delete browseForFiles; | 530 | // delete browseForFiles; |
534 | // editor->setEdited( FALSE); | 531 | // editor->setEdited( FALSE); |
535 | // edited1=FALSE; | 532 | // edited1=FALSE; |
536 | // edited=FALSE; | 533 | // edited=FALSE; |
537 | // if(caption().left(1)=="*") | 534 | // if(caption().left(1)=="*") |
538 | // setCaption(caption().right(caption().length()-1)); | 535 | // setCaption(caption().right(caption().length()-1)); |
539 | // doSearchBar(); | 536 | // doSearchBar(); |
540 | } | 537 | } |
541 | 538 | ||
542 | void TextEdit::doSearchBar() | 539 | void TextEdit::doSearchBar() |
543 | { | 540 | { |
544 | Config cfg("TextEdit"); | 541 | Config cfg("TextEdit"); |
545 | cfg.setGroup("View"); | 542 | cfg.setGroup("View"); |
546 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 543 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
547 | searchBar->hide(); | 544 | searchBar->hide(); |
548 | } | 545 | } |
549 | 546 | ||
550 | #if 0 | 547 | #if 0 |
551 | void TextEdit::slotFind() | 548 | void TextEdit::slotFind() |
552 | { | 549 | { |
553 | FindDialog frmFind( tr("Text Editor"), this ); | 550 | FindDialog frmFind( tr("Text Editor"), this ); |
554 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 551 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
@@ -600,134 +597,136 @@ void TextEdit::editFind() | |||
600 | searchVisible = TRUE; | 597 | searchVisible = TRUE; |
601 | searchEdit->setFocus(); | 598 | searchEdit->setFocus(); |
602 | Config cfg("TextEdit"); | 599 | Config cfg("TextEdit"); |
603 | cfg.setGroup("View"); | 600 | cfg.setGroup("View"); |
604 | cfg.writeEntry("SearchBar","Opened"); | 601 | cfg.writeEntry("SearchBar","Opened"); |
605 | 602 | ||
606 | } | 603 | } |
607 | 604 | ||
608 | void TextEdit::findNext() | 605 | void TextEdit::findNext() |
609 | { | 606 | { |
610 | editor->find( searchEdit->text(), FALSE, FALSE ); | 607 | editor->find( searchEdit->text(), FALSE, FALSE ); |
611 | 608 | ||
612 | } | 609 | } |
613 | 610 | ||
614 | void TextEdit::findClose() | 611 | void TextEdit::findClose() |
615 | { | 612 | { |
616 | searchVisible = FALSE; | 613 | searchVisible = FALSE; |
617 | searchBar->hide(); | 614 | searchBar->hide(); |
618 | Config cfg("TextEdit"); | 615 | Config cfg("TextEdit"); |
619 | cfg.setGroup("View"); | 616 | cfg.setGroup("View"); |
620 | cfg.writeEntry("SearchBar","Closed"); | 617 | cfg.writeEntry("SearchBar","Closed"); |
621 | cfg.write(); | 618 | cfg.write(); |
622 | } | 619 | } |
623 | 620 | ||
624 | void TextEdit::search() | 621 | void TextEdit::search() |
625 | { | 622 | { |
626 | editor->find( searchEdit->text(), FALSE, FALSE ); | 623 | editor->find( searchEdit->text(), FALSE, FALSE ); |
627 | } | 624 | } |
628 | 625 | ||
629 | void TextEdit::newFile( const DocLnk &f ) | 626 | void TextEdit::newFile( const DocLnk &f ) |
630 | { | 627 | { |
631 | DocLnk nf = f; | 628 | DocLnk nf = f; |
632 | nf.setType("text/plain"); | 629 | nf.setType("text/plain"); |
633 | clear(); | 630 | clear(); |
634 | setWState (WState_Reserved1 ); | 631 | setWState (WState_Reserved1 ); |
635 | editor->setFocus(); | 632 | editor->setFocus(); |
636 | doc = new DocLnk(nf); | 633 | doc = new DocLnk(nf); |
637 | currentFileName = "Unnamed"; | 634 | currentFileName = "Unnamed"; |
638 | qDebug("newFile "+currentFileName); | 635 | qDebug("newFile "+currentFileName); |
639 | updateCaption( currentFileName); | 636 | updateCaption( currentFileName); |
640 | // editor->setEdited( FALSE); | 637 | // editor->setEdited( FALSE); |
641 | } | 638 | } |
642 | 639 | ||
643 | void TextEdit::openFile( const QString &f ) | 640 | void TextEdit::openFile( const QString &f ) |
644 | { | 641 | { |
645 | qDebug("filename is "+ f); | 642 | qDebug("filename is "+ f); |
646 | QString filer; | 643 | QString filer; |
647 | // bFromDocView = TRUE; | 644 | // bFromDocView = TRUE; |
648 | if(f.find(".desktop",0,TRUE)) { | 645 | if(f.find(".desktop",0,TRUE) != -1) { |
649 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 646 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
650 | tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), | 647 | tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), |
651 | tr(".desktop File"),tr("Link"),0,0,1) ) { | 648 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { |
652 | case 0: | 649 | case 0: |
653 | filer = f; | 650 | filer = f; |
654 | break; | 651 | break; |
655 | case 1: | 652 | case 1: |
656 | DocLnk sf(f); | 653 | DocLnk sf(f); |
657 | filer = sf.file(); | 654 | filer = sf.file(); |
658 | break; | 655 | break; |
659 | } | 656 | } |
660 | } | 657 | } else |
658 | filer = f; | ||
659 | |||
661 | DocLnk nf; | 660 | DocLnk nf; |
662 | nf.setType("text/plain"); | 661 | nf.setType("text/plain"); |
663 | nf.setFile(filer); | 662 | nf.setFile(filer); |
664 | currentFileName=filer; | 663 | currentFileName=filer; |
665 | QFileInfo fi( currentFileName); | 664 | QFileInfo fi( currentFileName); |
666 | nf.setName(fi.baseName()); | 665 | nf.setName(fi.baseName()); |
667 | qDebug("openFile string "+currentFileName); | 666 | qDebug("openFile string "+currentFileName); |
668 | 667 | ||
669 | openFile(nf); | 668 | openFile(nf); |
670 | showEditTools(); | 669 | showEditTools(); |
671 | // Show filename in caption | 670 | // Show filename in caption |
672 | QString name = filer; | 671 | QString name = filer; |
673 | int sep = name.findRev( '/' ); | 672 | int sep = name.findRev( '/' ); |
674 | if ( sep > 0 ) | 673 | if ( sep > 0 ) |
675 | name = name.mid( sep+1 ); | 674 | name = name.mid( sep+1 ); |
676 | updateCaption( name ); | 675 | updateCaption( name ); |
677 | } | 676 | } |
678 | 677 | ||
679 | void TextEdit::openFile( const DocLnk &f ) | 678 | void TextEdit::openFile( const DocLnk &f ) |
680 | { | 679 | { |
681 | // clear(); | 680 | // clear(); |
682 | // bFromDocView = TRUE; | 681 | // bFromDocView = TRUE; |
683 | FileManager fm; | 682 | FileManager fm; |
684 | QString txt; | 683 | QString txt; |
685 | currentFileName=f.name(); | 684 | currentFileName=f.file(); |
686 | qDebug("openFile doclnk " + currentFileName); | 685 | qDebug("openFile doclnk " + currentFileName); |
687 | if ( !fm.loadFile( f, txt ) ) { | 686 | if ( !fm.loadFile( f, txt ) ) { |
688 | // ####### could be a new file | 687 | // ####### could be a new file |
689 | qDebug( "Cannot open file" ); | 688 | qDebug( "Cannot open file" ); |
690 | } | 689 | } |
691 | // fileNew(); | 690 | // fileNew(); |
692 | if ( doc ) | 691 | if ( doc ) |
693 | delete doc; | 692 | delete doc; |
694 | doc = new DocLnk(f); | 693 | doc = new DocLnk(f); |
695 | editor->setText(txt); | 694 | editor->setText(txt); |
696 | editor->setEdited( FALSE); | 695 | editor->setEdited( FALSE); |
697 | edited1=FALSE; | 696 | edited1=FALSE; |
698 | edited=FALSE; | 697 | edited=FALSE; |
699 | 698 | ||
700 | doc->setName(currentFileName); | 699 | doc->setName(currentFileName); |
701 | updateCaption(); | 700 | updateCaption(); |
702 | } | 701 | } |
703 | 702 | ||
704 | void TextEdit::showEditTools() | 703 | void TextEdit::showEditTools() |
705 | { | 704 | { |
706 | // if ( !doc ) | 705 | // if ( !doc ) |
707 | // close(); | 706 | // close(); |
708 | // clear(); | 707 | // clear(); |
709 | menu->show(); | 708 | menu->show(); |
710 | editBar->show(); | 709 | editBar->show(); |
711 | if ( searchVisible ) | 710 | if ( searchVisible ) |
712 | searchBar->show(); | 711 | searchBar->show(); |
713 | // updateCaption(); | 712 | // updateCaption(); |
714 | setWState (WState_Reserved1 ); | 713 | setWState (WState_Reserved1 ); |
715 | } | 714 | } |
716 | 715 | ||
717 | /*! | 716 | /*! |
718 | unprompted save */ | 717 | unprompted save */ |
719 | bool TextEdit::save() | 718 | bool TextEdit::save() |
720 | { | 719 | { |
721 | QString file = doc->file(); | 720 | QString file = doc->file(); |
722 | qDebug("saver file "+file); | 721 | qDebug("saver file "+file); |
723 | QString name= doc->name(); | 722 | QString name= doc->name(); |
724 | qDebug("File named "+name); | 723 | qDebug("File named "+name); |
725 | QString rt = editor->text(); | 724 | QString rt = editor->text(); |
726 | if( !rt.isEmpty() ) { | 725 | if( !rt.isEmpty() ) { |
727 | if(name.isEmpty()) { | 726 | if(name.isEmpty()) { |
728 | saveAs(); | 727 | saveAs(); |
729 | } else { | 728 | } else { |
730 | currentFileName= name ; | 729 | currentFileName= name ; |
731 | qDebug("saveFile "+currentFileName); | 730 | qDebug("saveFile "+currentFileName); |
732 | 731 | ||
733 | struct stat buf; | 732 | struct stat buf; |