12 str = unicode |
12 str = unicode |
13 except (NameError): |
13 except (NameError): |
14 pass |
14 pass |
15 |
15 |
16 from PyQt4.QtCore import Qt, QRegExp, qVersion |
16 from PyQt4.QtCore import Qt, QRegExp, qVersion |
17 from PyQt4.QtGui import QTreeWidget, QTreeWidgetItem, QApplication, QAbstractItemView, \ |
17 from PyQt4.QtGui import QTreeWidget, QTreeWidgetItem, QApplication, \ |
18 QMenu |
18 QAbstractItemView, QMenu |
19 from PyQt4.QtGui import QTextDocument # __IGNORE_WARNING__ |
19 from PyQt4.QtGui import QTextDocument # __IGNORE_WARNING__ |
20 |
20 |
21 from E5Gui.E5Application import e5App |
21 from E5Gui.E5Application import e5App |
22 |
22 |
23 from DebugClients.Python3.DebugConfig import ConfigVarTypeStrings |
23 from DebugClients.Python3.DebugConfig import ConfigVarTypeStrings |
80 |
80 |
81 def data(self, column, role): |
81 def data(self, column, role): |
82 """ |
82 """ |
83 Public method to return the data for the requested role. |
83 Public method to return the data for the requested role. |
84 |
84 |
85 This implementation changes the original behavior in a way, that the display |
85 This implementation changes the original behavior in a way, that the |
86 data is returned as the tooltip for column 1. |
86 display data is returned as the tooltip for column 1. |
87 |
87 |
88 @param column column number (integer) |
88 @param column column number (integer) |
89 @param role data role (Qt.ItemDataRole) |
89 @param role data role (Qt.ItemDataRole) |
90 @return requested data |
90 @return requested data |
91 """ |
91 """ |
215 def key(self, column): |
215 def key(self, column): |
216 """ |
216 """ |
217 Public method generating the key for this item. |
217 Public method generating the key for this item. |
218 |
218 |
219 @param column the column to sort on (integer) |
219 @param column the column to sort on (integer) |
|
220 @return key of the item (string) |
220 """ |
221 """ |
221 if column == 0: |
222 if column == 0: |
222 return self.arrayElementKey |
223 return self.arrayElementKey |
223 else: |
224 else: |
224 return VariableItem.key(self, column) |
225 return VariableItem.key(self, column) |
225 |
226 |
226 |
227 |
227 class SpecialArrayElementVarItem(SpecialVarItem): |
228 class SpecialArrayElementVarItem(SpecialVarItem): |
228 """ |
229 """ |
229 Class implementing a QTreeWidgetItem that represents a special array variable node. |
230 Class implementing a QTreeWidgetItem that represents a special array |
|
231 variable node. |
230 """ |
232 """ |
231 def __init__(self, parent, dvar, dvalue, dtype, frmnr, scope): |
233 def __init__(self, parent, dvar, dvalue, dtype, frmnr, scope): |
232 """ |
234 """ |
233 Constructor |
235 Constructor |
234 |
236 |
237 @param dvalue value string (string) |
239 @param dvalue value string (string) |
238 @param dtype type string (string) |
240 @param dtype type string (string) |
239 @param frmnr frame number (0 is the current frame) (int) |
241 @param frmnr frame number (0 is the current frame) (int) |
240 @param scope flag indicating global (1) or local (0) variables |
242 @param scope flag indicating global (1) or local (0) variables |
241 """ |
243 """ |
242 SpecialVarItem.__init__(self, parent, dvar, dvalue, dtype, frmnr, scope) |
244 SpecialVarItem.__init__(self, parent, dvar, dvalue, dtype, frmnr, |
|
245 scope) |
243 |
246 |
244 """ |
247 """ |
245 Array elements have numbers as names, but the key must be |
248 Array elements have numbers as names, but the key must be |
246 right justified and zero filled to 6 decimal places. Then |
249 right justified and zero filled to 6 decimal places. Then |
247 element 2 will have a key of '000002' and appear before |
250 element 2 will have a key of '000002' and appear before |
253 def key(self, column): |
256 def key(self, column): |
254 """ |
257 """ |
255 Public method generating the key for this item. |
258 Public method generating the key for this item. |
256 |
259 |
257 @param column the column to sort on (integer) |
260 @param column the column to sort on (integer) |
|
261 @return key of the item (string) |
258 """ |
262 """ |
259 if column == 0: |
263 if column == 0: |
260 return self.arrayElementKey |
264 return self.arrayElementKey |
261 else: |
265 else: |
262 return SpecialVarItem.key(self, column) |
266 return SpecialVarItem.key(self, column) |
283 @param parent the parent (QWidget) |
287 @param parent the parent (QWidget) |
284 @param scope flag indicating global (1) or local (0) variables |
288 @param scope flag indicating global (1) or local (0) variables |
285 """ |
289 """ |
286 super(VariablesViewer, self).__init__(parent) |
290 super(VariablesViewer, self).__init__(parent) |
287 |
291 |
288 self.indicators = {'list': '[]', 'tuple': '()', 'dict': '{}', # Python types |
292 self.indicators = {'list': '[]', 'tuple': '()', 'dict': '{}', |
289 'Array': '[]', 'Hash': '{}'} # Ruby types |
293 # Python types |
|
294 'Array': '[]', 'Hash': '{}'} |
|
295 # Ruby types |
290 |
296 |
291 self.rx_class = QRegExp('<.*(instance|object) at 0x.*>') |
297 self.rx_class = QRegExp('<.*(instance|object) at 0x.*>') |
292 self.rx_class2 = QRegExp('class .*') |
298 self.rx_class2 = QRegExp('class .*') |
293 self.rx_class3 = QRegExp('<class .* at 0x.*>') |
299 self.rx_class3 = QRegExp('<class .* at 0x.*>') |
294 self.dvar_rx_class1 = QRegExp(r'<.*(instance|object) at 0x.*>(\[\]|\{\}|\(\))') |
300 self.dvar_rx_class1 = QRegExp( |
|
301 r'<.*(instance|object) at 0x.*>(\[\]|\{\}|\(\))') |
295 self.dvar_rx_class2 = QRegExp(r'<class .* at 0x.*>(\[\]|\{\}|\(\))') |
302 self.dvar_rx_class2 = QRegExp(r'<class .* at 0x.*>(\[\]|\{\}|\(\))') |
296 self.dvar_rx_array_element = QRegExp(r'^\d+$') |
303 self.dvar_rx_array_element = QRegExp(r'^\d+$') |
297 self.dvar_rx_special_array_element = QRegExp(r'^\d+(\[\]|\{\}|\(\))$') |
304 self.dvar_rx_special_array_element = QRegExp(r'^\d+(\[\]|\{\}|\(\))$') |
298 self.rx_nonprintable = QRegExp(r"""(\\x\d\d)+""") |
305 self.rx_nonprintable = QRegExp(r"""(\\x\d\d)+""") |
299 |
306 |
500 QAbstractItemView.PositionAtTop) |
507 QAbstractItemView.PositionAtTop) |
501 else: |
508 else: |
502 self.scrollToItem(citm, QAbstractItemView.PositionAtTop) |
509 self.scrollToItem(citm, QAbstractItemView.PositionAtTop) |
503 self.current = None |
510 self.current = None |
504 elif self.__scrollToItem: |
511 elif self.__scrollToItem: |
505 self.scrollToItem(self.__scrollToItem, QAbstractItemView.PositionAtTop) |
512 self.scrollToItem(self.__scrollToItem, |
|
513 QAbstractItemView.PositionAtTop) |
506 |
514 |
507 self.resortEnabled = resortEnabled |
515 self.resortEnabled = resortEnabled |
508 self.__resort() |
516 self.__resort() |
509 |
517 |
510 def __generateItem(self, parent, dvar, dvalue, dtype, isSpecial=False): |
518 def __generateItem(self, parent, dvar, dvalue, dtype, isSpecial=False): |
513 |
521 |
514 @param parent parent of the item to be generated |
522 @param parent parent of the item to be generated |
515 @param dvar variable name (string) |
523 @param dvar variable name (string) |
516 @param dvalue value string (string) |
524 @param dvalue value string (string) |
517 @param dtype type string (string) |
525 @param dtype type string (string) |
518 @param isSpecial flag indicating that a special node should be generated (boolean) |
526 @param isSpecial flag indicating that a special node should be |
|
527 generated (boolean) |
519 @return The item that was generated (VariableItem). |
528 @return The item that was generated (VariableItem). |
520 """ |
529 """ |
521 if isSpecial and \ |
530 if isSpecial and \ |
522 (self.dvar_rx_class1.exactMatch(dvar) or \ |
531 (self.dvar_rx_class1.exactMatch(dvar) or \ |
523 self.dvar_rx_class2.exactMatch(dvar)): |
532 self.dvar_rx_class2.exactMatch(dvar)): |
595 try: |
604 try: |
596 i = ConfigVarTypeStrings.index(vtype) |
605 i = ConfigVarTypeStrings.index(vtype) |
597 dvtype = self.trUtf8(ConfigVarTypeDispStrings[i]) |
606 dvtype = self.trUtf8(ConfigVarTypeDispStrings[i]) |
598 except ValueError: |
607 except ValueError: |
599 if vtype == 'classobj': |
608 if vtype == 'classobj': |
600 dvtype = self.trUtf8( |
609 dvtype = self.trUtf8(ConfigVarTypeDispStrings[ |
601 ConfigVarTypeDispStrings[ConfigVarTypeStrings.index('instance')]\ |
610 ConfigVarTypeStrings.index('instance')]) |
602 ) |
|
603 else: |
611 else: |
604 dvtype = vtype |
612 dvtype = vtype |
605 return dvtype |
613 return dvtype |
606 |
614 |
607 def mouseDoubleClickEvent(self, mouseEvent): |
615 def mouseDoubleClickEvent(self, mouseEvent): |
608 """ |
616 """ |
609 Protected method of QAbstractItemView. |
617 Protected method of QAbstractItemView. |
610 |
618 |
611 Reimplemented to disable expanding/collapsing |
619 Reimplemented to disable expanding/collapsing of items when |
612 of items when double-clicking. Instead the double-clicked entry is opened. |
620 double-clicking. Instead the double-clicked entry is opened. |
613 |
621 |
614 @param mouseEvent the mouse event object (QMouseEvent) |
622 @param mouseEvent the mouse event object (QMouseEvent) |
615 """ |
623 """ |
616 itm = self.itemAt(mouseEvent.pos()) |
624 itm = self.itemAt(mouseEvent.pos()) |
617 self.__showVariableDetails(itm) |
625 self.__showVariableDetails(itm) |
684 |
692 |
685 def __expandItemSignal(self, parentItem): |
693 def __expandItemSignal(self, parentItem): |
686 """ |
694 """ |
687 Private slot to handle the expanded signal. |
695 Private slot to handle the expanded signal. |
688 |
696 |
689 @param parentItem reference to the item being expanded (QTreeWidgetItem) |
697 @param parentItem reference to the item being expanded |
|
698 (QTreeWidgetItem) |
690 """ |
699 """ |
691 self.expandItem(parentItem) |
700 self.expandItem(parentItem) |
692 self.__scrollToItem = parentItem |
701 self.__scrollToItem = parentItem |
693 |
702 |
694 def expandItem(self, parentItem): |
703 def expandItem(self, parentItem): |
695 """ |
704 """ |
696 Public slot to handle the expanded signal. |
705 Public slot to handle the expanded signal. |
697 |
706 |
698 @param parentItem reference to the item being expanded (QTreeWidgetItem) |
707 @param parentItem reference to the item being expanded |
|
708 (QTreeWidgetItem) |
699 """ |
709 """ |
700 pathlist = self.__buildTreePath(parentItem) |
710 pathlist = self.__buildTreePath(parentItem) |
701 self.openItems.append(pathlist) |
711 self.openItems.append(pathlist) |
702 if parentItem.populated: |
712 if parentItem.populated: |
703 return |
713 return |
710 |
720 |
711 def collapseItem(self, parentItem): |
721 def collapseItem(self, parentItem): |
712 """ |
722 """ |
713 Public slot to handle the collapsed signal. |
723 Public slot to handle the collapsed signal. |
714 |
724 |
715 @param parentItem reference to the item being collapsed (QTreeWidgetItem) |
725 @param parentItem reference to the item being collapsed |
|
726 (QTreeWidgetItem) |
716 """ |
727 """ |
717 pathlist = self.__buildTreePath(parentItem) |
728 pathlist = self.__buildTreePath(parentItem) |
718 self.openItems.remove(pathlist) |
729 self.openItems.remove(pathlist) |
719 |
730 |
720 try: |
731 try: |
725 def __resort(self): |
736 def __resort(self): |
726 """ |
737 """ |
727 Private method to resort the tree. |
738 Private method to resort the tree. |
728 """ |
739 """ |
729 if self.resortEnabled: |
740 if self.resortEnabled: |
730 self.sortItems(self.sortColumn(), self.header().sortIndicatorOrder()) |
741 self.sortItems(self.sortColumn(), |
|
742 self.header().sortIndicatorOrder()) |
731 |
743 |
732 def handleResetUI(self): |
744 def handleResetUI(self): |
733 """ |
745 """ |
734 Public method to reset the VariablesViewer. |
746 Public method to reset the VariablesViewer. |
735 """ |
747 """ |