Mercurial > lcfOS
diff python/ide/astviewer.py @ 333:dcae6574c974
Increment to qt5
author | Windel Bouwman |
---|---|
date | Sun, 09 Feb 2014 15:27:57 +0100 |
parents | b145f8e6050b |
children |
line wrap: on
line diff
--- a/python/ide/astviewer.py Fri Feb 07 12:51:55 2014 +0100 +++ b/python/ide/astviewer.py Sun Feb 09 15:27:57 2014 +0100 @@ -1,13 +1,12 @@ -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from qtwrapper import QtGui, QtCore, QtWidgets, pyqtSignal, get_icon from ppci.c3 import Visitor, astnodes class AstModelBuilder: def __init__(self): - self.functionIco = QIcon(QPixmap('icons/functionicon.png').scaled(32, 32)) - self.variableIco = QIcon(QPixmap('icons/variableicon.png').scaled(32, 32)) - self.model = QStandardItemModel() - self.model.setHorizontalHeaderLabels(['Object', 'Type']) + self.functionIco = get_icon('functionicon.png') + self.variableIco = get_icon('variableicon.png') + self.model = QtGui.QStandardItemModel() + self.model.setHorizontalHeaderLabels(['Object', 'Type']) def build(self, pkg): #self.model.clear() @@ -28,7 +27,7 @@ else: return typ = str(node.typ) if hasattr(node, 'typ') else '' - ti = QStandardItem(str(typ)) + ti = QtGui.QStandardItem(str(typ)) ti.setData(node) i.setData(node) self.curItem.appendRow([i, ti]) @@ -38,14 +37,15 @@ if type(node) in [astnodes.Variable, astnodes.Function, astnodes.Package]: self.curItem = self.curItem.parent() + # The actual widget: -class AstViewer(QTreeView): +class AstViewer(QtWidgets.QTreeView): sigNodeSelected = pyqtSignal(object) def __init__(self, parent=None): - super(AstViewer, self).__init__(parent) - self.clicked.connect(self.selectHandler) - self.modelBuilder = AstModelBuilder() - self.setModel(self.modelBuilder.model) + super().__init__(parent) + self.clicked.connect(self.selectHandler) + self.modelBuilder = AstModelBuilder() + self.setModel(self.modelBuilder.model) def setAst(self, ast): """ Create a new model and add all ast elements to it """ @@ -53,11 +53,9 @@ self.expandAll() def selectHandler(self, index): - if not index.isValid(): - return - model = self.model() - item = model.itemFromIndex(index) - node = item.data() - self.sigNodeSelected.emit(node) - - + if not index.isValid(): + return + model = self.model() + item = model.itemFromIndex(index) + node = item.data() + self.sigNodeSelected.emit(node)