def __init__(self, parent=None): Panel.__init__( self, self.IDENTIFIER, self.DESCRIPTION, parent) self.fold_indicators = [] self.setMouseTracking(True) self.logger = logging.getLogger( __name__ + "." + self.__class__.__name__)
def _onStateChanged(self, state): Panel._onStateChanged(self, state) if state is True: self.editor.codeEdit.visibleBlocksChanged.connect(self.update) self.editor.codeEdit.blockCountChanged.connect(self.updateGeometry) else: self.editor.codeEdit.visibleBlocksChanged.disconnect(self.update) self.editor.codeEdit.blockCountChanged.disconnect(self.updateGeometry)
def __init__(self, name, markersReadOnly=False, parent=None): Panel.__init__( self, name, "Display markers foreach line", parent) self.markers = [] #: prevent user from adding/removing markers with mouse click self.markersReadOnly = markersReadOnly self.setMouseTracking(True) self.timer = QTimer() self._tooltipPos = -1 self._prev_line = -1 self.logger = logging.getLogger( __name__ + "." + self.__class__.__name__)
def _onStateChanged(self, state): Panel._onStateChanged(self, state) if state is True: self.editor.codeEdit.visibleBlocksChanged.connect(self.update) self.editor.codeEdit.blockCountChanged.connect(self.__onBlockCountChanged) self.editor.codeEdit.newTextSet.connect(self.__onNewTextSet) self.editor.codeEdit.keyPressed.connect(self.__updateCursorPos) else: self.editor.codeEdit.visibleBlocksChanged.disconnect(self.update) self.editor.codeEdit.blockCountChanged.disconnect(self.__onBlockCountChanged) self.editor.codeEdit.newTextSet.disconnect(self.__onNewTextSet) self.editor.codeEdit.keyPressed.disconnect(self.__updateCursorPos)
def __init__(self, parent=None): Panel.__init__(self, "Search and replace", "The search and replace Panel", parent) self.ui = search_panel_ui.Ui_SearchPanel() self.ui.setupUi(self) self._decorations = [] self._numOccurrences = 0 self._processing = False self.numOccurrencesChanged.connect(self.__updateUi) self.ui.actionFindNext.triggered.connect(self.findNext) self.ui.actionFindPrevious.triggered.connect(self.findPrevious) self.ui.actionSearch.triggered.connect(self.showSearchPanel) self.ui.actionActionSearchAndReplace.triggered.connect(self.showSearchAndReplacePanel) self.hide() self.logger = logging.getLogger(__name__ + "." + self.__class__.__name__)
def paintEvent(self, event): """ Paints the widget """ if self.enabled is False: return Panel.paintEvent(self, event) painter = QPainter(self) painter.fillRect(event.rect(), self.back_brush) for vb in self.editor.codeEdit.visible_blocks: line = vb.row # paint marker for line marker = self.getIndicatorForLine(line) if marker is None: continue # use the normal pen to draw the fold indicator drawLines = False pen = self.normal_pen if marker.hover is True: pen = self.highlight_pen drawLines = True painter.setPen(pen) # get the text to draw txt = '-' if marker.folded is True: drawLines = False txt = '+' offset = 4 h = self.size_hint.height() fm = QFontMetricsF(self.editor.codeEdit.font()) hoffset = (fm.height() - h) / 2.0 r = QRect(vb.rect.x(), vb.rect.y() + hoffset, self.size_hint.width(), self.size_hint.height()) painter.setFont(self.font) painter.drawText(r, Qt.AlignVCenter | Qt.AlignHCenter, txt) w = self.size_hint.width() - 2 * offset h = self.size_hint.width() - 2 * offset hoffset = (fm.height() - h) / 2.0 r.setX(vb.rect.x() + offset) r.setY(vb.rect.y() + hoffset) r.setWidth(w) r.setHeight(h) painter.drawRect(r) if drawLines is True: top = (vb.rect.x() + self.size_hint.width() / 2.0, vb.rect.y() + hoffset + offset * 2) delta = ((marker.end - marker.start) * vb.height) # - (vb.rect.height() / 2.0) bottom = (top[0], top[1] + delta) painter.drawLine(top[0], top[1], bottom[0], bottom[1]) painter.drawLine(bottom[0], bottom[1], bottom[0] + self.size_hint.width() / 2.0, bottom[1]) return
def paintEvent(self, event): """ Paints the widgets: - paints the background - paint each visible blocks that intersects the widget bbox. """ painter = QPainter(self) painter.fillRect(event.rect(), self.back_brush) painter.setPen(self.text_pen) painter.setFont(self.font) w = self.width() - 2 # better name lookup speed painter_drawText = painter.drawText align_right = Qt.AlignRight normal_font = painter.font() normal_font.setBold(False) bold_font = QFont(normal_font) bold_font.setBold(True) active = self.editor.codeEdit.textCursor().blockNumber() for vb in self.editor.codeEdit.visible_blocks: row = vb.row if row == active + 1: painter.setFont(bold_font) else: painter.setFont(normal_font) painter_drawText(0, vb.top, w, vb.height, align_right, str(row)) return Panel.paintEvent(self, event)
def paintEvent(self, event): """ Paints the widget """ if self.enabled is False: return Panel.paintEvent(self, event) painter = QPainter(self) painter.fillRect(event.rect(), self.back_brush) for vb in self.editor.codeEdit.visible_blocks: l = vb.row marker = self.__getMarkerForLine(l) if marker: if marker.icon is not None: r = QRect() r.setX(vb.rect.x()) r.setY(vb.rect.y()) r.setWidth(self.size_hint.width()) r.setHeight(self.size_hint.height()) marker.icon.paint(painter, r) return
def install(self, editor): Panel.install(self, editor)
def __init__(self, parent=None): Panel.__init__( self, self.IDENTIFIER, "Display text line numbers", parent)
def install(self, editor): """ Install the Panel on the editor """ Panel.install(self, editor) self.__updateUi() self.__installActions()
def install(self, editor): Panel.install(self, editor) self.bc = self.editor.codeEdit.blockCount() self.__updateCursorPos()
def install(self, editor): """ Install the Panel on the editor """ Panel.install(self, editor) self.bc = self.editor.codeEdit.blockCount() self.__updateCursorPos()