eric6/UI/PythonDisViewer.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
39 class PythonDisViewer(QWidget, Ui_PythonDisViewer): 39 class PythonDisViewer(QWidget, Ui_PythonDisViewer):
40 """ 40 """
41 Class implementing a widget to visualize the Python Disassembly for some 41 Class implementing a widget to visualize the Python Disassembly for some
42 Python sources. 42 Python sources.
43 """ 43 """
44 StartLineRole = Qt.UserRole 44 StartLineRole = Qt.ItemDataRole.UserRole
45 EndLineRole = Qt.UserRole + 1 45 EndLineRole = Qt.ItemDataRole.UserRole + 1
46 CodeInfoRole = Qt.UserRole + 2 46 CodeInfoRole = Qt.ItemDataRole.UserRole + 2
47 47
48 def __init__(self, viewmanager, 48 def __init__(self, viewmanager,
49 mode=PythonDisViewerModes.SourceDisassemblyMode, 49 mode=PythonDisViewerModes.SourceDisassemblyMode,
50 parent=None): 50 parent=None):
51 """ 51 """
358 if instr.argrepr: 358 if instr.argrepr:
359 fields.append('(' + instr.argrepr + ')') 359 fields.append('(' + instr.argrepr + ')')
360 360
361 itm = QTreeWidgetItem(parent, fields) 361 itm = QTreeWidgetItem(parent, fields)
362 for col in (0, 1, 3): 362 for col in (0, 1, 3):
363 itm.setTextAlignment(col, Qt.AlignRight) 363 itm.setTextAlignment(col, Qt.AlignmentFlag.AlignRight)
364 # set font to indicate current instruction and jump target 364 # set font to indicate current instruction and jump target
365 font = itm.font(0) 365 font = itm.font(0)
366 if instr.offset == lasti: 366 if instr.offset == lasti:
367 font.setItalic(True) 367 font.setItalic(True)
368 if instr.is_jump_target: 368 if instr.is_jump_target:
551 self.setUpdatesEnabled(True) 551 self.setUpdatesEnabled(True)
552 552
553 if lasti: 553 if lasti:
554 lastInstructions = self.disWidget.findItems( 554 lastInstructions = self.disWidget.findItems(
555 "{0:d}".format(lasti), 555 "{0:d}".format(lasti),
556 Qt.MatchFixedString | Qt.MatchRecursive, 1) 556 Qt.MatchFlag.MatchFixedString |
557 Qt.MatchFlag.MatchRecursive,
558 1
559 )
557 if lastInstructions: 560 if lastInstructions:
558 self.disWidget.scrollToItem( 561 self.disWidget.scrollToItem(
559 lastInstructions[0], 562 lastInstructions[0],
560 QAbstractItemView.PositionAtCenter) 563 QAbstractItemView.ScrollHint.PositionAtCenter)
561 564
562 if "codeinfo" in disassembly: 565 if "codeinfo" in disassembly:
563 self.__showCodeInfoData(disassembly["codeinfo"]) 566 self.__showCodeInfoData(disassembly["codeinfo"])
564 567
565 def __resizeDisColumns(self): 568 def __resizeDisColumns(self):
607 child.setSelected(True) 610 child.setSelected(True)
608 self.__selectChildren(child, lineno) 611 self.__selectChildren(child, lineno)
609 612
610 if child.data(0, self.StartLineRole) == lineno: 613 if child.data(0, self.StartLineRole) == lineno:
611 self.disWidget.scrollToItem( 614 self.disWidget.scrollToItem(
612 child, QAbstractItemView.PositionAtCenter) 615 child, QAbstractItemView.ScrollHint.PositionAtCenter)
613 616
614 def __selectItemForEditorLine(self): 617 def __selectItemForEditorLine(self):
615 """ 618 """
616 Private slot to select the items corresponding with the cursor line 619 Private slot to select the items corresponding with the cursor line
617 of the current editor. 620 of the current editor.
800 [title, str(len(infoList))]) 803 [title, str(len(infoList))])
801 parent.setExpanded(self.__showCodeInfoDetails) 804 parent.setExpanded(self.__showCodeInfoDetails)
802 805
803 for index, value in enumerate(infoList): 806 for index, value in enumerate(infoList):
804 itm = QTreeWidgetItem(parent, [str(index), str(value)]) 807 itm = QTreeWidgetItem(parent, [str(index), str(value)])
805 itm.setTextAlignment(0, Qt.AlignRight) 808 itm.setTextAlignment(0, Qt.AlignmentFlag.AlignRight)
806 809
807 self.codeInfoWidget.clear() 810 self.codeInfoWidget.clear()
808 811
809 if codeInfo: 812 if codeInfo:
810 QTreeWidgetItem(self.codeInfoWidget, [ 813 QTreeWidgetItem(self.codeInfoWidget, [

eric ide

mercurial