Mercurial > lcfOS
comparison python/ide.py @ 281:4496cae24d7f
Improved logview
author | Windel Bouwman |
---|---|
date | Sat, 02 Nov 2013 11:11:40 +0100 |
parents | 2ccd57b1d78c |
children | c137f1fe3e65 |
comparison
equal
deleted
inserted
replaced
280:02385f62f250 | 281:4496cae24d7f |
---|---|
9 | 9 |
10 # Compiler imports: | 10 # Compiler imports: |
11 import ppci | 11 import ppci |
12 from astviewer import AstViewer | 12 from astviewer import AstViewer |
13 from codeedit import CodeEdit | 13 from codeedit import CodeEdit |
14 from logview import LogView as BuildOutput | |
14 stutil = __import__('st-util') | 15 stutil = __import__('st-util') |
15 import c3 | 16 import c3 |
16 import zcc | 17 import zcc |
17 import outstream | 18 import outstream |
18 | |
19 | |
20 class BuildOutput(QTextEdit): | |
21 """ Build output component """ | |
22 def __init__(self, parent=None): | |
23 super(BuildOutput, self).__init__(parent) | |
24 fmt = logging.Formatter(fmt=zcc.logformat) | |
25 | |
26 class MyHandler(logging.Handler): | |
27 def emit(self2, x): | |
28 self.append(str(fmt.format(x))) | |
29 | |
30 logging.getLogger().addHandler(MyHandler()) | |
31 self.setCurrentFont(QFont('Courier')) | |
32 self.setReadOnly(True) | |
33 logging.info('Build output will appear here!') | |
34 | 19 |
35 | 20 |
36 class BuildErrors(QTreeView): | 21 class BuildErrors(QTreeView): |
37 sigErrorSelected = pyqtSignal(object) | 22 sigErrorSelected = pyqtSignal(object) |
38 | 23 |
42 self.setModel(model) | 27 self.setModel(model) |
43 self.clicked.connect(self.itemSelected) | 28 self.clicked.connect(self.itemSelected) |
44 self.errorIcon = QIcon('icons/error.png') | 29 self.errorIcon = QIcon('icons/error.png') |
45 self.model = QStandardItemModel() | 30 self.model = QStandardItemModel() |
46 self.model.setHorizontalHeaderLabels(['Message', 'Row', 'Column']) | 31 self.model.setHorizontalHeaderLabels(['Message', 'Row', 'Column']) |
32 self.header().setStretchLastSection(True) | |
47 self.setModel(self.model) | 33 self.setModel(self.model) |
48 | 34 |
49 def setErrorList(self, errorlist): | 35 def setErrorList(self, errorlist): |
50 c = self.model.rowCount() | 36 c = self.model.rowCount() |
51 self.model.removeRows(0, c) | 37 self.model.removeRows(0, c) |
57 irow.setData(e) | 43 irow.setData(e) |
58 col = str(e.loc.col) if e.loc else '' | 44 col = str(e.loc.col) if e.loc else '' |
59 icol = QStandardItem(col) | 45 icol = QStandardItem(col) |
60 icol.setData(e) | 46 icol.setData(e) |
61 self.model.appendRow([item, irow, icol]) | 47 self.model.appendRow([item, irow, icol]) |
48 for i in range(3): | |
49 self.resizeColumnToContents(i) | |
62 | 50 |
63 def itemSelected(self, index): | 51 def itemSelected(self, index): |
64 if not index.isValid(): | 52 if not index.isValid(): |
65 return | 53 return |
66 item = self.model.itemFromIndex(index) | 54 item = self.model.itemFromIndex(index) |