Commit 5c7edbef authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

HS: Use profiles name instead of RK (select only).

No related merge requests found
Pipeline #58922 failed with stages
in 2 minutes and 10 seconds
Showing with 28 additions and 2 deletions
+28 -2
...@@ -253,6 +253,15 @@ class ProfileXYZ(Profile, SQLSubModel): ...@@ -253,6 +253,15 @@ class ProfileXYZ(Profile, SQLSubModel):
return point return point
def display_name(self):
name = ""
if self.name != "":
name += f"{self.name} "
name += f"({self.rk})"
return name
def x(self): def x(self):
return [point.x for point in self.points] return [point.x for point in self.points]
......
...@@ -65,7 +65,8 @@ class ComboBoxDelegate(QItemDelegate): ...@@ -65,7 +65,8 @@ class ComboBoxDelegate(QItemDelegate):
if reach is not None: if reach is not None:
val = list( val = list(
map( map(
lambda rk: str(rk), reach.reach.get_rk() lambda p: p.display_name(),
reach.reach.profiles
) )
) )
else: else:
...@@ -89,7 +90,23 @@ class ComboBoxDelegate(QItemDelegate): ...@@ -89,7 +90,23 @@ class ComboBoxDelegate(QItemDelegate):
def setModelData(self, editor, model, index): def setModelData(self, editor, model, index):
text = str(editor.currentText()) text = str(editor.currentText())
model.setData(index, text)
if self._mode == "rk":
reach = self._data.hydraulic_structures\
.get(index.row())\
.input_reach
profiles = list(
filter(
lambda p: p.display_name() == text,
reach.reach.profiles
)
)
value = profiles[0].rk if len(profiles) > 0 else None
else:
value = text
model.setData(index, value)
editor.close() editor.close()
editor.deleteLater() editor.deleteLater()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment