Example #1
0
 def index(self, row, column, parent=QModelIndex()):
     """Creates the index"""
     if parent.isValid() or \
        row < 0 or row >= len(self.watchpoints) or \
        column < 0 or column >= len(self.header):
         return QModelIndex()
     return self.createIndex(row, column, self.watchpoints[row])
 def addBreakpoint(self, bpoint):
     """Adds a new breakpoint to the list"""
     cnt = len(self.breakpoints)
     self.beginInsertRows(QModelIndex(), cnt, cnt)
     self.breakpoints.append(bpoint)
     self.endInsertRows()
     self.sigBreakpoinsChanged.emit()
 def deleteAll(self):
     """Deletes all breakpoints"""
     if self.breakpoints:
         self.beginRemoveRows(QModelIndex(), 0, len(self.breakpoints) - 1)
         self.breakpoints = []
         self.endRemoveRows()
         self.sigBreakpoinsChanged.emit()
Example #4
0
 def deleteWatchPointByIndex(self, index):
     """Sets the values of a watch expression given by index"""
     if index.isValid():
         row = index.row()
         self.beginRemoveRows(QModelIndex(), row, row)
         del self.watchpoints[row]
         self.endRemoveRows()
Example #5
0
 def addWatchPoint(self, cond, special, properties):
     """Adds a new watch expression to the list"""
     wpoint = [cond, special] + list(properties)
     cnt = len(self.watchpoints)
     self.beginInsertRows(QModelIndex(), cnt, cnt)
     self.watchpoints.append(wpoint)
     self.endInsertRows()
Example #6
0
 def selectionChanged(self, selected, deselected):
     """The slot is called when the selection has changed"""
     if selected.indexes():
         self.sigSelectionChanged.emit(selected.indexes()[0])
     else:
         self.sigSelectionChanged.emit(QModelIndex())
     QTreeView.selectionChanged(self, selected, deselected)
 def deleteBreakPointByIndex(self, index):
     """Deletes the breakpoint by its index"""
     if index.isValid():
         row = index.row()
         self.beginRemoveRows(QModelIndex(), row, row)
         del self.breakpoints[row]
         self.endRemoveRows()
         self.sigBreakpoinsChanged.emit()
 def getBreakPointIndex(self, fname, lineno):
     """Provides an index of a breakpoint"""
     for row in range(len(self.breakpoints)):
         bpoint = self.breakpoints[row]
         if bpoint.getAbsoluteFileName() == fname and \
            bpoint.getLineNumber() == lineno:
             return self.createIndex(row, 0, self.breakpoints[row])
     return QModelIndex()
    def index(self, row, column, parent=None):
        """Creates an index"""
        if (parent and parent.isValid()) or \
           row < 0 or row >= len(self.breakpoints) or \
           column < 0 or column >= self.__columnCount:
            return QModelIndex()

        return self.createIndex(row, column, self.breakpoints[row])
Example #10
0
 def getWatchPointIndex(self, cond, special=""):
     """Provides the index of a watch expression given by expression"""
     for row in range(len(self.watchpoints)):
         wpoint = self.watchpoints[row]
         if wpoint[0] == cond:
             if special and wpoint[1] != special:
                 continue
             return self.createIndex(row, 0, self.watchpoints[row])
     return QModelIndex()
Example #11
0
 def deleteWatchPoints(self, idxList):
     """Deletes a list of watch expressions given by their indexes"""
     rows = []
     for index in idxList:
         if index.isValid():
             rows.append(index.row())
     rows.sort(reverse=True)
     for row in rows:
         self.beginRemoveRows(QModelIndex(), row, row)
         del self.watchpoints[row]
         self.endRemoveRows()
Example #12
0
 def restoreBreakpoints(self):
     """Restores the breakpoints"""
     for _, bpoint in self.__breakpoints.items():
         line = bpoint.getLineNumber()
         self.setBlockValue(
             self._qpart.document().findBlockByNumber(line - 1), 0)
     self.__breakpoints = {}
     self.__addBreakPoints(
         QModelIndex(), 0,
         self.__debugger.getBreakPointModel().rowCount() - 1)
     self.validateBreakpoints()
     self.update()
 def deleteBreakPoints(self, idxList):
     """Deletes a list of breakpoints"""
     rows = []
     for index in idxList:
         if index.isValid():
             rows.append(index.row())
     rows.sort(reverse=True)
     for row in rows:
         self.beginRemoveRows(QModelIndex(), row, row)
         del self.breakpoints[row]
         self.endRemoveRows()
     self.sigBreakpoinsChanged.emit()
