50 |
51 |
51 def setModel(self, model): |
52 def setModel(self, model): |
52 """ |
53 """ |
53 Public slot to set the watch expression model. |
54 Public slot to set the watch expression model. |
54 |
55 |
55 @param model reference to the watch expression model (WatchPointModel) |
56 @param model reference to the watch expression model |
|
57 @type WatchPointModel |
56 """ |
58 """ |
57 self.__model = model |
59 self.__model = model |
58 |
60 |
59 self.sortingModel = QSortFilterProxyModel() |
61 self.sortingModel = QSortFilterProxyModel() |
60 self.sortingModel.setDynamicSortFilter(True) |
62 self.sortingModel.setDynamicSortFilter(True) |
95 |
97 |
96 def __toSourceIndex(self, index): |
98 def __toSourceIndex(self, index): |
97 """ |
99 """ |
98 Private slot to convert an index to a source index. |
100 Private slot to convert an index to a source index. |
99 |
101 |
100 @param index index to be converted (QModelIndex) |
102 @param index index to be converted |
101 @return mapped index (QModelIndex) |
103 @type QModelIndex |
|
104 @return mapped index |
|
105 @rtype QModelIndex |
102 """ |
106 """ |
103 return self.sortingModel.mapToSource(index) |
107 return self.sortingModel.mapToSource(index) |
104 |
108 |
105 def __fromSourceIndex(self, sindex): |
109 def __fromSourceIndex(self, sindex): |
106 """ |
110 """ |
107 Private slot to convert a source index to an index. |
111 Private slot to convert a source index to an index. |
108 |
112 |
109 @param sindex source index to be converted (QModelIndex) |
113 @param sindex source index to be converted |
110 @return mapped index (QModelIndex) |
114 @type QModelIndex |
|
115 @return mapped index |
|
116 @rtype QModelIndex |
111 """ |
117 """ |
112 return self.sortingModel.mapFromSource(sindex) |
118 return self.sortingModel.mapFromSource(sindex) |
113 |
119 |
114 def __setRowSelected(self, index, selected=True): |
120 def __setRowSelected(self, index, selected=True): |
115 """ |
121 """ |
116 Private slot to select a complete row. |
122 Private slot to select a complete row. |
117 |
123 |
118 @param index index determining the row to be selected (QModelIndex) |
124 @param index index determining the row to be selected |
119 @param selected flag indicating the action (bool) |
125 @type QModelIndex |
|
126 @param selected flag indicating the action |
|
127 @type bool |
120 """ |
128 """ |
121 if not index.isValid(): |
129 if not index.isValid(): |
122 return |
130 return |
123 |
131 |
124 flags = ( |
132 flags = ( |
191 |
199 |
192 def __showContextMenu(self, coord): |
200 def __showContextMenu(self, coord): |
193 """ |
201 """ |
194 Private slot to show the context menu. |
202 Private slot to show the context menu. |
195 |
203 |
196 @param coord the position of the mouse pointer (QPoint) |
204 @param coord the position of the mouse pointer |
|
205 @type QPoint |
197 """ |
206 """ |
198 cnt = self.__getSelectedItemsCount() |
207 cnt = self.__getSelectedItemsCount() |
199 if cnt <= 1: |
208 if cnt <= 1: |
200 index = self.indexAt(coord) |
209 index = self.indexAt(coord) |
201 if index.isValid(): |
210 if index.isValid(): |
218 |
227 |
219 def __findDuplicates(self, cond, special, showMessage=False, index=None): |
228 def __findDuplicates(self, cond, special, showMessage=False, index=None): |
220 """ |
229 """ |
221 Private method to check, if an entry already exists. |
230 Private method to check, if an entry already exists. |
222 |
231 |
223 @param cond condition to check (string) |
232 @param cond condition to check |
224 @param special special condition to check (string) |
233 @type str |
|
234 @param special special condition to check |
|
235 @type str |
225 @param showMessage flag indicating a message should be shown, |
236 @param showMessage flag indicating a message should be shown, |
226 if a duplicate entry is found (boolean) |
237 if a duplicate entry is found |
|
238 @type bool |
227 @param index index that should not be considered duplicate |
239 @param index index that should not be considered duplicate |
228 (QModelIndex) |
240 @type QModelIndex |
229 @return flag indicating a duplicate entry (boolean) |
241 @return flag indicating a duplicate entry |
|
242 @rtype bool |
230 """ |
243 """ |
231 if index is None: |
244 if index is None: |
232 index = QModelIndex() |
245 index = QModelIndex() |
233 idx = self.__model.getWatchPointIndex(cond, special) |
246 idx = self.__model.getWatchPointIndex(cond, special) |
234 duplicate = idx.isValid() and idx.internalPointer() != index.internalPointer() |
247 duplicate = idx.isValid() and idx.internalPointer() != index.internalPointer() |
264 |
277 |
265 def __doubleClicked(self, index): |
278 def __doubleClicked(self, index): |
266 """ |
279 """ |
267 Private slot to handle the double clicked signal. |
280 Private slot to handle the double clicked signal. |
268 |
281 |
269 @param index index of the entry that was double clicked (QModelIndex) |
282 @param index index of the entry that was double clicked |
|
283 @type QModelIndex |
270 """ |
284 """ |
271 if index.isValid(): |
285 if index.isValid(): |
272 self.__doEditWatchPoint(index) |
286 self.__doEditWatchPoint(index) |
273 |
287 |
274 def __editWatchPoint(self): |
288 def __editWatchPoint(self): |
281 |
295 |
282 def __doEditWatchPoint(self, index): |
296 def __doEditWatchPoint(self, index): |
283 """ |
297 """ |
284 Private slot to edit a watch expression. |
298 Private slot to edit a watch expression. |
285 |
299 |
286 @param index index of watch expression to be edited (QModelIndex) |
300 @param index index of watch expression to be edited |
|
301 @type QModelIndex |
287 """ |
302 """ |
288 from .EditWatchpointDialog import EditWatchpointDialog |
303 from .EditWatchpointDialog import EditWatchpointDialog |
289 |
304 |
290 sindex = self.__toSourceIndex(index) |
305 sindex = self.__toSourceIndex(index) |
291 if sindex.isValid(): |
306 if sindex.isValid(): |
308 def __setWpEnabled(self, index, enabled): |
323 def __setWpEnabled(self, index, enabled): |
309 """ |
324 """ |
310 Private method to set the enabled status of a watch expression. |
325 Private method to set the enabled status of a watch expression. |
311 |
326 |
312 @param index index of watch expression to be enabled/disabled |
327 @param index index of watch expression to be enabled/disabled |
313 (QModelIndex) |
328 @type QModelIndex |
314 @param enabled flag indicating the enabled status to be set (boolean) |
329 @param enabled flag indicating the enabled status to be set |
|
330 @type bool |
315 """ |
331 """ |
316 sindex = self.__toSourceIndex(index) |
332 sindex = self.__toSourceIndex(index) |
317 if sindex.isValid(): |
333 if sindex.isValid(): |
318 self.__model.setWatchPointEnabledByIndex(sindex, enabled) |
334 self.__model.setWatchPointEnabledByIndex(sindex, enabled) |
319 |
335 |
424 |
440 |
425 def __getSelectedItemsCount(self): |
441 def __getSelectedItemsCount(self): |
426 """ |
442 """ |
427 Private method to get the count of items selected. |
443 Private method to get the count of items selected. |
428 |
444 |
429 @return count of items selected (integer) |
445 @return count of items selected |
|
446 @rtype int |
430 """ |
447 """ |
431 count = len(self.selectedIndexes()) // (self.__model.columnCount() - 1) |
448 count = len(self.selectedIndexes()) // (self.__model.columnCount() - 1) |
432 # column count is 1 greater than selectable |
449 # column count is 1 greater than selectable |
433 return count |
450 return count |
434 |
451 |