Debugger/WatchPointViewer.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1112
8a7d1b9d18db
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
15 15
16 from .EditWatchpointDialog import EditWatchpointDialog 16 from .EditWatchpointDialog import EditWatchpointDialog
17 17
18 import Utilities 18 import Utilities
19 19
20
20 class WatchPointViewer(QTreeView): 21 class WatchPointViewer(QTreeView):
21 """ 22 """
22 Class implementing the watch expression viewer widget. 23 Class implementing the watch expression viewer widget.
23 24
24 Watch expressions will be shown with all their details. They can be modified through 25 Watch expressions will be shown with all their details. They can be modified through
25 the context menu of this widget. 26 the context menu of this widget.
26 """ 27 """
27 def __init__(self, parent = None): 28 def __init__(self, parent=None):
28 """ 29 """
29 Constructor 30 Constructor
30 31
31 @param parent the parent (QWidget) 32 @param parent the parent (QWidget)
32 """ 33 """
33 QTreeView.__init__(self,parent) 34 QTreeView.__init__(self, parent)
34 self.setObjectName("WatchExpressionViewer") 35 self.setObjectName("WatchExpressionViewer")
35 36
36 self.__model = None 37 self.__model = None
37 38
38 self.setItemsExpandable(False) 39 self.setItemsExpandable(False)
87 88
88 def __resort(self): 89 def __resort(self):
89 """ 90 """
90 Private slot to resort the tree. 91 Private slot to resort the tree.
91 """ 92 """
92 self.model().sort(self.header().sortIndicatorSection(), 93 self.model().sort(self.header().sortIndicatorSection(),
93 self.header().sortIndicatorOrder()) 94 self.header().sortIndicatorOrder())
94 95
95 def __toSourceIndex(self, index): 96 def __toSourceIndex(self, index):
96 """ 97 """
97 Private slot to convert an index to a source index. 98 Private slot to convert an index to a source index.
106 107
107 @param sindex source index to be converted (QModelIndex) 108 @param sindex source index to be converted (QModelIndex)
108 """ 109 """
109 return self.sortingModel.mapFromSource(sindex) 110 return self.sortingModel.mapFromSource(sindex)
110 111
111 def __setRowSelected(self, index, selected = True): 112 def __setRowSelected(self, index, selected=True):
112 """ 113 """
113 Private slot to select a complete row. 114 Private slot to select a complete row.
114 115
115 @param index index determining the row to be selected (QModelIndex) 116 @param index index determining the row to be selected (QModelIndex)
116 @param selected flag indicating the action (bool) 117 @param selected flag indicating the action (bool)
147 148
148 self.backMenuActions = {} 149 self.backMenuActions = {}
149 self.backMenu = QMenu() 150 self.backMenu = QMenu()
150 self.backMenu.addAction(self.trUtf8("Add"), self.__addWatchPoint) 151 self.backMenu.addAction(self.trUtf8("Add"), self.__addWatchPoint)
151 self.backMenuActions["EnableAll"] = \ 152 self.backMenuActions["EnableAll"] = \
152 self.backMenu.addAction(self.trUtf8("Enable all"), 153 self.backMenu.addAction(self.trUtf8("Enable all"),
153 self.__enableAllWatchPoints) 154 self.__enableAllWatchPoints)
154 self.backMenuActions["DisableAll"] = \ 155 self.backMenuActions["DisableAll"] = \
155 self.backMenu.addAction(self.trUtf8("Disable all"), 156 self.backMenu.addAction(self.trUtf8("Disable all"),
156 self.__disableAllWatchPoints) 157 self.__disableAllWatchPoints)
157 self.backMenuActions["DeleteAll"] = \ 158 self.backMenuActions["DeleteAll"] = \
158 self.backMenu.addAction(self.trUtf8("Delete all"), 159 self.backMenu.addAction(self.trUtf8("Delete all"),
159 self.__deleteAllWatchPoints) 160 self.__deleteAllWatchPoints)
160 self.backMenu.addSeparator() 161 self.backMenu.addSeparator()
161 self.backMenu.addAction(self.trUtf8("Configure..."), self.__configure) 162 self.backMenu.addAction(self.trUtf8("Configure..."), self.__configure)
162 self.backMenu.aboutToShow.connect(self.__showBackMenu) 163 self.backMenu.aboutToShow.connect(self.__showBackMenu)
163 164
164 self.multiMenu = QMenu() 165 self.multiMenu = QMenu()
165 self.multiMenu.addAction(self.trUtf8("Add"), self.__addWatchPoint) 166 self.multiMenu.addAction(self.trUtf8("Add"), self.__addWatchPoint)
166 self.multiMenu.addSeparator() 167 self.multiMenu.addSeparator()
167 self.multiMenu.addAction(self.trUtf8("Enable selected"), 168 self.multiMenu.addAction(self.trUtf8("Enable selected"),
168 self.__enableSelectedWatchPoints) 169 self.__enableSelectedWatchPoints)
169 self.multiMenu.addAction(self.trUtf8("Enable all"), self.__enableAllWatchPoints) 170 self.multiMenu.addAction(self.trUtf8("Enable all"), self.__enableAllWatchPoints)
170 self.multiMenu.addSeparator() 171 self.multiMenu.addSeparator()
171 self.multiMenu.addAction(self.trUtf8("Disable selected"), 172 self.multiMenu.addAction(self.trUtf8("Disable selected"),
172 self.__disableSelectedWatchPoints) 173 self.__disableSelectedWatchPoints)
173 self.multiMenu.addAction(self.trUtf8("Disable all"), self.__disableAllWatchPoints) 174 self.multiMenu.addAction(self.trUtf8("Disable all"), self.__disableAllWatchPoints)
174 self.multiMenu.addSeparator() 175 self.multiMenu.addSeparator()
175 self.multiMenu.addAction(self.trUtf8("Delete selected"), 176 self.multiMenu.addAction(self.trUtf8("Delete selected"),
176 self.__deleteSelectedWatchPoints) 177 self.__deleteSelectedWatchPoints)
177 self.multiMenu.addAction(self.trUtf8("Delete all"), self.__deleteAllWatchPoints) 178 self.multiMenu.addAction(self.trUtf8("Delete all"), self.__deleteAllWatchPoints)
178 self.multiMenu.addSeparator() 179 self.multiMenu.addSeparator()
179 self.multiMenu.addAction(self.trUtf8("Configure..."), self.__configure) 180 self.multiMenu.addAction(self.trUtf8("Configure..."), self.__configure)
180 181
203 Private slot to clear the selection. 204 Private slot to clear the selection.
204 """ 205 """
205 for index in self.selectedIndexes(): 206 for index in self.selectedIndexes():
206 self.__setRowSelected(index, False) 207 self.__setRowSelected(index, False)
207 208
208 def __findDuplicates(self, cond, special, showMessage = False, index = QModelIndex()): 209 def __findDuplicates(self, cond, special, showMessage=False, index=QModelIndex()):
209 """ 210 """
210 Private method to check, if an entry already exists. 211 Private method to check, if an entry already exists.
211 212
212 @param cond condition to check (string) 213 @param cond condition to check (string)
213 @param special special condition to check (string) 214 @param special special condition to check (string)
279 dlg = EditWatchpointDialog( 280 dlg = EditWatchpointDialog(
280 (cond, temp, enabled, count, special), self) 281 (cond, temp, enabled, count, special), self)
281 if dlg.exec_() == QDialog.Accepted: 282 if dlg.exec_() == QDialog.Accepted:
282 cond, temp, enabled, count, special = dlg.getData() 283 cond, temp, enabled, count, special = dlg.getData()
283 if not self.__findDuplicates(cond, special, True, sindex): 284 if not self.__findDuplicates(cond, special, True, sindex):
284 self.__model.setWatchPointByIndex(sindex, 285 self.__model.setWatchPointByIndex(sindex,
285 cond, special, (temp, enabled, count)) 286 cond, special, (temp, enabled, count))
286 self.__resizeColumns() 287 self.__resizeColumns()
287 self.__resort() 288 self.__resort()
288 289
289 def __setWpEnabled(self, index, enabled): 290 def __setWpEnabled(self, index, enabled):
400 """ 401 """
401 Private method to get the count of items selected. 402 Private method to get the count of items selected.
402 403
403 @return count of items selected (integer) 404 @return count of items selected (integer)
404 """ 405 """
405 count = len(self.selectedIndexes()) // (self.__model.columnCount()-1) 406 count = len(self.selectedIndexes()) // (self.__model.columnCount() - 1)
406 # column count is 1 greater than selectable 407 # column count is 1 greater than selectable
407 return count 408 return count
408 409
409 def __configure(self): 410 def __configure(self):
410 """ 411 """

eric ide

mercurial