示例#1
0
    def paintEvent(self, event):
        """QWidget.paintEvent() implementation
        Draw markers
        """
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.palette().color(QPalette.Window))

        block = self._qpart.firstVisibleBlock()
        blockBoundingGeometry = self._qpart.blockBoundingGeometry(block).translated(self._qpart.contentOffset())
        top = blockBoundingGeometry.top()
        bottom = top + blockBoundingGeometry.height()

        for block in qutepart.iterateBlocksFrom(block):
            height = self._qpart.blockBoundingGeometry(block).height()
            if top > event.rect().bottom():
                break
            if block.isVisible() and \
               bottom >= event.rect().top():
                if block.blockNumber() in self._qpart.lintMarks:
                    msgType, msgText = self._qpart.lintMarks[block.blockNumber()]
                    pixMap = self._lintPixmaps[msgType]
                    yPos = top + ((height - pixMap.height()) / 2)  # centered
                    painter.drawPixmap(0, yPos, pixMap)

                if self.isBlockMarked(block):
                    yPos = top + ((height - self._bookmarkPixmap.height()) / 2)  # centered
                    painter.drawPixmap(0, yPos, self._bookmarkPixmap)

            top += height
示例#2
0
 def clear(self, startBlock, endBlock):
     """Clear bookmarks on block range including start and end
     """
     for block in qutepart.iterateBlocksFrom(startBlock):
         self._setBlockMarked(block, False)
         if block == endBlock:
             break
示例#3
0
 def clear(self, startBlock, endBlock):
     """Clear bookmarks on block range including start and end
     """
     for block in qutepart.iterateBlocksFrom(startBlock):
         self._setBlockMarked(block, False)
         if block == endBlock:
             break
示例#4
0
    def paintEvent(self, event):
        """QWidget.paintEvent() implementation
        Draw markers
        """
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.palette().color(QPalette.Window))

        block = self._qpart.firstVisibleBlock()
        blockBoundingGeometry = self._qpart.blockBoundingGeometry(block).translated(self._qpart.contentOffset())
        top = blockBoundingGeometry.top()
        bottom = top + blockBoundingGeometry.height()

        for block in qutepart.iterateBlocksFrom(block):
            height = self._qpart.blockBoundingGeometry(block).height()
            if top > event.rect().bottom():
                break
            if block.isVisible() and \
               bottom >= event.rect().top():
                if block.blockNumber() in self._qpart.lintMarks:
                    msgType, msgText = self._qpart.lintMarks[block.blockNumber()]
                    pixMap = self._lintPixmaps[msgType]
                    yPos = top + ((height - pixMap.height()) / 2)  # centered
                    painter.drawPixmap(0, yPos, pixMap)

                if Bookmarks.isBlockMarked(block):
                    yPos = top + ((height - self._bookmarkPixmap.height()) / 2)  # centered
                    painter.drawPixmap(0, yPos, self._bookmarkPixmap)

            top += height
示例#5
0
 def _onNextBookmark(self):
     """Previous Bookmark action triggered. Move cursor
     """
     for block in qutepart.iterateBlocksFrom(self._qpart.textCursor().block().next()):
         if self.isBlockMarked(block):
             self._qpart.setTextCursor(QTextCursor(block))
             return
示例#6
0
 def _onNextBookmark(self):
     """Previous Bookmark action triggered. Move cursor
     """
     for block in qutepart.iterateBlocksFrom(
             self._qpart.textCursor().block().next()):
         if self.isBlockMarked(block):
             self._qpart.setTextCursor(QTextCursor(block))
             return
示例#7
0
    def paintEvent(self, event):
        """Paints the margin"""
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.__bgColor)
        oneLineHeight = self._qpart.fontMetrics().height()

        block = self._qpart.firstVisibleBlock()
        geometry = self._qpart.blockBoundingGeometry(block)
        blockBoundingGeometry = geometry.translated(
            self._qpart.contentOffset())
        top = blockBoundingGeometry.top()
        # bottom = top + blockBoundingGeometry.height()

        for block in qutepart.iterateBlocksFrom(block):
            height = self._qpart.blockBoundingGeometry(block).height()
            if top > event.rect().bottom():
                break
            if block.isVisible():
                lineNo = block.blockNumber() + 1
                pixmap = None
                if lineNo == self.excptionLine:
                    pixmap = MARKS[self.EXC_MARK]
                elif lineNo == self.currentDebugLine:
                    pixmap = MARKS[self.CURRENT_MARK]
                elif self.isBlockMarked(block):
                    if lineNo in self.__ccMessages:
                        pixmap = MARKS[self.__ccMessages[lineNo][1]]
                    else:
                        pixmap = MARKS[self.FLAKES_MARK]

                if pixmap:
                    xPos = 0
                    yPos = top
                    pixmapSide = self.width()  # Pixmap is square!
                    if oneLineHeight >= pixmapSide:
                        # More than enough vertical space, width is fixed
                        yPos += math.ceil((oneLineHeight - pixmapSide) / 2)
                    else:
                        # Not enough vertical space, width is fixed
                        xPos += math.ceil((pixmapSide - oneLineHeight) / 2)
                        pixmapSide = oneLineHeight
                    painter.drawPixmap(xPos, yPos, pixmapSide, pixmapSide,
                                       pixmap)
            top += height
