Fixes to qt5 port of viewer app

This commit is contained in:
Thomas Krijnen
2018-05-17 15:53:40 +02:00
parent 33635c2c40
commit 6b772d18b8
2 changed files with 18 additions and 23 deletions
@@ -49,13 +49,11 @@ from .main import settings, iterator
from .occ_utils import display_shape
from .. import open as open_ifc_file
from .. import get_supertype
# Depending on Python version and what not there may or may not be a QString
try:
except ImportError:
QString = str
from .. import version as ifcopenshell_version
if ifcopenshell_version < "0.6":
# not yet ported
from .. import get_supertype
class configuration(object):
def __init__(self):
@@ -158,7 +156,7 @@ class application(QtWidgets.QApplication):
elif action in displaymode:
self.instanceDisplayModeChanged.emit(inst, displaymode.index(action))
def clicked(self, index):
def clicked_(self, index):
inst = index.data(QtCore.Qt.UserRole)
if hasattr(inst, 'toPyObject'):
inst = inst
@@ -215,7 +213,7 @@ class application(QtWidgets.QApplication):
itm.setData(0, QtCore.Qt.UserRole, product)
self.children[parent].append(product)
self.product_to_item = dict(zip(items.keys(), map(self.indexFromItem, items.values())))
self.clicked[QModelIndex].connect(self.clicked)
self.clicked.connect(self.clicked_)
self.expandAll()
class type_treeview(abstract_treeview):
@@ -239,7 +237,8 @@ class application(QtWidgets.QApplication):
itm.setData(0, QtCore.Qt.UserRole, t2)
self.children[s2].append(t2)
add(t)
if ifcopenshell_version < "0.6":
add(t)
for p in products:
t = QString(p.is_a())
@@ -248,7 +247,7 @@ class application(QtWidgets.QApplication):
self.children[t].append(p)
self.product_to_item = dict(zip(items.keys(), map(self.indexFromItem, items.values())))
self.clicked[QModelIndex].connect(self.clicked)
self.clicked.connect(self.clicked)
self.expandAll()
class property_table(QtWidgets.QWidget):
@@ -7,10 +7,10 @@ import sys
import logging
from code import InteractiveConsole
from PyQt4 import QtCore, QtGui
from PyQt5 import QtCore, QtGui, QtWidgets
try:
from PyQt4 import QtWidgets
from PyQt5 import QtWidgets
except BaseException:
QtWidgets = QtGui
@@ -48,7 +48,7 @@ class StdoutRedirector(object):
self.widget.moveCursor(QtGui.QTextCursor.End)
class code_edit(QtGui.QWidget):
class code_edit(QtWidgets.QWidget):
class Console(InteractiveConsole):
def __init__(*args):
InteractiveConsole.__init__(*args)
@@ -73,18 +73,15 @@ class code_edit(QtGui.QWidget):
self.c = self.Console({'model': self.model, 'viewer': self.viewer, 'selection': product})
def __init__(self, viewer, snippets=None):
self.model = None
self.viewer = viewer
QtGui.QWidget.__init__(self)
self.layout = QtGui.QVBoxLayout(self)
QtWidgets.QWidget.__init__(self)
self.layout = QtWidgets.QVBoxLayout(self)
self.setLayout(self.layout)
self.c = None
self.tools = QtGui.QHBoxLayout(self)
self.tools = QtWidgets.QHBoxLayout(self)
self.layout.addLayout(self.tools)
self.runbutton = QtGui.QPushButton("Run")
self.runbutton = QtWidgets.QPushButton("Run")
width = self.runbutton.fontMetrics().boundingRect("Run").width() + 20
self.runbutton.setMaximumWidth(width)
self.tools.addWidget(self.runbutton)
@@ -129,11 +126,10 @@ class code_edit(QtGui.QWidget):
for snip_name in self.snippets.keys():
self.list.addItem(snip_name)
self.tools.addWidget(self.list)
QtCore.QObject.connect(self.list, QtCore.SIGNAL("currentIndexChanged(int)"), self.replace_snippet)
self.list.currentIndexChanged[int].connect(self.replace_snippet)
self.layout.addWidget(self.editor)
self.output = QtGui.QTextEdit()
self.output = QtWidgets.QTextEdit()
self.output.setReadOnly(True)
self.output.setStyleSheet('font-size: 10pt; font-family: Consolas, Courier; background-color: #444;')
self.layout.addWidget(self.output)