3456:96232974dcdb | 3484:645c12de6b0c |
---|---|
26 | 26 |
27 from E5Gui.E5Application import e5App | 27 from E5Gui.E5Application import e5App |
28 from E5Gui import E5FileDialog, E5MessageBox | 28 from E5Gui import E5FileDialog, E5MessageBox |
29 | 29 |
30 from .QsciScintillaCompat import QsciScintillaCompat, QSCINTILLA_VERSION | 30 from .QsciScintillaCompat import QsciScintillaCompat, QSCINTILLA_VERSION |
31 from .EditorMarkerMap import EditorMarkerMap | |
31 | 32 |
32 import Preferences | 33 import Preferences |
33 import Utilities | 34 import Utilities |
34 | 35 |
35 import UI.PixmapCache | 36 import UI.PixmapCache |
147 @param editor reference to an Editor object, if this is a cloned view | 148 @param editor reference to an Editor object, if this is a cloned view |
148 @param tv reference to the task viewer object | 149 @param tv reference to the task viewer object |
149 @exception IOError raised to indicate an issue accessing the file | 150 @exception IOError raised to indicate an issue accessing the file |
150 """ | 151 """ |
151 super(Editor, self).__init__() | 152 super(Editor, self).__init__() |
152 ## self.setAttribute(Qt.WA_DeleteOnClose) | |
153 self.setAttribute(Qt.WA_KeyCompression) | 153 self.setAttribute(Qt.WA_KeyCompression) |
154 self.setUtf8(True) | 154 self.setUtf8(True) |
155 | 155 |
156 self.dbs = dbs | 156 self.dbs = dbs |
157 self.taskViewer = tv | 157 self.taskViewer = tv |
297 (1 << self.dbreakpoint) | 297 (1 << self.dbreakpoint) |
298 | 298 |
299 self.changeMarkersMask = (1 << self.__changeMarkerSaved) | \ | 299 self.changeMarkersMask = (1 << self.__changeMarkerSaved) | \ |
300 (1 << self.__changeMarkerUnsaved) | 300 (1 << self.__changeMarkerUnsaved) |
301 | 301 |
302 self.__markerMap = EditorMarkerMap(self) | |
303 | |
302 # configure the margins | 304 # configure the margins |
303 self.__setMarginsDisplay() | 305 self.__setMarginsDisplay() |
304 self.linesChanged.connect(self.__resizeLinenoMargin) | 306 self.linesChanged.connect(self.__resizeLinenoMargin) |
305 | 307 |
306 self.marginClicked.connect(self.__marginClicked) | 308 self.marginClicked.connect(self.__marginClicked) |
321 if self.fileName is not None: | 323 if self.fileName is not None: |
322 if (QFileInfo(self.fileName).size() // 1024) > \ | 324 if (QFileInfo(self.fileName).size() // 1024) > \ |
323 Preferences.getEditor("WarnFilesize"): | 325 Preferences.getEditor("WarnFilesize"): |
324 res = E5MessageBox.yesNo( | 326 res = E5MessageBox.yesNo( |
325 self, | 327 self, |
326 self.trUtf8("Open File"), | 328 self.tr("Open File"), |
327 self.trUtf8("""<p>The size of the file <b>{0}</b>""" | 329 self.tr("""<p>The size of the file <b>{0}</b>""" |
328 """ is <b>{1} KB</b>.""" | 330 """ is <b>{1} KB</b>.""" |
329 """ Do you really want to load it?</p>""") | 331 """ Do you really want to load it?</p>""") |
330 .format(self.fileName, | 332 .format(self.fileName, |
331 QFileInfo(self.fileName).size() // 1024), | 333 QFileInfo(self.fileName).size() // 1024), |
332 icon=E5MessageBox.Warning) | 334 icon=E5MessageBox.Warning) |
333 if not res: | 335 if not res: |
334 raise IOError() | 336 raise IOError() |
372 # Make sure tabbing through a QWorkspace works. | 374 # Make sure tabbing through a QWorkspace works. |
373 self.setFocusPolicy(Qt.StrongFocus) | 375 self.setFocusPolicy(Qt.StrongFocus) |
374 | 376 |
375 self.__updateReadOnly(True) | 377 self.__updateReadOnly(True) |
376 | 378 |
377 self.setWhatsThis(self.trUtf8( | 379 self.setWhatsThis(self.tr( |
378 """<b>A Source Editor Window</b>""" | 380 """<b>A Source Editor Window</b>""" |
379 """<p>This window is used to display and edit a source file.""" | 381 """<p>This window is used to display and edit a source file.""" |
380 """ You can open as many of these as you like. The name of the""" | 382 """ You can open as many of these as you like. The name of the""" |
381 """ file is displayed in the window's titlebar.</p>""" | 383 """ file is displayed in the window's titlebar.</p>""" |
382 """<p>In order to set breakpoints just click in the space""" | 384 """<p>In order to set breakpoints just click in the space""" |
448 self.project.isProjectSource(self.fileName): | 450 self.project.isProjectSource(self.fileName): |
449 self.project.projectPropertiesChanged.connect( | 451 self.project.projectPropertiesChanged.connect( |
450 self.__projectPropertiesChanged) | 452 self.__projectPropertiesChanged) |
451 | 453 |
452 self.grabGesture(Qt.PinchGesture) | 454 self.grabGesture(Qt.PinchGesture) |
455 | |
456 self.SCN_ZOOM.connect(self.__markerMap.update) | |
457 self.__markerMap.update() | |
453 | 458 |
454 def __registerImages(self): | 459 def __registerImages(self): |
455 """ | 460 """ |
456 Private method to register images for autocompletion lists. | 461 Private method to register images for autocompletion lists. |
457 """ | 462 """ |
539 bindName = "dummy.rb" | 544 bindName = "dummy.rb" |
540 elif self.filetype == "D": | 545 elif self.filetype == "D": |
541 bindName = "dummy.d" | 546 bindName = "dummy.d" |
542 elif self.filetype == "Properties": | 547 elif self.filetype == "Properties": |
543 bindName = "dummy.ini" | 548 bindName = "dummy.ini" |
549 elif self.filetype == "JavaScript": | |
550 bindName = "dummy.js" | |
544 | 551 |
545 # #! marker detection | 552 # #! marker detection |
546 if not bindName and line0.startswith("#!"): | 553 if not bindName and line0.startswith("#!"): |
547 if "python3" in line0: | 554 if "python3" in line0: |
548 bindName = "dummy.py" | 555 bindName = "dummy.py" |
626 self.encodingsMenu = self.__initContextMenuEncodings() | 633 self.encodingsMenu = self.__initContextMenuEncodings() |
627 self.__menus["Encodings"] = self.encodingsMenu | 634 self.__menus["Encodings"] = self.encodingsMenu |
628 | 635 |
629 self.menuActs["Undo"] = self.menu.addAction( | 636 self.menuActs["Undo"] = self.menu.addAction( |
630 UI.PixmapCache.getIcon("editUndo.png"), | 637 UI.PixmapCache.getIcon("editUndo.png"), |
631 self.trUtf8('Undo'), self.undo) | 638 self.tr('Undo'), self.undo) |
632 self.menuActs["Redo"] = self.menu.addAction( | 639 self.menuActs["Redo"] = self.menu.addAction( |
633 UI.PixmapCache.getIcon("editRedo.png"), | 640 UI.PixmapCache.getIcon("editRedo.png"), |
634 self.trUtf8('Redo'), self.redo) | 641 self.tr('Redo'), self.redo) |
635 self.menuActs["Revert"] = self.menu.addAction( | 642 self.menuActs["Revert"] = self.menu.addAction( |
636 self.trUtf8("Revert to last saved state"), | 643 self.tr("Revert to last saved state"), |
637 self.revertToUnmodified) | 644 self.revertToUnmodified) |
638 self.menu.addSeparator() | 645 self.menu.addSeparator() |
639 self.menuActs["Cut"] = self.menu.addAction( | 646 self.menuActs["Cut"] = self.menu.addAction( |
640 UI.PixmapCache.getIcon("editCut.png"), | 647 UI.PixmapCache.getIcon("editCut.png"), |
641 self.trUtf8('Cut'), self.cut) | 648 self.tr('Cut'), self.cut) |
642 self.menuActs["Copy"] = self.menu.addAction( | 649 self.menuActs["Copy"] = self.menu.addAction( |
643 UI.PixmapCache.getIcon("editCopy.png"), | 650 UI.PixmapCache.getIcon("editCopy.png"), |
644 self.trUtf8('Copy'), self.copy) | 651 self.tr('Copy'), self.copy) |
645 self.menu.addAction( | 652 self.menu.addAction( |
646 UI.PixmapCache.getIcon("editPaste.png"), | 653 UI.PixmapCache.getIcon("editPaste.png"), |
647 self.trUtf8('Paste'), self.paste) | 654 self.tr('Paste'), self.paste) |
648 if not self.miniMenu: | 655 if not self.miniMenu: |
649 self.menu.addSeparator() | 656 self.menu.addSeparator() |
650 self.menu.addAction( | 657 self.menu.addAction( |
651 UI.PixmapCache.getIcon("editIndent.png"), | 658 UI.PixmapCache.getIcon("editIndent.png"), |
652 self.trUtf8('Indent'), self.indentLineOrSelection) | 659 self.tr('Indent'), self.indentLineOrSelection) |
653 self.menu.addAction( | 660 self.menu.addAction( |
654 UI.PixmapCache.getIcon("editUnindent.png"), | 661 UI.PixmapCache.getIcon("editUnindent.png"), |
655 self.trUtf8('Unindent'), self.unindentLineOrSelection) | 662 self.tr('Unindent'), self.unindentLineOrSelection) |
656 self.menuActs["Comment"] = self.menu.addAction( | 663 self.menuActs["Comment"] = self.menu.addAction( |
657 UI.PixmapCache.getIcon("editComment.png"), | 664 UI.PixmapCache.getIcon("editComment.png"), |
658 self.trUtf8('Comment'), self.commentLineOrSelection) | 665 self.tr('Comment'), self.commentLineOrSelection) |
659 self.menuActs["Uncomment"] = self.menu.addAction( | 666 self.menuActs["Uncomment"] = self.menu.addAction( |
660 UI.PixmapCache.getIcon("editUncomment.png"), | 667 UI.PixmapCache.getIcon("editUncomment.png"), |
661 self.trUtf8('Uncomment'), self.uncommentLineOrSelection) | 668 self.tr('Uncomment'), self.uncommentLineOrSelection) |
662 self.menuActs["StreamComment"] = self.menu.addAction( | 669 self.menuActs["StreamComment"] = self.menu.addAction( |
663 self.trUtf8('Stream Comment'), | 670 self.tr('Stream Comment'), |
664 self.streamCommentLineOrSelection) | 671 self.streamCommentLineOrSelection) |
665 self.menuActs["BoxComment"] = self.menu.addAction( | 672 self.menuActs["BoxComment"] = self.menu.addAction( |
666 self.trUtf8('Box Comment'), | 673 self.tr('Box Comment'), |
667 self.boxCommentLineOrSelection) | 674 self.boxCommentLineOrSelection) |
668 self.menu.addSeparator() | 675 self.menu.addSeparator() |
669 self.menu.addAction( | 676 self.menu.addAction( |
670 self.trUtf8('Select to brace'), self.selectToMatchingBrace) | 677 self.tr('Select to brace'), self.selectToMatchingBrace) |
671 self.menu.addAction(self.trUtf8('Select all'), self.__selectAll) | 678 self.menu.addAction(self.tr('Select all'), self.__selectAll) |
672 self.menu.addAction( | 679 self.menu.addAction( |
673 self.trUtf8('Deselect all'), self.__deselectAll) | 680 self.tr('Deselect all'), self.__deselectAll) |
674 self.menu.addSeparator() | 681 self.menu.addSeparator() |
675 self.menuActs["SpellCheck"] = self.menu.addAction( | 682 self.menuActs["SpellCheck"] = self.menu.addAction( |
676 UI.PixmapCache.getIcon("spellchecking.png"), | 683 UI.PixmapCache.getIcon("spellchecking.png"), |
677 self.trUtf8('Check spelling...'), self.checkSpelling) | 684 self.tr('Check spelling...'), self.checkSpelling) |
678 self.menuActs["SpellCheckSelection"] = self.menu.addAction( | 685 self.menuActs["SpellCheckSelection"] = self.menu.addAction( |
679 UI.PixmapCache.getIcon("spellchecking.png"), | 686 UI.PixmapCache.getIcon("spellchecking.png"), |
680 self.trUtf8('Check spelling of selection...'), | 687 self.tr('Check spelling of selection...'), |
681 self.__checkSpellingSelection) | 688 self.__checkSpellingSelection) |
682 self.menuActs["SpellCheckRemove"] = self.menu.addAction( | 689 self.menuActs["SpellCheckRemove"] = self.menu.addAction( |
683 self.trUtf8("Remove from dictionary"), | 690 self.tr("Remove from dictionary"), |
684 self.__removeFromSpellingDictionary) | 691 self.__removeFromSpellingDictionary) |
685 self.menu.addSeparator() | 692 self.menu.addSeparator() |
686 self.menu.addAction( | 693 self.menu.addAction( |
687 self.trUtf8('Shorten empty lines'), self.shortenEmptyLines) | 694 self.tr('Shorten empty lines'), self.shortenEmptyLines) |
688 self.menu.addSeparator() | 695 self.menu.addSeparator() |
689 self.menuActs["Languages"] = self.menu.addMenu(self.languagesMenu) | 696 self.menuActs["Languages"] = self.menu.addMenu(self.languagesMenu) |
690 self.menuActs["Encodings"] = self.menu.addMenu(self.encodingsMenu) | 697 self.menuActs["Encodings"] = self.menu.addMenu(self.encodingsMenu) |
691 self.menuActs["Eol"] = self.menu.addMenu(self.eolMenu) | 698 self.menuActs["Eol"] = self.menu.addMenu(self.eolMenu) |
692 self.menu.addSeparator() | 699 self.menu.addSeparator() |
693 self.menuActs["MonospacedFont"] = self.menu.addAction( | 700 self.menuActs["MonospacedFont"] = self.menu.addAction( |
694 self.trUtf8("Use Monospaced Font"), | 701 self.tr("Use Monospaced Font"), |
695 self.handleMonospacedEnable) | 702 self.handleMonospacedEnable) |
696 self.menuActs["MonospacedFont"].setCheckable(True) | 703 self.menuActs["MonospacedFont"].setCheckable(True) |
697 self.menuActs["MonospacedFont"].setChecked(self.useMonospaced) | 704 self.menuActs["MonospacedFont"].setChecked(self.useMonospaced) |
698 self.menuActs["AutosaveEnable"] = self.menu.addAction( | 705 self.menuActs["AutosaveEnable"] = self.menu.addAction( |
699 self.trUtf8("Autosave enabled"), self.__autosaveEnable) | 706 self.tr("Autosave enabled"), self.__autosaveEnable) |
700 self.menuActs["AutosaveEnable"].setCheckable(True) | 707 self.menuActs["AutosaveEnable"].setCheckable(True) |
701 self.menuActs["AutosaveEnable"].setChecked(self.autosaveEnabled) | 708 self.menuActs["AutosaveEnable"].setChecked(self.autosaveEnabled) |
702 self.menuActs["TypingAidsEnabled"] = self.menu.addAction( | 709 self.menuActs["TypingAidsEnabled"] = self.menu.addAction( |
703 self.trUtf8("Typing aids enabled"), self.__toggleTypingAids) | 710 self.tr("Typing aids enabled"), self.__toggleTypingAids) |
704 self.menuActs["TypingAidsEnabled"].setCheckable(True) | 711 self.menuActs["TypingAidsEnabled"].setCheckable(True) |
705 self.menuActs["TypingAidsEnabled"].setEnabled( | 712 self.menuActs["TypingAidsEnabled"].setEnabled( |
706 self.completer is not None) | 713 self.completer is not None) |
707 self.menuActs["TypingAidsEnabled"].setChecked( | 714 self.menuActs["TypingAidsEnabled"].setChecked( |
708 self.completer is not None and self.completer.isEnabled()) | 715 self.completer is not None and self.completer.isEnabled()) |
709 self.menuActs["AutoCompletionEnable"] = self.menu.addAction( | 716 self.menuActs["AutoCompletionEnable"] = self.menu.addAction( |
710 self.trUtf8("Autocompletion enabled"), | 717 self.tr("Autocompletion enabled"), |
711 self.__toggleAutoCompletionEnable) | 718 self.__toggleAutoCompletionEnable) |
712 self.menuActs["AutoCompletionEnable"].setCheckable(True) | 719 self.menuActs["AutoCompletionEnable"].setCheckable(True) |
713 self.menuActs["AutoCompletionEnable"].setChecked( | 720 self.menuActs["AutoCompletionEnable"].setChecked( |
714 self.autoCompletionThreshold() != -1) | 721 self.autoCompletionThreshold() != -1) |
715 if not self.isResourcesFile: | 722 if not self.isResourcesFile: |
726 self.menu.addSeparator() | 733 self.menu.addSeparator() |
727 self.menuActs["Tools"] = self.menu.addMenu(self.toolsMenu) | 734 self.menuActs["Tools"] = self.menu.addMenu(self.toolsMenu) |
728 self.menu.addSeparator() | 735 self.menu.addSeparator() |
729 self.menu.addAction( | 736 self.menu.addAction( |
730 UI.PixmapCache.getIcon("documentNewView.png"), | 737 UI.PixmapCache.getIcon("documentNewView.png"), |
731 self.trUtf8('New Document View'), self.__newView) | 738 self.tr('New Document View'), self.__newView) |
732 self.menuActs["NewSplit"] = self.menu.addAction( | 739 self.menuActs["NewSplit"] = self.menu.addAction( |
733 UI.PixmapCache.getIcon("splitVertical.png"), | 740 UI.PixmapCache.getIcon("splitVertical.png"), |
734 self.trUtf8('New Document View (with new split)'), | 741 self.tr('New Document View (with new split)'), |
735 self.__newViewNewSplit) | 742 self.__newViewNewSplit) |
736 self.menuActs["NewSplit"].setEnabled(self.vm.canSplit()) | 743 self.menuActs["NewSplit"].setEnabled(self.vm.canSplit()) |
737 self.menu.addAction( | 744 self.menu.addAction( |
738 UI.PixmapCache.getIcon("close.png"), | 745 UI.PixmapCache.getIcon("close.png"), |
739 self.trUtf8('Close'), self.__contextClose) | 746 self.tr('Close'), self.__contextClose) |
740 self.menu.addSeparator() | 747 self.menu.addSeparator() |
748 self.reopenEncodingMenu = self.__initContextMenuReopenWithEncoding() | |
749 self.menuActs["Reopen"] = self.menu.addMenu(self.reopenEncodingMenu) | |
741 self.menuActs["Save"] = self.menu.addAction( | 750 self.menuActs["Save"] = self.menu.addAction( |
742 UI.PixmapCache.getIcon("fileSave.png"), | 751 UI.PixmapCache.getIcon("fileSave.png"), |
743 self.trUtf8('Save'), self.__contextSave) | 752 self.tr('Save'), self.__contextSave) |
744 self.menu.addAction( | 753 self.menu.addAction( |
745 UI.PixmapCache.getIcon("fileSaveAs.png"), | 754 UI.PixmapCache.getIcon("fileSaveAs.png"), |
746 self.trUtf8('Save As...'), self.__contextSaveAs) | 755 self.tr('Save As...'), self.__contextSaveAs) |
747 if not self.miniMenu: | 756 if not self.miniMenu: |
748 self.menu.addMenu(self.exportersMenu) | 757 self.menu.addMenu(self.exportersMenu) |
749 self.menu.addSeparator() | 758 self.menu.addSeparator() |
750 self.menuActs["OpenRejections"] = self.menu.addAction( | 759 self.menuActs["OpenRejections"] = self.menu.addAction( |
751 self.trUtf8("Open 'rejection' file"), | 760 self.tr("Open 'rejection' file"), |
752 self.__contextOpenRejections) | 761 self.__contextOpenRejections) |
753 self.menu.addSeparator() | 762 self.menu.addSeparator() |
754 self.menu.addAction( | 763 self.menu.addAction( |
755 UI.PixmapCache.getIcon("printPreview.png"), | 764 UI.PixmapCache.getIcon("printPreview.png"), |
756 self.trUtf8("Print Preview"), self.printPreviewFile) | 765 self.tr("Print Preview"), self.printPreviewFile) |
757 self.menu.addAction( | 766 self.menu.addAction( |
758 UI.PixmapCache.getIcon("print.png"), | 767 UI.PixmapCache.getIcon("print.png"), |
759 self.trUtf8('Print'), self.printFile) | 768 self.tr('Print'), self.printFile) |
760 else: | 769 else: |
761 self.menuActs["OpenRejections"] = None | 770 self.menuActs["OpenRejections"] = None |
762 | 771 |
763 self.menu.aboutToShow.connect(self.__showContextMenu) | 772 self.menu.aboutToShow.connect(self.__showContextMenu) |
764 | 773 |
773 """ | 782 """ |
774 Private method used to setup the Checks context sub menu. | 783 Private method used to setup the Checks context sub menu. |
775 | 784 |
776 @return reference to the generated menu (QMenu) | 785 @return reference to the generated menu (QMenu) |
777 """ | 786 """ |
778 menu = QMenu(self.trUtf8('Autocomplete')) | 787 menu = QMenu(self.tr('Autocomplete')) |
779 | 788 |
780 self.menuActs["acDynamic"] = menu.addAction( | 789 self.menuActs["acDynamic"] = menu.addAction( |
781 self.trUtf8('dynamic'), self.autoComplete) | 790 self.tr('dynamic'), self.autoComplete) |
782 menu.addSeparator() | 791 menu.addSeparator() |
783 menu.addAction( | 792 menu.addAction( |
784 self.trUtf8('from Document'), self.autoCompleteFromDocument) | 793 self.tr('from Document'), self.autoCompleteFromDocument) |
785 self.menuActs["acAPI"] = menu.addAction( | 794 self.menuActs["acAPI"] = menu.addAction( |
786 self.trUtf8('from APIs'), self.autoCompleteFromAPIs) | 795 self.tr('from APIs'), self.autoCompleteFromAPIs) |
787 self.menuActs["acAPIDocument"] = menu.addAction( | 796 self.menuActs["acAPIDocument"] = menu.addAction( |
788 self.trUtf8('from Document and APIs'), self.autoCompleteFromAll) | 797 self.tr('from Document and APIs'), self.autoCompleteFromAll) |
789 menu.addSeparator() | 798 menu.addSeparator() |
790 self.menuActs["calltip"] = menu.addAction( | 799 self.menuActs["calltip"] = menu.addAction( |
791 self.trUtf8('Calltip'), self.callTip) | 800 self.tr('Calltip'), self.callTip) |
792 | 801 |
793 menu.aboutToShow.connect(self.__showContextMenuAutocompletion) | 802 menu.aboutToShow.connect(self.__showContextMenuAutocompletion) |
794 | 803 |
795 return menu | 804 return menu |
796 | 805 |
798 """ | 807 """ |
799 Private method used to setup the Checks context sub menu. | 808 Private method used to setup the Checks context sub menu. |
800 | 809 |
801 @return reference to the generated menu (QMenu) | 810 @return reference to the generated menu (QMenu) |
802 """ | 811 """ |
803 menu = QMenu(self.trUtf8('Check')) | 812 menu = QMenu(self.tr('Check')) |
804 menu.aboutToShow.connect(self.__showContextMenuChecks) | 813 menu.aboutToShow.connect(self.__showContextMenuChecks) |
805 return menu | 814 return menu |
806 | 815 |
807 def __initContextMenuTools(self): | 816 def __initContextMenuTools(self): |
808 """ | 817 """ |
809 Private method used to setup the Tools context sub menu. | 818 Private method used to setup the Tools context sub menu. |
810 | 819 |
811 @return reference to the generated menu (QMenu) | 820 @return reference to the generated menu (QMenu) |
812 """ | 821 """ |
813 menu = QMenu(self.trUtf8('Tools')) | 822 menu = QMenu(self.tr('Tools')) |
814 menu.aboutToShow.connect(self.__showContextMenuTools) | 823 menu.aboutToShow.connect(self.__showContextMenuTools) |
815 return menu | 824 return menu |
816 | 825 |
817 def __initContextMenuShow(self): | 826 def __initContextMenuShow(self): |
818 """ | 827 """ |
819 Private method used to setup the Show context sub menu. | 828 Private method used to setup the Show context sub menu. |
820 | 829 |
821 @return reference to the generated menu (QMenu) | 830 @return reference to the generated menu (QMenu) |
822 """ | 831 """ |
823 menu = QMenu(self.trUtf8('Show')) | 832 menu = QMenu(self.tr('Show')) |
824 | 833 |
825 menu.addAction(self.trUtf8('Code metrics...'), self.__showCodeMetrics) | 834 menu.addAction(self.tr('Code metrics...'), self.__showCodeMetrics) |
826 self.coverageMenuAct = menu.addAction( | 835 self.coverageMenuAct = menu.addAction( |
827 self.trUtf8('Code coverage...'), self.__showCodeCoverage) | 836 self.tr('Code coverage...'), self.__showCodeCoverage) |
828 self.coverageShowAnnotationMenuAct = menu.addAction( | 837 self.coverageShowAnnotationMenuAct = menu.addAction( |
829 self.trUtf8('Show code coverage annotations'), | 838 self.tr('Show code coverage annotations'), |
830 self.codeCoverageShowAnnotations) | 839 self.codeCoverageShowAnnotations) |
831 self.coverageHideAnnotationMenuAct = menu.addAction( | 840 self.coverageHideAnnotationMenuAct = menu.addAction( |
832 self.trUtf8('Hide code coverage annotations'), | 841 self.tr('Hide code coverage annotations'), |
833 self.__codeCoverageHideAnnotations) | 842 self.__codeCoverageHideAnnotations) |
834 self.profileMenuAct = menu.addAction( | 843 self.profileMenuAct = menu.addAction( |
835 self.trUtf8('Profile data...'), self.__showProfileData) | 844 self.tr('Profile data...'), self.__showProfileData) |
836 | 845 |
837 menu.aboutToShow.connect(self.__showContextMenuShow) | 846 menu.aboutToShow.connect(self.__showContextMenuShow) |
838 | 847 |
839 return menu | 848 return menu |
840 | 849 |
842 """ | 851 """ |
843 Private method used to setup the diagrams context sub menu. | 852 Private method used to setup the diagrams context sub menu. |
844 | 853 |
845 @return reference to the generated menu (QMenu) | 854 @return reference to the generated menu (QMenu) |
846 """ | 855 """ |
847 menu = QMenu(self.trUtf8('Diagrams')) | 856 menu = QMenu(self.tr('Diagrams')) |
848 | 857 |
849 menu.addAction( | 858 menu.addAction( |
850 self.trUtf8('Class Diagram...'), self.__showClassDiagram) | 859 self.tr('Class Diagram...'), self.__showClassDiagram) |
851 menu.addAction( | 860 menu.addAction( |
852 self.trUtf8('Package Diagram...'), self.__showPackageDiagram) | 861 self.tr('Package Diagram...'), self.__showPackageDiagram) |
853 menu.addAction( | 862 menu.addAction( |
854 self.trUtf8('Imports Diagram...'), self.__showImportsDiagram) | 863 self.tr('Imports Diagram...'), self.__showImportsDiagram) |
855 self.applicationDiagramMenuAct = menu.addAction( | 864 self.applicationDiagramMenuAct = menu.addAction( |
856 self.trUtf8('Application Diagram...'), | 865 self.tr('Application Diagram...'), |
857 self.__showApplicationDiagram) | 866 self.__showApplicationDiagram) |
858 menu.addSeparator() | 867 menu.addSeparator() |
859 menu.addAction( | 868 menu.addAction( |
860 UI.PixmapCache.getIcon("open.png"), | 869 UI.PixmapCache.getIcon("open.png"), |
861 self.trUtf8("Load Diagram..."), self.__loadDiagram) | 870 self.tr("Load Diagram..."), self.__loadDiagram) |
862 | 871 |
863 menu.aboutToShow.connect(self.__showContextMenuGraphics) | 872 menu.aboutToShow.connect(self.__showContextMenuGraphics) |
864 | 873 |
865 return menu | 874 return menu |
866 | 875 |
868 """ | 877 """ |
869 Private method used to setup the Languages context sub menu. | 878 Private method used to setup the Languages context sub menu. |
870 | 879 |
871 @return reference to the generated menu (QMenu) | 880 @return reference to the generated menu (QMenu) |
872 """ | 881 """ |
873 menu = QMenu(self.trUtf8("Languages")) | 882 menu = QMenu(self.tr("Languages")) |
874 | 883 |
875 self.languagesActGrp = QActionGroup(self) | 884 self.languagesActGrp = QActionGroup(self) |
876 self.noLanguageAct = menu.addAction(self.trUtf8("No Language")) | 885 self.noLanguageAct = menu.addAction(self.tr("No Language")) |
877 self.noLanguageAct.setCheckable(True) | 886 self.noLanguageAct.setCheckable(True) |
878 self.noLanguageAct.setData("None") | 887 self.noLanguageAct.setData("None") |
879 self.languagesActGrp.addAction(self.noLanguageAct) | 888 self.languagesActGrp.addAction(self.noLanguageAct) |
880 menu.addSeparator() | 889 menu.addSeparator() |
881 | 890 |
894 act.setData(language) | 903 act.setData(language) |
895 self.supportedLanguages[language].append(act) | 904 self.supportedLanguages[language].append(act) |
896 self.languagesActGrp.addAction(act) | 905 self.languagesActGrp.addAction(act) |
897 | 906 |
898 menu.addSeparator() | 907 menu.addSeparator() |
899 self.pygmentsAct = menu.addAction(self.trUtf8("Guessed")) | 908 self.pygmentsAct = menu.addAction(self.tr("Guessed")) |
900 self.pygmentsAct.setCheckable(True) | 909 self.pygmentsAct.setCheckable(True) |
901 self.pygmentsAct.setData("Guessed") | 910 self.pygmentsAct.setData("Guessed") |
902 self.languagesActGrp.addAction(self.pygmentsAct) | 911 self.languagesActGrp.addAction(self.pygmentsAct) |
903 self.pygmentsSelAct = menu.addAction(self.trUtf8("Alternatives")) | 912 self.pygmentsSelAct = menu.addAction(self.tr("Alternatives")) |
904 self.pygmentsSelAct.setData("Alternatives") | 913 self.pygmentsSelAct.setData("Alternatives") |
905 | 914 |
906 menu.triggered.connect(self.__languageMenuTriggered) | 915 menu.triggered.connect(self.__languageMenuTriggered) |
907 menu.aboutToShow.connect(self.__showContextMenuLanguages) | 916 menu.aboutToShow.connect(self.__showContextMenuLanguages) |
908 | 917 |
914 | 923 |
915 @return reference to the generated menu (QMenu) | 924 @return reference to the generated menu (QMenu) |
916 """ | 925 """ |
917 self.supportedEncodings = {} | 926 self.supportedEncodings = {} |
918 | 927 |
919 menu = QMenu(self.trUtf8("Encodings")) | 928 menu = QMenu(self.tr("Encodings")) |
920 | 929 |
921 self.encodingsActGrp = QActionGroup(self) | 930 self.encodingsActGrp = QActionGroup(self) |
922 | 931 |
923 for encoding in sorted(Utilities.supportedCodecs): | 932 for encoding in sorted(Utilities.supportedCodecs): |
924 act = menu.addAction(encoding) | 933 act = menu.addAction(encoding) |
930 menu.triggered.connect(self.__encodingsMenuTriggered) | 939 menu.triggered.connect(self.__encodingsMenuTriggered) |
931 menu.aboutToShow.connect(self.__showContextMenuEncodings) | 940 menu.aboutToShow.connect(self.__showContextMenuEncodings) |
932 | 941 |
933 return menu | 942 return menu |
934 | 943 |
944 def __initContextMenuReopenWithEncoding(self): | |
945 """ | |
946 Private method used to setup the Reopen With Encoding context sub menu. | |
947 | |
948 @return reference to the generated menu (QMenu) | |
949 """ | |
950 menu = QMenu(self.tr("Re-Open With Encoding")) | |
951 menu.setIcon(UI.PixmapCache.getIcon("open.png")) | |
952 | |
953 for encoding in sorted(Utilities.supportedCodecs): | |
954 act = menu.addAction(encoding) | |
955 act.setData(encoding) | |
956 | |
957 menu.triggered.connect(self.__reopenWithEncodingMenuTriggered) | |
958 | |
959 return menu | |
960 | |
935 def __initContextMenuEol(self): | 961 def __initContextMenuEol(self): |
936 """ | 962 """ |
937 Private method to setup the eol context sub menu. | 963 Private method to setup the eol context sub menu. |
938 | 964 |
939 @return reference to the generated menu (QMenu) | 965 @return reference to the generated menu (QMenu) |
940 """ | 966 """ |
941 self.supportedEols = {} | 967 self.supportedEols = {} |
942 | 968 |
943 menu = QMenu(self.trUtf8("End-of-Line Type")) | 969 menu = QMenu(self.tr("End-of-Line Type")) |
944 | 970 |
945 self.eolActGrp = QActionGroup(self) | 971 self.eolActGrp = QActionGroup(self) |
946 | 972 |
947 act = menu.addAction(UI.PixmapCache.getIcon("eolLinux.png"), | 973 act = menu.addAction(UI.PixmapCache.getIcon("eolLinux.png"), |
948 self.trUtf8("Unix")) | 974 self.tr("Unix")) |
949 act.setCheckable(True) | 975 act.setCheckable(True) |
950 act.setData('\n') | 976 act.setData('\n') |
951 self.supportedEols['\n'] = act | 977 self.supportedEols['\n'] = act |
952 self.eolActGrp.addAction(act) | 978 self.eolActGrp.addAction(act) |
953 | 979 |
954 act = menu.addAction(UI.PixmapCache.getIcon("eolWindows.png"), | 980 act = menu.addAction(UI.PixmapCache.getIcon("eolWindows.png"), |
955 self.trUtf8("Windows")) | 981 self.tr("Windows")) |
956 act.setCheckable(True) | 982 act.setCheckable(True) |
957 act.setData('\r\n') | 983 act.setData('\r\n') |
958 self.supportedEols['\r\n'] = act | 984 self.supportedEols['\r\n'] = act |
959 self.eolActGrp.addAction(act) | 985 self.eolActGrp.addAction(act) |
960 | 986 |
961 act = menu.addAction(UI.PixmapCache.getIcon("eolMac.png"), | 987 act = menu.addAction(UI.PixmapCache.getIcon("eolMac.png"), |
962 self.trUtf8("Macintosh")) | 988 self.tr("Macintosh")) |
963 act.setCheckable(True) | 989 act.setCheckable(True) |
964 act.setData('\r') | 990 act.setData('\r') |
965 self.supportedEols['\r'] = act | 991 self.supportedEols['\r'] = act |
966 self.eolActGrp.addAction(act) | 992 self.eolActGrp.addAction(act) |
967 | 993 |
974 """ | 1000 """ |
975 Private method used to setup the Exporters context sub menu. | 1001 Private method used to setup the Exporters context sub menu. |
976 | 1002 |
977 @return reference to the generated menu (QMenu) | 1003 @return reference to the generated menu (QMenu) |
978 """ | 1004 """ |
979 menu = QMenu(self.trUtf8("Export as")) | 1005 menu = QMenu(self.tr("Export as")) |
980 | 1006 |
981 from . import Exporters | 1007 from . import Exporters |
982 supportedExporters = Exporters.getSupportedFormats() | 1008 supportedExporters = Exporters.getSupportedFormats() |
983 exporters = sorted(list(supportedExporters.keys())) | 1009 exporters = sorted(list(supportedExporters.keys())) |
984 for exporter in exporters: | 1010 for exporter in exporters: |
1007 """ | 1033 """ |
1008 # bookmark margin | 1034 # bookmark margin |
1009 self.bmMarginMenu = QMenu() | 1035 self.bmMarginMenu = QMenu() |
1010 | 1036 |
1011 self.bmMarginMenu.addAction( | 1037 self.bmMarginMenu.addAction( |
1012 self.trUtf8('Toggle bookmark'), self.menuToggleBookmark) | 1038 self.tr('Toggle bookmark'), self.menuToggleBookmark) |
1013 self.marginMenuActs["NextBookmark"] = self.bmMarginMenu.addAction( | 1039 self.marginMenuActs["NextBookmark"] = self.bmMarginMenu.addAction( |
1014 self.trUtf8('Next bookmark'), self.nextBookmark) | 1040 self.tr('Next bookmark'), self.nextBookmark) |
1015 self.marginMenuActs["PreviousBookmark"] = self.bmMarginMenu.addAction( | 1041 self.marginMenuActs["PreviousBookmark"] = self.bmMarginMenu.addAction( |
1016 self.trUtf8('Previous bookmark'), self.previousBookmark) | 1042 self.tr('Previous bookmark'), self.previousBookmark) |
1017 self.marginMenuActs["ClearBookmark"] = self.bmMarginMenu.addAction( | 1043 self.marginMenuActs["ClearBookmark"] = self.bmMarginMenu.addAction( |
1018 self.trUtf8('Clear all bookmarks'), self.clearBookmarks) | 1044 self.tr('Clear all bookmarks'), self.clearBookmarks) |
1019 | 1045 |
1020 self.bmMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) | 1046 self.bmMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) |
1021 | 1047 |
1022 # breakpoint margin | 1048 # breakpoint margin |
1023 self.bpMarginMenu = QMenu() | 1049 self.bpMarginMenu = QMenu() |
1024 | 1050 |
1025 self.marginMenuActs["Breakpoint"] = self.bpMarginMenu.addAction( | 1051 self.marginMenuActs["Breakpoint"] = self.bpMarginMenu.addAction( |
1026 self.trUtf8('Toggle breakpoint'), self.menuToggleBreakpoint) | 1052 self.tr('Toggle breakpoint'), self.menuToggleBreakpoint) |
1027 self.marginMenuActs["TempBreakpoint"] = self.bpMarginMenu.addAction( | 1053 self.marginMenuActs["TempBreakpoint"] = self.bpMarginMenu.addAction( |
1028 self.trUtf8('Toggle temporary breakpoint'), | 1054 self.tr('Toggle temporary breakpoint'), |
1029 self.__menuToggleTemporaryBreakpoint) | 1055 self.__menuToggleTemporaryBreakpoint) |
1030 self.marginMenuActs["EditBreakpoint"] = self.bpMarginMenu.addAction( | 1056 self.marginMenuActs["EditBreakpoint"] = self.bpMarginMenu.addAction( |
1031 self.trUtf8('Edit breakpoint...'), self.menuEditBreakpoint) | 1057 self.tr('Edit breakpoint...'), self.menuEditBreakpoint) |
1032 self.marginMenuActs["EnableBreakpoint"] = self.bpMarginMenu.addAction( | 1058 self.marginMenuActs["EnableBreakpoint"] = self.bpMarginMenu.addAction( |
1033 self.trUtf8('Enable breakpoint'), | 1059 self.tr('Enable breakpoint'), |
1034 self.__menuToggleBreakpointEnabled) | 1060 self.__menuToggleBreakpointEnabled) |
1035 self.marginMenuActs["NextBreakpoint"] = self.bpMarginMenu.addAction( | 1061 self.marginMenuActs["NextBreakpoint"] = self.bpMarginMenu.addAction( |
1036 self.trUtf8('Next breakpoint'), self.menuNextBreakpoint) | 1062 self.tr('Next breakpoint'), self.menuNextBreakpoint) |
1037 self.marginMenuActs["PreviousBreakpoint"] = \ | 1063 self.marginMenuActs["PreviousBreakpoint"] = \ |
1038 self.bpMarginMenu.addAction( | 1064 self.bpMarginMenu.addAction( |
1039 self.trUtf8('Previous breakpoint'), | 1065 self.tr('Previous breakpoint'), |
1040 self.menuPreviousBreakpoint) | 1066 self.menuPreviousBreakpoint) |
1041 self.marginMenuActs["ClearBreakpoint"] = self.bpMarginMenu.addAction( | 1067 self.marginMenuActs["ClearBreakpoint"] = self.bpMarginMenu.addAction( |
1042 self.trUtf8('Clear all breakpoints'), self.__menuClearBreakpoints) | 1068 self.tr('Clear all breakpoints'), self.__menuClearBreakpoints) |
1043 | 1069 |
1044 self.bpMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) | 1070 self.bpMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) |
1045 | 1071 |
1046 # indicator margin | 1072 # indicator margin |
1047 self.indicMarginMenu = QMenu() | 1073 self.indicMarginMenu = QMenu() |
1048 | 1074 |
1049 self.marginMenuActs["GotoSyntaxError"] = \ | 1075 self.marginMenuActs["GotoSyntaxError"] = \ |
1050 self.indicMarginMenu.addAction( | 1076 self.indicMarginMenu.addAction( |
1051 self.trUtf8('Goto syntax error'), self.gotoSyntaxError) | 1077 self.tr('Goto syntax error'), self.gotoSyntaxError) |
1052 self.marginMenuActs["ShowSyntaxError"] = \ | 1078 self.marginMenuActs["ShowSyntaxError"] = \ |
1053 self.indicMarginMenu.addAction( | 1079 self.indicMarginMenu.addAction( |
1054 self.trUtf8('Show syntax error message'), | 1080 self.tr('Show syntax error message'), |
1055 self.__showSyntaxError) | 1081 self.__showSyntaxError) |
1056 self.marginMenuActs["ClearSyntaxError"] = \ | 1082 self.marginMenuActs["ClearSyntaxError"] = \ |
1057 self.indicMarginMenu.addAction( | 1083 self.indicMarginMenu.addAction( |
1058 self.trUtf8('Clear syntax error'), self.clearSyntaxError) | 1084 self.tr('Clear syntax error'), self.clearSyntaxError) |
1059 self.indicMarginMenu.addSeparator() | 1085 self.indicMarginMenu.addSeparator() |
1060 self.marginMenuActs["NextWarningMarker"] = \ | 1086 self.marginMenuActs["NextWarningMarker"] = \ |
1061 self.indicMarginMenu.addAction( | 1087 self.indicMarginMenu.addAction( |
1062 self.trUtf8("Next warning"), self.nextWarning) | 1088 self.tr("Next warning"), self.nextWarning) |
1063 self.marginMenuActs["PreviousWarningMarker"] = \ | 1089 self.marginMenuActs["PreviousWarningMarker"] = \ |
1064 self.indicMarginMenu.addAction( | 1090 self.indicMarginMenu.addAction( |
1065 self.trUtf8("Previous warning"), self.previousWarning) | 1091 self.tr("Previous warning"), self.previousWarning) |
1066 self.marginMenuActs["ShowWarning"] = \ | 1092 self.marginMenuActs["ShowWarning"] = \ |
1067 self.indicMarginMenu.addAction( | 1093 self.indicMarginMenu.addAction( |
1068 self.trUtf8('Show warning message'), self.__showWarning) | 1094 self.tr('Show warning message'), self.__showWarning) |
1069 self.marginMenuActs["ClearWarnings"] = \ | 1095 self.marginMenuActs["ClearWarnings"] = \ |
1070 self.indicMarginMenu.addAction( | 1096 self.indicMarginMenu.addAction( |
1071 self.trUtf8('Clear warnings'), self.clearWarnings) | 1097 self.tr('Clear warnings'), self.clearWarnings) |
1072 self.indicMarginMenu.addSeparator() | 1098 self.indicMarginMenu.addSeparator() |
1073 self.marginMenuActs["NextCoverageMarker"] = \ | 1099 self.marginMenuActs["NextCoverageMarker"] = \ |
1074 self.indicMarginMenu.addAction( | 1100 self.indicMarginMenu.addAction( |
1075 self.trUtf8('Next uncovered line'), self.nextUncovered) | 1101 self.tr('Next uncovered line'), self.nextUncovered) |
1076 self.marginMenuActs["PreviousCoverageMarker"] = \ | 1102 self.marginMenuActs["PreviousCoverageMarker"] = \ |
1077 self.indicMarginMenu.addAction( | 1103 self.indicMarginMenu.addAction( |
1078 self.trUtf8('Previous uncovered line'), self.previousUncovered) | 1104 self.tr('Previous uncovered line'), self.previousUncovered) |
1079 self.indicMarginMenu.addSeparator() | 1105 self.indicMarginMenu.addSeparator() |
1080 self.marginMenuActs["NextTaskMarker"] = \ | 1106 self.marginMenuActs["NextTaskMarker"] = \ |
1081 self.indicMarginMenu.addAction( | 1107 self.indicMarginMenu.addAction( |
1082 self.trUtf8('Next task'), self.nextTask) | 1108 self.tr('Next task'), self.nextTask) |
1083 self.marginMenuActs["PreviousTaskMarker"] = \ | 1109 self.marginMenuActs["PreviousTaskMarker"] = \ |
1084 self.indicMarginMenu.addAction( | 1110 self.indicMarginMenu.addAction( |
1085 self.trUtf8('Previous task'), self.previousTask) | 1111 self.tr('Previous task'), self.previousTask) |
1086 self.indicMarginMenu.addSeparator() | 1112 self.indicMarginMenu.addSeparator() |
1087 self.marginMenuActs["NextChangeMarker"] = \ | 1113 self.marginMenuActs["NextChangeMarker"] = \ |
1088 self.indicMarginMenu.addAction( | 1114 self.indicMarginMenu.addAction( |
1089 self.trUtf8('Next change'), self.nextChange) | 1115 self.tr('Next change'), self.nextChange) |
1090 self.marginMenuActs["PreviousChangeMarker"] = \ | 1116 self.marginMenuActs["PreviousChangeMarker"] = \ |
1091 self.indicMarginMenu.addAction( | 1117 self.indicMarginMenu.addAction( |
1092 self.trUtf8('Previous change'), self.previousChange) | 1118 self.tr('Previous change'), self.previousChange) |
1093 | 1119 |
1094 self.indicMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) | 1120 self.indicMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) |
1095 | 1121 |
1096 def __initContextMenuUnifiedMargins(self): | 1122 def __initContextMenuUnifiedMargins(self): |
1097 """ | 1123 """ |
1098 Private method used to setup the context menu for the unified margins. | 1124 Private method used to setup the context menu for the unified margins. |
1099 """ | 1125 """ |
1100 self.marginMenu = QMenu() | 1126 self.marginMenu = QMenu() |
1101 | 1127 |
1102 self.marginMenu.addAction( | 1128 self.marginMenu.addAction( |
1103 self.trUtf8('Toggle bookmark'), self.menuToggleBookmark) | 1129 self.tr('Toggle bookmark'), self.menuToggleBookmark) |
1104 self.marginMenuActs["NextBookmark"] = self.marginMenu.addAction( | 1130 self.marginMenuActs["NextBookmark"] = self.marginMenu.addAction( |
1105 self.trUtf8('Next bookmark'), self.nextBookmark) | 1131 self.tr('Next bookmark'), self.nextBookmark) |
1106 self.marginMenuActs["PreviousBookmark"] = self.marginMenu.addAction( | 1132 self.marginMenuActs["PreviousBookmark"] = self.marginMenu.addAction( |
1107 self.trUtf8('Previous bookmark'), self.previousBookmark) | 1133 self.tr('Previous bookmark'), self.previousBookmark) |
1108 self.marginMenuActs["ClearBookmark"] = self.marginMenu.addAction( | 1134 self.marginMenuActs["ClearBookmark"] = self.marginMenu.addAction( |
1109 self.trUtf8('Clear all bookmarks'), self.clearBookmarks) | 1135 self.tr('Clear all bookmarks'), self.clearBookmarks) |
1110 self.marginMenu.addSeparator() | 1136 self.marginMenu.addSeparator() |
1111 self.marginMenuActs["GotoSyntaxError"] = self.marginMenu.addAction( | 1137 self.marginMenuActs["GotoSyntaxError"] = self.marginMenu.addAction( |
1112 self.trUtf8('Goto syntax error'), self.gotoSyntaxError) | 1138 self.tr('Goto syntax error'), self.gotoSyntaxError) |
1113 self.marginMenuActs["ShowSyntaxError"] = self.marginMenu.addAction( | 1139 self.marginMenuActs["ShowSyntaxError"] = self.marginMenu.addAction( |
1114 self.trUtf8('Show syntax error message'), self.__showSyntaxError) | 1140 self.tr('Show syntax error message'), self.__showSyntaxError) |
1115 self.marginMenuActs["ClearSyntaxError"] = self.marginMenu.addAction( | 1141 self.marginMenuActs["ClearSyntaxError"] = self.marginMenu.addAction( |
1116 self.trUtf8('Clear syntax error'), self.clearSyntaxError) | 1142 self.tr('Clear syntax error'), self.clearSyntaxError) |
1117 self.marginMenu.addSeparator() | 1143 self.marginMenu.addSeparator() |
1118 self.marginMenuActs["NextWarningMarker"] = self.marginMenu.addAction( | 1144 self.marginMenuActs["NextWarningMarker"] = self.marginMenu.addAction( |
1119 self.trUtf8("Next warning"), self.nextWarning) | 1145 self.tr("Next warning"), self.nextWarning) |
1120 self.marginMenuActs["PreviousWarningMarker"] = \ | 1146 self.marginMenuActs["PreviousWarningMarker"] = \ |
1121 self.marginMenu.addAction( | 1147 self.marginMenu.addAction( |
1122 self.trUtf8("Previous warning"), self.previousWarning) | 1148 self.tr("Previous warning"), self.previousWarning) |
1123 self.marginMenuActs["ShowWarning"] = self.marginMenu.addAction( | 1149 self.marginMenuActs["ShowWarning"] = self.marginMenu.addAction( |
1124 self.trUtf8('Show warning message'), self.__showWarning) | 1150 self.tr('Show warning message'), self.__showWarning) |
1125 self.marginMenuActs["ClearWarnings"] = self.marginMenu.addAction( | 1151 self.marginMenuActs["ClearWarnings"] = self.marginMenu.addAction( |
1126 self.trUtf8('Clear warnings'), self.clearWarnings) | 1152 self.tr('Clear warnings'), self.clearWarnings) |
1127 self.marginMenu.addSeparator() | 1153 self.marginMenu.addSeparator() |
1128 self.marginMenuActs["Breakpoint"] = self.marginMenu.addAction( | 1154 self.marginMenuActs["Breakpoint"] = self.marginMenu.addAction( |
1129 self.trUtf8('Toggle breakpoint'), self.menuToggleBreakpoint) | 1155 self.tr('Toggle breakpoint'), self.menuToggleBreakpoint) |
1130 self.marginMenuActs["TempBreakpoint"] = self.marginMenu.addAction( | 1156 self.marginMenuActs["TempBreakpoint"] = self.marginMenu.addAction( |
1131 self.trUtf8('Toggle temporary breakpoint'), | 1157 self.tr('Toggle temporary breakpoint'), |
1132 self.__menuToggleTemporaryBreakpoint) | 1158 self.__menuToggleTemporaryBreakpoint) |
1133 self.marginMenuActs["EditBreakpoint"] = self.marginMenu.addAction( | 1159 self.marginMenuActs["EditBreakpoint"] = self.marginMenu.addAction( |
1134 self.trUtf8('Edit breakpoint...'), self.menuEditBreakpoint) | 1160 self.tr('Edit breakpoint...'), self.menuEditBreakpoint) |
1135 self.marginMenuActs["EnableBreakpoint"] = self.marginMenu.addAction( | 1161 self.marginMenuActs["EnableBreakpoint"] = self.marginMenu.addAction( |
1136 self.trUtf8('Enable breakpoint'), | 1162 self.tr('Enable breakpoint'), |
1137 self.__menuToggleBreakpointEnabled) | 1163 self.__menuToggleBreakpointEnabled) |
1138 self.marginMenuActs["NextBreakpoint"] = self.marginMenu.addAction( | 1164 self.marginMenuActs["NextBreakpoint"] = self.marginMenu.addAction( |
1139 self.trUtf8('Next breakpoint'), self.menuNextBreakpoint) | 1165 self.tr('Next breakpoint'), self.menuNextBreakpoint) |
1140 self.marginMenuActs["PreviousBreakpoint"] = self.marginMenu.addAction( | 1166 self.marginMenuActs["PreviousBreakpoint"] = self.marginMenu.addAction( |
1141 self.trUtf8('Previous breakpoint'), self.menuPreviousBreakpoint) | 1167 self.tr('Previous breakpoint'), self.menuPreviousBreakpoint) |
1142 self.marginMenuActs["ClearBreakpoint"] = self.marginMenu.addAction( | 1168 self.marginMenuActs["ClearBreakpoint"] = self.marginMenu.addAction( |
1143 self.trUtf8('Clear all breakpoints'), self.__menuClearBreakpoints) | 1169 self.tr('Clear all breakpoints'), self.__menuClearBreakpoints) |
1144 self.marginMenu.addSeparator() | 1170 self.marginMenu.addSeparator() |
1145 self.marginMenuActs["NextCoverageMarker"] = self.marginMenu.addAction( | 1171 self.marginMenuActs["NextCoverageMarker"] = self.marginMenu.addAction( |
1146 self.trUtf8('Next uncovered line'), self.nextUncovered) | 1172 self.tr('Next uncovered line'), self.nextUncovered) |
1147 self.marginMenuActs["PreviousCoverageMarker"] = \ | 1173 self.marginMenuActs["PreviousCoverageMarker"] = \ |
1148 self.marginMenu.addAction( | 1174 self.marginMenu.addAction( |
1149 self.trUtf8('Previous uncovered line'), self.previousUncovered) | 1175 self.tr('Previous uncovered line'), self.previousUncovered) |
1150 self.marginMenu.addSeparator() | 1176 self.marginMenu.addSeparator() |
1151 self.marginMenuActs["NextTaskMarker"] = self.marginMenu.addAction( | 1177 self.marginMenuActs["NextTaskMarker"] = self.marginMenu.addAction( |
1152 self.trUtf8('Next task'), self.nextTask) | 1178 self.tr('Next task'), self.nextTask) |
1153 self.marginMenuActs["PreviousTaskMarker"] = self.marginMenu.addAction( | 1179 self.marginMenuActs["PreviousTaskMarker"] = self.marginMenu.addAction( |
1154 self.trUtf8('Previous task'), self.previousTask) | 1180 self.tr('Previous task'), self.previousTask) |
1155 self.marginMenu.addSeparator() | 1181 self.marginMenu.addSeparator() |
1156 self.marginMenuActs["NextChangeMarker"] = self.marginMenu.addAction( | 1182 self.marginMenuActs["NextChangeMarker"] = self.marginMenu.addAction( |
1157 self.trUtf8('Next change'), self.nextChange) | 1183 self.tr('Next change'), self.nextChange) |
1158 self.marginMenuActs["PreviousChangeMarker"] = \ | 1184 self.marginMenuActs["PreviousChangeMarker"] = \ |
1159 self.marginMenu.addAction( | 1185 self.marginMenu.addAction( |
1160 self.trUtf8('Previous change'), self.previousChange) | 1186 self.tr('Previous change'), self.previousChange) |
1161 self.marginMenu.addSeparator() | 1187 self.marginMenu.addSeparator() |
1162 self.marginMenuActs["LMBbookmarks"] = self.marginMenu.addAction( | 1188 self.marginMenuActs["LMBbookmarks"] = self.marginMenu.addAction( |
1163 self.trUtf8('LMB toggles bookmarks'), self.__lmBbookmarks) | 1189 self.tr('LMB toggles bookmarks'), self.__lmBbookmarks) |
1164 self.marginMenuActs["LMBbookmarks"].setCheckable(True) | 1190 self.marginMenuActs["LMBbookmarks"].setCheckable(True) |
1165 self.marginMenuActs["LMBbookmarks"].setChecked(False) | 1191 self.marginMenuActs["LMBbookmarks"].setChecked(False) |
1166 self.marginMenuActs["LMBbreakpoints"] = self.marginMenu.addAction( | 1192 self.marginMenuActs["LMBbreakpoints"] = self.marginMenu.addAction( |
1167 self.trUtf8('LMB toggles breakpoints'), self.__lmBbreakpoints) | 1193 self.tr('LMB toggles breakpoints'), self.__lmBbreakpoints) |
1168 self.marginMenuActs["LMBbreakpoints"].setCheckable(True) | 1194 self.marginMenuActs["LMBbreakpoints"].setCheckable(True) |
1169 self.marginMenuActs["LMBbreakpoints"].setChecked(True) | 1195 self.marginMenuActs["LMBbreakpoints"].setChecked(True) |
1170 | 1196 |
1171 self.marginMenu.aboutToShow.connect(self.__showContextMenuMargin) | 1197 self.marginMenu.aboutToShow.connect(self.__showContextMenuMargin) |
1172 | 1198 |
1191 if exporter: | 1217 if exporter: |
1192 exporter.exportSource() | 1218 exporter.exportSource() |
1193 else: | 1219 else: |
1194 E5MessageBox.critical( | 1220 E5MessageBox.critical( |
1195 self, | 1221 self, |
1196 self.trUtf8("Export source"), | 1222 self.tr("Export source"), |
1197 self.trUtf8( | 1223 self.tr( |
1198 """<p>No exporter available for the """ | 1224 """<p>No exporter available for the """ |
1199 """export format <b>{0}</b>. Aborting...</p>""") | 1225 """export format <b>{0}</b>. Aborting...</p>""") |
1200 .format(exporterFormat)) | 1226 .format(exporterFormat)) |
1201 else: | 1227 else: |
1202 E5MessageBox.critical( | 1228 E5MessageBox.critical( |
1203 self, | 1229 self, |
1204 self.trUtf8("Export source"), | 1230 self.tr("Export source"), |
1205 self.trUtf8("""No export format given. Aborting...""")) | 1231 self.tr("""No export format given. Aborting...""")) |
1206 | 1232 |
1207 def __showContextMenuLanguages(self): | 1233 def __showContextMenuLanguages(self): |
1208 """ | 1234 """ |
1209 Private slot handling the aboutToShow signal of the languages context | 1235 Private slot handling the aboutToShow signal of the languages context |
1210 menu. | 1236 menu. |
1211 """ | 1237 """ |
1212 if self.apiLanguage.startswith("Pygments|"): | 1238 if self.apiLanguage.startswith("Pygments|"): |
1213 self.pygmentsSelAct.setText( | 1239 self.pygmentsSelAct.setText( |
1214 self.trUtf8("Alternatives ({0})").format( | 1240 self.tr("Alternatives ({0})").format( |
1215 self.getLanguage(normalized=False))) | 1241 self.getLanguage(normalized=False))) |
1216 else: | 1242 else: |
1217 self.pygmentsSelAct.setText(self.trUtf8("Alternatives")) | 1243 self.pygmentsSelAct.setText(self.tr("Alternatives")) |
1218 self.showMenu.emit("Languages", self.languagesMenu, self) | 1244 self.showMenu.emit("Languages", self.languagesMenu, self) |
1219 | 1245 |
1220 def __selectPygmentsLexer(self): | 1246 def __selectPygmentsLexer(self): |
1221 """ | 1247 """ |
1222 Private method to select a specific pygments lexer. | 1248 Private method to select a specific pygments lexer. |
1223 | 1249 |
1230 self.getLanguage(normalized=False, forPygments=True)) | 1256 self.getLanguage(normalized=False, forPygments=True)) |
1231 except ValueError: | 1257 except ValueError: |
1232 lexerSel = 0 | 1258 lexerSel = 0 |
1233 lexerName, ok = QInputDialog.getItem( | 1259 lexerName, ok = QInputDialog.getItem( |
1234 self, | 1260 self, |
1235 self.trUtf8("Pygments Lexer"), | 1261 self.tr("Pygments Lexer"), |
1236 self.trUtf8("Select the Pygments lexer to apply."), | 1262 self.tr("Select the Pygments lexer to apply."), |
1237 lexerList, | 1263 lexerList, |
1238 lexerSel, | 1264 lexerSel, |
1239 False) | 1265 False) |
1240 if ok and lexerName: | 1266 if ok and lexerName: |
1241 return lexerName | 1267 return lexerName |
1367 def __showContextMenuEncodings(self): | 1393 def __showContextMenuEncodings(self): |
1368 """ | 1394 """ |
1369 Private slot handling the aboutToShow signal of the encodings context | 1395 Private slot handling the aboutToShow signal of the encodings context |
1370 menu. | 1396 menu. |
1371 """ | 1397 """ |
1372 self.showMenu.emit("Encodings", self.encodingsMenu, self) | 1398 self.showMenu.emit("Encodings", self.encodingsMenu, self) |
1373 | 1399 |
1374 def __encodingsMenuTriggered(self, act): | 1400 def __encodingsMenuTriggered(self, act): |
1375 """ | 1401 """ |
1376 Private method to handle the selection of an encoding. | 1402 Private method to handle the selection of an encoding. |
1377 | 1403 |
1378 @param act reference to the action that was triggered (QAction) | 1404 @param act reference to the action that was triggered (QAction) |
1379 """ | 1405 """ |
1380 encoding = act.data() | 1406 encoding = act.data() |
1407 self.setModified(True) | |
1381 self.__encodingChanged("{0}-selected".format(encoding)) | 1408 self.__encodingChanged("{0}-selected".format(encoding)) |
1382 | 1409 |
1383 def __checkEncoding(self): | 1410 def __checkEncoding(self): |
1384 """ | 1411 """ |
1385 Private method to check the selected encoding of the encodings submenu. | 1412 Private method to check the selected encoding of the encodings submenu. |
1403 if not self.inEncodingChanged and propagate: | 1430 if not self.inEncodingChanged and propagate: |
1404 self.inEncodingChanged = True | 1431 self.inEncodingChanged = True |
1405 self.encodingChanged.emit(self.encoding) | 1432 self.encodingChanged.emit(self.encoding) |
1406 self.inEncodingChanged = False | 1433 self.inEncodingChanged = False |
1407 | 1434 |
1408 def __normalizedEncoding(self): | 1435 def __normalizedEncoding(self, encoding=""): |
1409 """ | 1436 """ |
1410 Private method to calculate the normalized encoding string. | 1437 Private method to calculate the normalized encoding string. |
1411 | 1438 |
1439 @param encoding encoding to be normalized (string) | |
1412 @return normalized encoding (string) | 1440 @return normalized encoding (string) |
1413 """ | 1441 """ |
1414 return self.encoding.replace("-default", "")\ | 1442 if not encoding: |
1415 .replace("-guessed", "")\ | 1443 encoding = self.encoding |
1416 .replace("-selected", "") | 1444 return encoding.replace("-default", "")\ |
1445 .replace("-guessed", "")\ | |
1446 .replace("-selected", "") | |
1417 | 1447 |
1418 def __showContextMenuEol(self): | 1448 def __showContextMenuEol(self): |
1419 """ | 1449 """ |
1420 Private slot handling the aboutToShow signal of the eol context menu. | 1450 Private slot handling the aboutToShow signal of the eol context menu. |
1421 """ | 1451 """ |
1422 self.showMenu.emit("Eol", self.eolMenu, self) | 1452 self.showMenu.emit("Eol", self.eolMenu, self) |
1423 | 1453 |
1424 def __eolMenuTriggered(self, act): | 1454 def __eolMenuTriggered(self, act): |
1425 """ | 1455 """ |
1426 Private method to handle the selection of an eol type. | 1456 Private method to handle the selection of an eol type. |
1427 | 1457 |
1464 (self.lexer_.lexer() == "container" or self.lexer_.lexer() is None): | 1494 (self.lexer_.lexer() == "container" or self.lexer_.lexer() is None): |
1465 self.SCN_STYLENEEDED.disconnect(self.__styleNeeded) | 1495 self.SCN_STYLENEEDED.disconnect(self.__styleNeeded) |
1466 | 1496 |
1467 language = "" | 1497 language = "" |
1468 basename = os.path.basename(filename) | 1498 basename = os.path.basename(filename) |
1469 if self.project.isOpen() and self.project.isProjectFile(filename): | 1499 if not self.filetype: |
1470 language = self.project.getEditorLexerAssoc(basename) | 1500 if self.project.isOpen() and self.project.isProjectFile(filename): |
1471 if not language: | 1501 language = self.project.getEditorLexerAssoc(basename) |
1472 language = Preferences.getEditorLexerAssoc(basename) | 1502 if not language: |
1473 if not language: | 1503 language = Preferences.getEditorLexerAssoc(basename) |
1474 bindName = self.__bindName(self.text(0)) | 1504 if not language: |
1475 language = Preferences.getEditorLexerAssoc(bindName) | 1505 bindName = self.__bindName(self.text(0)) |
1476 if language == "Python": | 1506 language = Preferences.getEditorLexerAssoc(bindName) |
1477 # correction for Python | 1507 if language == "Python": |
1478 pyVer = Utilities.determinePythonVersion( | 1508 # correction for Python |
1479 filename, self.text(0), self) | 1509 pyVer = Utilities.determinePythonVersion( |
1480 language = "Python{0}".format(pyVer) | 1510 filename, self.text(0), self) |
1481 if language in ['Python2', 'Python3']: | 1511 language = "Python{0}".format(pyVer) |
1482 self.filetype = language | 1512 if language in ['Python2', 'Python3']: |
1483 else: | 1513 self.filetype = language |
1484 self.filetype = "" | 1514 else: |
1515 self.filetype = "" | |
1516 else: | |
1517 language = self.filetype | |
1485 | 1518 |
1486 if language.startswith("Pygments|"): | 1519 if language.startswith("Pygments|"): |
1487 pyname = language.split("|", 1)[1] | 1520 pyname = language.split("|", 1)[1] |
1488 language = "" | 1521 language = "" |
1489 | 1522 |
1588 self.completer = None | 1621 self.completer = None |
1589 | 1622 |
1590 filename = os.path.basename(filename) | 1623 filename = os.path.basename(filename) |
1591 apiLanguage = Preferences.getEditorLexerAssoc(filename) | 1624 apiLanguage = Preferences.getEditorLexerAssoc(filename) |
1592 if apiLanguage == "": | 1625 if apiLanguage == "": |
1593 pyVer = self.getPyVersion() | 1626 pyVer = self.__getPyVersion() |
1594 if pyVer: | 1627 if pyVer: |
1595 apiLanguage = "Python{0}".format(pyVer) | 1628 apiLanguage = "Python{0}".format(pyVer) |
1596 elif self.isRubyFile(): | 1629 elif self.isRubyFile(): |
1597 apiLanguage = "Ruby" | 1630 apiLanguage = "Ruby" |
1598 | 1631 |
1653 doSpelling = False | 1686 doSpelling = False |
1654 if doSpelling: | 1687 if doSpelling: |
1655 pos = self.positionFromLineIndex(self.lastLine, self.lastIndex) | 1688 pos = self.positionFromLineIndex(self.lastLine, self.lastIndex) |
1656 self.spell.checkWord(pos) | 1689 self.spell.checkWord(pos) |
1657 | 1690 |
1691 if self.lastLine != line: | |
1692 self.__markerMap.update() | |
1693 | |
1658 self.lastLine = line | 1694 self.lastLine = line |
1659 self.lastIndex = index | 1695 self.lastIndex = index |
1660 | 1696 |
1661 def __modificationReadOnly(self): | 1697 def __modificationReadOnly(self): |
1662 """ | 1698 """ |
1663 Private slot to handle the modificationAttempted signal. | 1699 Private slot to handle the modificationAttempted signal. |
1664 """ | 1700 """ |
1665 E5MessageBox.warning( | 1701 E5MessageBox.warning( |
1666 self, | 1702 self, |
1667 self.trUtf8("Modification of Read Only file"), | 1703 self.tr("Modification of Read Only file"), |
1668 self.trUtf8("""You are attempting to change a read only file. """ | 1704 self.tr("""You are attempting to change a read only file. """ |
1669 """Please save to a different file first.""")) | 1705 """Please save to a different file first.""")) |
1670 | 1706 |
1671 def setNoName(self, noName): | 1707 def setNoName(self, noName): |
1672 """ | 1708 """ |
1673 Public method to set the display string for an unnamed editor. | 1709 Public method to set the display string for an unnamed editor. |
1674 | 1710 |
1719 | 1755 |
1720 @return type of the displayed file or an empty string (string) | 1756 @return type of the displayed file or an empty string (string) |
1721 """ | 1757 """ |
1722 ftype = self.filetype | 1758 ftype = self.filetype |
1723 if not ftype: | 1759 if not ftype: |
1724 pyVer = self.getPyVersion() | 1760 pyVer = self.__getPyVersion() |
1725 if pyVer: | 1761 if pyVer: |
1726 ftype = "Python{0}".format(pyVer) | 1762 ftype = "Python{0}".format(pyVer) |
1727 elif self.isRubyFile(): | 1763 elif self.isRubyFile(): |
1728 ftype = "Ruby" | 1764 ftype = "Ruby" |
1729 else: | 1765 else: |
1737 | 1773 |
1738 @return current encoding (string) | 1774 @return current encoding (string) |
1739 """ | 1775 """ |
1740 return self.encoding | 1776 return self.encoding |
1741 | 1777 |
1742 def getPyVersion(self): | 1778 def __getPyVersion(self): |
1743 """ | 1779 """ |
1744 Public methode to return the Python main version (2 or 3) or 0 if it's | 1780 Private method to return the Python main version (2 or 3) or 0 if it's |
1745 not a Python file at all. | 1781 not a Python file at all. |
1746 | 1782 |
1747 @return Python version (2 or 3) or 0 if it's not a Python file (int) | 1783 @return Python version (2 or 3) or 0 if it's not a Python file (int) |
1748 """ | 1784 """ |
1749 return Utilities.determinePythonVersion( | 1785 return Utilities.determinePythonVersion( |
1750 self.fileName, self.text(0), self) | 1786 self.fileName, self.text(0), self) |
1751 | 1787 |
1788 def isPyFile(self): | |
1789 """ | |
1790 Public method to return a flag indicating a Python (2 or 3) file. | |
1791 | |
1792 @return flag indicating a Python (2 or 3) file (boolean) | |
1793 """ | |
1794 return self.__getPyVersion() in [2, 3] | |
1795 | |
1752 def isPy2File(self): | 1796 def isPy2File(self): |
1753 """ | 1797 """ |
1754 Public method to return a flag indicating a Python file. | 1798 Public method to return a flag indicating a Python2 file. |
1755 | 1799 |
1756 @return flag indicating a Python file (boolean) | 1800 @return flag indicating a Python2 file (boolean) |
1757 """ | 1801 """ |
1758 return self.getPyVersion() == 2 | 1802 return self.__getPyVersion() == 2 |
1759 | 1803 |
1760 def isPy3File(self): | 1804 def isPy3File(self): |
1761 """ | 1805 """ |
1762 Public method to return a flag indicating a Python3 file. | 1806 Public method to return a flag indicating a Python3 file. |
1763 | 1807 |
1764 @return flag indicating a Python3 file (boolean) | 1808 @return flag indicating a Python3 file (boolean) |
1765 """ | 1809 """ |
1766 return self.getPyVersion() == 3 | 1810 return self.__getPyVersion() == 3 |
1767 | 1811 |
1768 def isRubyFile(self): | 1812 def isRubyFile(self): |
1769 """ | 1813 """ |
1770 Public method to return a flag indicating a Ruby file. | 1814 Public method to return a flag indicating a Ruby file. |
1771 | 1815 |
1783 | 1827 |
1784 if self.fileName is not None and \ | 1828 if self.fileName is not None and \ |
1785 os.path.splitext(self.fileName)[1] in \ | 1829 os.path.splitext(self.fileName)[1] in \ |
1786 self.dbs.getExtensions('Ruby'): | 1830 self.dbs.getExtensions('Ruby'): |
1787 self.filetype = "Ruby" | 1831 self.filetype = "Ruby" |
1832 return True | |
1833 | |
1834 return False | |
1835 | |
1836 def isJavascriptFile(self): | |
1837 """ | |
1838 Public method to return a flag indicating a Javascript file. | |
1839 | |
1840 @return flag indicating a Javascript file (boolean) | |
1841 """ | |
1842 if self.filetype == "JavaScript": | |
1843 return True | |
1844 | |
1845 if self.filetype == "": | |
1846 if self.fileName is not None and \ | |
1847 os.path.splitext(self.fileName)[1] == ".js": | |
1848 self.filetype = "JavaScript" | |
1788 return True | 1849 return True |
1789 | 1850 |
1790 return False | 1851 return False |
1791 | 1852 |
1792 def highlightVisible(self): | 1853 def highlightVisible(self): |
1885 """ | 1946 """ |
1886 for handle in list(self.breaks.keys()): | 1947 for handle in list(self.breaks.keys()): |
1887 self.markerDeleteHandle(handle) | 1948 self.markerDeleteHandle(handle) |
1888 self.__addBreakPoints( | 1949 self.__addBreakPoints( |
1889 QModelIndex(), 0, self.breakpointModel.rowCount() - 1) | 1950 QModelIndex(), 0, self.breakpointModel.rowCount() - 1) |
1951 self.__markerMap.update() | |
1890 | 1952 |
1891 def __deleteBreakPoints(self, parentIndex, start, end): | 1953 def __deleteBreakPoints(self, parentIndex, start, end): |
1892 """ | 1954 """ |
1893 Private slot to delete breakpoints. | 1955 Private slot to delete breakpoints. |
1894 | 1956 |
1961 # not found, simply ignore it | 2023 # not found, simply ignore it |
1962 return | 2024 return |
1963 | 2025 |
1964 del self.breaks[handle] | 2026 del self.breaks[handle] |
1965 self.markerDeleteHandle(handle) | 2027 self.markerDeleteHandle(handle) |
2028 self.__markerMap.update() | |
1966 | 2029 |
1967 def newBreakpointWithProperties(self, line, properties): | 2030 def newBreakpointWithProperties(self, line, properties): |
1968 """ | 2031 """ |
1969 Private method to set a new breakpoint and its properties. | 2032 Private method to set a new breakpoint and its properties. |
1970 | 2033 |
1981 | 2044 |
1982 if self.markersAtLine(line - 1) & self.breakpointMask == 0: | 2045 if self.markersAtLine(line - 1) & self.breakpointMask == 0: |
1983 handle = self.markerAdd(line - 1, marker) | 2046 handle = self.markerAdd(line - 1, marker) |
1984 self.breaks[handle] = (line,) + properties | 2047 self.breaks[handle] = (line,) + properties |
1985 self.breakpointToggled.emit(self) | 2048 self.breakpointToggled.emit(self) |
2049 self.__markerMap.update() | |
1986 | 2050 |
1987 def __toggleBreakpoint(self, line, temporary=False): | 2051 def __toggleBreakpoint(self, line, temporary=False): |
1988 """ | 2052 """ |
1989 Private method to toggle a breakpoint. | 2053 Private method to toggle a breakpoint. |
1990 | 2054 |
2014 | 2078 |
2015 @param line line number of the breakpoint (integer) | 2079 @param line line number of the breakpoint (integer) |
2016 @param temporary flag indicating a temporary breakpoint (boolean) | 2080 @param temporary flag indicating a temporary breakpoint (boolean) |
2017 """ | 2081 """ |
2018 if self.fileName and \ | 2082 if self.fileName and \ |
2019 (self.getPyVersion() or self.isRubyFile()): | 2083 (self.isPyFile() or self.isRubyFile()): |
2020 self.breakpointModel.addBreakPoint( | 2084 self.breakpointModel.addBreakPoint( |
2021 self.fileName, line, ('', temporary, True, 0)) | 2085 self.fileName, line, ('', temporary, True, 0)) |
2022 self.breakpointToggled.emit(self) | 2086 self.breakpointToggled.emit(self) |
2023 | 2087 |
2024 def __toggleBreakpointEnabled(self, line): | 2088 def __toggleBreakpointEnabled(self, line): |
2045 | 2109 |
2046 @return flag indicating the presence of a breakpoint (boolean) | 2110 @return flag indicating the presence of a breakpoint (boolean) |
2047 """ | 2111 """ |
2048 line, _ = self.getCursorPosition() | 2112 line, _ = self.getCursorPosition() |
2049 return self.markersAtLine(line) & self.breakpointMask != 0 | 2113 return self.markersAtLine(line) & self.breakpointMask != 0 |
2114 | |
2115 def getBreakpointLines(self): | |
2116 """ | |
2117 Public method to get the lines containing a breakpoint. | |
2118 | |
2119 @return list of lines containing a breakpoint (list of integer) | |
2120 """ | |
2121 lines = [] | |
2122 line = -1 | |
2123 while True: | |
2124 line = self.markerFindNext(line + 1, self.breakpointMask) | |
2125 if line < 0: | |
2126 break | |
2127 else: | |
2128 lines.append(line) | |
2129 return lines | |
2050 | 2130 |
2051 def hasBreakpoints(self): | 2131 def hasBreakpoints(self): |
2052 """ | 2132 """ |
2053 Public method to check for the presence of breakpoints. | 2133 Public method to check for the presence of breakpoints. |
2054 | 2134 |
2188 | 2268 |
2189 @param line line number of the bookmark (integer) | 2269 @param line line number of the bookmark (integer) |
2190 """ | 2270 """ |
2191 for handle in self.bookmarks: | 2271 for handle in self.bookmarks: |
2192 if self.markerLine(handle) == line - 1: | 2272 if self.markerLine(handle) == line - 1: |
2273 self.bookmarks.remove(handle) | |
2274 self.markerDeleteHandle(handle) | |
2193 break | 2275 break |
2194 else: | 2276 else: |
2195 # set a new bookmark | 2277 # set a new bookmark |
2196 handle = self.markerAdd(line - 1, self.bookmark) | 2278 handle = self.markerAdd(line - 1, self.bookmark) |
2197 self.bookmarks.append(handle) | 2279 self.bookmarks.append(handle) |
2198 self.bookmarkToggled.emit(self) | |
2199 return | |
2200 | |
2201 self.bookmarks.remove(handle) | |
2202 self.markerDeleteHandle(handle) | |
2203 self.bookmarkToggled.emit(self) | 2280 self.bookmarkToggled.emit(self) |
2281 self.__markerMap.update() | |
2204 | 2282 |
2205 def getBookmarks(self): | 2283 def getBookmarks(self): |
2206 """ | 2284 """ |
2207 Public method to retrieve the bookmarks. | 2285 Public method to retrieve the bookmarks. |
2208 | 2286 |
2213 for handle in self.bookmarks: | 2291 for handle in self.bookmarks: |
2214 bmlist.append(self.markerLine(handle) + 1) | 2292 bmlist.append(self.markerLine(handle) + 1) |
2215 | 2293 |
2216 bmlist.sort() | 2294 bmlist.sort() |
2217 return bmlist | 2295 return bmlist |
2296 | |
2297 def getBookmarkLines(self): | |
2298 """ | |
2299 Public method to get the lines containing a bookmark. | |
2300 | |
2301 @return list of lines containing a bookmark (list of integer) | |
2302 """ | |
2303 lines = [] | |
2304 line = -1 | |
2305 while True: | |
2306 line = self.markerFindNext(line + 1, 1 << self.bookmark) | |
2307 if line < 0: | |
2308 break | |
2309 else: | |
2310 lines.append(line) | |
2311 return lines | |
2218 | 2312 |
2219 def hasBookmarks(self): | 2313 def hasBookmarks(self): |
2220 """ | 2314 """ |
2221 Public method to check for the presence of bookmarks. | 2315 Public method to check for the presence of bookmarks. |
2222 | 2316 |
2275 """ | 2369 """ |
2276 for handle in self.bookmarks: | 2370 for handle in self.bookmarks: |
2277 self.markerDeleteHandle(handle) | 2371 self.markerDeleteHandle(handle) |
2278 self.bookmarks = [] | 2372 self.bookmarks = [] |
2279 self.bookmarkToggled.emit(self) | 2373 self.bookmarkToggled.emit(self) |
2374 self.__markerMap.update() | |
2280 | 2375 |
2281 ########################################################################### | 2376 ########################################################################### |
2282 ## Printing methods below | 2377 ## Printing methods below |
2283 ########################################################################### | 2378 ########################################################################### |
2284 | 2379 |
2291 sb = e5App().getObject("UserInterface").statusBar() | 2386 sb = e5App().getObject("UserInterface").statusBar() |
2292 printDialog = QPrintDialog(printer, self) | 2387 printDialog = QPrintDialog(printer, self) |
2293 if self.hasSelectedText(): | 2388 if self.hasSelectedText(): |
2294 printDialog.addEnabledOption(QAbstractPrintDialog.PrintSelection) | 2389 printDialog.addEnabledOption(QAbstractPrintDialog.PrintSelection) |
2295 if printDialog.exec_() == QDialog.Accepted: | 2390 if printDialog.exec_() == QDialog.Accepted: |
2296 sb.showMessage(self.trUtf8('Printing...')) | 2391 sb.showMessage(self.tr('Printing...')) |
2297 QApplication.processEvents() | 2392 QApplication.processEvents() |
2298 fn = self.getFileName() | 2393 fn = self.getFileName() |
2299 if fn is not None: | 2394 if fn is not None: |
2300 printer.setDocName(os.path.basename(fn)) | 2395 printer.setDocName(os.path.basename(fn)) |
2301 else: | 2396 else: |
2308 # Qscintilla seems to print one line more than told | 2403 # Qscintilla seems to print one line more than told |
2309 res = printer.printRange(self, fromLine, toLine - 1) | 2404 res = printer.printRange(self, fromLine, toLine - 1) |
2310 else: | 2405 else: |
2311 res = printer.printRange(self) | 2406 res = printer.printRange(self) |
2312 if res: | 2407 if res: |
2313 sb.showMessage(self.trUtf8('Printing completed'), 2000) | 2408 sb.showMessage(self.tr('Printing completed'), 2000) |
2314 else: | 2409 else: |
2315 sb.showMessage(self.trUtf8('Error while printing'), 2000) | 2410 sb.showMessage(self.tr('Error while printing'), 2000) |
2316 QApplication.processEvents() | 2411 QApplication.processEvents() |
2317 else: | 2412 else: |
2318 sb.showMessage(self.trUtf8('Printing aborted'), 2000) | 2413 sb.showMessage(self.tr('Printing aborted'), 2000) |
2319 QApplication.processEvents() | 2414 QApplication.processEvents() |
2320 | 2415 |
2321 def printPreviewFile(self): | 2416 def printPreviewFile(self): |
2322 """ | 2417 """ |
2323 Public slot to show a print preview of the text. | 2418 Public slot to show a print preview of the text. |
2345 printer.printRange(self) | 2440 printer.printRange(self) |
2346 | 2441 |
2347 ########################################################################### | 2442 ########################################################################### |
2348 ## Task handling methods below | 2443 ## Task handling methods below |
2349 ########################################################################### | 2444 ########################################################################### |
2350 | 2445 |
2446 def getTaskLines(self): | |
2447 """ | |
2448 Public method to get the lines containing a task. | |
2449 | |
2450 @return list of lines containing a task (list of integer) | |
2451 """ | |
2452 lines = [] | |
2453 line = -1 | |
2454 while True: | |
2455 line = self.markerFindNext(line + 1, 1 << self.taskmarker) | |
2456 if line < 0: | |
2457 break | |
2458 else: | |
2459 lines.append(line) | |
2460 return lines | |
2461 | |
2351 def hasTaskMarkers(self): | 2462 def hasTaskMarkers(self): |
2352 """ | 2463 """ |
2353 Public method to determine, if this editor contains any task markers. | 2464 Public method to determine, if this editor contains any task markers. |
2354 | 2465 |
2355 @return flag indicating the presence of task markers (boolean) | 2466 @return flag indicating the presence of task markers (boolean) |
2431 shouldBreak = True | 2542 shouldBreak = True |
2432 break | 2543 break |
2433 if shouldBreak: | 2544 if shouldBreak: |
2434 break | 2545 break |
2435 self.taskMarkersUpdated.emit(self) | 2546 self.taskMarkersUpdated.emit(self) |
2547 self.__markerMap.update() | |
2436 | 2548 |
2437 ########################################################################### | 2549 ########################################################################### |
2438 ## Change tracing methods below | 2550 ## Change tracing methods below |
2439 ########################################################################### | 2551 ########################################################################### |
2440 | 2552 |
2514 self.markerAdd(lineNo, self.__changeMarkerUnsaved) | 2626 self.markerAdd(lineNo, self.__changeMarkerUnsaved) |
2515 self.__hasChangeMarkers = True | 2627 self.__hasChangeMarkers = True |
2516 | 2628 |
2517 if self.__hasChangeMarkers: | 2629 if self.__hasChangeMarkers: |
2518 self.changeMarkersUpdated.emit(self) | 2630 self.changeMarkersUpdated.emit(self) |
2631 self.__markerMap.update() | |
2519 | 2632 |
2520 def __resetOnlineChangeTraceInfo(self): | 2633 def __resetOnlineChangeTraceInfo(self): |
2521 """ | 2634 """ |
2522 Private slot to reset the online change trace info. | 2635 Private slot to reset the online change trace info. |
2523 """ | 2636 """ |
2535 self.markerAdd(lineNo, self.__changeMarkerSaved) | 2648 self.markerAdd(lineNo, self.__changeMarkerSaved) |
2536 self.__hasChangeMarkers = True | 2649 self.__hasChangeMarkers = True |
2537 | 2650 |
2538 if self.__hasChangeMarkers: | 2651 if self.__hasChangeMarkers: |
2539 self.changeMarkersUpdated.emit(self) | 2652 self.changeMarkersUpdated.emit(self) |
2653 self.__markerMap.update() | |
2540 | 2654 |
2541 def __deleteAllChangeMarkers(self): | 2655 def __deleteAllChangeMarkers(self): |
2542 """ | 2656 """ |
2543 Private slot to delete all change markers. | 2657 Private slot to delete all change markers. |
2544 """ | 2658 """ |
2545 self.markerDeleteAll(self.__changeMarkerUnsaved) | 2659 self.markerDeleteAll(self.__changeMarkerUnsaved) |
2546 self.markerDeleteAll(self.__changeMarkerSaved) | 2660 self.markerDeleteAll(self.__changeMarkerSaved) |
2547 self.__hasChangeMarkers = False | 2661 self.__hasChangeMarkers = False |
2548 self.changeMarkersUpdated.emit(self) | 2662 self.changeMarkersUpdated.emit(self) |
2663 self.__markerMap.update() | |
2664 | |
2665 def getChangeLines(self): | |
2666 """ | |
2667 Public method to get the lines containing a change. | |
2668 | |
2669 @return list of lines containing a change (list of integer) | |
2670 """ | |
2671 lines = [] | |
2672 line = -1 | |
2673 while True: | |
2674 line = self.markerFindNext(line + 1, self.changeMarkersMask) | |
2675 if line < 0: | |
2676 break | |
2677 else: | |
2678 lines.append(line) | |
2679 return lines | |
2549 | 2680 |
2550 def hasChangeMarkers(self): | 2681 def hasChangeMarkers(self): |
2551 """ | 2682 """ |
2552 Public method to determine, if this editor contains any change markers. | 2683 Public method to determine, if this editor contains any change markers. |
2553 | 2684 |
2636 fn = self.fileName | 2767 fn = self.fileName |
2637 if fn is None: | 2768 if fn is None: |
2638 fn = self.noName | 2769 fn = self.noName |
2639 res = E5MessageBox.okToClearData( | 2770 res = E5MessageBox.okToClearData( |
2640 self, | 2771 self, |
2641 self.trUtf8("File Modified"), | 2772 self.tr("File Modified"), |
2642 self.trUtf8("<p>The file <b>{0}</b> has unsaved changes.</p>") | 2773 self.tr("<p>The file <b>{0}</b> has unsaved changes.</p>") |
2643 .format(fn), | 2774 .format(fn), |
2644 self.saveFile) | 2775 self.saveFile) |
2645 if res: | 2776 if res: |
2646 self.vm.setEditorName(self, self.fileName) | 2777 self.vm.setEditorName(self, self.fileName) |
2647 return res | 2778 return res |
2666 self.redo() | 2797 self.redo() |
2667 else: | 2798 else: |
2668 break | 2799 break |
2669 # Couldn't find the unmodified state | 2800 # Couldn't find the unmodified state |
2670 | 2801 |
2671 def readFile(self, fn, createIt=False): | 2802 def readFile(self, fn, createIt=False, encoding=""): |
2672 """ | 2803 """ |
2673 Public slot to read the text from a file. | 2804 Public slot to read the text from a file. |
2674 | 2805 |
2675 @param fn filename to read from (string) | 2806 @param fn filename to read from (string) |
2676 @param createIt flag indicating the creation of a new file, if the | 2807 @keyparam createIt flag indicating the creation of a new file, if the |
2677 given one doesn't exist (boolean) | 2808 given one doesn't exist (boolean) |
2809 @keyparam encoding encoding to be used to read the file (string) | |
2810 (Note: this parameter overrides encoding detection) | |
2678 """ | 2811 """ |
2679 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) | 2812 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
2680 | 2813 |
2681 try: | 2814 try: |
2682 if createIt and not os.path.exists(fn): | 2815 if createIt and not os.path.exists(fn): |
2683 f = open(fn, "w") | 2816 f = open(fn, "w") |
2684 f.close() | 2817 f.close() |
2685 txt, self.encoding = Utilities.readEncodedFile(fn) | 2818 if encoding: |
2819 txt, self.encoding = Utilities.readEncodedFileWithEncoding( | |
2820 fn, encoding) | |
2821 else: | |
2822 txt, self.encoding = Utilities.readEncodedFile(fn) | |
2686 except (UnicodeDecodeError, IOError) as why: | 2823 except (UnicodeDecodeError, IOError) as why: |
2687 QApplication.restoreOverrideCursor() | 2824 QApplication.restoreOverrideCursor() |
2688 E5MessageBox.critical( | 2825 E5MessageBox.critical( |
2689 self.vm, | 2826 self.vm, |
2690 self.trUtf8('Open File'), | 2827 self.tr('Open File'), |
2691 self.trUtf8('<p>The file <b>{0}</b> could not be opened.</p>' | 2828 self.tr('<p>The file <b>{0}</b> could not be opened.</p>' |
2692 '<p>Reason: {1}</p>') | 2829 '<p>Reason: {1}</p>') |
2693 .format(fn, str(why))) | 2830 .format(fn, str(why))) |
2694 QApplication.restoreOverrideCursor() | 2831 QApplication.restoreOverrideCursor() |
2695 raise | 2832 raise |
2696 fileEol = self.detectEolString(txt) | 2833 fileEol = self.detectEolString(txt) |
2697 | 2834 |
2788 os.chmod(fn, permissions) | 2925 os.chmod(fn, permissions) |
2789 return True | 2926 return True |
2790 except (IOError, Utilities.CodingError, UnicodeError) as why: | 2927 except (IOError, Utilities.CodingError, UnicodeError) as why: |
2791 E5MessageBox.critical( | 2928 E5MessageBox.critical( |
2792 self, | 2929 self, |
2793 self.trUtf8('Save File'), | 2930 self.tr('Save File'), |
2794 self.trUtf8('<p>The file <b>{0}</b> could not be saved.<br/>' | 2931 self.tr('<p>The file <b>{0}</b> could not be saved.<br/>' |
2795 'Reason: {1}</p>') | 2932 'Reason: {1}</p>') |
2796 .format(fn, str(why))) | 2933 .format(fn, str(why))) |
2797 return False | 2934 return False |
2798 | 2935 |
2799 def saveFile(self, saveas=False, path=None): | 2936 def saveFile(self, saveas=False, path=None): |
2800 """ | 2937 """ |
2837 defaultFilter = Preferences.getEditor("DefaultSaveFilter") | 2974 defaultFilter = Preferences.getEditor("DefaultSaveFilter") |
2838 else: | 2975 else: |
2839 defaultFilter = Preferences.getEditor("DefaultSaveFilter") | 2976 defaultFilter = Preferences.getEditor("DefaultSaveFilter") |
2840 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( | 2977 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
2841 self, | 2978 self, |
2842 self.trUtf8("Save File"), | 2979 self.tr("Save File"), |
2843 path, | 2980 path, |
2844 Lexers.getSaveFileFiltersList(True, True), | 2981 Lexers.getSaveFileFiltersList(True, True), |
2845 defaultFilter, | 2982 defaultFilter, |
2846 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) | 2983 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
2847 | 2984 |
2855 if ex: | 2992 if ex: |
2856 fn += ex | 2993 fn += ex |
2857 if QFileInfo(fn).exists(): | 2994 if QFileInfo(fn).exists(): |
2858 res = E5MessageBox.yesNo( | 2995 res = E5MessageBox.yesNo( |
2859 self, | 2996 self, |
2860 self.trUtf8("Save File"), | 2997 self.tr("Save File"), |
2861 self.trUtf8("<p>The file <b>{0}</b> already exists." | 2998 self.tr("<p>The file <b>{0}</b> already exists." |
2862 " Overwrite it?</p>").format(fn), | 2999 " Overwrite it?</p>").format(fn), |
2863 icon=E5MessageBox.Warning) | 3000 icon=E5MessageBox.Warning) |
2864 if not res: | 3001 if not res: |
2865 return False | 3002 return False |
2866 fn = Utilities.toNativeSeparators(fn) | 3003 fn = Utilities.toNativeSeparators(fn) |
2867 newName = fn | 3004 newName = fn |
3699 """ | 3836 """ |
3700 Public method to go to the next Python method or class definition. | 3837 Public method to go to the next Python method or class definition. |
3701 | 3838 |
3702 @param goUp flag indicating the move direction (boolean) | 3839 @param goUp flag indicating the move direction (boolean) |
3703 """ | 3840 """ |
3704 if self.getPyVersion() or self.isRubyFile(): | 3841 if self.isPyFile() or self.isRubyFile(): |
3705 lineNo = self.getCursorPosition()[0] | 3842 lineNo = self.getCursorPosition()[0] |
3706 line = self.text(lineNo) | 3843 line = self.text(lineNo) |
3707 if line.strip().startswith(("class ", "def ", "module ")): | 3844 if line.strip().startswith(("class ", "def ", "module ")): |
3708 if goUp: | 3845 if goUp: |
3709 lineNo -= 1 | 3846 lineNo -= 1 |
3825 self.markerDefine(self.__createChangeMarkerPixmap( | 3962 self.markerDefine(self.__createChangeMarkerPixmap( |
3826 "OnlineChangeTraceMarkerSaved"), self.__changeMarkerSaved) | 3963 "OnlineChangeTraceMarkerSaved"), self.__changeMarkerSaved) |
3827 | 3964 |
3828 # refresh the annotations display | 3965 # refresh the annotations display |
3829 self.__refreshAnnotations() | 3966 self.__refreshAnnotations() |
3967 | |
3968 self.__markerMap.initColors() | |
3830 | 3969 |
3831 def __setLineMarkerColours(self): | 3970 def __setLineMarkerColours(self): |
3832 """ | 3971 """ |
3833 Private method to set the line marker colours. | 3972 Private method to set the line marker colours. |
3834 """ | 3973 """ |
4062 self.setColor(Preferences.getEditorColour("EditAreaForeground")) | 4201 self.setColor(Preferences.getEditorColour("EditAreaForeground")) |
4063 self.setPaper(Preferences.getEditorColour("EditAreaBackground")) | 4202 self.setPaper(Preferences.getEditorColour("EditAreaBackground")) |
4064 | 4203 |
4065 self.setVirtualSpaceOptions( | 4204 self.setVirtualSpaceOptions( |
4066 Preferences.getEditor("VirtualSpaceOptions")) | 4205 Preferences.getEditor("VirtualSpaceOptions")) |
4206 | |
4207 self.__markerMap.setEnabled(True) | |
4067 | 4208 |
4068 def __setEolMode(self): | 4209 def __setEolMode(self): |
4069 """ | 4210 """ |
4070 Private method to configure the eol mode of the editor. | 4211 Private method to configure the eol mode of the editor. |
4071 """ | 4212 """ |
4162 elif acs == QsciScintilla.AcsAll: | 4303 elif acs == QsciScintilla.AcsAll: |
4163 self.autoCompleteFromAll() | 4304 self.autoCompleteFromAll() |
4164 else: | 4305 else: |
4165 E5MessageBox.information( | 4306 E5MessageBox.information( |
4166 self, | 4307 self, |
4167 self.trUtf8("Autocompletion"), | 4308 self.tr("Autocompletion"), |
4168 self.trUtf8( | 4309 self.tr( |
4169 """Autocompletion is not available because""" | 4310 """Autocompletion is not available because""" |
4170 """ there is no autocompletion source set.""")) | 4311 """ there is no autocompletion source set.""")) |
4171 | 4312 |
4172 def setAutoCompletionEnabled(self, enable): | 4313 def setAutoCompletionEnabled(self, enable): |
4173 """ | 4314 """ |
4263 """ | 4404 """ |
4264 if self.__acHookFunction is not None: | 4405 if self.__acHookFunction is not None: |
4265 # there is another provider registered already | 4406 # there is another provider registered already |
4266 E5MessageBox.warning( | 4407 E5MessageBox.warning( |
4267 self, | 4408 self, |
4268 self.trUtf8("Activating Auto-Completion Provider"), | 4409 self.tr("Activating Auto-Completion Provider"), |
4269 self.trUtf8("""Auto-completion provider cannot be connected""" | 4410 self.tr("""Auto-completion provider cannot be connected""" |
4270 """ because there is already another one active.""" | 4411 """ because there is already another one active.""" |
4271 """ Please check your configuration.""")) | 4412 """ Please check your configuration.""")) |
4272 return | 4413 return |
4273 | 4414 |
4274 if self.autoCompletionThreshold() > 0: | 4415 if self.autoCompletionThreshold() > 0: |
4275 self.setAutoCompletionThreshold(0) | 4416 self.setAutoCompletionThreshold(0) |
4276 self.__acHookFunction = func | 4417 self.__acHookFunction = func |
4347 depth += 1 | 4488 depth += 1 |
4348 elif ch == '(': | 4489 elif ch == '(': |
4349 depth -= 1 | 4490 depth -= 1 |
4350 if depth == 0: | 4491 if depth == 0: |
4351 break | 4492 break |
4352 ch, pos = self.__getCharacter(pos) | 4493 ch, pos = self.__getCharacter(pos) |
4353 elif ch == '(': | 4494 elif ch == '(': |
4354 found = True | 4495 found = True |
4355 break | 4496 break |
4356 | 4497 |
4357 ch, pos = self.__getCharacter(pos) | 4498 ch, pos = self.__getCharacter(pos) |
4453 """ | 4594 """ |
4454 if self.__ctHookFunction is not None: | 4595 if self.__ctHookFunction is not None: |
4455 # there is another provider registered already | 4596 # there is another provider registered already |
4456 E5MessageBox.warning( | 4597 E5MessageBox.warning( |
4457 self, | 4598 self, |
4458 self.trUtf8("Activating Calltip Provider"), | 4599 self.tr("Activating Calltip Provider"), |
4459 self.trUtf8("""Calltip provider cannot be connected""" | 4600 self.tr("""Calltip provider cannot be connected""" |
4460 """ because there is already another one active.""" | 4601 """ because there is already another one active.""" |
4461 """ Please check your configuration.""")) | 4602 """ Please check your configuration.""")) |
4462 return | 4603 return |
4463 | 4604 |
4464 self.__ctHookFunction = func | 4605 self.__ctHookFunction = func |
4465 | 4606 |
4466 def unsetCallTipHook(self): | 4607 def unsetCallTipHook(self): |
4525 | 4666 |
4526 def __showContextMenu(self): | 4667 def __showContextMenu(self): |
4527 """ | 4668 """ |
4528 Private slot handling the aboutToShow signal of the context menu. | 4669 Private slot handling the aboutToShow signal of the context menu. |
4529 """ | 4670 """ |
4671 self.menuActs["Reopen"].setEnabled( | |
4672 not self.isModified() and bool(self.fileName)) | |
4530 self.menuActs["Save"].setEnabled(self.isModified()) | 4673 self.menuActs["Save"].setEnabled(self.isModified()) |
4531 self.menuActs["Undo"].setEnabled(self.isUndoAvailable()) | 4674 self.menuActs["Undo"].setEnabled(self.isUndoAvailable()) |
4532 self.menuActs["Redo"].setEnabled(self.isRedoAvailable()) | 4675 self.menuActs["Redo"].setEnabled(self.isRedoAvailable()) |
4533 self.menuActs["Revert"].setEnabled(self.isModified()) | 4676 self.menuActs["Revert"].setEnabled(self.isModified()) |
4534 if not self.miniMenu: | 4677 if not self.miniMenu: |
4535 self.menuActs["Cut"].setEnabled(self.hasSelectedText()) | 4678 self.menuActs["Cut"].setEnabled(self.hasSelectedText()) |
4536 self.menuActs["Copy"].setEnabled(self.hasSelectedText()) | 4679 self.menuActs["Copy"].setEnabled(self.hasSelectedText()) |
4537 if not self.isResourcesFile: | 4680 if not self.isResourcesFile: |
4538 if self.fileName and self.getPyVersion(): | 4681 if self.fileName and self.isPyFile(): |
4539 self.menuActs["Show"].setEnabled(True) | 4682 self.menuActs["Show"].setEnabled(True) |
4540 else: | 4683 else: |
4541 self.menuActs["Show"].setEnabled(False) | 4684 self.menuActs["Show"].setEnabled(False) |
4542 if self.fileName and \ | 4685 if self.fileName and \ |
4543 (self.getPyVersion() or self.isRubyFile()): | 4686 (self.isPyFile() or self.isRubyFile()): |
4544 self.menuActs["Diagrams"].setEnabled(True) | 4687 self.menuActs["Diagrams"].setEnabled(True) |
4545 else: | 4688 else: |
4546 self.menuActs["Diagrams"].setEnabled(False) | 4689 self.menuActs["Diagrams"].setEnabled(False) |
4547 if not self.miniMenu: | 4690 if not self.miniMenu: |
4548 if self.lexer_ is not None: | 4691 if self.lexer_ is not None: |
4590 self.menuActs["NewSplit"].setIcon( | 4733 self.menuActs["NewSplit"].setIcon( |
4591 UI.PixmapCache.getIcon("splitVertical.png")) | 4734 UI.PixmapCache.getIcon("splitVertical.png")) |
4592 | 4735 |
4593 self.menuActs["Tools"].setEnabled(not self.toolsMenu.isEmpty()) | 4736 self.menuActs["Tools"].setEnabled(not self.toolsMenu.isEmpty()) |
4594 | 4737 |
4595 self.showMenu.emit("Main", self.menu, self) | 4738 self.showMenu.emit("Main", self.menu, self) |
4596 | 4739 |
4597 def __showContextMenuAutocompletion(self): | 4740 def __showContextMenuAutocompletion(self): |
4598 """ | 4741 """ |
4599 Private slot called before the autocompletion menu is shown. | 4742 Private slot called before the autocompletion menu is shown. |
4600 """ | 4743 """ |
4602 self.acAPI or self.__acHookFunction is not None) | 4745 self.acAPI or self.__acHookFunction is not None) |
4603 self.menuActs["acAPI"].setEnabled(self.acAPI) | 4746 self.menuActs["acAPI"].setEnabled(self.acAPI) |
4604 self.menuActs["acAPIDocument"].setEnabled(self.acAPI) | 4747 self.menuActs["acAPIDocument"].setEnabled(self.acAPI) |
4605 self.menuActs["calltip"].setEnabled(self.acAPI) | 4748 self.menuActs["calltip"].setEnabled(self.acAPI) |
4606 | 4749 |
4607 self.showMenu.emit("Autocompletion", self.autocompletionMenu, self) | 4750 self.showMenu.emit("Autocompletion", self.autocompletionMenu, self) |
4608 | 4751 |
4609 def __showContextMenuShow(self): | 4752 def __showContextMenuShow(self): |
4610 """ | 4753 """ |
4611 Private slot called before the show menu is shown. | 4754 Private slot called before the show menu is shown. |
4612 """ | 4755 """ |
4654 self.coverageShowAnnotationMenuAct.setEnabled( | 4797 self.coverageShowAnnotationMenuAct.setEnabled( |
4655 coEnable and len(self.notcoveredMarkers) == 0) | 4798 coEnable and len(self.notcoveredMarkers) == 0) |
4656 self.coverageHideAnnotationMenuAct.setEnabled( | 4799 self.coverageHideAnnotationMenuAct.setEnabled( |
4657 len(self.notcoveredMarkers) > 0) | 4800 len(self.notcoveredMarkers) > 0) |
4658 | 4801 |
4659 self.showMenu.emit("Show", self.menuShow, self) | 4802 self.showMenu.emit("Show", self.menuShow, self) |
4660 | 4803 |
4661 def __showContextMenuGraphics(self): | 4804 def __showContextMenuGraphics(self): |
4662 """ | 4805 """ |
4663 Private slot handling the aboutToShow signal of the diagrams context | 4806 Private slot handling the aboutToShow signal of the diagrams context |
4664 menu. | 4807 menu. |
4667 self.project.isProjectSource(self.fileName): | 4810 self.project.isProjectSource(self.fileName): |
4668 self.applicationDiagramMenuAct.setEnabled(True) | 4811 self.applicationDiagramMenuAct.setEnabled(True) |
4669 else: | 4812 else: |
4670 self.applicationDiagramMenuAct.setEnabled(False) | 4813 self.applicationDiagramMenuAct.setEnabled(False) |
4671 | 4814 |
4672 self.showMenu.emit("Graphics", self.graphicsMenu, self) | 4815 self.showMenu.emit("Graphics", self.graphicsMenu, self) |
4673 | 4816 |
4674 def __showContextMenuMargin(self): | 4817 def __showContextMenuMargin(self): |
4675 """ | 4818 """ |
4676 Private slot handling the aboutToShow signal of the margins context | 4819 Private slot handling the aboutToShow signal of the margins context |
4677 menu. | 4820 menu. |
4678 """ | 4821 """ |
4679 if self.fileName and (self.getPyVersion() or self.isRubyFile()): | 4822 if self.fileName and (self.isPyFile() or self.isRubyFile()): |
4680 self.marginMenuActs["Breakpoint"].setEnabled(True) | 4823 self.marginMenuActs["Breakpoint"].setEnabled(True) |
4681 self.marginMenuActs["TempBreakpoint"].setEnabled(True) | 4824 self.marginMenuActs["TempBreakpoint"].setEnabled(True) |
4682 if self.markersAtLine(self.line) & self.breakpointMask: | 4825 if self.markersAtLine(self.line) & self.breakpointMask: |
4683 self.marginMenuActs["EditBreakpoint"].setEnabled(True) | 4826 self.marginMenuActs["EditBreakpoint"].setEnabled(True) |
4684 self.marginMenuActs["EnableBreakpoint"].setEnabled(True) | 4827 self.marginMenuActs["EnableBreakpoint"].setEnabled(True) |
4685 else: | 4828 else: |
4686 self.marginMenuActs["EditBreakpoint"].setEnabled(False) | 4829 self.marginMenuActs["EditBreakpoint"].setEnabled(False) |
4687 self.marginMenuActs["EnableBreakpoint"].setEnabled(False) | 4830 self.marginMenuActs["EnableBreakpoint"].setEnabled(False) |
4688 if self.markersAtLine(self.line) & (1 << self.dbreakpoint): | 4831 if self.markersAtLine(self.line) & (1 << self.dbreakpoint): |
4689 self.marginMenuActs["EnableBreakpoint"].setText( | 4832 self.marginMenuActs["EnableBreakpoint"].setText( |
4690 self.trUtf8('Enable breakpoint')) | 4833 self.tr('Enable breakpoint')) |
4691 else: | 4834 else: |
4692 self.marginMenuActs["EnableBreakpoint"].setText( | 4835 self.marginMenuActs["EnableBreakpoint"].setText( |
4693 self.trUtf8('Disable breakpoint')) | 4836 self.tr('Disable breakpoint')) |
4694 if self.breaks: | 4837 if self.breaks: |
4695 self.marginMenuActs["NextBreakpoint"].setEnabled(True) | 4838 self.marginMenuActs["NextBreakpoint"].setEnabled(True) |
4696 self.marginMenuActs["PreviousBreakpoint"].setEnabled(True) | 4839 self.marginMenuActs["PreviousBreakpoint"].setEnabled(True) |
4697 self.marginMenuActs["ClearBreakpoint"].setEnabled(True) | 4840 self.marginMenuActs["ClearBreakpoint"].setEnabled(True) |
4698 else: | 4841 else: |
4762 self.marginMenuActs["NextChangeMarker"].setEnabled(True) | 4905 self.marginMenuActs["NextChangeMarker"].setEnabled(True) |
4763 else: | 4906 else: |
4764 self.marginMenuActs["PreviousChangeMarker"].setEnabled(False) | 4907 self.marginMenuActs["PreviousChangeMarker"].setEnabled(False) |
4765 self.marginMenuActs["NextChangeMarker"].setEnabled(False) | 4908 self.marginMenuActs["NextChangeMarker"].setEnabled(False) |
4766 | 4909 |
4767 self.showMenu.emit("Margin", self.sender(), self) | 4910 self.showMenu.emit("Margin", self.sender(), self) |
4768 | 4911 |
4769 def __showContextMenuChecks(self): | 4912 def __showContextMenuChecks(self): |
4770 """ | 4913 """ |
4771 Private slot handling the aboutToShow signal of the checks context | 4914 Private slot handling the aboutToShow signal of the checks context |
4772 menu. | 4915 menu. |
4773 """ | 4916 """ |
4774 self.showMenu.emit("Checks", self.checksMenu, self) | 4917 self.showMenu.emit("Checks", self.checksMenu, self) |
4775 | 4918 |
4776 def __showContextMenuTools(self): | 4919 def __showContextMenuTools(self): |
4777 """ | 4920 """ |
4778 Private slot handling the aboutToShow signal of the tools context | 4921 Private slot handling the aboutToShow signal of the tools context |
4779 menu. | 4922 menu. |
4780 """ | 4923 """ |
4781 self.showMenu.emit("Tools", self.toolsMenu, self) | 4924 self.showMenu.emit("Tools", self.toolsMenu, self) |
4925 | |
4926 def __reopenWithEncodingMenuTriggered(self, act): | |
4927 """ | |
4928 Private method to handle the rereading of the file with a selected | |
4929 encoding. | |
4930 | |
4931 @param act reference to the action that was triggered (QAction) | |
4932 """ | |
4933 encoding = act.data() | |
4934 self.readFile(self.fileName, encoding=encoding) | |
4782 | 4935 |
4783 def __contextSave(self): | 4936 def __contextSave(self): |
4784 """ | 4937 """ |
4785 Private slot handling the save context menu entry. | 4938 Private slot handling the save context menu entry. |
4786 """ | 4939 """ |
5023 | 5176 |
5024 if files: | 5177 if files: |
5025 if len(files) > 1: | 5178 if len(files) > 1: |
5026 fn, ok = QInputDialog.getItem( | 5179 fn, ok = QInputDialog.getItem( |
5027 self, | 5180 self, |
5028 self.trUtf8("Code Coverage"), | 5181 self.tr("Code Coverage"), |
5029 self.trUtf8("Please select a coverage file"), | 5182 self.tr("Please select a coverage file"), |
5030 files, | 5183 files, |
5031 0, False) | 5184 0, False) |
5032 if not ok: | 5185 if not ok: |
5033 return | 5186 return |
5034 else: | 5187 else: |
5074 missing = cover.analysis2(self.fileName)[3] | 5227 missing = cover.analysis2(self.fileName)[3] |
5075 if missing: | 5228 if missing: |
5076 for line in missing: | 5229 for line in missing: |
5077 handle = self.markerAdd(line - 1, self.notcovered) | 5230 handle = self.markerAdd(line - 1, self.notcovered) |
5078 self.notcoveredMarkers.append(handle) | 5231 self.notcoveredMarkers.append(handle) |
5079 self.coverageMarkersShown.emit(True) | 5232 self.coverageMarkersShown.emit(True) |
5233 self.__markerMap.update() | |
5080 else: | 5234 else: |
5081 if not silent: | 5235 if not silent: |
5082 E5MessageBox.information( | 5236 E5MessageBox.information( |
5083 self, | 5237 self, |
5084 self.trUtf8("Show Code Coverage Annotations"), | 5238 self.tr("Show Code Coverage Annotations"), |
5085 self.trUtf8("""All lines have been covered.""")) | 5239 self.tr("""All lines have been covered.""")) |
5086 self.showingNotcoveredMarkers = True | 5240 self.showingNotcoveredMarkers = True |
5087 else: | 5241 else: |
5088 if not silent: | 5242 if not silent: |
5089 E5MessageBox.warning( | 5243 E5MessageBox.warning( |
5090 self, | 5244 self, |
5091 self.trUtf8("Show Code Coverage Annotations"), | 5245 self.tr("Show Code Coverage Annotations"), |
5092 self.trUtf8("""There is no coverage file available.""")) | 5246 self.tr("""There is no coverage file available.""")) |
5093 | 5247 |
5094 def __codeCoverageHideAnnotations(self): | 5248 def __codeCoverageHideAnnotations(self): |
5095 """ | 5249 """ |
5096 Private method to handle the hide code coverage annotations context | 5250 Private method to handle the hide code coverage annotations context |
5097 menu action. | 5251 menu action. |
5099 for handle in self.notcoveredMarkers: | 5253 for handle in self.notcoveredMarkers: |
5100 self.markerDeleteHandle(handle) | 5254 self.markerDeleteHandle(handle) |
5101 self.notcoveredMarkers = [] | 5255 self.notcoveredMarkers = [] |
5102 self.coverageMarkersShown.emit(False) | 5256 self.coverageMarkersShown.emit(False) |
5103 self.showingNotcoveredMarkers = False | 5257 self.showingNotcoveredMarkers = False |
5258 self.__markerMap.update() | |
5259 | |
5260 def getCoverageLines(self): | |
5261 """ | |
5262 Public method to get the lines containing a coverage marker. | |
5263 | |
5264 @return list of lines containing a coverage marker (list of integer) | |
5265 """ | |
5266 lines = [] | |
5267 line = -1 | |
5268 while True: | |
5269 line = self.markerFindNext(line + 1, 1 << self.notcovered) | |
5270 if line < 0: | |
5271 break | |
5272 else: | |
5273 lines.append(line) | |
5274 return lines | |
5104 | 5275 |
5105 def hasCoverageMarkers(self): | 5276 def hasCoverageMarkers(self): |
5106 """ | 5277 """ |
5107 Public method to test, if there are coverage markers. | 5278 Public method to test, if there are coverage markers. |
5108 | 5279 |
5184 | 5355 |
5185 if files: | 5356 if files: |
5186 if len(files) > 1: | 5357 if len(files) > 1: |
5187 fn, ok = QInputDialog.getItem( | 5358 fn, ok = QInputDialog.getItem( |
5188 self, | 5359 self, |
5189 self.trUtf8("Profile Data"), | 5360 self.tr("Profile Data"), |
5190 self.trUtf8("Please select a profile file"), | 5361 self.tr("Please select a profile file"), |
5191 files, | 5362 files, |
5192 0, False) | 5363 0, False) |
5193 if not ok: | 5364 if not ok: |
5194 return | 5365 return |
5195 else: | 5366 else: |
5238 line = 1 | 5409 line = 1 |
5239 # hack to show a syntax error marker, if line is reported to be 0 | 5410 # hack to show a syntax error marker, if line is reported to be 0 |
5240 if error: | 5411 if error: |
5241 # set a new syntax error marker | 5412 # set a new syntax error marker |
5242 markers = self.markersAtLine(line - 1) | 5413 markers = self.markersAtLine(line - 1) |
5414 index += self.indentation(line - 1) | |
5243 if not (markers & (1 << self.syntaxerror)): | 5415 if not (markers & (1 << self.syntaxerror)): |
5244 handle = self.markerAdd(line - 1, self.syntaxerror) | 5416 handle = self.markerAdd(line - 1, self.syntaxerror) |
5245 index += self.indentation(line - 1) | |
5246 self.syntaxerrors[handle] = [(msg, index)] | 5417 self.syntaxerrors[handle] = [(msg, index)] |
5247 self.syntaxerrorToggled.emit(self) | 5418 self.syntaxerrorToggled.emit(self) |
5248 else: | 5419 else: |
5249 for handle in list(self.syntaxerrors.keys()): | 5420 for handle in list(self.syntaxerrors.keys()): |
5250 if self.markerLine(handle) == line - 1 and \ | 5421 if self.markerLine(handle) == line - 1 and \ |
5259 del self.syntaxerrors[handle] | 5430 del self.syntaxerrors[handle] |
5260 self.markerDeleteHandle(handle) | 5431 self.markerDeleteHandle(handle) |
5261 self.syntaxerrorToggled.emit(self) | 5432 self.syntaxerrorToggled.emit(self) |
5262 | 5433 |
5263 self.__setAnnotation(line - 1) | 5434 self.__setAnnotation(line - 1) |
5435 self.__markerMap.update() | |
5264 | 5436 |
5265 def getSyntaxErrors(self): | 5437 def getSyntaxErrors(self): |
5266 """ | 5438 """ |
5267 Public method to retrieve the syntax error markers. | 5439 Public method to retrieve the syntax error markers. |
5268 | 5440 |
5273 for handle in list(self.syntaxerrors.keys()): | 5445 for handle in list(self.syntaxerrors.keys()): |
5274 selist.append(self.markerLine(handle) + 1) | 5446 selist.append(self.markerLine(handle) + 1) |
5275 | 5447 |
5276 selist.sort() | 5448 selist.sort() |
5277 return selist | 5449 return selist |
5450 | |
5451 def getSyntaxErrorLines(self): | |
5452 """ | |
5453 Public method to get the lines containing a syntax error. | |
5454 | |
5455 @return list of lines containing a syntax error (list of integer) | |
5456 """ | |
5457 lines = [] | |
5458 line = -1 | |
5459 while True: | |
5460 line = self.markerFindNext(line + 1, 1 << self.syntaxerror) | |
5461 if line < 0: | |
5462 break | |
5463 else: | |
5464 lines.append(line) | |
5465 return lines | |
5278 | 5466 |
5279 def hasSyntaxErrors(self): | 5467 def hasSyntaxErrors(self): |
5280 """ | 5468 """ |
5281 Public method to check for the presence of syntax errors. | 5469 Public method to check for the presence of syntax errors. |
5282 | 5470 |
5321 for handle in list(self.syntaxerrors.keys()): | 5509 for handle in list(self.syntaxerrors.keys()): |
5322 if self.markerLine(handle) == line: | 5510 if self.markerLine(handle) == line: |
5323 errors = [e[0] for e in self.syntaxerrors[handle]] | 5511 errors = [e[0] for e in self.syntaxerrors[handle]] |
5324 E5MessageBox.critical( | 5512 E5MessageBox.critical( |
5325 self, | 5513 self, |
5326 self.trUtf8("Syntax Error"), | 5514 self.tr("Syntax Error"), |
5327 "\n".join(errors)) | 5515 "\n".join(errors)) |
5328 break | 5516 break |
5329 else: | 5517 else: |
5330 E5MessageBox.critical( | 5518 E5MessageBox.critical( |
5331 self, | 5519 self, |
5332 self.trUtf8("Syntax Error"), | 5520 self.tr("Syntax Error"), |
5333 self.trUtf8("No syntax error message available.")) | 5521 self.tr("No syntax error message available.")) |
5334 | 5522 |
5335 ########################################################################### | 5523 ########################################################################### |
5336 ## Warning handling methods below | 5524 ## Warning handling methods below |
5337 ########################################################################### | 5525 ########################################################################### |
5338 | 5526 |
5372 del self.warnings[handle] | 5560 del self.warnings[handle] |
5373 self.markerDeleteHandle(handle) | 5561 self.markerDeleteHandle(handle) |
5374 self.syntaxerrorToggled.emit(self) | 5562 self.syntaxerrorToggled.emit(self) |
5375 | 5563 |
5376 self.__setAnnotation(line - 1) | 5564 self.__setAnnotation(line - 1) |
5565 self.__markerMap.update() | |
5377 | 5566 |
5378 def getWarnings(self): | 5567 def getWarnings(self): |
5379 """ | 5568 """ |
5380 Public method to retrieve the warning markers. | 5569 Public method to retrieve the warning markers. |
5381 | 5570 |
5387 fwlist.append(self.markerLine(handle) + 1) | 5576 fwlist.append(self.markerLine(handle) + 1) |
5388 | 5577 |
5389 fwlist.sort() | 5578 fwlist.sort() |
5390 return fwlist | 5579 return fwlist |
5391 | 5580 |
5581 def getWarningLines(self): | |
5582 """ | |
5583 Public method to get the lines containing a warning. | |
5584 | |
5585 @return list of lines containing a warning (list of integer) | |
5586 """ | |
5587 lines = [] | |
5588 line = -1 | |
5589 while True: | |
5590 line = self.markerFindNext(line + 1, 1 << self.warning) | |
5591 if line < 0: | |
5592 break | |
5593 else: | |
5594 lines.append(line) | |
5595 return lines | |
5596 | |
5392 def hasWarnings(self): | 5597 def hasWarnings(self): |
5393 """ | 5598 """ |
5394 Public method to check for the presence of warnings. | 5599 Public method to check for the presence of warnings. |
5395 | 5600 |
5396 @return flag indicating the presence of warnings (boolean) | 5601 @return flag indicating the presence of warnings (boolean) |
5467 else: | 5672 else: |
5468 del self.warnings[handle] | 5673 del self.warnings[handle] |
5469 self.__setAnnotation(self.markerLine(handle)) | 5674 self.__setAnnotation(self.markerLine(handle)) |
5470 self.markerDeleteHandle(handle) | 5675 self.markerDeleteHandle(handle) |
5471 self.syntaxerrorToggled.emit(self) | 5676 self.syntaxerrorToggled.emit(self) |
5677 self.__markerMap.update() | |
5472 | 5678 |
5473 def clearWarnings(self): | 5679 def clearWarnings(self): |
5474 """ | 5680 """ |
5475 Public slot to clear all warnings. | 5681 Public slot to clear all warnings. |
5476 """ | 5682 """ |
5478 self.warnings[handle] = [] | 5684 self.warnings[handle] = [] |
5479 self.__setAnnotation(self.markerLine(handle)) | 5685 self.__setAnnotation(self.markerLine(handle)) |
5480 self.markerDeleteHandle(handle) | 5686 self.markerDeleteHandle(handle) |
5481 self.warnings = {} | 5687 self.warnings = {} |
5482 self.syntaxerrorToggled.emit(self) | 5688 self.syntaxerrorToggled.emit(self) |
5689 self.__markerMap.update() | |
5483 | 5690 |
5484 def __showWarning(self, line=-1): | 5691 def __showWarning(self, line=-1): |
5485 """ | 5692 """ |
5486 Private slot to handle the 'Show warning' context menu action. | 5693 Private slot to handle the 'Show warning' context menu action. |
5487 | 5694 |
5492 | 5699 |
5493 for handle in list(self.warnings.keys()): | 5700 for handle in list(self.warnings.keys()): |
5494 if self.markerLine(handle) == line: | 5701 if self.markerLine(handle) == line: |
5495 E5MessageBox.warning( | 5702 E5MessageBox.warning( |
5496 self, | 5703 self, |
5497 self.trUtf8("Warning"), | 5704 self.tr("Warning"), |
5498 '\n'.join([w[0] for w in self.warnings[handle]])) | 5705 '\n'.join([w[0] for w in self.warnings[handle]])) |
5499 break | 5706 break |
5500 else: | 5707 else: |
5501 E5MessageBox.warning( | 5708 E5MessageBox.warning( |
5502 self, | 5709 self, |
5503 self.trUtf8("Warning"), | 5710 self.tr("Warning"), |
5504 self.trUtf8("No warning messages available.")) | 5711 self.tr("No warning messages available.")) |
5505 | 5712 |
5506 ########################################################################### | 5713 ########################################################################### |
5507 ## Annotation handling methods below | 5714 ## Annotation handling methods below |
5508 ########################################################################### | 5715 ########################################################################### |
5509 | 5716 |
5558 for handle in self.warnings.keys(): | 5765 for handle in self.warnings.keys(): |
5559 if self.markerLine(handle) == line: | 5766 if self.markerLine(handle) == line: |
5560 for msg, warningType in self.warnings[handle]: | 5767 for msg, warningType in self.warnings[handle]: |
5561 if warningType == self.WarningStyle: | 5768 if warningType == self.WarningStyle: |
5562 styleAnnotations.append( | 5769 styleAnnotations.append( |
5563 self.trUtf8("Style: {0}").format(msg)) | 5770 self.tr("Style: {0}").format(msg)) |
5564 else: | 5771 else: |
5565 warningAnnotations.append( | 5772 warningAnnotations.append( |
5566 self.trUtf8("Warning: {0}").format(msg)) | 5773 self.tr("Warning: {0}").format(msg)) |
5567 | 5774 |
5568 # step 2: do syntax errors | 5775 # step 2: do syntax errors |
5569 for handle in self.syntaxerrors.keys(): | 5776 for handle in self.syntaxerrors.keys(): |
5570 if self.markerLine(handle) == line: | 5777 if self.markerLine(handle) == line: |
5571 for msg, _ in self.syntaxerrors[handle]: | 5778 for msg, _ in self.syntaxerrors[handle]: |
5572 errorAnnotations.append( | 5779 errorAnnotations.append( |
5573 self.trUtf8("Error: {0}").format(msg)) | 5780 self.tr("Error: {0}").format(msg)) |
5574 | 5781 |
5575 annotations = [] | 5782 annotations = [] |
5576 if styleAnnotations: | 5783 if styleAnnotations: |
5577 annotationStyleTxt = "\n".join(styleAnnotations) | 5784 annotationStyleTxt = "\n".join(styleAnnotations) |
5578 if warningAnnotations or errorAnnotations: | 5785 if warningAnnotations or errorAnnotations: |
5623 for s in list(self.macros.keys()): | 5830 for s in list(self.macros.keys()): |
5624 qs.append(s) | 5831 qs.append(s) |
5625 qs.sort() | 5832 qs.sort() |
5626 return QInputDialog.getItem( | 5833 return QInputDialog.getItem( |
5627 self, | 5834 self, |
5628 self.trUtf8("Macro Name"), | 5835 self.tr("Macro Name"), |
5629 self.trUtf8("Select a macro name:"), | 5836 self.tr("Select a macro name:"), |
5630 qs, | 5837 qs, |
5631 0, False) | 5838 0, False) |
5632 | 5839 |
5633 def macroRun(self): | 5840 def macroRun(self): |
5634 """ | 5841 """ |
5651 Public method to load a macro from a file. | 5858 Public method to load a macro from a file. |
5652 """ | 5859 """ |
5653 configDir = Utilities.getConfigDir() | 5860 configDir = Utilities.getConfigDir() |
5654 fname = E5FileDialog.getOpenFileName( | 5861 fname = E5FileDialog.getOpenFileName( |
5655 self, | 5862 self, |
5656 self.trUtf8("Load macro file"), | 5863 self.tr("Load macro file"), |
5657 configDir, | 5864 configDir, |
5658 self.trUtf8("Macro files (*.macro)")) | 5865 self.tr("Macro files (*.macro)")) |
5659 | 5866 |
5660 if not fname: | 5867 if not fname: |
5661 return # user aborted | 5868 return # user aborted |
5662 | 5869 |
5663 try: | 5870 try: |
5665 lines = f.readlines() | 5872 lines = f.readlines() |
5666 f.close() | 5873 f.close() |
5667 except IOError: | 5874 except IOError: |
5668 E5MessageBox.critical( | 5875 E5MessageBox.critical( |
5669 self, | 5876 self, |
5670 self.trUtf8("Error loading macro"), | 5877 self.tr("Error loading macro"), |
5671 self.trUtf8( | 5878 self.tr( |
5672 "<p>The macro file <b>{0}</b> could not be read.</p>") | 5879 "<p>The macro file <b>{0}</b> could not be read.</p>") |
5673 .format(fname)) | 5880 .format(fname)) |
5674 return | 5881 return |
5675 | 5882 |
5676 if len(lines) != 2: | 5883 if len(lines) != 2: |
5677 E5MessageBox.critical( | 5884 E5MessageBox.critical( |
5678 self, | 5885 self, |
5679 self.trUtf8("Error loading macro"), | 5886 self.tr("Error loading macro"), |
5680 self.trUtf8("<p>The macro file <b>{0}</b> is corrupt.</p>") | 5887 self.tr("<p>The macro file <b>{0}</b> is corrupt.</p>") |
5681 .format(fname)) | 5888 .format(fname)) |
5682 return | 5889 return |
5683 | 5890 |
5684 macro = QsciMacro(lines[1], self) | 5891 macro = QsciMacro(lines[1], self) |
5685 self.macros[lines[0].strip()] = macro | 5892 self.macros[lines[0].strip()] = macro |
5694 if not ok or not name: | 5901 if not ok or not name: |
5695 return # user abort | 5902 return # user abort |
5696 | 5903 |
5697 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( | 5904 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
5698 self, | 5905 self, |
5699 self.trUtf8("Save macro file"), | 5906 self.tr("Save macro file"), |
5700 configDir, | 5907 configDir, |
5701 self.trUtf8("Macro files (*.macro)"), | 5908 self.tr("Macro files (*.macro)"), |
5702 "", | 5909 "", |
5703 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) | 5910 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
5704 | 5911 |
5705 if not fname: | 5912 if not fname: |
5706 return # user aborted | 5913 return # user aborted |
5711 if ex: | 5918 if ex: |
5712 fname += ex | 5919 fname += ex |
5713 if QFileInfo(fname).exists(): | 5920 if QFileInfo(fname).exists(): |
5714 res = E5MessageBox.yesNo( | 5921 res = E5MessageBox.yesNo( |
5715 self, | 5922 self, |
5716 self.trUtf8("Save macro"), | 5923 self.tr("Save macro"), |
5717 self.trUtf8("<p>The macro file <b>{0}</b> already exists." | 5924 self.tr("<p>The macro file <b>{0}</b> already exists." |
5718 " Overwrite it?</p>").format(fname), | 5925 " Overwrite it?</p>").format(fname), |
5719 icon=E5MessageBox.Warning) | 5926 icon=E5MessageBox.Warning) |
5720 if not res: | 5927 if not res: |
5721 return | 5928 return |
5722 fname = Utilities.toNativeSeparators(fname) | 5929 fname = Utilities.toNativeSeparators(fname) |
5723 | 5930 |
5727 f.write(self.macros[name].save()) | 5934 f.write(self.macros[name].save()) |
5728 f.close() | 5935 f.close() |
5729 except IOError: | 5936 except IOError: |
5730 E5MessageBox.critical( | 5937 E5MessageBox.critical( |
5731 self, | 5938 self, |
5732 self.trUtf8("Error saving macro"), | 5939 self.tr("Error saving macro"), |
5733 self.trUtf8( | 5940 self.tr( |
5734 "<p>The macro file <b>{0}</b> could not be written.</p>") | 5941 "<p>The macro file <b>{0}</b> could not be written.</p>") |
5735 .format(fname)) | 5942 .format(fname)) |
5736 return | 5943 return |
5737 | 5944 |
5738 def macroRecordingStart(self): | 5945 def macroRecordingStart(self): |
5740 Public method to start macro recording. | 5947 Public method to start macro recording. |
5741 """ | 5948 """ |
5742 if self.recording: | 5949 if self.recording: |
5743 res = E5MessageBox.yesNo( | 5950 res = E5MessageBox.yesNo( |
5744 self, | 5951 self, |
5745 self.trUtf8("Start Macro Recording"), | 5952 self.tr("Start Macro Recording"), |
5746 self.trUtf8("Macro recording is already active. Start new?"), | 5953 self.tr("Macro recording is already active. Start new?"), |
5747 icon=E5MessageBox.Warning, | 5954 icon=E5MessageBox.Warning, |
5748 yesDefault=True) | 5955 yesDefault=True) |
5749 if res: | 5956 if res: |
5750 self.macroRecordingStop() | 5957 self.macroRecordingStop() |
5751 else: | 5958 else: |
5766 self.curMacro.endRecording() | 5973 self.curMacro.endRecording() |
5767 self.recording = False | 5974 self.recording = False |
5768 | 5975 |
5769 name, ok = QInputDialog.getText( | 5976 name, ok = QInputDialog.getText( |
5770 self, | 5977 self, |
5771 self.trUtf8("Macro Recording"), | 5978 self.tr("Macro Recording"), |
5772 self.trUtf8("Enter name of the macro:"), | 5979 self.tr("Enter name of the macro:"), |
5773 QLineEdit.Normal) | 5980 QLineEdit.Normal) |
5774 | 5981 |
5775 if ok and name: | 5982 if ok and name: |
5776 self.macros[name] = self.curMacro | 5983 self.macros[name] = self.curMacro |
5777 | 5984 |
5888 self.lastModified.toString(): | 6095 self.lastModified.toString(): |
5889 self.inReopenPrompt = True | 6096 self.inReopenPrompt = True |
5890 if Preferences.getEditor("AutoReopen") and not self.isModified(): | 6097 if Preferences.getEditor("AutoReopen") and not self.isModified(): |
5891 self.refresh() | 6098 self.refresh() |
5892 else: | 6099 else: |
5893 msg = self.trUtf8( | 6100 msg = self.tr( |
5894 """<p>The file <b>{0}</b> has been changed while it""" | 6101 """<p>The file <b>{0}</b> has been changed while it""" |
5895 """ was opened in eric5. Reread it?</p>""")\ | 6102 """ was opened in eric5. Reread it?</p>""")\ |
5896 .format(self.fileName) | 6103 .format(self.fileName) |
5897 yesDefault = True | 6104 yesDefault = True |
5898 if self.isModified(): | 6105 if self.isModified(): |
5899 msg += self.trUtf8( | 6106 msg += self.tr( |
5900 """<br><b>Warning:</b> You will lose""" | 6107 """<br><b>Warning:</b> You will lose""" |
5901 """ your changes upon reopening it.""") | 6108 """ your changes upon reopening it.""") |
5902 yesDefault = False | 6109 yesDefault = False |
5903 res = E5MessageBox.yesNo( | 6110 res = E5MessageBox.yesNo( |
5904 self, | 6111 self, |
5905 self.trUtf8("File changed"), msg, | 6112 self.tr("File changed"), msg, |
5906 icon=E5MessageBox.Warning, | 6113 icon=E5MessageBox.Warning, |
5907 yesDefault=yesDefault) | 6114 yesDefault=yesDefault) |
5908 if res: | 6115 if res: |
5909 self.refresh() | 6116 self.refresh() |
5910 else: | 6117 else: |
5944 if self.windowState() == Qt.WindowStates(Qt.WindowMinimized): | 6151 if self.windowState() == Qt.WindowStates(Qt.WindowMinimized): |
5945 cap = os.path.basename(self.fileName) | 6152 cap = os.path.basename(self.fileName) |
5946 else: | 6153 else: |
5947 cap = self.fileName | 6154 cap = self.fileName |
5948 if self.isReadOnly(): | 6155 if self.isReadOnly(): |
5949 cap = self.trUtf8("{0} (ro)").format(cap) | 6156 cap = self.tr("{0} (ro)").format(cap) |
5950 self.setWindowTitle(cap) | 6157 self.setWindowTitle(cap) |
5951 | 6158 |
5952 super(Editor, self).changeEvent(evt) | 6159 super(Editor, self).changeEvent(evt) |
5953 | 6160 |
5954 def mousePressEvent(self, event): | 6161 def mousePressEvent(self, event): |
6017 zoom = 20 | 6224 zoom = 20 |
6018 pinch.setScaleFactor(3.0) | 6225 pinch.setScaleFactor(3.0) |
6019 self.zoomTo(zoom) | 6226 self.zoomTo(zoom) |
6020 evt.accept() | 6227 evt.accept() |
6021 | 6228 |
6229 def resizeEvent(self, evt): | |
6230 """ | |
6231 Protected method handling resize events. | |
6232 | |
6233 @param evt reference to the resize event (QResizeEvent) | |
6234 """ | |
6235 super(Editor, self).resizeEvent(evt) | |
6236 self.__markerMap.calculateGeometry() | |
6237 | |
6238 def viewportEvent(self, evt): | |
6239 """ | |
6240 Protected method handling event of the viewport. | |
6241 | |
6242 @param evt reference to the event (QEvent) | |
6243 @return flag indiating that the event was handled (boolean) | |
6244 """ | |
6245 self.__markerMap.calculateGeometry() | |
6246 return super(Editor, self).viewportEvent(evt) | |
6247 | |
6022 def __updateReadOnly(self, bForce=True): | 6248 def __updateReadOnly(self, bForce=True): |
6023 """ | 6249 """ |
6024 Private method to update the readOnly information for this editor. | 6250 Private method to update the readOnly information for this editor. |
6025 | 6251 |
6026 If bForce is True, then updates everything regardless if | 6252 If bForce is True, then updates everything regardless if |
6037 self.isReadOnly() | 6263 self.isReadOnly() |
6038 if not bForce and (readOnly == self.isReadOnly()): | 6264 if not bForce and (readOnly == self.isReadOnly()): |
6039 return | 6265 return |
6040 cap = self.fileName | 6266 cap = self.fileName |
6041 if readOnly: | 6267 if readOnly: |
6042 cap = self.trUtf8("{0} (ro)".format(cap)) | 6268 cap = self.tr("{0} (ro)".format(cap)) |
6043 self.setReadOnly(readOnly) | 6269 self.setReadOnly(readOnly) |
6044 self.setWindowTitle(cap) | 6270 self.setWindowTitle(cap) |
6045 self.captionChanged.emit(cap, self) | 6271 self.captionChanged.emit(cap, self) |
6046 | 6272 |
6047 def refresh(self): | 6273 def refresh(self): |
6063 | 6289 |
6064 # clear breakpoint markers | 6290 # clear breakpoint markers |
6065 for handle in list(self.breaks.keys()): | 6291 for handle in list(self.breaks.keys()): |
6066 self.markerDeleteHandle(handle) | 6292 self.markerDeleteHandle(handle) |
6067 self.breaks = {} | 6293 self.breaks = {} |
6294 | |
6295 if not os.path.exists(self.fileName): | |
6296 # close the file, if it was deleted in the background | |
6297 self.close() | |
6298 return | |
6068 | 6299 |
6069 # reread the file | 6300 # reread the file |
6070 try: | 6301 try: |
6071 self.readFile(self.fileName) | 6302 self.readFile(self.fileName) |
6072 except IOError: | 6303 except IOError: |
6087 self.toggleBookmark(bm) | 6318 self.toggleBookmark(bm) |
6088 self.__restoreBreakpoints() | 6319 self.__restoreBreakpoints() |
6089 | 6320 |
6090 self.editorSaved.emit(self.fileName) | 6321 self.editorSaved.emit(self.fileName) |
6091 self.__autoSyntaxCheck() | 6322 self.__autoSyntaxCheck() |
6323 | |
6324 self.__markerMap.update() | |
6092 | 6325 |
6093 self.refreshed.emit() | 6326 self.refreshed.emit() |
6094 | 6327 |
6095 def setMonospaced(self, on): | 6328 def setMonospaced(self, on): |
6096 """ | 6329 """ |
6172 if not QFileInfo(fname).isDir(): | 6405 if not QFileInfo(fname).isDir(): |
6173 self.vm.openSourceFile(fname) | 6406 self.vm.openSourceFile(fname) |
6174 else: | 6407 else: |
6175 E5MessageBox.information( | 6408 E5MessageBox.information( |
6176 self, | 6409 self, |
6177 self.trUtf8("Drop Error"), | 6410 self.tr("Drop Error"), |
6178 self.trUtf8("""<p><b>{0}</b> is not a file.</p>""") | 6411 self.tr("""<p><b>{0}</b> is not a file.</p>""") |
6179 .format(fname)) | 6412 .format(fname)) |
6180 event.acceptProposedAction() | 6413 event.acceptProposedAction() |
6181 else: | 6414 else: |
6182 super(Editor, self).dropEvent(event) | 6415 super(Editor, self).dropEvent(event) |
6183 | 6416 |
6191 """ | 6424 """ |
6192 Private method used to setup the Resources context sub menu. | 6425 Private method used to setup the Resources context sub menu. |
6193 | 6426 |
6194 @return reference to the generated menu (QMenu) | 6427 @return reference to the generated menu (QMenu) |
6195 """ | 6428 """ |
6196 menu = QMenu(self.trUtf8('Resources')) | 6429 menu = QMenu(self.tr('Resources')) |
6197 | 6430 |
6198 menu.addAction( | 6431 menu.addAction( |
6199 self.trUtf8('Add file...'), self.__addFileResource) | 6432 self.tr('Add file...'), self.__addFileResource) |
6200 menu.addAction( | 6433 menu.addAction( |
6201 self.trUtf8('Add files...'), self.__addFileResources) | 6434 self.tr('Add files...'), self.__addFileResources) |
6202 menu.addAction( | 6435 menu.addAction( |
6203 self.trUtf8('Add aliased file...'), | 6436 self.tr('Add aliased file...'), |
6204 self.__addFileAliasResource) | 6437 self.__addFileAliasResource) |
6205 menu.addAction( | 6438 menu.addAction( |
6206 self.trUtf8('Add localized resource...'), | 6439 self.tr('Add localized resource...'), |
6207 self.__addLocalizedResource) | 6440 self.__addLocalizedResource) |
6208 menu.addSeparator() | 6441 menu.addSeparator() |
6209 menu.addAction( | 6442 menu.addAction( |
6210 self.trUtf8('Add resource frame'), self.__addResourceFrame) | 6443 self.tr('Add resource frame'), self.__addResourceFrame) |
6211 | 6444 |
6212 menu.aboutToShow.connect(self.__showContextMenuResources) | 6445 menu.aboutToShow.connect(self.__showContextMenuResources) |
6213 | 6446 |
6214 return menu | 6447 return menu |
6215 | 6448 |
6216 def __showContextMenuResources(self): | 6449 def __showContextMenuResources(self): |
6217 """ | 6450 """ |
6218 Private slot handling the aboutToShow signal of the resources context | 6451 Private slot handling the aboutToShow signal of the resources context |
6219 menu. | 6452 menu. |
6220 """ | 6453 """ |
6221 self.showMenu.emit("Resources", self.resourcesMenu, self) | 6454 self.showMenu.emit("Resources", self.resourcesMenu, self) |
6222 | 6455 |
6223 def __addFileResource(self): | 6456 def __addFileResource(self): |
6224 """ | 6457 """ |
6225 Private method to handle the Add file context menu action. | 6458 Private method to handle the Add file context menu action. |
6226 """ | 6459 """ |
6227 dirStr = os.path.dirname(self.fileName) | 6460 dirStr = os.path.dirname(self.fileName) |
6228 file = E5FileDialog.getOpenFileName( | 6461 file = E5FileDialog.getOpenFileName( |
6229 self, | 6462 self, |
6230 self.trUtf8("Add file resource"), | 6463 self.tr("Add file resource"), |
6231 dirStr, | 6464 dirStr, |
6232 "") | 6465 "") |
6233 if file: | 6466 if file: |
6234 relFile = QDir(dirStr).relativeFilePath(file) | 6467 relFile = QDir(dirStr).relativeFilePath(file) |
6235 line, index = self.getCursorPosition() | 6468 line, index = self.getCursorPosition() |
6241 Private method to handle the Add files context menu action. | 6474 Private method to handle the Add files context menu action. |
6242 """ | 6475 """ |
6243 dirStr = os.path.dirname(self.fileName) | 6476 dirStr = os.path.dirname(self.fileName) |
6244 files = E5FileDialog.getOpenFileNames( | 6477 files = E5FileDialog.getOpenFileNames( |
6245 self, | 6478 self, |
6246 self.trUtf8("Add file resources"), | 6479 self.tr("Add file resources"), |
6247 dirStr, | 6480 dirStr, |
6248 "") | 6481 "") |
6249 if files: | 6482 if files: |
6250 myDir = QDir(dirStr) | 6483 myDir = QDir(dirStr) |
6251 filesText = "" | 6484 filesText = "" |
6261 Private method to handle the Add aliased file context menu action. | 6494 Private method to handle the Add aliased file context menu action. |
6262 """ | 6495 """ |
6263 dirStr = os.path.dirname(self.fileName) | 6496 dirStr = os.path.dirname(self.fileName) |
6264 file = E5FileDialog.getOpenFileName( | 6497 file = E5FileDialog.getOpenFileName( |
6265 self, | 6498 self, |
6266 self.trUtf8("Add aliased file resource"), | 6499 self.tr("Add aliased file resource"), |
6267 dirStr, | 6500 dirStr, |
6268 "") | 6501 "") |
6269 if file: | 6502 if file: |
6270 relFile = QDir(dirStr).relativeFilePath(file) | 6503 relFile = QDir(dirStr).relativeFilePath(file) |
6271 alias, ok = QInputDialog.getText( | 6504 alias, ok = QInputDialog.getText( |
6272 self, | 6505 self, |
6273 self.trUtf8("Add aliased file resource"), | 6506 self.tr("Add aliased file resource"), |
6274 self.trUtf8("Alias for file <b>{0}</b>:").format(relFile), | 6507 self.tr("Alias for file <b>{0}</b>:").format(relFile), |
6275 QLineEdit.Normal, | 6508 QLineEdit.Normal, |
6276 relFile) | 6509 relFile) |
6277 if ok and alias: | 6510 if ok and alias: |
6278 line, index = self.getCursorPosition() | 6511 line, index = self.getCursorPosition() |
6279 self.insert(' <file alias="{1}">{0}</file>\n' | 6512 self.insert(' <file alias="{1}">{0}</file>\n' |
6332 | 6565 |
6333 package = os.path.isdir(self.fileName) and \ | 6566 package = os.path.isdir(self.fileName) and \ |
6334 self.fileName or os.path.dirname(self.fileName) | 6567 self.fileName or os.path.dirname(self.fileName) |
6335 res = E5MessageBox.yesNo( | 6568 res = E5MessageBox.yesNo( |
6336 self, | 6569 self, |
6337 self.trUtf8("Package Diagram"), | 6570 self.tr("Package Diagram"), |
6338 self.trUtf8("""Include class attributes?"""), | 6571 self.tr("""Include class attributes?"""), |
6339 yesDefault=True) | 6572 yesDefault=True) |
6340 self.packageDiagram = UMLDialog( | 6573 self.packageDiagram = UMLDialog( |
6341 UMLDialog.PackageDiagram, self.project, package, | 6574 UMLDialog.PackageDiagram, self.project, package, |
6342 self, noAttrs=not res) | 6575 self, noAttrs=not res) |
6343 self.packageDiagram.show() | 6576 self.packageDiagram.show() |
6352 | 6585 |
6353 package = os.path.isdir(self.fileName) and self.fileName \ | 6586 package = os.path.isdir(self.fileName) and self.fileName \ |
6354 or os.path.dirname(self.fileName) | 6587 or os.path.dirname(self.fileName) |
6355 res = E5MessageBox.yesNo( | 6588 res = E5MessageBox.yesNo( |
6356 self, | 6589 self, |
6357 self.trUtf8("Imports Diagram"), | 6590 self.tr("Imports Diagram"), |
6358 self.trUtf8("""Include imports from external modules?""")) | 6591 self.tr("""Include imports from external modules?""")) |
6359 self.importsDiagram = UMLDialog( | 6592 self.importsDiagram = UMLDialog( |
6360 UMLDialog.ImportsDiagram, self.project, package, | 6593 UMLDialog.ImportsDiagram, self.project, package, |
6361 self, showExternalImports=res) | 6594 self, showExternalImports=res) |
6362 self.importsDiagram.show() | 6595 self.importsDiagram.show() |
6363 | 6596 |
6366 Private method to handle the Imports Diagram context menu action. | 6599 Private method to handle the Imports Diagram context menu action. |
6367 """ | 6600 """ |
6368 from Graphics.UMLDialog import UMLDialog | 6601 from Graphics.UMLDialog import UMLDialog |
6369 res = E5MessageBox.yesNo( | 6602 res = E5MessageBox.yesNo( |
6370 self, | 6603 self, |
6371 self.trUtf8("Application Diagram"), | 6604 self.tr("Application Diagram"), |
6372 self.trUtf8("""Include module names?"""), | 6605 self.tr("""Include module names?"""), |
6373 yesDefault=True) | 6606 yesDefault=True) |
6374 self.applicationDiagram = UMLDialog( | 6607 self.applicationDiagram = UMLDialog( |
6375 UMLDialog.ApplicationDiagram, self.project, | 6608 UMLDialog.ApplicationDiagram, self.project, |
6376 self, noModules=not res) | 6609 self, noModules=not res) |
6377 self.applicationDiagram.show() | 6610 self.applicationDiagram.show() |
6654 self.spellingMenu.addAction(suggestion)) | 6887 self.spellingMenu.addAction(suggestion)) |
6655 if suggestions: | 6888 if suggestions: |
6656 self.spellingMenu.addSeparator() | 6889 self.spellingMenu.addSeparator() |
6657 self.spellingMenu.addAction( | 6890 self.spellingMenu.addAction( |
6658 UI.PixmapCache.getIcon("spellchecking.png"), | 6891 UI.PixmapCache.getIcon("spellchecking.png"), |
6659 self.trUtf8("Check spelling..."), self.__checkSpellingWord) | 6892 self.tr("Check spelling..."), self.__checkSpellingWord) |
6660 self.spellingMenu.addAction( | 6893 self.spellingMenu.addAction( |
6661 self.trUtf8("Add to dictionary"), self.__addToSpellingDictionary) | 6894 self.tr("Add to dictionary"), self.__addToSpellingDictionary) |
6662 self.spellingMenu.addAction( | 6895 self.spellingMenu.addAction( |
6663 self.trUtf8("Ignore All"), self.__ignoreSpellingAlways) | 6896 self.tr("Ignore All"), self.__ignoreSpellingAlways) |
6664 | 6897 |
6665 self.showMenu.emit("Spelling", self.spellingMenu, self) | 6898 self.showMenu.emit("Spelling", self.spellingMenu, self) |
6666 | 6899 |
6667 def __contextMenuSpellingTriggered(self, action): | 6900 def __contextMenuSpellingTriggered(self, action): |
6668 """ | 6901 """ |
6669 Private slot to handle the selection of a suggestion of the spelling | 6902 Private slot to handle the selection of a suggestion of the spelling |
6670 context menu. | 6903 context menu. |
7068 try: | 7301 try: |
7069 txt = float(txt) | 7302 txt = float(txt) |
7070 except ValueError: | 7303 except ValueError: |
7071 E5MessageBox.critical( | 7304 E5MessageBox.critical( |
7072 self, | 7305 self, |
7073 self.trUtf8("Sort Lines"), | 7306 self.tr("Sort Lines"), |
7074 self.trUtf8( | 7307 self.tr( |
7075 """The selection contains illegal data for a""" | 7308 """The selection contains illegal data for a""" |
7076 """ numerical sort.""")) | 7309 """ numerical sort.""")) |
7077 return | 7310 return |
7078 | 7311 |
7079 if txt in selText: | 7312 if txt in selText: |