示例#8
0
    def paintEvent(self, event):
        """Paint the margin"""
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.__bgColor)
        oneLineHeight = self._qpart.fontMetrics().height()

        block = self._qpart.firstVisibleBlock()
        geometry = self._qpart.blockBoundingGeometry(block)
        blockBoundingGeometry = geometry.translated(
            self._qpart.contentOffset())
        top = blockBoundingGeometry.top()
        # bottom = top + blockBoundingGeometry.height()

        for block in qutepart.iterateBlocksFrom(block):
            height = self._qpart.blockBoundingGeometry(block).height()
            if top > event.rect().bottom():
                break
            if block.isVisible():
                # lineNo = block.blockNumber() + 1
                blockValue = self.getBlockValue(block)
                pixmap = None
                if blockValue != 0:
                    bpoint = self.__breakpoints[blockValue]
                    if not bpoint.isEnabled():
                        markType = self.DISABLED_BPOINT_MARK
                    elif bpoint.isTemporary():
                        markType = self.TMP_BPOINT_MARK
                    else:
                        markType = self.BPOINT_MARK
                    pixmap, edge = self.__marks[markType]

                if pixmap:
                    xPos = 0
                    yPos = top
                    if edge <= oneLineHeight:
                        yPos += math.ceil((oneLineHeight - edge) / 2)
                    else:
                        edge = oneLineHeight
                        xPos = math.ceil((self.width() - edge) / 2)
                    painter.drawPixmap(xPos, yPos, edge, edge, pixmap)
            top += height
示例#9
0
    def __onBlockCountChanged(self):
        """Number of lines in the file has changed"""
        if not self.__breakpoints:
            return

        oldSet = set(self.__breakpoints.keys())

        currentSet = set()
        currentHandleToLine = {}
        startBlock = self._qpart.document().firstBlock()
        for block in qutepart.iterateBlocksFrom(startBlock):
            handle = self.getBlockValue(block)
            if handle != 0:
                currentSet.add(handle)
                currentHandleToLine[handle] = block.blockNumber() + 1

        deletedHandles = oldSet - currentSet

        changedLineHandles = set()
        for cHandle, cLine in currentHandleToLine.items():
            if self.__breakpoints[cHandle].getLineNumber() != cLine:
                changedLineHandles.add(cHandle)

        if deletedHandles or changedLineHandles:
            fileName = self._qpart._parent.getFileName()
            model = self.__debugger.getBreakPointModel()

            for deletedHandle in deletedHandles:
                deletedBP = self.__breakpoints[deletedHandle]
                deletedLine = deletedBP.getLineNumber()
                del self.__breakpoints[deletedHandle]
                index = model.getBreakPointIndex(fileName, deletedLine)
                model.deleteBreakPointByIndex(index)

            for changedHandle in changedLineHandles:
                newLineNo = currentHandleToLine[changedHandle]
                self.__breakpoints[changedHandle].updateLineNumber(newLineNo)
                index = model.getBreakPointIndex(fileName, newLineNo)
                model.updateLineNumberByIndex(index, newLineNo)
示例#10
0
    def paintEvent(self, event):
        """Paints the margin"""
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.__bgColor)
        oneLineHeight = self._qpart.fontMetrics().height()

        block = self._qpart.firstVisibleBlock()
        geometry = self._qpart.blockBoundingGeometry(block)
        blockBoundingGeometry = geometry.translated(
            self._qpart.contentOffset())
        top = blockBoundingGeometry.top()
        # bottom = top + blockBoundingGeometry.height()

        for block in qutepart.iterateBlocksFrom(block):
            height = self._qpart.blockBoundingGeometry(block).height()
            if top > event.rect().bottom():
                break
            if block.isVisible():
                lineNo = block.blockNumber() + 1
                pixmap = None
                if lineNo == self.excptionLine:
                    pixmap, edge = self.__marks[self.EXC_MARK]
                elif lineNo == self.currentDebugLine:
                    pixmap, edge = self.__marks[self.CURRENT_MARK]
                elif self.isBlockMarked(block):
                    pixmap, edge = self.__marks[self.FLAKES_MARK]

                if pixmap:
                    xPos = 0
                    yPos = top
                    if edge <= oneLineHeight:
                        yPos += math.ceil((oneLineHeight - edge) / 2)
                    else:
                        edge = oneLineHeight
                        xPos = math.ceil((self.width() - edge) / 2)
                    painter.drawPixmap(xPos, yPos, edge, edge, pixmap)
            top += height
示例#11
0
 def _markedBlocks(self):
     bookMarksObject = self.qpart._bookmarks
     return [block.blockNumber() \
                 for block in iterateBlocksFrom(self.qpart.document().firstBlock()) \
                     if bookMarksObject.isBlockMarked(block)]
示例#12
0
 def _markedBlocks(self):
     bookMarksObject = self.qpart._bookmarks
     return [block.blockNumber() \
                 for block in iterateBlocksFrom(self.qpart.document().firstBlock()) \
                     if bookMarksObject.isBlockMarked(block)]