BC, LC: Forbidden duplicate window.

results
Pierre-Antoine Rouby 2023-08-04 15:55:25 +02:00
parent 289c8ed129
commit 94a0a96659
6 changed files with 57 additions and 25 deletions

View File

@ -71,7 +71,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
self._title = (
_translate("Edit boundary condition", self._title) +
f" - {self._study.name} " +
f" - {self._data.name} " +
f" - {self._data.name} ({self._data.id}) " +
f"({long_types[self._data.bctype]} - {node_name})"
)

View File

@ -65,7 +65,7 @@ logger = logging.getLogger()
class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
def __init__(self, title="Boundary conditions", study=None, parent=None):
title = title + " - " + study.name
self._title = title + " - " + study.name
super(BoundaryConditionWindow, self).__init__(
name=title, ui="BoundaryConditions", parent=parent
@ -79,7 +79,7 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
self.setup_graph()
self.setup_connections()
self.ui.setWindowTitle(title)
self.ui.setWindowTitle(self._title)
def setup_sc(self):
self._undo_stack = QUndoStack()
@ -220,9 +220,17 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
tab = self.current_tab()
rows = self.index_selected_rows()
for row in rows:
win = self.sub_win_filter_first(
"Edit boundary condition",
contain = [f"({self._bcs.get(tab, row).id})"]
)
if win is None:
win = EditBoundaryConditionWindow(
data=self._bcs.get(tab, row),
study=self._study,
parent=self
)
win.show()
else:
win.activateWindow()

View File

@ -45,7 +45,7 @@ from View.LateralContribution.Edit.Plot import Plot
_translate = QCoreApplication.translate
class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow):
def __init__(self, title="Edit lateral conditribution",
def __init__(self, title="Edit lateral contribution",
data=None, study=None, parent=None):
self._data = data
self._study = study
@ -54,7 +54,7 @@ class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow):
self.compute_title()
super(EditLateralContributionWindow, self).__init__(
name=self._title, ui="EditLateralContribution", parent=parent
name=title, ui="EditLateralContribution", parent=parent
)
self.ui.setWindowTitle(self._title)
@ -69,9 +69,9 @@ class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow):
edge_name = (self._data.edge.name if self._data.edge is not None
else _translate("LateralContribution", "Not associate"))
self._title = (
_translate("Edit Lateral contribution", self._title) +
_translate("Edit lateral contribution", self._title) +
f" - {self._study.name} " +
f" - {self._data.name} " +
f" - {self._data.name} ({self._data.id}) " +
f"({long_types[self._data.lctype]} - {edge_name})"
)

View File

@ -65,7 +65,7 @@ logger = logging.getLogger()
class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
def __init__(self, title="Lateral contribution", study=None, parent=None):
title = title + " - " + study.name
self._title = title + " - " + study.name
super(LateralContributionWindow, self).__init__(
name=title, ui="LateralContributions", parent=parent
@ -79,7 +79,7 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
self.setup_graph()
self.setup_connections()
self.ui.setWindowTitle(title)
self.ui.setWindowTitle(self._title)
def setup_sc(self):
self._undo_stack = QUndoStack()
@ -266,9 +266,17 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
tab = self.current_tab()
rows = self.index_selected_rows()
for row in rows:
win = self.sub_win_filter_first(
"Edit lateral contribution",
contain = [f"({self._lcs.get(tab, row).id})"]
)
if win is None:
win = EditLateralContributionWindow(
data=self._lcs.get(tab, row),
study=self._study,
parent=self
)
win.show()
else:
win.activateWindow()

View File

@ -83,7 +83,7 @@ class ListedSubWindow(object):
return next(
filter(
lambda n: (
(n[0] == name) and
(name in n[0]) and
reduce(
lambda acc, c: acc and (c in n[1]._title),
contain,

View File

@ -461,7 +461,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
contain = [self.model.river.current_reach().name]
)
if geometry == None:
if geometry is None:
geometry = GeometryWindow(model=self.model, parent=self)
geometry.show()
else:
@ -470,12 +470,28 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self.msg_select_reach()
def open_boundary_cond(self):
bound = self.sub_win_filter_first(
"Boundary conditions",
contain = []
)
if bound is None:
bound = BoundaryConditionWindow(study = self.model, parent = self)
bound.show()
else:
bound.activateWindow()
def open_lateral_contrib(self):
lateral = self.sub_win_filter_first(
"Lateral contribution",
contain = []
)
if lateral is None:
lateral = LateralContributionWindow(study = self.model, parent = self)
lateral.show()
else:
lateral.activateWindow()
def open_stricklers(self):
strick = StricklersWindow(