mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 22:47:53 +00:00
Fixes to qt5 port of viewer app
This commit is contained in:
@@ -49,13 +49,11 @@ from .main import settings, iterator
|
|||||||
from .occ_utils import display_shape
|
from .occ_utils import display_shape
|
||||||
|
|
||||||
from .. import open as open_ifc_file
|
from .. import open as open_ifc_file
|
||||||
from .. import get_supertype
|
from .. import version as ifcopenshell_version
|
||||||
|
|
||||||
# Depending on Python version and what not there may or may not be a QString
|
|
||||||
try:
|
|
||||||
except ImportError:
|
|
||||||
QString = str
|
|
||||||
|
|
||||||
|
if ifcopenshell_version < "0.6":
|
||||||
|
# not yet ported
|
||||||
|
from .. import get_supertype
|
||||||
|
|
||||||
class configuration(object):
|
class configuration(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -158,7 +156,7 @@ class application(QtWidgets.QApplication):
|
|||||||
elif action in displaymode:
|
elif action in displaymode:
|
||||||
self.instanceDisplayModeChanged.emit(inst, displaymode.index(action))
|
self.instanceDisplayModeChanged.emit(inst, displaymode.index(action))
|
||||||
|
|
||||||
def clicked(self, index):
|
def clicked_(self, index):
|
||||||
inst = index.data(QtCore.Qt.UserRole)
|
inst = index.data(QtCore.Qt.UserRole)
|
||||||
if hasattr(inst, 'toPyObject'):
|
if hasattr(inst, 'toPyObject'):
|
||||||
inst = inst
|
inst = inst
|
||||||
@@ -215,7 +213,7 @@ class application(QtWidgets.QApplication):
|
|||||||
itm.setData(0, QtCore.Qt.UserRole, product)
|
itm.setData(0, QtCore.Qt.UserRole, product)
|
||||||
self.children[parent].append(product)
|
self.children[parent].append(product)
|
||||||
self.product_to_item = dict(zip(items.keys(), map(self.indexFromItem, items.values())))
|
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()
|
self.expandAll()
|
||||||
|
|
||||||
class type_treeview(abstract_treeview):
|
class type_treeview(abstract_treeview):
|
||||||
@@ -239,7 +237,8 @@ class application(QtWidgets.QApplication):
|
|||||||
itm.setData(0, QtCore.Qt.UserRole, t2)
|
itm.setData(0, QtCore.Qt.UserRole, t2)
|
||||||
self.children[s2].append(t2)
|
self.children[s2].append(t2)
|
||||||
|
|
||||||
add(t)
|
if ifcopenshell_version < "0.6":
|
||||||
|
add(t)
|
||||||
|
|
||||||
for p in products:
|
for p in products:
|
||||||
t = QString(p.is_a())
|
t = QString(p.is_a())
|
||||||
@@ -248,7 +247,7 @@ class application(QtWidgets.QApplication):
|
|||||||
self.children[t].append(p)
|
self.children[t].append(p)
|
||||||
|
|
||||||
self.product_to_item = dict(zip(items.keys(), map(self.indexFromItem, items.values())))
|
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()
|
self.expandAll()
|
||||||
|
|
||||||
class property_table(QtWidgets.QWidget):
|
class property_table(QtWidgets.QWidget):
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import sys
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from code import InteractiveConsole
|
from code import InteractiveConsole
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
except BaseException:
|
except BaseException:
|
||||||
QtWidgets = QtGui
|
QtWidgets = QtGui
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class StdoutRedirector(object):
|
|||||||
self.widget.moveCursor(QtGui.QTextCursor.End)
|
self.widget.moveCursor(QtGui.QTextCursor.End)
|
||||||
|
|
||||||
|
|
||||||
class code_edit(QtGui.QWidget):
|
class code_edit(QtWidgets.QWidget):
|
||||||
class Console(InteractiveConsole):
|
class Console(InteractiveConsole):
|
||||||
def __init__(*args):
|
def __init__(*args):
|
||||||
InteractiveConsole.__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})
|
self.c = self.Console({'model': self.model, 'viewer': self.viewer, 'selection': product})
|
||||||
|
|
||||||
def __init__(self, viewer, snippets=None):
|
def __init__(self, viewer, snippets=None):
|
||||||
|
|
||||||
self.model = None
|
self.model = None
|
||||||
self.viewer = viewer
|
self.viewer = viewer
|
||||||
QtGui.QWidget.__init__(self)
|
QtWidgets.QWidget.__init__(self)
|
||||||
self.layout = QtGui.QVBoxLayout(self)
|
self.layout = QtWidgets.QVBoxLayout(self)
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
self.c = None
|
self.c = None
|
||||||
|
self.tools = QtWidgets.QHBoxLayout(self)
|
||||||
self.tools = QtGui.QHBoxLayout(self)
|
|
||||||
self.layout.addLayout(self.tools)
|
self.layout.addLayout(self.tools)
|
||||||
|
self.runbutton = QtWidgets.QPushButton("Run")
|
||||||
self.runbutton = QtGui.QPushButton("Run")
|
|
||||||
width = self.runbutton.fontMetrics().boundingRect("Run").width() + 20
|
width = self.runbutton.fontMetrics().boundingRect("Run").width() + 20
|
||||||
self.runbutton.setMaximumWidth(width)
|
self.runbutton.setMaximumWidth(width)
|
||||||
self.tools.addWidget(self.runbutton)
|
self.tools.addWidget(self.runbutton)
|
||||||
@@ -129,11 +126,10 @@ class code_edit(QtGui.QWidget):
|
|||||||
for snip_name in self.snippets.keys():
|
for snip_name in self.snippets.keys():
|
||||||
self.list.addItem(snip_name)
|
self.list.addItem(snip_name)
|
||||||
self.tools.addWidget(self.list)
|
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.layout.addWidget(self.editor)
|
||||||
|
self.output = QtWidgets.QTextEdit()
|
||||||
self.output = QtGui.QTextEdit()
|
|
||||||
self.output.setReadOnly(True)
|
self.output.setReadOnly(True)
|
||||||
self.output.setStyleSheet('font-size: 10pt; font-family: Consolas, Courier; background-color: #444;')
|
self.output.setStyleSheet('font-size: 10pt; font-family: Consolas, Courier; background-color: #444;')
|
||||||
self.layout.addWidget(self.output)
|
self.layout.addWidget(self.output)
|
||||||
|
|||||||
Reference in New Issue
Block a user