10 import copy |
10 import copy |
11 |
11 |
12 from PyQt6.QtCore import pyqtSignal, Qt, QAbstractItemModel, QModelIndex |
12 from PyQt6.QtCore import pyqtSignal, Qt, QAbstractItemModel, QModelIndex |
13 |
13 |
14 |
14 |
|
15 # TODO: change column numbers to class attributes |
15 class BreakPointModel(QAbstractItemModel): |
16 class BreakPointModel(QAbstractItemModel): |
16 """ |
17 """ |
17 Class implementing a custom model for breakpoints. |
18 Class implementing a custom model for breakpoints. |
18 |
19 |
19 @signal dataAboutToBeChanged(QModelIndex, QModelIndex) emitted to indicate |
20 @signal dataAboutToBeChanged(QModelIndex, QModelIndex) emitted to indicate |
104 |
105 |
105 if ( |
106 if ( |
106 role == Qt.ItemDataRole.CheckStateRole and |
107 role == Qt.ItemDataRole.CheckStateRole and |
107 index.column() in (3, 4) |
108 index.column() in (3, 4) |
108 ): |
109 ): |
109 return self.breakpoints[index.row()][index.column()] |
110 if self.breakpoints[index.row()][index.column()]: |
|
111 return Qt.CheckState.Checked |
|
112 else: |
|
113 return Qt.CheckState.Unchecked |
110 |
114 |
111 if ( |
115 if ( |
112 role == Qt.ItemDataRole.ToolTipRole and |
116 role == Qt.ItemDataRole.ToolTipRole and |
113 index.column() in (0, 2) |
117 index.column() in (0, 2) |
114 ): |
118 ): |
278 """ |
282 """ |
279 if index.isValid(): |
283 if index.isValid(): |
280 row = index.row() |
284 row = index.row() |
281 index1 = self.createIndex(row, 0, self.breakpoints[row]) |
285 index1 = self.createIndex(row, 0, self.breakpoints[row]) |
282 index2 = self.createIndex( |
286 index2 = self.createIndex( |
283 row, len(self.breakpoints[row]), self.breakpoints[row]) |
287 row, len(self.breakpoints[row]) - 1, self.breakpoints[row]) |
284 self.dataAboutToBeChanged.emit(index1, index2) |
288 self.dataAboutToBeChanged.emit(index1, index2) |
285 self.breakpoints[row] = [fn, line] + list(properties) |
289 self.breakpoints[row] = [fn, line] + list(properties) |
286 self.dataChanged.emit(index1, index2) |
290 self.dataChanged.emit(index1, index2) |
287 |
291 |
288 def setBreakPointEnabledByIndex(self, index, enabled): |
292 def setBreakPointEnabledByIndex(self, index, enabled): |