--- a/eric6/Debugger/BreakPointModel.py Mon Feb 01 10:38:43 2021 +0100 +++ b/eric6/Debugger/BreakPointModel.py Tue Mar 02 17:12:08 2021 +0100 @@ -7,6 +7,8 @@ Module implementing the Breakpoint model. """ +import copy + from PyQt5.QtCore import pyqtSignal, Qt, QAbstractItemModel, QModelIndex @@ -19,15 +21,19 @@ """ dataAboutToBeChanged = pyqtSignal(QModelIndex, QModelIndex) - def __init__(self, parent=None): + def __init__(self, project, parent=None): """ Constructor + @param project reference to the project object + @type Project @param parent reference to the parent widget @type QObject """ super(BreakPointModel, self).__init__(parent) + self.__project = project + self.breakpoints = [] self.header = [ self.tr("Filename"), @@ -87,15 +93,21 @@ return None if role == Qt.DisplayRole: - if index.column() in [0, 1, 2, 5]: + if index.column() == 0: + filename = self.breakpoints[index.row()][0] + if self.__project.isOpen(): + return self.__project.getRelativePath(filename) + else: + return filename + elif index.column() in (1, 2, 5): return self.breakpoints[index.row()][index.column()] if role == Qt.CheckStateRole: - if index.column() in [3, 4]: + if index.column() in (3, 4): return self.breakpoints[index.row()][index.column()] if role == Qt.ToolTipRole: - if index.column() in [0, 2]: + if index.column() in (0, 2): return self.breakpoints[index.row()][index.column()] if role == Qt.TextAlignmentRole: @@ -227,6 +239,19 @@ self.breakpoints.append(bp) self.endInsertRows() + def addBreakPoints(self, breakpoints): + """ + Public method to add multiple breakpoints to the list. + + @param breakpoints list of breakpoints with file name, line number, + condition, temporary flag, enabled flag and ignore count each + @type list of (str, int, str, bool, bool, int) + """ + cnt = len(self.breakpoints) + self.beginInsertRows(QModelIndex(), cnt, cnt + len(breakpoints) - 1) + self.breakpoints += breakpoints + self.endInsertRows() + def setBreakPointByIndex(self, index, fn, line, properties): """ Public method to set the values of a breakpoint given by index. @@ -321,7 +346,16 @@ return self.breakpoints[index.row()][:] # return a copy else: return [] - + + def getAllBreakpoints(self): + """ + Public method to get a copy of the breakpoints. + + @return list of breakpoints + @rtype list of list of [str, int, str, bool, bool, int] + """ + return copy.deepcopy(self.breakpoints) + def getBreakPointIndex(self, fn, lineno): """ Public method to get the index of a breakpoint given by filename and