eric6/Debugger/WatchPointModel.py

branch
jsonfiles
changeset 8009
29818ac4853c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
equal deleted inserted replaced
8006:c4110b8b5931 8009:29818ac4853c
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the Watch expression model. 7 Module implementing the Watch expression model.
8 """ 8 """
9
10 import copy
9 11
10 from PyQt5.QtCore import pyqtSignal, Qt, QAbstractItemModel, QModelIndex 12 from PyQt5.QtCore import pyqtSignal, Qt, QAbstractItemModel, QModelIndex
11 13
12 14
13 class WatchPointModel(QAbstractItemModel): 15 class WatchPointModel(QAbstractItemModel):
167 169
168 def addWatchPoint(self, cond, special, properties): 170 def addWatchPoint(self, cond, special, properties):
169 """ 171 """
170 Public method to add a new watch expression to the list. 172 Public method to add a new watch expression to the list.
171 173
172 @param cond expression of the watch expression (string) 174 @param cond expression of the watch expression
173 @param special special condition of the watch expression (string) 175 @type str
176 @param special special condition of the watch expression
177 @type str
174 @param properties properties of the watch expression 178 @param properties properties of the watch expression
175 (tuple of temporary flag (bool), enabled flag (bool), 179 (tuple of temporary flag, enabled flag, ignore count)
176 ignore count (integer)) 180 @type tuple of (bool, bool, int)
177 """ 181 """
178 wp = [cond, special] + list(properties) 182 wp = [cond, special] + list(properties)
179 cnt = len(self.watchpoints) 183 cnt = len(self.watchpoints)
180 self.beginInsertRows(QModelIndex(), cnt, cnt) 184 self.beginInsertRows(QModelIndex(), cnt, cnt)
181 self.watchpoints.append(wp) 185 self.watchpoints.append(wp)
186 self.endInsertRows()
187
188 def addWatchPoints(self, watchpoints):
189 """
190 Public method to add multiple watch expressions to the list.
191
192 @param watchpoints list of watch expressions with expression, special
193 condition, temporary flag, enabled flag and ignore count each
194 @type list of (str, str, bool, bool, int)
195 """
196 cnt = len(self.watchpoints)
197 self.beginInsertRows(QModelIndex(), cnt, cnt + len(watchpoints) - 1)
198 self.watchpoints += watchpoints
182 self.endInsertRows() 199 self.endInsertRows()
183 200
184 def setWatchPointByIndex(self, index, cond, special, properties): 201 def setWatchPointByIndex(self, index, cond, special, properties):
185 """ 202 """
186 Public method to set the values of a watch expression given by index. 203 Public method to set the values of a watch expression given by index.
196 row = index.row() 213 row = index.row()
197 index1 = self.createIndex(row, 0, self.watchpoints[row]) 214 index1 = self.createIndex(row, 0, self.watchpoints[row])
198 index2 = self.createIndex( 215 index2 = self.createIndex(
199 row, len(self.watchpoints[row]), self.watchpoints[row]) 216 row, len(self.watchpoints[row]), self.watchpoints[row])
200 self.dataAboutToBeChanged.emit(index1, index2) 217 self.dataAboutToBeChanged.emit(index1, index2)
201 i = 0 218 self.watchpoints[row] = [cond, special] + list(properties)
202 for value in [cond, special] + list(properties):
203 self.watchpoints[row][i] = value
204 i += 1
205 self.dataChanged.emit(index1, index2) 219 self.dataChanged.emit(index1, index2)
206 220
207 def setWatchPointEnabledByIndex(self, index, enabled): 221 def setWatchPointEnabledByIndex(self, index, enabled):
208 """ 222 """
209 Public method to set the enabled state of a watch expression given by 223 Public method to set the enabled state of a watch expression given by
263 """ 277 """
264 Public method to get the values of a watch expression given by index. 278 Public method to get the values of a watch expression given by index.
265 279
266 @param index index of the watch expression (QModelIndex) 280 @param index index of the watch expression (QModelIndex)
267 @return watch expression (list of six values (expression, 281 @return watch expression (list of six values (expression,
268 special condition, temporary flag, enabled flag, ignore count, 282 special condition, temporary flag, enabled flag, ignore count))
269 index)) 283 @rtype tuple of (str, str, bool, bool, int)
270 """ 284 """
271 if index.isValid(): 285 if index.isValid():
272 return self.watchpoints[index.row()][:] # return a copy 286 return self.watchpoints[index.row()][:] # return a copy
273 else: 287 else:
274 return [] 288 return []
275 289
290 def getAllWatchpoints(self):
291 """
292 Public method to get the list of watchpoints.
293
294 @return list of watchpoints
295 @rtype list of list of [str, str, bool, bool, int]
296 """
297 return copy.deepcopy(self.watchpoints)
298
276 def getWatchPointIndex(self, cond, special=""): 299 def getWatchPointIndex(self, cond, special=""):
277 """ 300 """
278 Public method to get the index of a watch expression given by 301 Public method to get the index of a watch expression given by
279 expression. 302 expression.
280 303

eric ide

mercurial