def __init__(self, mainwindow, parent=None): """ Initialize the editable node information box. """ super().__init__(mainwindow, parent) self.textKey = Key('Label', self) self.textField = Str(self) self.textField.setReadOnly(False) connect(self.textField.editingFinished, self.editingFinished) self.nameKey = Key('Name', self) self.nameField = Str(self) self.nameField.setReadOnly(False) connect(self.nameField.editingFinished, self.editingFinished) self.predPropHeader = Header('Predicate properties', self) self.predPropLayout = QFormLayout() self.predPropLayout.setSpacing(0) self.nodePropLayout.insertRow(2, self.textKey, self.textField) self.predPropLayout.addRow(self.nameKey, self.nameField) self.mainLayout.insertWidget(0, self.predPropHeader) self.mainLayout.insertLayout(1, self.predPropLayout)
def __init__(self, parent=None): """ Initialize the stacked widget. :type parent: QWidget """ super().__init__(parent) connect(self.currentChanged, self.currentIndexChanged)
def __init__(self, mainwindow, parent=None): """ Initialize the diagram scene. :type mainwindow: MainWindow :type parent: QWidget """ super().__init__(parent) self.document = File(parent=self) self.guid = GUID(self) self.factory = ItemFactory(self) self.index = ItemIndex(self) self.meta = PredicateMetaIndex(self) self.undostack = QUndoStack(self) self.undostack.setUndoLimit(50) self.validator = OWL2Validator(self) self.mainwindow = mainwindow self.pasteOffsetX = Clipboard.PasteOffsetX self.pasteOffsetY = Clipboard.PasteOffsetY self.mode = DiagramMode.Idle self.modeParam = Item.Undefined self.mouseOverNode = None self.mousePressEdge = None self.mousePressPos = None self.mousePressNode = None self.mousePressNodePos = None self.mousePressData = {} connect(self.sgnItemAdded, self.index.add) connect(self.sgnItemRemoved, self.index.remove)
def __init__(self, mainwindow, parent=None): """ Initialize the editable node information box. """ super().__init__(mainwindow, parent) self.textKey = Key('Label', self) self.textField = Str(self) self.textField.setReadOnly(False) connect(self.textField.editingFinished, self.editingFinished) self.nameKey = Key('Name', self) self.nameField = Str(self) self.nameField.setReadOnly(False) connect(self.nameField.editingFinished, self.editingFinished) self.predPropHeader = Header('Predicate properties', self) self.predPropLayout = QFormLayout() self.predPropLayout.setSpacing(0) self.nodePropLayout.insertRow(2, self.textKey, self.textField) self.predPropLayout.addRow(self.nameKey, self.nameField) self.mainLayout.insertWidget(0, self.predPropHeader) self.mainLayout.insertLayout(1, self.predPropLayout)
def __init__(self, parent=None): """ Initialize the stacked widget. :type parent: QWidget """ super().__init__(parent) connect(self.currentChanged, self.currentIndexChanged)
def addSubWindow(self, subwindow, flags=0): """ Add a subwindow to the MDI area. :type subwindow: MdiSubWindow :type flags: int """ menu = subwindow.systemMenu() closeAll = QAction('Close All', menu) closeAll.setIcon(menu.actions()[7].icon()) connect(closeAll.triggered, self.closeAllSubWindows) menu.addAction(closeAll) return super().addSubWindow(subwindow)
def __init__(self, scene, node, parent=None): """ Initialize the editable node properties dialog. :type scene: DiagramScene :type node: AbstractNode :type parent: QWidget """ super().__init__(scene, node, parent) ################################################################################################################ # # # ORDERING TAB # # # ################################################################################################################ if self.node.inputs: self.orderWidget = QWidget() self.orderLayout = QFormLayout(self.orderWidget) self.list = QListWidget(self.orderWidget) for i in self.node.inputs: edge = self.scene.edge(i) item = QListWidgetItem('{} ({})'.format( edge.source.text(), edge.source.id)) item.setData(Qt.UserRole, edge.id) self.list.addItem(item) self.list.setCurrentRow(0) self.list.setDragDropMode(QAbstractItemView.NoDragDrop) self.buttonUp = QPushButton(self) self.buttonUp.setIcon(QIcon(':/icons/arrow-up')) self.buttonUp.setFixedSize(20, 20) connect(self.buttonUp.clicked, self.moveUp) self.buttonDown = QPushButton(self) self.buttonDown.setIcon(QIcon(':/icons/arrow-down')) self.buttonDown.setFixedSize(20, 20) inLayout = QVBoxLayout() inLayout.addWidget(self.buttonUp) inLayout.addWidget(self.buttonDown) connect(self.buttonDown.clicked, self.moveDown) outLayout = QHBoxLayout() outLayout.addWidget(self.list) outLayout.addLayout(inLayout) self.orderLayout.addRow('Sort', outLayout) self.mainWidget.addTab(self.orderWidget, 'Ordering')
def __init__(self, mainwindow, parent=None): """ Initialize the Attribute node information box. """ super().__init__(mainwindow, parent) self.functKey = Key('Funct.', self) functParent = Parent(self) self.functBox = CheckBox(functParent) self.functBox.setCheckable(True) self.functBox.setProperty('attribute', 'functional') connect(self.functBox.clicked, self.flagChanged) self.predPropLayout.addRow(self.functKey, functParent)
def __init__(self, mainwindow, parent=None): """ Initialize the Attribute node information box. """ super().__init__(mainwindow, parent) self.functKey = Key('Funct.', self) functParent = Parent(self) self.functBox = CheckBox(functParent) self.functBox.setCheckable(True) self.functBox.setProperty('attribute', 'functional') connect(self.functBox.clicked, self.flagChanged) self.predPropLayout.addRow(self.functKey, functParent)
def __init__(self, mainwindow, parent=None): """ Initialize the inclusion edge information box. :type mainwindow: MainWindow :type parent: QWidget """ super().__init__(mainwindow, parent) self.completeKey = Key('Complete', self) parent = Parent(self) self.completeBox = CheckBox(parent) self.completeBox.setCheckable(True) connect(self.completeBox.clicked, self.mainwindow.toggleEdgeComplete) self.generalLayout.addRow(self.completeKey, parent)
def __init__(self, mainwindow, parent=None): """ Initialize the inclusion edge information box. :type mainwindow: MainWindow :type parent: QWidget """ super().__init__(mainwindow, parent) self.completeKey = Key('Complete', self) parent = Parent(self) self.completeBox = CheckBox(parent) self.completeBox.setCheckable(True) connect(self.completeBox.clicked, self.mainwindow.toggleEdgeComplete) self.generalLayout.addRow(self.completeKey, parent)
def browse(self, view): """ Set the widget to browse the given view. :type view: MainView """ self.reset() if view: scene = view.scene() connect(scene.selectionChanged, self.updateView) connect(scene.sgnUpdated, self.updateView) self.setScene(scene) self.mainview = view self.updateView()
def newConnection(self): """ Executed whenever a message is received. """ if self.inSocket: # Disconnect previously connected signal slot. disconnect(self.inSocket.readyRead, self.readyRead) # Create a new socket. self.inSocket = self.server.nextPendingConnection() if self.inSocket: self.inStream = QTextStream(self.inSocket) self.inStream.setCodec('UTF-8') connect(self.inSocket.readyRead, self.readyRead) self.activate()
def newConnection(self): """ Executed whenever a message is received. """ if self.inSocket: # Disconnect previously connected signal slot. disconnect(self.inSocket.readyRead, self.readyRead) # Create a new socket. self.inSocket = self.server.nextPendingConnection() if self.inSocket: self.inStream = QTextStream(self.inSocket) self.inStream.setCodec('UTF-8') connect(self.inSocket.readyRead, self.readyRead) self.activate()
def base_except_hook(exc_type, exc_value, exc_traceback): """ Used to handle all uncaught exceptions. :type exc_type: class :type exc_value: Exception :type exc_traceback: Traceback """ global app global box if issubclass(exc_type, KeyboardInterrupt): app.quit() else: if not box: m1 = 'This is embarrassing ...\n\n' \ 'A critical error has just occurred. ' \ 'Eddy will continue to work, however a reboot is highly recommended.' m2 = 'If the problem persists please <a href="{}">submit a bug report</a>.'.format(BUG_TRACKER) m3 = ''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)) box = QMessageBox() box.setIconPixmap(QPixmap(':/images/eddy-sad')) box.setWindowIcon(QIcon(':/images/eddy')) box.setWindowTitle('Unhandled error!') box.setText(m1) box.setInformativeText(m2) box.setDetailedText(m3) box.setStandardButtons(QMessageBox.Close|QMessageBox.Ok) buttonOk = box.button(QMessageBox.Ok) buttonOk.setText('Close') buttonQuit = box.button(QMessageBox.Close) buttonQuit.setText('Quit {}'.format(APPNAME)) connect(buttonOk.clicked, box.close) connect(buttonQuit.clicked, app.quit) # noinspection PyArgumentList QApplication.beep() box.exec_() box = None
def __init__(self, node, parent=None): """ Initialize the form dialog. :type node: IndividualNode :type parent: QWidget """ super().__init__(parent) # DATATYPE COMBO BOX self.datatypeField = ComboBox(self) for datatype in XsdDatatype: self.datatypeField.addItem(datatype.value, datatype) # VALUE STRING FIELD self.valueField = StringField(self) self.valueField.setFixedWidth(300) # FILL FIELDS WITH DATA if node.identity is Identity.Value: datatype = node.datatype for i in range(self.datatypeField.count()): if self.datatypeField.itemData(i) is datatype: self.datatypeField.setCurrentIndex(i) break self.valueField.setValue(node.value) else: self.datatypeField.setCurrentIndex(0) self.valueField.setValue('') # CONFIRMATION BOX self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.mainLayout = QFormLayout(self) self.mainLayout.addRow('Datatype', self.datatypeField) self.mainLayout.addRow('Value', self.valueField) self.mainLayout.addRow(self.buttonBox) self.setWindowTitle('Compose value') self.setWindowIcon(QIcon(':/images/eddy')) self.setFixedSize(self.sizeHint()) connect(self.buttonBox.accepted, self.accept) connect(self.buttonBox.rejected, self.reject)
def __init__(self, mainwindow): """ Initialize the Explorer. :type mainwindow: MainWindow """ super().__init__(mainwindow) self.expanded = {} self.searched = {} self.scrolled = {} self.mainview = None self.iconA = QIcon(':/icons/treeview-icon-attribute') self.iconC = QIcon(':/icons/treeview-icon-concept') self.iconD = QIcon(':/icons/treeview-icon-datarange') self.iconI = QIcon(':/icons/treeview-icon-instance') self.iconR = QIcon(':/icons/treeview-icon-role') self.iconV = QIcon(':/icons/treeview-icon-value') self.search = StringField(self) self.search.setAcceptDrops(False) self.search.setClearButtonEnabled(True) self.search.setPlaceholderText('Search...') self.search.setFixedHeight(30) self.model = QStandardItemModel(self) self.proxy = QSortFilterProxyModel(self) self.proxy.setDynamicSortFilter(False) self.proxy.setFilterCaseSensitivity(Qt.CaseInsensitive) self.proxy.setSortCaseSensitivity(Qt.CaseSensitive) self.proxy.setSourceModel(self.model) self.view = ExplorerView(mainwindow, self) self.view.setModel(self.proxy) self.mainLayout = QVBoxLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addWidget(self.search) self.mainLayout.addWidget(self.view) self.setContentsMargins(0, 0, 0, 0) self.setMinimumWidth(216) self.setMinimumHeight(160) connect(self.view.doubleClicked, self.itemDoubleClicked) connect(self.view.pressed, self.itemPressed) connect(self.view.collapsed, self.itemCollapsed) connect(self.view.expanded, self.itemExpanded) connect(self.search.textChanged, self.filterItem)
def browse(self, view): """ Set the widget to inspect the given view. :type view: MainView """ self.reset() self.mainview = view if self.mainview: scene = self.mainview.scene() connect(scene.index.sgnItemAdded, self.add) connect(scene.index.sgnItemRemoved, self.remove) for item in scene.index.nodes(): self.add(item) if self.mainview in self.expanded: expanded = self.expanded[self.mainview] for i in range(self.model.rowCount()): item = self.model.item(i) index = self.proxy.mapFromSource( self.model.indexFromItem(item)) self.view.setExpanded(index, item.text() in expanded) key = '' if self.mainview in self.searched: key = self.searched[self.mainview] self.search.setText(key) if self.mainview in self.scrolled: rect = self.rect() item = first(self.model.findItems( self.scrolled[self.mainview])) for i in range(self.model.rowCount()): self.view.scrollTo( self.proxy.mapFromSource( self.model.indexFromItem(self.model.item(i)))) index = self.proxy.mapToSource( self.view.indexAt(rect.topLeft())) if self.model.itemFromIndex(index) is item: break
def __init__(self, mainwindow, parent=None): """ Initialize the Literal node information box. """ super().__init__(mainwindow, parent) self.datatypeKey = Key('Datatype', self) self.datatypeField = Select(self) connect(self.datatypeField.activated, self.valueChanged) self.valueKey = Key('Value', self) self.valueField = Str(self) self.valueField.setReadOnly(False) connect(self.valueField.editingFinished, self.valueChanged) for datatype in XsdDatatype: if Facet.forDatatype(datatype): self.datatypeField.addItem(datatype.value, datatype) self.nodePropLayout.addRow(self.datatypeKey, self.datatypeField) self.nodePropLayout.addRow(self.valueKey, self.valueField)
def startMove(self, delta, rate): """ Start the view movement. :type delta: QPointF :type rate: float """ if self.moveTimer: self.stopMove() # move the view: this is needed before the timer so that if we keep # moving the mouse fast outside the viewport rectangle we still are able # to move the view; if we don't do this the timer may not have kicked in # and thus we remain with a non-moving view with a unfocused graphicsitem self.moveBy(delta) # setup a timer for future move, so the view keeps moving # also if we are not moving the mouse anymore but we are # holding the position outside the viewport rect self.moveTimer = QTimer() connect(self.moveTimer.timeout, self.moveBy, delta) self.moveTimer.start(rate)
def __init__(self, mainwindow, parent=None): """ Initialize the Literal node information box. """ super().__init__(mainwindow, parent) self.datatypeKey = Key('Datatype', self) self.datatypeField = Select(self) connect(self.datatypeField.activated, self.valueChanged) self.valueKey = Key('Value', self) self.valueField = Str(self) self.valueField.setReadOnly(False) connect(self.valueField.editingFinished, self.valueChanged) for datatype in XsdDatatype: if Facet.forDatatype(datatype): self.datatypeField.addItem(datatype.value, datatype) self.nodePropLayout.addRow(self.datatypeKey, self.datatypeField) self.nodePropLayout.addRow(self.valueKey, self.valueField)
def startMove(self, delta, rate): """ Start the view movement. :type delta: QPointF :type rate: float """ if self.moveTimer: self.stopMove() # move the view: this is needed before the timer so that if we keep # moving the mouse fast outside the viewport rectangle we still are able # to move the view; if we don't do this the timer may not have kicked in # and thus we remain with a non-moving view with a unfocused graphicsitem self.moveBy(delta) # setup a timer for future move, so the view keeps moving # also if we are not moving the mouse anymore but we are # holding the position outside the viewport rect self.moveTimer = QTimer() connect(self.moveTimer.timeout, self.moveBy, delta) self.moveTimer.start(rate)
def browse(self, scene): """ Set the widget to inspect the given scene. :type scene: DiagramScene """ self.reset() self.scene = scene if self.scene: connect(scene.selectionChanged, self.stack) connect(scene.sgnItemAdded, self.stack) connect(scene.sgnItemRemoved, self.stack) connect(scene.sgnUpdated, self.stack) self.stack()
def browse(self, scene): """ Set the widget to inspect the given scene. :type scene: DiagramScene """ self.reset() self.scene = scene if self.scene: connect(scene.selectionChanged, self.stack) connect(scene.sgnItemAdded, self.stack) connect(scene.sgnItemRemoved, self.stack) connect(scene.sgnUpdated, self.stack) self.stack()
def __init__(self, node, parent=None): """ Initialize the form dialog. :type node: AbstractNode :type parent: QWidget """ super().__init__(parent) self.node = node self.renameField = StringField(self) self.renameField.setFixedWidth(200) self.renameField.setValue(self.node.text()) self.invalidName = QLabel('\'\' is not a valid predicate name', self) self.invalidName.setProperty('class', 'invalid') self.invalidName.setVisible(False) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.mainLayout = QFormLayout(self) self.mainLayout.addRow('Name', self.renameField) self.mainLayout.addRow(self.invalidName) self.mainLayout.addRow(self.buttonBox) self.setWindowTitle('Rename') self.setWindowIcon(QIcon(':/images/eddy')) self.setFixedSize(self.sizeHint()) connect(self.buttonBox.accepted, self.validate) connect(self.buttonBox.rejected, self.reject) connect(self.renameField.textChanged, self.nameChanged)
def __init__(self, parent=None): """ Initialize the form dialog. :type parent: QWidget """ super().__init__(parent) self.minCardinalityValue = None self.maxCardinalityValue = None self.minCardinalityField = IntField(self) self.maxCardinalityField = IntField(self) self.minCardinalityField.setFixedWidth(80) self.maxCardinalityField.setFixedWidth(80) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.mainLayout = QFormLayout(self) self.mainLayout.addRow('Min. cardinality', self.minCardinalityField) self.mainLayout.addRow('Max. cardinality', self.maxCardinalityField) self.mainLayout.addRow(self.buttonBox) self.setWindowTitle('Insert cardinality') self.setWindowIcon(QIcon(':/images/eddy')) self.setFixedSize(self.sizeHint()) connect(self.buttonBox.accepted, self.validate) connect(self.buttonBox.rejected, self.reject)
def __init__(self, node, parent=None): """ Initialize the form dialog. :type node: ValueRestrictionNode :type parent: QWidget """ super().__init__(parent) # DATATYPE COMBO BOX self.datatypeField = ComboBox(self) for datatype in XsdDatatype: # hide unrestrictable elements. if Facet.forDatatype(datatype): self.datatypeField.addItem(datatype.value, datatype) datatype = node.datatype for i in range(self.datatypeField.count()): if self.datatypeField.itemData(i) is datatype: self.datatypeField.setCurrentIndex(i) break # FACET COMBO BOX self.facetField = ComboBox(self) for facet in Facet.forDatatype(datatype): self.facetField.addItem(facet.value, facet) facet = node.facet for i in range(self.facetField.count()): if self.facetField.itemData(i) is facet: self.facetField.setCurrentIndex(i) break # VALUE STRING FIELD self.valueField = StringField(self) self.valueField.setFixedWidth(300) self.valueField.setValue(node.value) # CONFIRMATION BOX self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.mainLayout = QFormLayout(self) self.mainLayout.addRow('Datatype', self.datatypeField) self.mainLayout.addRow('Facet', self.facetField) self.mainLayout.addRow('Value', self.valueField) self.mainLayout.addRow(self.buttonBox) self.setWindowTitle('Compose value restriction') self.setWindowIcon(QIcon(':/images/eddy')) self.setFixedSize(self.sizeHint()) connect(self.buttonBox.accepted, self.accept) connect(self.buttonBox.rejected, self.reject) connect(self.datatypeField.currentIndexChanged[int], self.datatypeFieldChanged)
def showEvent(self, event): """ Executed when the dialog is shown :type event: QShowEvent """ self.workerThread = QThread() self.worker.moveToThread(self.workerThread) connect(self.worker.completed, self.completed) connect(self.worker.errored, self.errored) connect(self.workerThread.started, self.worker.work) self.workerThread.start()
def showEvent(self, event): """ Executed when the dialog is shown :type event: QShowEvent """ self.workerThread = QThread() self.worker.moveToThread(self.workerThread) connect(self.worker.completed, self.completed) connect(self.worker.errored, self.errored) connect(self.workerThread.started, self.worker.work) self.workerThread.start()
def __init__(self, scene, filepath, parent=None): """ Initialize the form dialog. :type scene: DiagramScene :type filepath: str :type parent: QWidget """ super().__init__(parent) self.scene = scene self.filepath = filepath self.worker = None self.workerThread = None self.iriField = StringField(self) self.iriField.setFixedWidth(300) self.iriField.setValidator(QRegExpValidator(QRegExp('[\w:\/\[\]=?%#~\.\-\+]*'), self)) self.prefixField = StringField(self) self.prefixField.setFixedWidth(300) self.prefixField.setValidator(QRegExpValidator(QRegExp('[\w]*'), self)) self.syntaxField = ComboBox(self) for syntax in OWLSyntax: self.syntaxField.addItem(syntax.value, syntax) self.syntaxField.setCurrentIndex(0) self.progressBar = QProgressBar(self) self.progressBar.setAlignment(Qt.AlignHCenter) self.progressBar.setRange(0, 100) self.progressBar.setValue(0) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.buttonBox.button(QDialogButtonBox.Ok).setDisabled(True) self.mainLayout = QFormLayout(self) self.mainLayout.addRow('IRI', self.iriField) self.mainLayout.addRow('Prefix', self.prefixField) self.mainLayout.addRow('Syntax', self.syntaxField) self.mainLayout.addRow(self.progressBar) self.mainLayout.addRow(self.buttonBox) self.setWindowTitle('OWL Translation') self.setWindowIcon(QIcon(':/images/eddy')) self.setFixedSize(self.sizeHint()) connect(self.buttonBox.accepted, self.run) connect(self.buttonBox.rejected, self.reject) connect(self.iriField.textChanged, self.iriChanged)
def run(self): """ Perform the Graphol -> OWL translation in a separate thread. """ ontoIRI = self.iriField.value() ontoPrefix = self.prefixField.value() self.buttonBox.setEnabled(False) self.syntaxField.setEnabled(False) if not ontoIRI.endswith('#'): ontoIRI = '{0}#'.format(ontoIRI) self.workerThread = QThread() self.worker = OWLExporter(scene=self.scene, ontoIRI=ontoIRI, ontoPrefix=ontoPrefix) self.worker.moveToThread(self.workerThread) connect(self.worker.completed, self.completed) connect(self.worker.errored, self.errored) connect(self.worker.progress, self.progress) connect(self.workerThread.started, self.worker.work) self.workerThread.start()
def __init__(self, parent=None): """ Inizialize the zoom widget. :type parent: QWidget """ super().__init__(parent) self.level = Zoom.Default self.levels = [x for x in rangeF(Zoom.Min, Zoom.Max + Zoom.Step, Zoom.Step)] self.buttonZoomIn = QToolButton() self.buttonZoomIn.setIcon(Icon(':/icons/zoom-in')) self.buttonZoomOut = QToolButton() self.buttonZoomOut.setIcon(Icon(':/icons/zoom-out')) self.buttonZoomReset = QToolButton() self.buttonZoomReset.setIcon(Icon(':/icons/zoom-reset')) connect(self.buttonZoomIn.clicked, self.zoomIn) connect(self.buttonZoomOut.clicked, self.zoomOut) connect(self.buttonZoomReset.clicked, self.zoomReset) self.setEnabled(False)
def __init__(self, parent=None): """ Inizialize the zoom widget. :type parent: QWidget """ super().__init__(parent) self.level = Zoom.Default self.levels = [ x for x in rangeF(Zoom.Min, Zoom.Max + Zoom.Step, Zoom.Step) ] self.buttonZoomIn = QToolButton() self.buttonZoomIn.setIcon(Icon(':/icons/zoom-in')) self.buttonZoomOut = QToolButton() self.buttonZoomOut.setIcon(Icon(':/icons/zoom-out')) self.buttonZoomReset = QToolButton() self.buttonZoomReset.setIcon(Icon(':/icons/zoom-reset')) connect(self.buttonZoomIn.clicked, self.zoomIn) connect(self.buttonZoomOut.clicked, self.zoomOut) connect(self.buttonZoomReset.clicked, self.zoomReset) self.setEnabled(False)
def __init__(self, scene, parent=None): """ Initialize the scene properties dialog. :type scene: DiagramScene :type parent: QWidget """ super().__init__(parent) self.scene = scene self.mainWidget = QTabWidget(self) ################################################################################################################ # # # GENERAL TAB # # # ################################################################################################################ self.generalWidget = QWidget() self.generalLayout = QFormLayout(self.generalWidget) # Amount of nodes in the scene self.nodesField = IntField(self.generalWidget) self.nodesField.setReadOnly(True) self.nodesField.setFixedWidth(300) self.nodesField.setValue(len(self.scene.nodes())) # Amount of edges in the scene self.edgesField = IntField(self.generalWidget) self.nodesField.setReadOnly(True) self.edgesField.setFixedWidth(300) self.edgesField.setValue(len(self.scene.edges())) self.generalLayout.addRow('N° nodes', self.nodesField) self.generalLayout.addRow('N° edges', self.edgesField) self.mainWidget.addTab(self.generalWidget, 'General') ################################################################################################################ # # # GEOMETRY TAB # # # ################################################################################################################ self.geometryWidget = QWidget() self.geometryLayout = QFormLayout(self.geometryWidget) R = self.scene.sceneRect() self.sceneSizeField = SpinBox(self) self.sceneSizeField.setRange(self.scene.MinSize, self.scene.MaxSize) self.sceneSizeField.setSingleStep(100) self.sceneSizeField.setValue(R.width()) self.geometryLayout.addRow('Size', self.sceneSizeField) self.mainWidget.addTab(self.geometryWidget, 'Geometry') ################################################################################################################ # # # DOCUMENT WIDGET # # # ################################################################################################################ if self.scene.document.path: self.documentWidget = QWidget() self.documentLayout = QFormLayout(self.documentWidget) # Filepath of the saved document. self.pathField = StringField(self.documentWidget) self.pathField.setReadOnly(True) self.pathField.setFixedWidth(300) self.pathField.setValue(self.scene.document.path) # Timestamp when the document has been last modified. self.editedField = StringField(self.documentWidget) self.editedField.setReadOnly(True) self.editedField.setFixedWidth(300) self.editedField.setValue( datetime.fromtimestamp(int( self.scene.document.edited)).strftime('%Y/%m/%d %H:%M:%S')) self.documentLayout.addRow('File', self.pathField) self.documentLayout.addRow('Last edit', self.editedField) self.mainWidget.addTab(self.documentWidget, 'Document') ################################################################################################################ # # # BUTTON BOX # # # ################################################################################################################ self.buttonBox = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) ################################################################################################################ # # # MAIN LAYOUT # # # ################################################################################################################ self.mainLayout = QVBoxLayout(self) self.mainLayout.addWidget(self.mainWidget) self.mainLayout.addWidget(self.buttonBox, 0, Qt.AlignRight) self.setFixedSize(self.sizeHint()) self.setWindowTitle('Scene properties') self.setWindowIcon(QIcon(':/images/eddy')) ################################################################################################################ # # # CONFIGURE SIGNALS # # # ################################################################################################################ connect(self.finished, self.completed) connect(self.buttonBox.accepted, self.accept) connect(self.buttonBox.rejected, self.reject)
def __init__(self, mainwindow, parent=None): """ Initialize the Role node information box. """ super().__init__(mainwindow, parent) self.functKey = Key('Funct.', self) functParent = Parent(self) self.functBox = CheckBox(functParent) self.functBox.setCheckable(True) self.functBox.setProperty('attribute', 'functional') connect(self.functBox.clicked, self.flagChanged) self.invFunctKey = Key('Inv. Funct.', self) invFunctParent = Parent(self) self.invFunctBox = CheckBox(invFunctParent) self.invFunctBox.setCheckable(True) self.invFunctBox.setProperty('attribute', 'inverseFunctional') connect(self.invFunctBox.clicked, self.flagChanged) self.asymmetricKey = Key('Asymmetric', self) asymmetricParent = Parent(self) self.asymmetricBox = CheckBox(asymmetricParent) self.asymmetricBox.setCheckable(True) self.asymmetricBox.setProperty('attribute', 'asymmetric') connect(self.asymmetricBox.clicked, self.flagChanged) self.irreflexiveKey = Key('Irreflexive', self) irreflexiveParent = Parent(self) self.irreflexiveBox = CheckBox(irreflexiveParent) self.irreflexiveBox.setCheckable(True) self.irreflexiveBox.setProperty('attribute', 'irreflexive') connect(self.irreflexiveBox.clicked, self.flagChanged) self.reflexiveKey = Key('Reflexive', self) reflexiveParent = Parent(self) self.reflexiveBox = CheckBox(reflexiveParent) self.reflexiveBox.setCheckable(True) self.reflexiveBox.setProperty('attribute', 'reflexive') connect(self.reflexiveBox.clicked, self.flagChanged) self.symmetricKey = Key('Symmetric', self) symmetricParent = Parent(self) self.symmetricBox = CheckBox(symmetricParent) self.symmetricBox.setCheckable(True) self.symmetricBox.setProperty('attribute', 'symmetric') connect(self.symmetricBox.clicked, self.flagChanged) self.transitiveKey = Key('Transitive', self) transitiveParent = Parent(self) self.transitiveBox = CheckBox(transitiveParent) self.transitiveBox.setCheckable(True) self.transitiveBox.setProperty('attribute', 'transitive') connect(self.transitiveBox.clicked, self.flagChanged) self.predPropLayout.addRow(self.functKey, functParent) self.predPropLayout.addRow(self.invFunctKey, invFunctParent) self.predPropLayout.addRow(self.asymmetricKey, asymmetricParent) self.predPropLayout.addRow(self.irreflexiveKey, irreflexiveParent) self.predPropLayout.addRow(self.reflexiveKey, reflexiveParent) self.predPropLayout.addRow(self.symmetricKey, symmetricParent) self.predPropLayout.addRow(self.transitiveKey, transitiveParent)
def __init__(self, argv): """ Initialize Eddy. :type argv: list """ super().__init__(argv) parser = ArgumentParser() parser.add_argument('--nosplash', dest='nosplash', action='store_true') parser.add_argument('--tests', dest='tests', action='store_true') options, args = parser.parse_known_args(args=argv) self.inSocket = None self.inStream = None self.outSocket = QLocalSocket() self.outSocket.connectToServer(APPID) self.outStream = None self.isRunning = self.outSocket.waitForConnected() self.mainwindow = None self.pendingOpen = [] self.server = None # We do not initialize a new instance of Eddy if there is a process running # and we are not executing the tests suite: we'll create a socket instead so we can # exchange messages between the 2 processes (this one and the already running one). if self.isRunning and not options.tests: self.outStream = QTextStream(self.outSocket) self.outStream.setCodec('UTF-8') else: self.server = QLocalServer() self.server.listen(APPID) self.outSocket = None self.outStream = None connect(self.server.newConnection, self.newConnection) connect(self.messageReceived, self.readMessage) ############################################################################################################ # # # PERFORM EDDY INITIALIZATION # # # ############################################################################################################ # Draw the splashscreen. self.splashscreen = None if not options.nosplash: self.splashscreen = SplashScreen(min_splash_time=4) self.splashscreen.show() # Setup layout. self.setStyle(Clean('Fusion')) with open(expandPath('@eddy/ui/clean.qss')) as sheet: self.setStyleSheet(sheet.read()) # Create the main window. self.mainwindow = MainWindow() # Close the splashscreen. if self.splashscreen: self.splashscreen.wait(self.splashscreen.remaining) self.splashscreen.close() # Display the mainwindow. self.mainwindow.show() if Platform.identify() is Platform.Darwin: # On MacOS files being opened are handled as a QFileOpenEvent but since we don't # have a Main Window initialized we store them locally and we open them here. for filepath in self.pendingOpen: self.openFile(filepath) self.pendingOpen = [] else: # Perform document opening if files have been added to sys.argv. This is not # executed on Mac OS since this is already handled as a QFileOpenEvent instance. for filepath in argv: self.openFile(filepath)
def __init__(self, mainwindow): """ Initialize the Preferences dialog. :type mainwindow: QMainWindow """ super().__init__(mainwindow) self.mainwindow = mainwindow ################################################################################################################ # # # EDITOR TAB # # # ################################################################################################################ self.diagramSizeF = SpinBox(self) self.diagramSizeF.setRange(2000, 1000000) self.diagramSizeF.setSingleStep(100) self.diagramSizeF.setValue(self.mainwindow.diagramSize) self.editorWidget = QWidget() self.editorLayout = QFormLayout(self.editorWidget) self.editorLayout.addRow('Diagram size', self.diagramSizeF) ################################################################################################################ # # # MAIN WIDGET # # # ################################################################################################################ self.mainWidget = QTabWidget(self) self.mainWidget.addTab(self.editorWidget, 'Editor') ################################################################################################################ # # # BUTTON BOX # # # ################################################################################################################ self.buttonBox = QDialogButtonBox(QDialogButtonBox.Save | QDialogButtonBox.Close, Qt.Horizontal, self) ################################################################################################################ # # # MAIN LAYOUT # # # ################################################################################################################ self.mainLayout = QVBoxLayout(self) self.mainLayout.addWidget(self.mainWidget) self.mainLayout.addWidget(self.buttonBox, 0, Qt.AlignRight) self.setFixedSize(self.sizeHint()) self.setWindowTitle('Preferences') ################################################################################################################ # # # CONFIGURE SIGNALS # # # ################################################################################################################ connect(self.buttonBox.accepted, self.accept) connect(self.buttonBox.rejected, self.reject) connect(self.finished, self.completed)
def __init__(self, scene, node, parent=None): """ Initialize the node properties dialog. :type scene: DiagramScene :type node: AbstractNode :type parent: QWidget """ super().__init__(parent) self.node = node self.scene = scene # GENERAL self.generalWidget = QWidget() self.generalLayout = QFormLayout(self.generalWidget) self.idField = StringField(self.generalWidget) self.idField.setReadOnly(True) self.idField.setFixedWidth(300) self.idField.setValue(self.node.id) self.itemField = StringField(self.generalWidget) self.itemField.setReadOnly(True) self.itemField.setFixedWidth(300) self.itemField.setValue(node.shortname.capitalize()) self.showIdentityField = StringField(self.generalWidget) self.showIdentityField.setReadOnly(True) self.showIdentityField.setFixedWidth(300) self.showIdentityField.setValue(self.node.identity.value) self.generalLayout.addRow('ID', self.idField) self.generalLayout.addRow('Type', self.itemField) self.generalLayout.addRow('Identity', self.showIdentityField) # GEOMETRY self.geometryWidget = QWidget() self.geometryLayout = QFormLayout(self.geometryWidget) P = self.node.pos() R = self.scene.sceneRect() self.xField = SpinBox(self.geometryWidget) self.xField.setFixedWidth(60) self.xField.setRange(R.left(), R.right()) self.xField.setValue(int(P.x())) self.yField = SpinBox(self.geometryWidget) self.yField.setFixedWidth(60) self.yField.setRange(R.top(), R.bottom()) self.yField.setValue(int(P.y())) self.wField = SpinBox(self.geometryWidget) self.wField.setRange(20, R.width()) self.wField.setReadOnly(True) self.wField.setFixedWidth(60) self.wField.setValue(int(self.node.width())) self.hField = SpinBox(self.geometryWidget) self.hField.setRange(20, R.height()) self.hField.setReadOnly(True) self.hField.setFixedWidth(60) self.hField.setValue(int(self.node.height())) self.geometryLayout.addRow('X', self.xField) self.geometryLayout.addRow('Y', self.yField) self.geometryLayout.addRow('Width', self.wField) self.geometryLayout.addRow('Height', self.hField) # MAIN self.mainWidget = QTabWidget(self) self.mainWidget.addTab(self.generalWidget, 'General') self.mainWidget.addTab(self.geometryWidget, 'Geometry') self.buttonBox = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.mainLayout = QVBoxLayout(self) self.mainLayout.addWidget(self.mainWidget) self.mainLayout.addWidget(self.buttonBox, 0, Qt.AlignRight) self.setWindowTitle('Properties') self.setWindowIcon(QIcon(':/images/eddy')) connect(self.finished, self.completed) connect(self.buttonBox.accepted, self.accept) connect(self.buttonBox.rejected, self.reject)
def __init__(self, mainwindow): """ Initialize the Preferences dialog. :type mainwindow: QMainWindow """ super().__init__(mainwindow) self.mainwindow = mainwindow ################################################################################################################ # # # EDITOR TAB # # # ################################################################################################################ self.diagramSizeF = SpinBox(self) self.diagramSizeF.setRange(2000, 1000000) self.diagramSizeF.setSingleStep(100) self.diagramSizeF.setValue(self.mainwindow.diagramSize) self.editorWidget = QWidget() self.editorLayout = QFormLayout(self.editorWidget) self.editorLayout.addRow('Diagram size', self.diagramSizeF) ################################################################################################################ # # # MAIN WIDGET # # # ################################################################################################################ self.mainWidget = QTabWidget(self) self.mainWidget.addTab(self.editorWidget, 'Editor') ################################################################################################################ # # # BUTTON BOX # # # ################################################################################################################ self.buttonBox = QDialogButtonBox( QDialogButtonBox.Save | QDialogButtonBox.Close, Qt.Horizontal, self) ################################################################################################################ # # # MAIN LAYOUT # # # ################################################################################################################ self.mainLayout = QVBoxLayout(self) self.mainLayout.addWidget(self.mainWidget) self.mainLayout.addWidget(self.buttonBox, 0, Qt.AlignRight) self.setFixedSize(self.sizeHint()) self.setWindowTitle('Preferences') ################################################################################################################ # # # CONFIGURE SIGNALS # # # ################################################################################################################ connect(self.buttonBox.accepted, self.accept) connect(self.buttonBox.rejected, self.reject) connect(self.finished, self.completed)
def __init__(self, mainwindow, parent=None): """ Initialize the Role node information box. """ super().__init__(mainwindow, parent) self.functKey = Key('Funct.', self) functParent = Parent(self) self.functBox = CheckBox(functParent) self.functBox.setCheckable(True) self.functBox.setProperty('attribute', 'functional') connect(self.functBox.clicked, self.flagChanged) self.invFunctKey = Key('Inv. Funct.', self) invFunctParent = Parent(self) self.invFunctBox = CheckBox(invFunctParent) self.invFunctBox.setCheckable(True) self.invFunctBox.setProperty('attribute', 'inverseFunctional') connect(self.invFunctBox.clicked, self.flagChanged) self.asymmetricKey = Key('Asymmetric', self) asymmetricParent = Parent(self) self.asymmetricBox = CheckBox(asymmetricParent) self.asymmetricBox.setCheckable(True) self.asymmetricBox.setProperty('attribute', 'asymmetric') connect(self.asymmetricBox.clicked, self.flagChanged) self.irreflexiveKey = Key('Irreflexive', self) irreflexiveParent = Parent(self) self.irreflexiveBox = CheckBox(irreflexiveParent) self.irreflexiveBox.setCheckable(True) self.irreflexiveBox.setProperty('attribute', 'irreflexive') connect(self.irreflexiveBox.clicked, self.flagChanged) self.reflexiveKey = Key('Reflexive', self) reflexiveParent = Parent(self) self.reflexiveBox = CheckBox(reflexiveParent) self.reflexiveBox.setCheckable(True) self.reflexiveBox.setProperty('attribute', 'reflexive') connect(self.reflexiveBox.clicked, self.flagChanged) self.symmetricKey = Key('Symmetric', self) symmetricParent = Parent(self) self.symmetricBox = CheckBox(symmetricParent) self.symmetricBox.setCheckable(True) self.symmetricBox.setProperty('attribute', 'symmetric') connect(self.symmetricBox.clicked, self.flagChanged) self.transitiveKey = Key('Transitive', self) transitiveParent = Parent(self) self.transitiveBox = CheckBox(transitiveParent) self.transitiveBox.setCheckable(True) self.transitiveBox.setProperty('attribute', 'transitive') connect(self.transitiveBox.clicked, self.flagChanged) self.predPropLayout.addRow(self.functKey, functParent) self.predPropLayout.addRow(self.invFunctKey, invFunctParent) self.predPropLayout.addRow(self.asymmetricKey, asymmetricParent) self.predPropLayout.addRow(self.irreflexiveKey, irreflexiveParent) self.predPropLayout.addRow(self.reflexiveKey, reflexiveParent) self.predPropLayout.addRow(self.symmetricKey, symmetricParent) self.predPropLayout.addRow(self.transitiveKey, transitiveParent)
def __init__(self, argv): """ Initialize Eddy. :type argv: list """ super().__init__(argv) parser = ArgumentParser() parser.add_argument('--nosplash', dest='nosplash', action='store_true') parser.add_argument('--tests', dest='tests', action='store_true') options, args = parser.parse_known_args(args=argv) self.inSocket = None self.inStream = None self.outSocket = QLocalSocket() self.outSocket.connectToServer(APPID) self.outStream = None self.isRunning = self.outSocket.waitForConnected() self.mainwindow = None self.pendingOpen = [] self.server = None # We do not initialize a new instance of Eddy if there is a process running # and we are not executing the tests suite: we'll create a socket instead so we can # exchange messages between the 2 processes (this one and the already running one). if self.isRunning and not options.tests: self.outStream = QTextStream(self.outSocket) self.outStream.setCodec('UTF-8') else: self.server = QLocalServer() self.server.listen(APPID) self.outSocket = None self.outStream = None connect(self.server.newConnection, self.newConnection) connect(self.messageReceived, self.readMessage) ############################################################################################################ # # # PERFORM EDDY INITIALIZATION # # # ############################################################################################################ # Draw the splashscreen. self.splashscreen = None if not options.nosplash: self.splashscreen = SplashScreen(min_splash_time=4) self.splashscreen.show() # Setup layout. self.setStyle(Clean('Fusion')) with open(expandPath('@eddy/ui/clean.qss')) as sheet: self.setStyleSheet(sheet.read()) # Create the main window. self.mainwindow = MainWindow() # Close the splashscreen. if self.splashscreen: self.splashscreen.wait(self.splashscreen.remaining) self.splashscreen.close() # Display the mainwindow. self.mainwindow.show() if Platform.identify() is Platform.Darwin: # On MacOS files being opened are handled as a QFileOpenEvent but since we don't # have a Main Window initialized we store them locally and we open them here. for filepath in self.pendingOpen: self.openFile(filepath) self.pendingOpen = [] else: # Perform document opening if files have been added to sys.argv. This is not # executed on Mac OS since this is already handled as a QFileOpenEvent instance. for filepath in argv: self.openFile(filepath)