Pollutants: Add translation for type of pol

dev_dylan
Dylan Jeannin 2026-05-28 11:44:03 +02:00
parent 26dc7d8761
commit 3087023caa
4 changed files with 39 additions and 19 deletions

View File

@ -34,18 +34,6 @@ from Model.BoundaryConditionsAdisTS.BoundaryConditionAdisTS import (
logger = logging.getLogger() logger = logging.getLogger()
# Types de polluants: indice -> nom du type
POLLUTANT_TYPES = {
0: "Soluté",
1: "Particules sphériques",
2: "Galets lisses",
3: "Sable naturel",
4: "Sable concassé",
5: "Cylindres longs",
6: "Limon, particules cohésives",
7: "Flocs"
}
class PollutantCharacteristics(SQLSubModel): class PollutantCharacteristics(SQLSubModel):
_sub_classes = [] _sub_classes = []

View File

@ -40,8 +40,6 @@ from View.Pollutants.Edit.UndoCommand import (
SetDataCommand, PasteCommand, SetDataCommand, PasteCommand,
) )
from Model.Pollutants.Pollutants import POLLUTANT_TYPES
_translate = QCoreApplication.translate _translate = QCoreApplication.translate
logger = logging.getLogger() logger = logging.getLogger()
@ -51,17 +49,20 @@ class ComboBoxDelegate(QItemDelegate):
def __init__(self, type_dict=None, trad=None, parent=None): def __init__(self, type_dict=None, trad=None, parent=None):
super(ComboBoxDelegate, self).__init__(parent) super(ComboBoxDelegate, self).__init__(parent)
self._type_dict = type_dict if type_dict else POLLUTANT_TYPES # self._type_dict = type_dict if type_dict else POLLUTANT_TYPES
self._trad = trad self._trad = trad
self.editor = None self.editor = None
self._type = {}
if self._trad is not None:
self._type = self._trad.get_dict("type")
def createEditor(self, parent, option, index): def createEditor(self, parent, option, index):
self.editor = QComboBox(parent) self.editor = QComboBox(parent)
# Ajouter les items du dictionnaire # Ajouter les items du dictionnaire
for key in sorted(self._type_dict.keys()): for key, value in self._type.items():
display_text = self._type_dict[key] self.editor.addItem(value, key)
self.editor.addItem(display_text, userData=key)
self.editor.currentTextChanged.connect(self.currentItemChanged) self.editor.currentTextChanged.connect(self.currentItemChanged)
return self.editor return self.editor
@ -96,6 +97,14 @@ class ComboBoxDelegate(QItemDelegate):
class TableModel(PamhyrTableModel): class TableModel(PamhyrTableModel):
def __init__(self, trad=None, **kwargs):
self._trad = trad
self._types = {}
if self._trad is not None:
self._types = self._trad.get_dict("types")
super(TableModel, self).__init__(trad=trad, **kwargs)
def is_same_data(self, index, value): def is_same_data(self, index, value):
row = index.row() row = index.row()
column = index.column() column = index.column()
@ -122,7 +131,7 @@ class TableModel(PamhyrTableModel):
# Si c'est la colonne "type", convertir l'indice en string # Si c'est la colonne "type", convertir l'indice en string
if self._headers[column] == "type": if self._headers[column] == "type":
return POLLUTANT_TYPES.get(int(value), str(value)) value = self._trad.get_dict("type").get(value, "")
return value return value

View File

@ -24,6 +24,17 @@ from View.Pollutants.Translate import PollutantsTranslate
_translate = QCoreApplication.translate _translate = QCoreApplication.translate
# Types de polluants: indice -> nom du type
POLLUTANT_TYPES = {
0: "Solutes",
1: "Spherical particles",
2: "Smooth pebbles",
3: "Natural sand",
4: "Crushed sand",
5: "Elongated cylinders",
6: "Silts, cohesive particles",
7: "Flocs"
}
class EditPollutantTranslate(PollutantsTranslate): class EditPollutantTranslate(PollutantsTranslate):
def __init__(self): def __init__(self):
@ -44,3 +55,14 @@ class EditPollutantTranslate(PollutantsTranslate):
"ac": self._dict["unit_ac"], "ac": self._dict["unit_ac"],
"bc": self._dict["unit_bc"], "bc": self._dict["unit_bc"],
} }
self._sub_dict["type"] = {
0: _translate("Pollutants", "Solutes"),
1: _translate("Pollutants", "Spherical particles"),
2: _translate("Pollutants", "Smooth pebbles"),
3: _translate("Pollutants", "Natural sand"),
4: _translate("Pollutants", "Crushed sand"),
5: _translate("Pollutants", "Elongated cylinders"),
6: _translate("Pollutants", "Silts, cohesive particles"),
7: _translate("Pollutants", "Flocs"),
}

View File

@ -95,6 +95,7 @@ class EditPolluantWindow(PamhyrWindow):
editable_headers=editable_headers, editable_headers=editable_headers,
delegates={"type": self._delegate_type}, delegates={"type": self._delegate_type},
data=self._data, data=self._data,
trad=self._trad,
undo=self._undo_stack, undo=self._undo_stack,
opt_data=self._study.time_system opt_data=self._study.time_system
) )