Mercurial > lcfOS
diff python/codeeditor.py @ 154:81e08e2e7777
Used error icon
author | Windel Bouwman |
---|---|
date | Sat, 02 Mar 2013 10:19:38 +0100 |
parents | af0d7913677a |
children | d8c735dc31f9 |
line wrap: on
line diff
--- a/python/codeeditor.py Sat Mar 02 09:58:31 2013 +0100 +++ b/python/codeeditor.py Sat Mar 02 10:19:38 2013 +0100 @@ -57,6 +57,10 @@ self.filename = None self.setFont(QFont('Courier')) self.lineNumberArea = LineNumberArea(self) + h = QFontMetrics(self.font()).height() + print(h) + self.errorPixmap = QPixmap('error.png').scaled(h, h) + self.errorList = [] self.blockCountChanged.connect(self.updateLineNumberAreaWidth) self.updateRequest.connect(self.updateLineNumberArea) @@ -102,6 +106,9 @@ self.setExtraSelections( [ selection ] ) def clearErrors(self): self.setExtraSelections( [ ] ) + def setErrors(self, el): + self.errorList = el + self.lineNumberArea.update() def lineNumberAreaWidth(self): digits = 1 @@ -109,7 +116,7 @@ while mx >= 10: mx = mx / 10 digits += 1 - space = 3 + self.fontMetrics().width('8') * digits + space = 3 + self.fontMetrics().width('8') * digits + self.errorPixmap.width() + 2 return space def lineNumberAreaPaintEvent(self, ev): painter = QPainter(self.lineNumberArea) @@ -123,6 +130,10 @@ num = str(blockNumber + 1) painter.setPen(Qt.black) painter.drawText(0, top, self.lineNumberArea.width(), self.fontMetrics().height(), Qt.AlignRight, num) + for e in self.errorList: + if e.loc.row == blockNumber + 1: + painter.drawPixmap(0, top, self.errorPixmap) + block = block.next() top = bottom bottom = top + self.blockBoundingRect(block).height()