17 @signal dataAboutToBeChanged(QModelIndex, QModelIndex) emitted to indicate |
19 @signal dataAboutToBeChanged(QModelIndex, QModelIndex) emitted to indicate |
18 a change of the data |
20 a change of the data |
19 """ |
21 """ |
20 dataAboutToBeChanged = pyqtSignal(QModelIndex, QModelIndex) |
22 dataAboutToBeChanged = pyqtSignal(QModelIndex, QModelIndex) |
21 |
23 |
22 def __init__(self, parent=None): |
24 def __init__(self, project, parent=None): |
23 """ |
25 """ |
24 Constructor |
26 Constructor |
25 |
27 |
|
28 @param project reference to the project object |
|
29 @type Project |
26 @param parent reference to the parent widget |
30 @param parent reference to the parent widget |
27 @type QObject |
31 @type QObject |
28 """ |
32 """ |
29 super(BreakPointModel, self).__init__(parent) |
33 super(BreakPointModel, self).__init__(parent) |
|
34 |
|
35 self.__project = project |
30 |
36 |
31 self.breakpoints = [] |
37 self.breakpoints = [] |
32 self.header = [ |
38 self.header = [ |
33 self.tr("Filename"), |
39 self.tr("Filename"), |
34 self.tr("Line"), |
40 self.tr("Line"), |
85 """ |
91 """ |
86 if not index.isValid(): |
92 if not index.isValid(): |
87 return None |
93 return None |
88 |
94 |
89 if role == Qt.DisplayRole: |
95 if role == Qt.DisplayRole: |
90 if index.column() in [0, 1, 2, 5]: |
96 if index.column() == 0: |
|
97 filename = self.breakpoints[index.row()][0] |
|
98 if self.__project.isOpen(): |
|
99 return self.__project.getRelativePath(filename) |
|
100 else: |
|
101 return filename |
|
102 elif index.column() in (1, 2, 5): |
91 return self.breakpoints[index.row()][index.column()] |
103 return self.breakpoints[index.row()][index.column()] |
92 |
104 |
93 if role == Qt.CheckStateRole: |
105 if role == Qt.CheckStateRole: |
94 if index.column() in [3, 4]: |
106 if index.column() in (3, 4): |
95 return self.breakpoints[index.row()][index.column()] |
107 return self.breakpoints[index.row()][index.column()] |
96 |
108 |
97 if role == Qt.ToolTipRole: |
109 if role == Qt.ToolTipRole: |
98 if index.column() in [0, 2]: |
110 if index.column() in (0, 2): |
99 return self.breakpoints[index.row()][index.column()] |
111 return self.breakpoints[index.row()][index.column()] |
100 |
112 |
101 if role == Qt.TextAlignmentRole: |
113 if role == Qt.TextAlignmentRole: |
102 if index.column() < len(self.alignments): |
114 if index.column() < len(self.alignments): |
103 return self.alignments[index.column()] |
115 return self.alignments[index.column()] |
223 """ |
235 """ |
224 bp = [fn, line] + list(properties) |
236 bp = [fn, line] + list(properties) |
225 cnt = len(self.breakpoints) |
237 cnt = len(self.breakpoints) |
226 self.beginInsertRows(QModelIndex(), cnt, cnt) |
238 self.beginInsertRows(QModelIndex(), cnt, cnt) |
227 self.breakpoints.append(bp) |
239 self.breakpoints.append(bp) |
|
240 self.endInsertRows() |
|
241 |
|
242 def addBreakPoints(self, breakpoints): |
|
243 """ |
|
244 Public method to add multiple breakpoints to the list. |
|
245 |
|
246 @param breakpoints list of breakpoints with file name, line number, |
|
247 condition, temporary flag, enabled flag and ignore count each |
|
248 @type list of (str, int, str, bool, bool, int) |
|
249 """ |
|
250 cnt = len(self.breakpoints) |
|
251 self.beginInsertRows(QModelIndex(), cnt, cnt + len(breakpoints) - 1) |
|
252 self.breakpoints += breakpoints |
228 self.endInsertRows() |
253 self.endInsertRows() |
229 |
254 |
230 def setBreakPointByIndex(self, index, fn, line, properties): |
255 def setBreakPointByIndex(self, index, fn, line, properties): |
231 """ |
256 """ |
232 Public method to set the values of a breakpoint given by index. |
257 Public method to set the values of a breakpoint given by index. |
319 """ |
344 """ |
320 if index.isValid(): |
345 if index.isValid(): |
321 return self.breakpoints[index.row()][:] # return a copy |
346 return self.breakpoints[index.row()][:] # return a copy |
322 else: |
347 else: |
323 return [] |
348 return [] |
324 |
349 |
|
350 def getAllBreakpoints(self): |
|
351 """ |
|
352 Public method to get a copy of the breakpoints. |
|
353 |
|
354 @return list of breakpoints |
|
355 @rtype list of list of [str, int, str, bool, bool, int] |
|
356 """ |
|
357 return copy.deepcopy(self.breakpoints) |
|
358 |
325 def getBreakPointIndex(self, fn, lineno): |
359 def getBreakPointIndex(self, fn, lineno): |
326 """ |
360 """ |
327 Public method to get the index of a breakpoint given by filename and |
361 Public method to get the index of a breakpoint given by filename and |
328 line number. |
362 line number. |
329 |
363 |