# HG changeset patch # User Windel Bouwman # Date 1362215978 -3600 # Node ID 81e08e2e7777837c2e756c9cbdc18557c439eb2d # Parent e05b2b216bfce32b90ec64d69f31589f60eba4b7 Used error icon diff -r e05b2b216bfc -r 81e08e2e7777 python/codeeditor.py --- 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() diff -r e05b2b216bfc -r 81e08e2e7777 python/ide.py --- 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__':