diff --git a/src/Model/BoundaryCondition/BoundaryConditionTypes.py b/src/Model/BoundaryCondition/BoundaryConditionTypes.py index b7515d432f7067f1a2e4de92f549233492ac7409..209e9ac77bb1dca83576b27901ace0294a2eb9d8 100644 --- a/src/Model/BoundaryCondition/BoundaryConditionTypes.py +++ b/src/Model/BoundaryCondition/BoundaryConditionTypes.py @@ -11,7 +11,6 @@ class NotDefined(BoundaryCondition): self._type = "ND" self._header = ["", ""] - self._types = [str, str] class PonctualContribution(BoundaryCondition): def __init__(self, name:str = ""): @@ -22,21 +21,21 @@ class PonctualContribution(BoundaryCondition): class TimeOverZ(BoundaryCondition): def __init__(self, name:str = ""): - super(PonctualContribution, self).__init__(name=name) + super(TimeOverZ, self).__init__(name=name) self._type = "TZ" self._header = ["time", "z"] class TimeOverDebit(BoundaryCondition): def __init__(self, name:str = ""): - super(PonctualContribution, self).__init__(name=name) + super(TimeOverDebit, self).__init__(name=name) self._type = "TD" self._header = ["time", "debit"] class ZOverDebit(BoundaryCondition): def __init__(self, name:str = ""): - super(PonctualContribution, self).__init__(name=name) + super(ZOverDebit, self).__init__(name=name) self._type = "ZD" self._header = ["z", "debit"] diff --git a/src/Model/Network/Graph.py b/src/Model/Network/Graph.py index ad9d6f67ab40b04044f56735c336e5fc18f581cc..3748dbedf97a72c9e2ee2e7637bd47598b666ad1 100644 --- a/src/Model/Network/Graph.py +++ b/src/Model/Network/Graph.py @@ -51,12 +51,17 @@ class Graph(object): ) def node(self, node_name:str): - return list( + node = list( filter( lambda n: n.name == node_name, self._nodes ) - )[0] + ) + + if len(node) == 0: + return None + + return node[0] def _add_node(self, node): self._nodes.append(node) diff --git a/src/View/BoundaryCondition/BCUndoCommand.py b/src/View/BoundaryCondition/BCUndoCommand.py index 9bcefc9c493e49a83a18e260a4c77e4506ecd076..3cd3774f0aaeb2024e35d13c7530bdadb53eba87 100644 --- a/src/View/BoundaryCondition/BCUndoCommand.py +++ b/src/View/BoundaryCondition/BCUndoCommand.py @@ -31,7 +31,7 @@ class SetNodeCommand(QUndoCommand): self._lst = lst self._index = index - self._old = self.lst[index].node + self._old = self._lst[index].node self._new = node def undo(self): @@ -47,8 +47,8 @@ class SetTypeCommand(QUndoCommand): self._lst = lst self._index = index self._type = _type - self._old = self.lst[index] - self._new = self.lst[index].convert(self._type) + self._old = self._lst[index] + self._new = self._lst[index].convert(self._type) def undo(self): self._lst[self._index] = self._old diff --git a/src/View/BoundaryCondition/BoundaryConditionWindow.py b/src/View/BoundaryCondition/BoundaryConditionWindow.py index ab23890125986b92fe326116bdcde0c4aa5fd474..538b5a52fd6378d432c5acef5b414d2406d03ba9 100644 --- a/src/View/BoundaryCondition/BoundaryConditionWindow.py +++ b/src/View/BoundaryCondition/BoundaryConditionWindow.py @@ -12,6 +12,7 @@ from PyQt5.QtGui import ( from PyQt5.QtCore import ( Qt, QVariant, QAbstractTableModel, QCoreApplication, QModelIndex, pyqtSlot, + QRect, ) from PyQt5.QtWidgets import ( @@ -68,10 +69,10 @@ class ComboBoxDelegate(QItemDelegate): self.editor = QComboBox(parent) if self._mode == "type": - self.editor.addItems(BC_types.keys()) + self.editor.addItems([long_types[k] for k in BC_types.keys()]) else: self.editor.addItems( - ["Not associate"] + + [_translate("BoundaryCondition", "Not associate")] + self._data.nodes_names() ) @@ -134,7 +135,7 @@ class TableModel(QAbstractTableModel): elif self._headers[column] == "node": n = self._lst[row].node if n is None: - return "-" + return _translate("BoundaryCondition", "Not associate") return n.name return QVariant() @@ -159,9 +160,10 @@ class TableModel(QAbstractTableModel): ) ) elif self._headers[column] == "type": + key = next(k for k, v in long_types.items() if v == value) self._undo.push( SetTypeCommand( - self._lst, row, BC_types[value] + self._lst, row, BC_types[key] ) ) elif self._headers[column] == "node":