23 from DebugClients.Python.DebugConfig import ConfigQtNames, ConfigKnownQtTypes |
23 from DebugClients.Python.DebugConfig import ConfigQtNames, ConfigKnownQtTypes |
24 |
24 |
25 import Preferences |
25 import Preferences |
26 import Utilities |
26 import Utilities |
27 |
27 |
28 SORT_ROLE = Qt.UserRole |
28 SORT_ROLE = Qt.ItemDataRole.UserRole |
29 |
29 |
30 |
30 |
31 class VariableItem(object): |
31 class VariableItem(object): |
32 """ |
32 """ |
33 Class implementing the data structure for all variable items. |
33 Class implementing the data structure for all variable items. |
552 @type QModelIndex |
552 @type QModelIndex |
553 @return item flags |
553 @return item flags |
554 @rtype QtCore.Qt.ItemFlag |
554 @rtype QtCore.Qt.ItemFlag |
555 """ |
555 """ |
556 if not index.isValid(): |
556 if not index.isValid(): |
557 return Qt.NoItemFlags |
557 return Qt.ItemFlag.NoItemFlags |
558 |
558 |
559 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
559 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable |
560 |
560 |
561 def hasChildren(self, parent=QModelIndex()): |
561 def hasChildren(self, parent=QModelIndex()): |
562 """ |
562 """ |
563 Public method to get a flag if parent has children. |
563 Public method to get a flag if parent has children. |
564 |
564 |
617 return QModelIndex() |
617 return QModelIndex() |
618 |
618 |
619 row = parentNode.parent.children.index(parentNode) |
619 row = parentNode.parent.children.index(parentNode) |
620 return self.createIndex(row, 0, parentNode) |
620 return self.createIndex(row, 0, parentNode) |
621 |
621 |
622 def data(self, index, role=Qt.DisplayRole): |
622 def data(self, index, role=Qt.ItemDataRole.DisplayRole): |
623 """ |
623 """ |
624 Public method get the role data of item. |
624 Public method get the role data of item. |
625 |
625 |
626 @param index the model index |
626 @param index the model index |
627 @type QModelIndex |
627 @type QModelIndex |
634 return None |
634 return None |
635 |
635 |
636 node = index.internalPointer() |
636 node = index.internalPointer() |
637 column = index.column() |
637 column = index.column() |
638 |
638 |
639 if role in (Qt.DisplayRole, SORT_ROLE, Qt.EditRole): |
639 if role in ( |
|
640 Qt.ItemDataRole.DisplayRole, SORT_ROLE, Qt.ItemDataRole.EditRole |
|
641 ): |
640 try: |
642 try: |
641 if column == 0: |
643 if column == 0: |
642 # Sort first column with values from third column |
644 # Sort first column with values from third column |
643 if role == SORT_ROLE: |
645 if role == SORT_ROLE: |
644 return node.sort |
646 return node.sort |
652 else: |
654 else: |
653 return None |
655 return None |
654 except AttributeError: |
656 except AttributeError: |
655 return ['None', '', '', ''][column] |
657 return ['None', '', '', ''][column] |
656 |
658 |
657 elif role == Qt.BackgroundRole: |
659 elif role == Qt.ItemDataRole.BackgroundRole: |
658 if node in node.parent.changedItems: |
660 if node in node.parent.changedItems: |
659 return self.__bgColorChanged |
661 return self.__bgColorChanged |
660 elif node in node.parent.newItems: |
662 elif node in node.parent.newItems: |
661 return self.__bgColorNew |
663 return self.__bgColorNew |
662 |
664 |
663 elif role == Qt.ToolTipRole: |
665 elif role == Qt.ItemDataRole.ToolTipRole: |
664 if column == 0: |
666 if column == 0: |
665 tooltip = node.name + node.indicator |
667 tooltip = node.name + node.indicator |
666 elif column == 1: |
668 elif column == 1: |
667 tooltip = node.tooltip |
669 tooltip = node.tooltip |
668 elif column == 2: |
670 elif column == 2: |
699 else: |
701 else: |
700 QToolTip.hideText() |
702 QToolTip.hideText() |
701 |
703 |
702 return None |
704 return None |
703 |
705 |
704 def headerData(self, section, orientation, role=Qt.DisplayRole): |
706 def headerData(self, section, orientation, |
|
707 role=Qt.ItemDataRole.DisplayRole): |
705 """ |
708 """ |
706 Public method get the header names. |
709 Public method get the header names. |
707 |
710 |
708 @param section the header section (row/coulumn) |
711 @param section the header section (row/coulumn) |
709 @type int |
712 @type int |
950 |
956 |
951 self.varModel.expand.connect(self.__mdlRequestExpand) |
957 self.varModel.expand.connect(self.__mdlRequestExpand) |
952 |
958 |
953 self.setSortingEnabled(True) |
959 self.setSortingEnabled(True) |
954 self.setAlternatingRowColors(True) |
960 self.setAlternatingRowColors(True) |
955 self.setSelectionBehavior(QAbstractItemView.SelectRows) |
961 self.setSelectionBehavior( |
|
962 QAbstractItemView.SelectionBehavior.SelectRows) |
956 |
963 |
957 if self.__globalScope: |
964 if self.__globalScope: |
958 self.setWindowTitle(self.tr("Global Variables")) |
965 self.setWindowTitle(self.tr("Global Variables")) |
959 self.setWhatsThis(self.tr( |
966 self.setWhatsThis(self.tr( |
960 """<b>The Global Variables Viewer Window</b>""" |
967 """<b>The Global Variables Viewer Window</b>""" |
968 """<p>This window displays the local variables""" |
975 """<p>This window displays the local variables""" |
969 """ of the debugged program.</p>""" |
976 """ of the debugged program.</p>""" |
970 )) |
977 )) |
971 |
978 |
972 header = self.header() |
979 header = self.header() |
973 header.setSortIndicator(0, Qt.AscendingOrder) |
980 header.setSortIndicator(0, Qt.SortOrder.AscendingOrder) |
974 header.setSortIndicatorShown(True) |
981 header.setSortIndicatorShown(True) |
975 |
982 |
976 try: |
983 try: |
977 header.setSectionsClickable(True) |
984 header.setSectionsClickable(True) |
978 except Exception: |
985 except Exception: |
983 header.resizeSection(2, 50) # type column |
990 header.resizeSection(2, 50) # type column |
984 |
991 |
985 header.sortIndicatorChanged.connect(lambda *x: self.varModel.getMore()) |
992 header.sortIndicatorChanged.connect(lambda *x: self.varModel.getMore()) |
986 |
993 |
987 self.__createPopupMenus() |
994 self.__createPopupMenus() |
988 self.setContextMenuPolicy(Qt.CustomContextMenu) |
995 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
989 self.customContextMenuRequested.connect(self.__showContextMenu) |
996 self.customContextMenuRequested.connect(self.__showContextMenu) |
990 |
997 |
991 self.resortEnabled = True |
998 self.resortEnabled = True |
992 |
999 |
993 def showVariables(self, vlist, frmnr): |
1000 def showVariables(self, vlist, frmnr): |