528 # invalidate them) |
528 # invalidate them) |
529 data = QTextBlockUserData() |
529 data = QTextBlockUserData() |
530 data.misspelled = misspellings |
530 data.misspelled = misspellings |
531 self.setCurrentBlockUserData(data) |
531 self.setCurrentBlockUserData(data) |
532 |
532 |
533 class EricSpellCheckedPlainTextEdit(QPlainTextEdit, SpellCheckMixin): |
533 else: |
534 """ |
534 |
535 Class implementing a QPlainTextEdit with built-in spell checker. |
535 class SpellCheckMixin(): |
536 """ |
536 """ |
537 def __init__(self, *args): |
537 Class implementing the spell-check mixin for the widget classes. |
|
538 """ |
|
539 # |
|
540 # This is just a stub to provide the same API as the enchant enabled |
|
541 # one. |
|
542 # |
|
543 def __init__(self): |
538 """ |
544 """ |
539 Constructor |
545 Constructor |
540 |
546 """ |
541 @param *args list of arguments for the QPlainTextEdit constructor. |
547 pass |
542 @type list |
548 |
543 """ |
549 def setFormat(self, formatName): |
544 QPlainTextEdit.__init__(self, *args) |
550 """ |
545 SpellCheckMixin.__init__(self) |
551 Public method to set the document format. |
546 |
552 |
547 class EricSpellCheckedTextEdit(QTextEdit, SpellCheckMixin): |
553 @param formatName name of the document format |
548 """ |
554 @type str |
549 Class implementing a QTextEdit with built-in spell checker. |
555 """ |
550 """ |
556 pass |
551 def __init__(self, *args): |
557 |
552 """ |
558 def dict(self): |
553 Constructor |
559 """ |
554 |
560 Public method to get a reference to the dictionary in use. |
555 @param *args list of arguments for the QPlainTextEdit constructor. |
561 |
556 @type list |
562 @return reference to the current dictionary |
557 """ |
563 @rtype enchant.Dict |
558 QTextEdit.__init__(self, *args) |
564 """ |
559 SpellCheckMixin.__init__(self) |
565 return None |
560 |
566 |
561 self.setFormat("html") |
567 def setDict(self, spellDict): |
562 |
568 """ |
563 def setAcceptRichText(self, accept): |
569 Public method to set the dictionary to be used. |
564 """ |
570 |
565 Public method to set the text edit mode. |
571 @param spellDict reference to the spell-check dictionary |
566 |
572 @type emchant.Dict |
567 @param accept flag indicating to accept rich text |
573 """ |
568 @type bool |
574 pass |
569 """ |
575 |
570 QTextEdit.setAcceptRichText(self, accept) |
576 @pyqtSlot(str) |
571 self.setFormat("html" if accept else "text") |
577 def setLanguage(self, language): |
572 else: |
578 """ |
573 # enchant not available |
579 Public slot to set the spellchecker language. |
574 EricSpellCheckedPlainTextEdit = QPlainTextEdit |
580 |
575 EricSpellCheckedTextEdit = QTextEdit |
581 @param language language to be set |
|
582 @type str |
|
583 """ |
|
584 pass |
|
585 |
|
586 @pyqtSlot(str, str, str) |
|
587 def setLanguageWithPWL(self, language, pwl, pel): |
|
588 """ |
|
589 Public slot to set the spellchecker language and associated user |
|
590 word lists. |
|
591 |
|
592 @param language language to be set |
|
593 @type str |
|
594 @param pwl file name of the personal word list |
|
595 @type str |
|
596 @param pel file name of the personal exclude list |
|
597 @type str |
|
598 """ |
|
599 pass |
|
600 |
|
601 @classmethod |
|
602 def setDefaultLanguage(cls, language, pwl=None, pel=None): |
|
603 """ |
|
604 Class method to set the default spell-check language. |
|
605 |
|
606 @param language language to be set as default |
|
607 @type str |
|
608 @param pwl file name of the personal word list |
|
609 @type str |
|
610 @param pel file name of the personal exclude list |
|
611 @type str |
|
612 """ |
|
613 pass |
|
614 |
|
615 class EricSpellCheckedPlainTextEdit(QPlainTextEdit, SpellCheckMixin): |
|
616 """ |
|
617 Class implementing a QPlainTextEdit with built-in spell checker. |
|
618 """ |
|
619 def __init__(self, *args): |
|
620 """ |
|
621 Constructor |
|
622 |
|
623 @param *args list of arguments for the QPlainTextEdit constructor. |
|
624 @type list |
|
625 """ |
|
626 QPlainTextEdit.__init__(self, *args) |
|
627 SpellCheckMixin.__init__(self) |
|
628 |
|
629 class EricSpellCheckedTextEdit(QTextEdit, SpellCheckMixin): |
|
630 """ |
|
631 Class implementing a QTextEdit with built-in spell checker. |
|
632 """ |
|
633 def __init__(self, *args): |
|
634 """ |
|
635 Constructor |
|
636 |
|
637 @param *args list of arguments for the QPlainTextEdit constructor. |
|
638 @type list |
|
639 """ |
|
640 QTextEdit.__init__(self, *args) |
|
641 SpellCheckMixin.__init__(self) |
|
642 |
|
643 self.setFormat("html") |
|
644 |
|
645 def setAcceptRichText(self, accept): |
|
646 """ |
|
647 Public method to set the text edit mode. |
|
648 |
|
649 @param accept flag indicating to accept rich text |
|
650 @type bool |
|
651 """ |
|
652 QTextEdit.setAcceptRichText(self, accept) |
|
653 self.setFormat("html" if accept else "text") |
576 |
654 |
577 if __name__ == '__main__': |
655 if __name__ == '__main__': |
578 import sys |
656 import sys |
579 import os |
657 import os |
580 from PyQt6.QtWidgets import QApplication |
658 from PyQt6.QtWidgets import QApplication |