6 """ |
6 """ |
7 Module implementing the Breakpoint model. |
7 Module implementing the Breakpoint model. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import * |
10 from PyQt4.QtCore import * |
|
11 |
11 |
12 |
12 class BreakPointModel(QAbstractItemModel): |
13 class BreakPointModel(QAbstractItemModel): |
13 """ |
14 """ |
14 Class implementing a custom model for breakpoints. |
15 Class implementing a custom model for breakpoints. |
15 """ |
16 """ |
16 dataAboutToBeChanged = pyqtSignal(QModelIndex, QModelIndex) |
17 dataAboutToBeChanged = pyqtSignal(QModelIndex, QModelIndex) |
17 |
18 |
18 def __init__(self, parent = None): |
19 def __init__(self, parent=None): |
19 """ |
20 """ |
20 Constructor |
21 Constructor |
21 |
22 |
22 @param reference to the parent widget (QObject) |
23 @param reference to the parent widget (QObject) |
23 """ |
24 """ |
39 Qt.Alignment(Qt.AlignHCenter), |
40 Qt.Alignment(Qt.AlignHCenter), |
40 Qt.Alignment(Qt.AlignRight), |
41 Qt.Alignment(Qt.AlignRight), |
41 Qt.Alignment(Qt.AlignHCenter), |
42 Qt.Alignment(Qt.AlignHCenter), |
42 ] |
43 ] |
43 |
44 |
44 def columnCount(self, parent = QModelIndex()): |
45 def columnCount(self, parent=QModelIndex()): |
45 """ |
46 """ |
46 Public method to get the current column count. |
47 Public method to get the current column count. |
47 |
48 |
48 @return column count (integer) |
49 @return column count (integer) |
49 """ |
50 """ |
50 return len(self.header) |
51 return len(self.header) |
51 |
52 |
52 def rowCount(self, parent = QModelIndex()): |
53 def rowCount(self, parent=QModelIndex()): |
53 """ |
54 """ |
54 Public method to get the current row count. |
55 Public method to get the current row count. |
55 |
56 |
56 @return row count (integer) |
57 @return row count (integer) |
57 """ |
58 """ |
100 if not index.isValid(): |
101 if not index.isValid(): |
101 return Qt.ItemIsEnabled |
102 return Qt.ItemIsEnabled |
102 |
103 |
103 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
104 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
104 |
105 |
105 def headerData(self, section, orientation, role = Qt.DisplayRole): |
106 def headerData(self, section, orientation, role=Qt.DisplayRole): |
106 """ |
107 """ |
107 Public method to get header data. |
108 Public method to get header data. |
108 |
109 |
109 @param section section number of the requested header data (integer) |
110 @param section section number of the requested header data (integer) |
110 @param orientation orientation of the header (Qt.Orientation) |
111 @param orientation orientation of the header (Qt.Orientation) |
117 else: |
118 else: |
118 return self.header[section] |
119 return self.header[section] |
119 |
120 |
120 return None |
121 return None |
121 |
122 |
122 def index(self, row, column, parent = QModelIndex()): |
123 def index(self, row, column, parent=QModelIndex()): |
123 """ |
124 """ |
124 Public method to create an index. |
125 Public method to create an index. |
125 |
126 |
126 @param row row number for the index (integer) |
127 @param row row number for the index (integer) |
127 @param column column number for the index (integer) |
128 @param column column number for the index (integer) |
142 @param index index of item to get parent (QModelIndex) |
143 @param index index of item to get parent (QModelIndex) |
143 @return index of parent (QModelIndex) |
144 @return index of parent (QModelIndex) |
144 """ |
145 """ |
145 return QModelIndex() |
146 return QModelIndex() |
146 |
147 |
147 def hasChildren(self, parent = QModelIndex()): |
148 def hasChildren(self, parent=QModelIndex()): |
148 """ |
149 """ |
149 Public method to check for the presence of child items. |
150 Public method to check for the presence of child items. |
150 |
151 |
151 @param parent index of parent item (QModelIndex) |
152 @param parent index of parent item (QModelIndex) |
152 @return flag indicating the presence of child items (boolean) |
153 @return flag indicating the presence of child items (boolean) |
163 Public method to add a new breakpoint to the list. |
164 Public method to add a new breakpoint to the list. |
164 |
165 |
165 @param fn filename of the breakpoint (string) |
166 @param fn filename of the breakpoint (string) |
166 @param line line number of the breakpoint (integer) |
167 @param line line number of the breakpoint (integer) |
167 @param properties properties of the breakpoint |
168 @param properties properties of the breakpoint |
168 (tuple of condition (string), temporary flag (bool), |
169 (tuple of condition (string), temporary flag (bool), |
169 enabled flag (bool), ignore count (integer)) |
170 enabled flag (bool), ignore count (integer)) |
170 """ |
171 """ |
171 bp = [fn, line] + list(properties) |
172 bp = [fn, line] + list(properties) |
172 cnt = len(self.breakpoints) |
173 cnt = len(self.breakpoints) |
173 self.beginInsertRows(QModelIndex(), cnt, cnt) |
174 self.beginInsertRows(QModelIndex(), cnt, cnt) |
180 |
181 |
181 @param index index of the breakpoint (QModelIndex) |
182 @param index index of the breakpoint (QModelIndex) |
182 @param fn filename of the breakpoint (string) |
183 @param fn filename of the breakpoint (string) |
183 @param line line number of the breakpoint (integer) |
184 @param line line number of the breakpoint (integer) |
184 @param properties properties of the breakpoint |
185 @param properties properties of the breakpoint |
185 (tuple of condition (string), temporary flag (bool), |
186 (tuple of condition (string), temporary flag (bool), |
186 enabled flag (bool), ignore count (integer)) |
187 enabled flag (bool), ignore count (integer)) |
187 """ |
188 """ |
188 if index.isValid(): |
189 if index.isValid(): |
189 row = index.row() |
190 row = index.row() |
190 index1 = self.createIndex(row, 0, self.breakpoints[row]) |
191 index1 = self.createIndex(row, 0, self.breakpoints[row]) |
191 index2 = self.createIndex(row, len(self.breakpoints[row]), |
192 index2 = self.createIndex(row, len(self.breakpoints[row]), |
192 self.breakpoints[row]) |
193 self.breakpoints[row]) |
193 self.dataAboutToBeChanged.emit(index1, index2) |
194 self.dataAboutToBeChanged.emit(index1, index2) |
194 i = 0 |
195 i = 0 |
195 for value in [fn, line] + list(properties): |
196 for value in [fn, line] + list(properties): |
196 self.breakpoints[row][i] = value |
197 self.breakpoints[row][i] = value |
232 """ |
233 """ |
233 rows = [] |
234 rows = [] |
234 for index in idxList: |
235 for index in idxList: |
235 if index.isValid(): |
236 if index.isValid(): |
236 rows.append(index.row()) |
237 rows.append(index.row()) |
237 rows.sort(reverse = True) |
238 rows.sort(reverse=True) |
238 for row in rows: |
239 for row in rows: |
239 self.beginRemoveRows(QModelIndex(), row, row) |
240 self.beginRemoveRows(QModelIndex(), row, row) |
240 del self.breakpoints[row] |
241 del self.breakpoints[row] |
241 self.endRemoveRows() |
242 self.endRemoveRows() |
242 |
243 |
256 @param index index of the breakpoint (QModelIndex) |
257 @param index index of the breakpoint (QModelIndex) |
257 @return breakpoint (list of seven values (filename, line number, |
258 @return breakpoint (list of seven values (filename, line number, |
258 condition, temporary flag, enabled flag, ignore count)) |
259 condition, temporary flag, enabled flag, ignore count)) |
259 """ |
260 """ |
260 if index.isValid(): |
261 if index.isValid(): |
261 return self.breakpoints[index.row()][:] # return a copy |
262 return self.breakpoints[index.row()][:] # return a copy |
262 else: |
263 else: |
263 return [] |
264 return [] |
264 |
265 |
265 def getBreakPointIndex(self, fn, lineno): |
266 def getBreakPointIndex(self, fn, lineno): |
266 """ |
267 """ |
282 Public method to test, if a breakpoint given by it's index is temporary. |
283 Public method to test, if a breakpoint given by it's index is temporary. |
283 |
284 |
284 @param index index of the breakpoint to test (QModelIndex) |
285 @param index index of the breakpoint to test (QModelIndex) |
285 @return flag indicating a temporary breakpoint (boolean) |
286 @return flag indicating a temporary breakpoint (boolean) |
286 """ |
287 """ |
287 if index.isValid(): |
288 if index.isValid(): |
288 return self.breakpoints[index.row()][3] |
289 return self.breakpoints[index.row()][3] |
289 else: |
290 else: |
290 return False |
291 return False |