diff --git a/src/View/LateralContribution/Edit/Table.py b/src/View/LateralContribution/Edit/Table.py index 2fff0895e9506bee8f366343ec031b7cb71f5898..8b43602d4f38533550fac8b45913ea79d33d91a3 100644 --- a/src/View/LateralContribution/Edit/Table.py +++ b/src/View/LateralContribution/Edit/Table.py @@ -22,8 +22,6 @@ from datetime import date, time, datetime, timedelta from tools import trace, timer -from View.ASubWindow import ASubMainWindow, AWidget -from View.ListedSubWindow import ListedSubWindow from View.Tools.PamhyrTable import PamhyrTableModel from PyQt5.QtCore import ( diff --git a/src/View/LateralContribution/Edit/Window.py b/src/View/LateralContribution/Edit/Window.py index 53576a6b7671afa7cd45bda4c75fbbee47da9fdd..f37c1759b31db6500450307d4ce00dee2a3f2da7 100644 --- a/src/View/LateralContribution/Edit/Window.py +++ b/src/View/LateralContribution/Edit/Window.py @@ -18,8 +18,7 @@ from tools import timer, trace -from View.ASubWindow import ASubMainWindow -from View.ListedSubWindow import ListedSubWindow +from View.Tools.PamhyrWindow import PamhyrWindow from View.Tools.PamhyrDelegate import PamhyrExTimeDelegate from PyQt5.QtGui import ( @@ -47,44 +46,36 @@ from View.LateralContribution.Edit.Plot import Plot _translate = QCoreApplication.translate -class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow): - def __init__(self, title="Edit lateral contribution", - data=None, study=None, parent=None): - self._data = data - self._study = study - self._title = title - - self.compute_title() - - super(EditLateralContributionWindow, self).__init__( - name=title, ui="EditLateralContribution", parent=parent - ) +class EditLateralContributionWindow(PamhyrWindow): + _pamhyr_ui = "EditLateralContribution" + _pamhyr_name = "Edit lateral contribution" - self.ui.setWindowTitle(self._title) - - self.setup_sc() - self.setup_table() - self.setup_plot() - self.setup_connections() + def __init__(self, data=None, + study=None, config=None, + parent=None): + self._data = data - def compute_title(self): + name = self._pamhyr_name if self._data is not None: 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) + - f" - {self._study.name} " + + name = ( + _translate("Edit lateral contribution", self._pamhyr_name) + + f" - {study.name} " + f" - {self._data.name} ({self._data.id}) " + f"({long_types[self._data.lctype]} - {edge_name})" ) - def setup_sc(self): - self._undo_stack = QUndoStack() + super(EditLateralContributionWindow, self).__init__( + title = name, + study = study, + config = config, + parent = parent + ) - self.undo_sc = QShortcut(QKeySequence.Undo, self) - self.redo_sc = QShortcut(QKeySequence.Redo, self) - self.copy_sc = QShortcut(QKeySequence.Copy, self) - self.paste_sc = QShortcut(QKeySequence.Paste, self) + self.setup_table() + self.setup_plot() + self.setup_connections() def setup_table(self): retranslate() @@ -133,17 +124,11 @@ class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow): ) self.plot.draw() - def setup_connections(self): self.find(QAction, "action_add").triggered.connect(self.add) self.find(QAction, "action_del").triggered.connect(self.delete) self.find(QAction, "action_sort").triggered.connect(self.sort) - self.undo_sc.activated.connect(self.undo) - self.redo_sc.activated.connect(self.redo) - self.copy_sc.activated.connect(self.copy) - self.paste_sc.activated.connect(self.paste) - self._table.dataChanged.connect(self.update) def update(self): @@ -199,8 +184,7 @@ class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow): self._table.move_down(row) self.plot.update() - - def copy(self): + def _copy(self): rows = self.index_selected_rows() table = [] @@ -212,7 +196,7 @@ class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow): self.copyTableIntoClipboard(table) - def paste(self): + def _paste(self): header, data = self.parseClipboardTable() if len(data) == 0: @@ -226,10 +210,10 @@ class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow): self._table.paste(row, header, data) self.plot.update() - def undo(self): + def _undo(self): self._table.undo() self.plot.update() - def redo(self): + def _redo(self): self._table.redo() self.plot.update() diff --git a/src/View/LateralContribution/Window.py b/src/View/LateralContribution/Window.py index 31f8290641c3fd58fc394ec285df08914d03093b..2793ee36990648221c5d45bf07294612a34410f1 100644 --- a/src/View/LateralContribution/Window.py +++ b/src/View/LateralContribution/Window.py @@ -20,8 +20,7 @@ import logging from tools import trace, timer -from View.ASubWindow import ASubMainWindow -from View.ListedSubWindow import ListedSubWindow +from View.Tools.PamhyrWindow import PamhyrWindow from PyQt5.QtGui import ( QKeySequence, @@ -66,32 +65,26 @@ _translate = QCoreApplication.translate logger = logging.getLogger() -class LateralContributionWindow(ASubMainWindow, ListedSubWindow): - def __init__(self, title="Lateral contribution", study=None, parent=None): - self._title = title + " - " + study.name +class LateralContributionWindow(PamhyrWindow): + _pamhyr_ui = "LateralContributions" + _pamhyr_name = "Lateral contribution" + + def __init__(self, study=None, config=None, parent=None): + name = self._pamhyr_name + " - " + study.name super(LateralContributionWindow, self).__init__( - name=title, ui="LateralContributions", parent=parent + title = name, + study = study, + config = config, + parent=parent ) - self._study = study self._lcs = self._study.river.lateral_contribution - self.setup_sc() self.setup_table() self.setup_graph() self.setup_connections() - self.ui.setWindowTitle(self._title) - - def setup_sc(self): - self._undo_stack = QUndoStack() - - self.undo_sc = QShortcut(QKeySequence.Undo, self) - self.redo_sc = QShortcut(QKeySequence.Redo, self) - self.copy_sc = QShortcut(QKeySequence.Copy, self) - self.paste_sc = QShortcut(QKeySequence.Paste, self) - def setup_table(self): retranslate() self._table = {} @@ -146,11 +139,6 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow): self.find(QAction, "action_edit").triggered.connect(self.edit) self.find(QAction, "action_sort").triggered.connect(self.sort) - self.undo_sc.activated.connect(self.undo) - self.redo_sc.activated.connect(self.redo) - self.copy_sc.activated.connect(self.copy) - self.paste_sc.activated.connect(self.paste) - for t in ["liquid", "solid", "suspenssion"]: table = self.find(QTableView, f"tableView_{t}") table.selectionModel()\ @@ -247,20 +235,20 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow): self._table[tab].move_down(row) self._set_current_reach() - def copy(self): + def _copy(self): logger.info("TODO: copy") self._set_current_reach() - def paste(self): + def _paste(self): logger.info("TODO: paste") self._set_current_reach() - def undo(self): + def _undo(self): tab = self.current_tab() self._table[tab].undo() self._set_current_reach() - def redo(self): + def _redo(self): tab = self.current_tab() self._table[tab].redo() self._set_current_reach() diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index f701a47447f46bffacd57e80e44bfc9ce216b96e..02a4e1fefe8475d344aa026078f96fd65bc3e85e 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -46,7 +46,7 @@ from View.About.Window import AboutWindow from View.Network.Window import NetworkWindow from View.Geometry.Window import GeometryWindow from View.BoundaryCondition.Window import BoundaryConditionWindow -# from View.LateralContribution.Window import LateralContributionWindow +from View.LateralContribution.Window import LateralContributionWindow # from View.InitialConditions.Window import InitialConditionsWindow # from View.Stricklers.Window import StricklersWindow # from View.Frictions.Window import FrictionsWindow