class StandardEventTimesWidget(QtGui.QWidget): commandIssued = QtCore.pyqtSignal(QtGui.QUndoCommand) criticalCommandIssued = QtCore.pyqtSignal() def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.layout = QtGui.QVBoxLayout(self) self.tableWidget = AddDelTableWidget(self) self.layout.addWidget(self.tableWidget) self.tableWidget.setItemDelegateForColumn(1, TimeDelegate(self)) self.setModel(StandardEventTimesModel(self)) def institution(self, i): self.tableWidget.update() def setModel(self, model): self.tableWidget.setModel(model) model.commandIssued.connect(self.emitCommand) model.criticalCommandIssued.connect(self.emitCriticalCommand) @QtCore.pyqtSlot(QtGui.QUndoCommand) def emitCommand(self, command): self.commandIssued.emit(command) @QtCore.pyqtSlot() def emitCriticalCommand(self): self.criticalCommandIssued.emit()
class EventWidget(QtGui.QWidget): commandIssued = QtCore.pyqtSignal(QtGui.QUndoCommand) criticalCommandIssued = QtCore.pyqtSignal() def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.layout = QtGui.QHBoxLayout(self) self.list_widget = AddDelTableWidget(self) self.layout.addWidget(self.list_widget) self.list_widget.objectSelected.connect(self.setEvent) self.list_widget.setItemDelegateForColumn(1, DateDelegate(self)) self.event_widget = widget_event.EventWidget(self) self.layout.addWidget(self.event_widget) self.event_widget.commandIssued.connect(self.emitCommand) self.event_widget.criticalCommandIssued.connect(self.emitCriticalCommand) def _set_model(self, model): self.list_widget.setModel(model) model.commandIssued.connect(self.emitCommand) model.criticalCommandIssued.connect(self.emitCriticalCommand) @QtCore.pyqtSlot(QtCore.QObject) def duration(self, duration): model = EventsModel(duration) self._set_model(model) return model @QtCore.pyqtSlot(QtCore.QObject) def setEvent(self, item): self.event_widget.setEvent(item) @QtCore.pyqtSlot(QtGui.QUndoCommand) def emitCommand(self, command): self.commandIssued.emit(command) @QtCore.pyqtSlot() def emitCriticalCommand(self): self.criticalCommandIssued.emit()