class PopulationWidget(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 = AddDelListWidget(self)
        self.layout.addWidget(self.list_widget)
        self.person_widget = PersonWidget(self)
        self.layout.addWidget(self.person_widget)
        self.list_widget.objectSelected.connect(self.person_widget.person)
        self.person_widget.commandIssued.connect(self.emitCommand)
        self.person_widget.criticalCommandIssued.connect(self.emitCriticalCommand)

    def institution(self, institution):
        model = PopulationModel(institution)
        self.setModel(model)
        return model

    def setModel(self, model):
        self.list_widget.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()
 def __init__(self, parent=None):
     QtGui.QWidget.__init__(self, parent)
     self.layout = QtGui.QHBoxLayout(self)
     self.list_widget = AddDelListWidget(self)
     self.layout.addWidget(self.list_widget)
     self.person_widget = PersonWidget(self)
     self.layout.addWidget(self.person_widget)
     self.list_widget.objectSelected.connect(self.person_widget.person)
     self.person_widget.commandIssued.connect(self.emitCommand)
     self.person_widget.criticalCommandIssued.connect(self.emitCriticalCommand)
class GlobalRolesWidget(QtGui.QWidget):
    commandIssued = QtCore.pyqtSignal(QtGui.QUndoCommand)
    criticalCommandIssued = QtCore.pyqtSignal()

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.layout = QtGui.QGridLayout(self)
        self.listWidget = AddDelListWidget(self)
        self.layout.addWidget(self.listWidget, 0, 0, 2, 2)
        self.singleRoleWidget = SingleRoleWidget(self)
        self.layout.addWidget(self.singleRoleWidget, 0, 2, 1, 1)
        self.tableView = QtGui.QTableView(self)
        self.layout.addWidget(self.tableView, 1, 2, 1, 1)

        self.listWidget.objectSelected.connect(self.singleRoleWidget.role)
        self.singleRoleWidget.commandIssued.connect(self.emitCommand)
        self.setup_models()

    def setup_models(self):
        model = AllRolesModel(GlobalRoleList)
        self.listWidget.setModel(model)
        model.commandIssued.connect(self.emitCommand)
        model.criticalCommandIssued.connect(self.emitCriticalCommand)
        compatibilities_model = RoleCompatibilitiesSettingModel(model)
        self.tableView.setModel(compatibilities_model)
        compatibilities_model.commandIssued.connect(self.emitCommand)

    @QtCore.pyqtSlot(QtGui.QUndoCommand)
    def emitCommand(self, command):
        self.commandIssued.emit(command)

    @QtCore.pyqtSlot()
    def emitCriticalCommand(self):
        self.criticalCommandIssued.emit()

    def institution(self, i):
        self.listWidget.update()
        self.tableView.update()
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.layout = QtGui.QGridLayout(self)
        self.listWidget = AddDelListWidget(self)
        self.layout.addWidget(self.listWidget, 0, 0, 2, 2)
        self.singleRoleWidget = SingleRoleWidget(self)
        self.layout.addWidget(self.singleRoleWidget, 0, 2, 1, 1)
        self.tableView = QtGui.QTableView(self)
        self.layout.addWidget(self.tableView, 1, 2, 1, 1)

        self.listWidget.objectSelected.connect(self.singleRoleWidget.role)
        self.singleRoleWidget.commandIssued.connect(self.emitCommand)
        self.setup_models()