Mercurial > lcfOS
changeset 154:81e08e2e7777
Used error icon
author | Windel Bouwman |
---|---|
date | Sat, 02 Mar 2013 10:19:38 +0100 |
parents | e05b2b216bfc |
children | b28a11c01dbe |
files | python/codeeditor.py python/ide.py |
diffstat | 2 files changed, 18 insertions(+), 2 deletions(-) [+] |
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()
--- a/python/ide.py Sat Mar 02 09:58:31 2013 +0100 +++ b/python/ide.py Sat Mar 02 10:19:38 2013 +0100 @@ -31,10 +31,11 @@ model = QStandardItemModel() self.setModel(model) self.clicked.connect(self.itemSelected) + self.errorIcon = QIcon('error.png') def setErrorList(self, errorlist): model = QStandardItemModel() for e in errorlist: - item = QStandardItem(str(e)) + item = QStandardItem(self.errorIcon, str(e)) item.setData(e) model.appendRow(item) self.setModel(model) @@ -352,6 +353,10 @@ #self.astViewer.setAst(mods[0]) for err in self.diag.diags: self.buildOutput.append(str(err)) + ce = self.activeMdiChild() + if ce: + print('setting errors') + ce.setErrors(self.diag.diags) self.buildOutput.append("Done!") if __name__ == '__main__':