6 """ |
6 """ |
7 Module implementing the Watch expression model. |
7 Module implementing the Watch expression model. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import * |
10 from PyQt4.QtCore import * |
|
11 |
11 |
12 |
12 class WatchPointModel(QAbstractItemModel): |
13 class WatchPointModel(QAbstractItemModel): |
13 """ |
14 """ |
14 Class implementing a custom model for watch expressions. |
15 Class implementing a custom model for watch expressions. |
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 """ |
36 Qt.Alignment(Qt.AlignHCenter), |
37 Qt.Alignment(Qt.AlignHCenter), |
37 Qt.Alignment(Qt.AlignHCenter), |
38 Qt.Alignment(Qt.AlignHCenter), |
38 Qt.Alignment(Qt.AlignRight), |
39 Qt.Alignment(Qt.AlignRight), |
39 ] |
40 ] |
40 |
41 |
41 def columnCount(self, parent = QModelIndex()): |
42 def columnCount(self, parent=QModelIndex()): |
42 """ |
43 """ |
43 Public method to get the current column count. |
44 Public method to get the current column count. |
44 |
45 |
45 @return column count (integer) |
46 @return column count (integer) |
46 """ |
47 """ |
47 return len(self.header) |
48 return len(self.header) |
48 |
49 |
49 def rowCount(self, parent = QModelIndex()): |
50 def rowCount(self, parent=QModelIndex()): |
50 """ |
51 """ |
51 Public method to get the current row count. |
52 Public method to get the current row count. |
52 |
53 |
53 @return row count (integer) |
54 @return row count (integer) |
54 """ |
55 """ |
97 if not index.isValid(): |
98 if not index.isValid(): |
98 return Qt.ItemIsEnabled |
99 return Qt.ItemIsEnabled |
99 |
100 |
100 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
101 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
101 |
102 |
102 def headerData(self, section, orientation, role = Qt.DisplayRole): |
103 def headerData(self, section, orientation, role=Qt.DisplayRole): |
103 """ |
104 """ |
104 Public method to get header data. |
105 Public method to get header data. |
105 |
106 |
106 @param section section number of the requested header data (integer) |
107 @param section section number of the requested header data (integer) |
107 @param orientation orientation of the header (Qt.Orientation) |
108 @param orientation orientation of the header (Qt.Orientation) |
114 else: |
115 else: |
115 return self.header[section] |
116 return self.header[section] |
116 |
117 |
117 return None |
118 return None |
118 |
119 |
119 def index(self, row, column, parent = QModelIndex()): |
120 def index(self, row, column, parent=QModelIndex()): |
120 """ |
121 """ |
121 Public method to create an index. |
122 Public method to create an index. |
122 |
123 |
123 @param row row number for the index (integer) |
124 @param row row number for the index (integer) |
124 @param column column number for the index (integer) |
125 @param column column number for the index (integer) |
139 @param index index of item to get parent (QModelIndex) |
140 @param index index of item to get parent (QModelIndex) |
140 @return index of parent (QModelIndex) |
141 @return index of parent (QModelIndex) |
141 """ |
142 """ |
142 return QModelIndex() |
143 return QModelIndex() |
143 |
144 |
144 def hasChildren(self, parent = QModelIndex()): |
145 def hasChildren(self, parent=QModelIndex()): |
145 """ |
146 """ |
146 Public method to check for the presence of child items. |
147 Public method to check for the presence of child items. |
147 |
148 |
148 @param parent index of parent item (QModelIndex) |
149 @param parent index of parent item (QModelIndex) |
149 @return flag indicating the presence of child items (boolean) |
150 @return flag indicating the presence of child items (boolean) |
181 (tuple of temporary flag (bool), enabled flag (bool), ignore count (integer)) |
182 (tuple of temporary flag (bool), enabled flag (bool), ignore count (integer)) |
182 """ |
183 """ |
183 if index.isValid(): |
184 if index.isValid(): |
184 row = index.row() |
185 row = index.row() |
185 index1 = self.createIndex(row, 0, self.watchpoints[row]) |
186 index1 = self.createIndex(row, 0, self.watchpoints[row]) |
186 index2 = self.createIndex(row, len(self.watchpoints[row]), |
187 index2 = self.createIndex(row, len(self.watchpoints[row]), |
187 self.watchpoints[row]) |
188 self.watchpoints[row]) |
188 self.dataAboutToBeChanged.emit(index1, index2) |
189 self.dataAboutToBeChanged.emit(index1, index2) |
189 i = 0 |
190 i = 0 |
190 for value in [cond, special] + list(properties): |
191 for value in [cond, special] + list(properties): |
191 self.watchpoints[row][i] = value |
192 self.watchpoints[row][i] = value |
227 """ |
228 """ |
228 rows = [] |
229 rows = [] |
229 for index in idxList: |
230 for index in idxList: |
230 if index.isValid(): |
231 if index.isValid(): |
231 rows.append(index.row()) |
232 rows.append(index.row()) |
232 rows.sort(reverse = True) |
233 rows.sort(reverse=True) |
233 for row in rows: |
234 for row in rows: |
234 self.beginRemoveRows(QModelIndex(), row, row) |
235 self.beginRemoveRows(QModelIndex(), row, row) |
235 del self.watchpoints[row] |
236 del self.watchpoints[row] |
236 self.endRemoveRows() |
237 self.endRemoveRows() |
237 |
238 |
251 @param index index of the watch expression (QModelIndex) |
252 @param index index of the watch expression (QModelIndex) |
252 @return watch expression (list of six values (expression, special condition, |
253 @return watch expression (list of six values (expression, special condition, |
253 temporary flag, enabled flag, ignore count, index)) |
254 temporary flag, enabled flag, ignore count, index)) |
254 """ |
255 """ |
255 if index.isValid(): |
256 if index.isValid(): |
256 return self.watchpoints[index.row()][:] # return a copy |
257 return self.watchpoints[index.row()][:] # return a copy |
257 else: |
258 else: |
258 return [] |
259 return [] |
259 |
260 |
260 def getWatchPointIndex(self, cond, special = ""): |
261 def getWatchPointIndex(self, cond, special=""): |
261 """ |
262 """ |
262 Public method to get the index of a watch expression given by expression. |
263 Public method to get the index of a watch expression given by expression. |
263 |
264 |
264 @param cond expression of the watch expression (string) |
265 @param cond expression of the watch expression (string) |
265 @param special special condition of the watch expression (string) |
266 @param special special condition of the watch expression (string) |