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