src/eric7/Debugger/WatchPointModel.py

branch
eric7
changeset 10417
c6011e501282
parent 10065
de4ae767b0e3
child 10439
21c28b0f9e41
equal deleted inserted replaced
10416:5d807e997391 10417:c6011e501282
52 52
53 def __init__(self, parent=None): 53 def __init__(self, parent=None):
54 """ 54 """
55 Constructor 55 Constructor
56 56
57 @param parent reference to the parent widget (QObject) 57 @param parent reference to the parent object
58 @type QObject
58 """ 59 """
59 super().__init__(parent) 60 super().__init__(parent)
60 61
61 self.watchpoints = [] 62 self.watchpoints = []
62 63
63 def columnCount(self, parent=None): # noqa: U100 64 def columnCount(self, parent=None): # noqa: U100
64 """ 65 """
65 Public method to get the current column count. 66 Public method to get the current column count.
66 67
67 @param parent index of the parent item (QModelIndex) (Unused) 68 @param parent index of the parent item (unused)
68 @return column count (integer) 69 @type QModelIndex
70 @return column count
71 @rtype int
69 """ 72 """
70 return len(WatchPointModel.Header) 73 return len(WatchPointModel.Header)
71 74
72 def rowCount(self, parent=None): 75 def rowCount(self, parent=None):
73 """ 76 """
74 Public method to get the current row count. 77 Public method to get the current row count.
75 78
76 @param parent index of the parent item (QModelIndex) 79 @param parent index of the parent item
77 @return row count (integer) 80 @type QModelIndex
81 @return row count
82 @rtype int
78 """ 83 """
79 # we do not have a tree, parent should always be invalid 84 # we do not have a tree, parent should always be invalid
80 if parent is None or not parent.isValid(): 85 if parent is None or not parent.isValid():
81 return len(self.watchpoints) 86 return len(self.watchpoints)
82 else: 87 else:
84 89
85 def data(self, index, role): 90 def data(self, index, role):
86 """ 91 """
87 Public method to get the requested data. 92 Public method to get the requested data.
88 93
89 @param index index of the requested data (QModelIndex) 94 @param index index of the requested data
90 @param role role of the requested data (Qt.ItemDataRole) 95 @type QModelIndex
96 @param role role of the requested data
97 @type Qt.ItemDataRole
91 @return the requested data 98 @return the requested data
99 @rtype Any
92 """ 100 """
93 if not index.isValid(): 101 if not index.isValid():
94 return None 102 return None
95 103
96 if role == Qt.ItemDataRole.DisplayRole and index.column() in ( 104 if role == Qt.ItemDataRole.DisplayRole and index.column() in (
124 132
125 def flags(self, index): 133 def flags(self, index):
126 """ 134 """
127 Public method to get item flags. 135 Public method to get item flags.
128 136
129 @param index index of the requested flags (QModelIndex) 137 @param index index of the requested flags
130 @return item flags for the given index (Qt.ItemFlags) 138 @type QModelIndex
139 @return item flags for the given index
140 @rtype Qt.ItemFlags
131 """ 141 """
132 if not index.isValid(): 142 if not index.isValid():
133 return Qt.ItemFlag.ItemIsEnabled 143 return Qt.ItemFlag.ItemIsEnabled
134 144
135 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable 145 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
136 146
137 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): 147 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole):
138 """ 148 """
139 Public method to get header data. 149 Public method to get header data.
140 150
141 @param section section number of the requested header data (integer) 151 @param section section number of the requested header data
142 @param orientation orientation of the header (Qt.Orientation) 152 @type int
143 @param role role of the requested data (Qt.ItemDataRole) 153 @param orientation orientation of the header
154 @type Qt.Orientation
155 @param role role of the requested data
156 @type Qt.ItemDataRole
144 @return header data 157 @return header data
158 @rtype Any
145 """ 159 """
146 if ( 160 if (
147 orientation == Qt.Orientation.Horizontal 161 orientation == Qt.Orientation.Horizontal
148 and role == Qt.ItemDataRole.DisplayRole 162 and role == Qt.ItemDataRole.DisplayRole
149 ): 163 ):
156 170
157 def index(self, row, column, parent=None): 171 def index(self, row, column, parent=None):
158 """ 172 """
159 Public method to create an index. 173 Public method to create an index.
160 174
161 @param row row number for the index (integer) 175 @param row row number for the index
162 @param column column number for the index (integer) 176 @type int
163 @param parent index of the parent item (QModelIndex) 177 @param column column number for the index
164 @return requested index (QModelIndex) 178 @type int
179 @param parent index of the parent item
180 @type QModelIndex
181 @return requested index
182 @rtype QModelIndex
165 """ 183 """
166 if ( 184 if (
167 (parent and parent.isValid()) 185 (parent and parent.isValid())
168 or row < 0 186 or row < 0
169 or row >= len(self.watchpoints) 187 or row >= len(self.watchpoints)
176 194
177 def parent(self, index): # noqa: U100 195 def parent(self, index): # noqa: U100
178 """ 196 """
179 Public method to get the parent index. 197 Public method to get the parent index.
180 198
181 @param index index of item to get parent (QModelIndex) 199 @param index index of item to get parent
182 @return index of parent (QModelIndex) 200 @type QModelIndex
201 @return index of parent
202 @rtype QModelIndex
183 """ 203 """
184 return QModelIndex() 204 return QModelIndex()
185 205
186 def hasChildren(self, parent=None): 206 def hasChildren(self, parent=None):
187 """ 207 """
188 Public method to check for the presence of child items. 208 Public method to check for the presence of child items.
189 209
190 @param parent index of parent item (QModelIndex) 210 @param parent index of parent item
191 @return flag indicating the presence of child items (boolean) 211 @type QModelIndex
212 @return flag indicating the presence of child items
213 @rtype bool
192 """ 214 """
193 if parent is None or not parent.isValid(): 215 if parent is None or not parent.isValid():
194 return len(self.watchpoints) > 0 216 return len(self.watchpoints) > 0
195 else: 217 else:
196 return False 218 return False
230 252
231 def setWatchPointByIndex(self, index, cond, special, properties): 253 def setWatchPointByIndex(self, index, cond, special, properties):
232 """ 254 """
233 Public method to set the values of a watch expression given by index. 255 Public method to set the values of a watch expression given by index.
234 256
235 @param index index of the watch expression (QModelIndex) 257 @param index index of the watch expression
236 @param cond expression of the watch expression (string) 258 @type QModelIndex
237 @param special special condition of the watch expression (string) 259 @param cond expression of the watch expression
260 @type str
261 @param special special condition of the watch expression
262 @type str
238 @param properties properties of the watch expression 263 @param properties properties of the watch expression
239 (tuple of temporary flag (bool), enabled flag (bool), 264 (tuple of temporary flag, enabled flag, ignore count)
240 ignore count (integer)) 265 @type tuple of (bool, bool, int)
241 """ 266 """
242 if index.isValid(): 267 if index.isValid():
243 row = index.row() 268 row = index.row()
244 index1 = self.createIndex(row, 0, self.watchpoints[row]) 269 index1 = self.createIndex(row, 0, self.watchpoints[row])
245 index2 = self.createIndex( 270 index2 = self.createIndex(
252 def setWatchPointEnabledByIndex(self, index, enabled): 277 def setWatchPointEnabledByIndex(self, index, enabled):
253 """ 278 """
254 Public method to set the enabled state of a watch expression given by 279 Public method to set the enabled state of a watch expression given by
255 index. 280 index.
256 281
257 @param index index of the watch expression (QModelIndex) 282 @param index index of the watch expression
258 @param enabled flag giving the enabled state (boolean) 283 @type QModelIndex
284 @param enabled flag giving the enabled state
285 @type bool
259 """ 286 """
260 if index.isValid(): 287 if index.isValid():
261 row = index.row() 288 row = index.row()
262 col = 3 289 col = 3
263 index1 = self.createIndex(row, col, self.watchpoints[row]) 290 index1 = self.createIndex(row, col, self.watchpoints[row])
267 294
268 def deleteWatchPointByIndex(self, index): 295 def deleteWatchPointByIndex(self, index):
269 """ 296 """
270 Public method to set the values of a watch expression given by index. 297 Public method to set the values of a watch expression given by index.
271 298
272 @param index index of the watch expression (QModelIndex) 299 @param index index of the watch expression
300 @type QModelIndex
273 """ 301 """
274 if index.isValid(): 302 if index.isValid():
275 row = index.row() 303 row = index.row()
276 self.beginRemoveRows(QModelIndex(), row, row) 304 self.beginRemoveRows(QModelIndex(), row, row)
277 del self.watchpoints[row] 305 del self.watchpoints[row]
280 def deleteWatchPoints(self, idxList): 308 def deleteWatchPoints(self, idxList):
281 """ 309 """
282 Public method to delete a list of watch expressions given by their 310 Public method to delete a list of watch expressions given by their
283 indexes. 311 indexes.
284 312
285 @param idxList list of watch expression indexes (list of QModelIndex) 313 @param idxList list of watch expression indexes
314 @type list of QModelIndex
286 """ 315 """
287 rows = [] 316 rows = []
288 for index in idxList: 317 for index in idxList:
289 if index.isValid(): 318 if index.isValid():
290 rows.append(index.row()) 319 rows.append(index.row())
306 335
307 def getWatchPointByIndex(self, index): 336 def getWatchPointByIndex(self, index):
308 """ 337 """
309 Public method to get the values of a watch expression given by index. 338 Public method to get the values of a watch expression given by index.
310 339
311 @param index index of the watch expression (QModelIndex) 340 @param index index of the watch expression
312 @return watch expression (list of six values (expression, 341 @type QModelIndex
313 special condition, temporary flag, enabled flag, ignore count)) 342 @return watch expression (tuple containing expression, special condition,
343 temporary flag, enabled flag, ignore count)
314 @rtype tuple of (str, str, bool, bool, int) 344 @rtype tuple of (str, str, bool, bool, int)
315 """ 345 """
316 if index.isValid(): 346 if index.isValid():
317 return self.watchpoints[index.row()][:] # return a copy 347 return self.watchpoints[index.row()][:] # return a copy
318 else: 348 else:
330 def getWatchPointIndex(self, cond, special=""): 360 def getWatchPointIndex(self, cond, special=""):
331 """ 361 """
332 Public method to get the index of a watch expression given by 362 Public method to get the index of a watch expression given by
333 expression. 363 expression.
334 364
335 @param cond expression of the watch expression (string) 365 @param cond expression of the watch expression
336 @param special special condition of the watch expression (string) 366 @type str
337 @return index (QModelIndex) 367 @param special special condition of the watch expression
368 @type str
369 @return index
370 @rtype QModelIndex
338 """ 371 """
339 for row in range(len(self.watchpoints)): 372 for row in range(len(self.watchpoints)):
340 wp = self.watchpoints[row] 373 wp = self.watchpoints[row]
341 if wp[0] == cond: 374 if wp[0] == cond:
342 if special and wp[1] != special: 375 if special and wp[1] != special:

eric ide

mercurial