Example #14
0
 def __findDuplicates(self,
                      cond,
                      special,
                      showMessage=False,
                      index=QModelIndex()):
     """Checks if an entry already exists"""
     idx = self.__model.getWatchPointIndex(cond, special)
     duplicate = idx.isValid(
     ) and idx.internalPointer() != index.internalPointer()
     #        if showMessage and duplicate:
     #            if not special:
     #                msg = """<p>A watch expression '<b>%1</b>'"""
     #                                  """ already exists.</p>""".arg(Utilities.html_encode(unicode(cond)))
     #            else:
     #                msg = self.trUtf8("""<p>A watch expression '<b>%1</b>'"""
     #                                  """ for the variable <b>%2</b> already exists.</p>""")\
     #                        .arg(special)\
     #                        .arg(Utilities.html_encode(unicode(cond)))
     #            KQMessageBox.warning(None,
     #                "Watch expression already exists", msg)
     return duplicate
Example #15
0
    def __validateBreakpoints(self):
        """Checks all the breakpoints validity and deletes invalid"""
        # It is excepted that the method is called when all the files are
        # saved, e.g. when a new debugging session is started.
        for row in range(0, self.__breakpointModel.rowCount()):
            index = self.__breakpointModel.index(row, 0, QModelIndex())
            bpoint = self.__breakpointModel.getBreakPointByIndex(index)
            fileName = bpoint.getAbsoluteFileName()
            line = bpoint.getLineNumber()

            if not os.path.exists(fileName):
                logging.warning("Breakpoint at " + fileName + ":" + str(line) +
                                " is invalid (the file "
                                "disappeared from the filesystem). "
                                "The breakpoint is deleted.")
                self.__breakpointModel.deleteBreakPointByIndex(index)
                continue

            breakableLines = getBreakpointLines(fileName, None, True)
            if breakableLines is None:
                logging.warning("Breakpoint at " + fileName + ":" + str(line) +
                                " does not point to a breakable "
                                "line (the file could not be compiled). "
                                "The breakpoint is deleted.")
                self.__breakpointModel.deleteBreakPointByIndex(index)
                continue
            if line not in breakableLines:
                logging.warning("Breakpoint at " + fileName + ":" + str(line) +
                                " does not point to a breakable "
                                "line (the file was modified). "
                                "The breakpoint is deleted.")
                self.__breakpointModel.deleteBreakPointByIndex(index)
                continue

            # The breakpoint is OK, keep it
        return
Example #16
0
 def deleteAll(self):
     """Deletes all watch expressions"""
     if self.watchpoints:
         self.beginRemoveRows(QModelIndex(), 0, len(self.watchpoints) - 1)
         self.watchpoints = []
         self.endRemoveRows()
Example #17
0
 def rowCount(self, parent=QModelIndex()):
     """Provides the current row count"""
     # we do not have a tree, parent should always be invalid
     if not parent.isValid():
         return len(self.watchpoints)
     return 0
Example #18
0
 def columnCount(self, parent=QModelIndex()):
     """Provides the current column count"""
     return len(self.header) + 1
Example #19
0
 def hasChildren(self, parent=QModelIndex()):
     """True if has children"""
     if not parent.isValid():
         return len(self.watchpoints) > 0
     return False
Example #20
0
 def __sendBreakpoints(self):
     """Sends the breakpoints to the debugged program"""
     self.__validateBreakpoints()
     self.__addBreakPoints(QModelIndex(), 0,
                           self.__breakpointModel.rowCount() - 1)
 def parent(self, index):
     """Provides the parent index"""
     return QModelIndex()
Example #22
0
 def __breakPointDataAboutToBeChanged(self, startIndex, endIndex):
     """Handles the sigDataAboutToBeChanged signal of the bpoint model"""
     self.__deleteBreakPoints(QModelIndex(), startIndex.row(),
                              endIndex.row())
Example #23
0
 def __changeBreakPoints(self, startIndex, endIndex):
     """Sets changed breakpoints"""
     self.__addBreakPoints(QModelIndex(), startIndex.row(), endIndex.row())