mirror of https://gitlab.com/pamhyr/pamhyr2
Pollutants: Add translation for type of pol
parent
26dc7d8761
commit
3087023caa
|
|
@ -34,18 +34,6 @@ from Model.BoundaryConditionsAdisTS.BoundaryConditionAdisTS import (
|
|||
|
||||
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):
|
||||
_sub_classes = []
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ from View.Pollutants.Edit.UndoCommand import (
|
|||
SetDataCommand, PasteCommand,
|
||||
)
|
||||
|
||||
from Model.Pollutants.Pollutants import POLLUTANT_TYPES
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
|
@ -51,17 +49,20 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
def __init__(self, type_dict=None, trad=None, parent=None):
|
||||
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.editor = None
|
||||
|
||||
self._type = {}
|
||||
if self._trad is not None:
|
||||
self._type = self._trad.get_dict("type")
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
self.editor = QComboBox(parent)
|
||||
|
||||
# Ajouter les items du dictionnaire
|
||||
for key in sorted(self._type_dict.keys()):
|
||||
display_text = self._type_dict[key]
|
||||
self.editor.addItem(display_text, userData=key)
|
||||
for key, value in self._type.items():
|
||||
self.editor.addItem(value, key)
|
||||
|
||||
self.editor.currentTextChanged.connect(self.currentItemChanged)
|
||||
return self.editor
|
||||
|
|
@ -96,6 +97,14 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
|
||||
|
||||
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):
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
|
@ -122,7 +131,7 @@ class TableModel(PamhyrTableModel):
|
|||
|
||||
# Si c'est la colonne "type", convertir l'indice en string
|
||||
if self._headers[column] == "type":
|
||||
return POLLUTANT_TYPES.get(int(value), str(value))
|
||||
value = self._trad.get_dict("type").get(value, "")
|
||||
|
||||
return value
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,17 @@ from View.Pollutants.Translate import PollutantsTranslate
|
|||
|
||||
_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):
|
||||
def __init__(self):
|
||||
|
|
@ -44,3 +55,14 @@ class EditPollutantTranslate(PollutantsTranslate):
|
|||
"ac": self._dict["unit_ac"],
|
||||
"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"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ class EditPolluantWindow(PamhyrWindow):
|
|||
editable_headers=editable_headers,
|
||||
delegates={"type": self._delegate_type},
|
||||
data=self._data,
|
||||
trad=self._trad,
|
||||
undo=self._undo_stack,
|
||||
opt_data=self._study.time_system
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue