mirror of https://gitlab.com/pamhyr/pamhyr2
refarctoring: Apply PamhyrWindow to frictions.
parent
b2b5c971c3
commit
809a0dd9cb
|
|
@ -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,
|
||||
|
|
@ -59,39 +58,35 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class FrictionsWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Frictions", study=None, parent=None):
|
||||
self._study = study
|
||||
self._reach = self._study.river.current_reach()
|
||||
class FrictionsWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "Frictions"
|
||||
_pamhyr_name = "Edit frictions"
|
||||
|
||||
def __init__(self, reach=None, study=None, config=None, parent=None):
|
||||
if reach is not None:
|
||||
self._reach = reach
|
||||
else:
|
||||
self._reach = study.river.current_reach()
|
||||
|
||||
self._frictions = self._reach.frictions
|
||||
|
||||
self.setup_title(title)
|
||||
|
||||
super(FrictionsWindow, self).__init__(
|
||||
name=title, ui="Frictions", parent=parent
|
||||
name = (
|
||||
self._pamhyr_name + " - "
|
||||
+ study.name + " - "
|
||||
+ self._reach.name
|
||||
)
|
||||
|
||||
super(FrictionsWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent = parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
def setup_title(self, title):
|
||||
self._title = (
|
||||
title + " - "
|
||||
+ self._study.name + " - "
|
||||
+ self._reach.name
|
||||
)
|
||||
|
||||
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()
|
||||
|
|
@ -156,11 +151,6 @@ class FrictionsWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||
self.find(QAction, "action_edit_stricklers").triggered.connect(self.edit_stricklers)
|
||||
|
||||
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)
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
table.selectionModel()\
|
||||
.selectionChanged\
|
||||
|
|
@ -234,16 +224,16 @@ class FrictionsWindow(ASubMainWindow, ListedSubWindow):
|
|||
row = self.index_selected_row()
|
||||
self._table.move_down(row)
|
||||
|
||||
def copy(self):
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
def _paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
def _undo(self):
|
||||
self._table.undo()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
self._table.redo()
|
||||
|
||||
def edit_stricklers(self):
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ from View.Geometry.Window import GeometryWindow
|
|||
from View.BoundaryCondition.Window import BoundaryConditionWindow
|
||||
from View.LateralContribution.Window import LateralContributionWindow
|
||||
from View.InitialConditions.Window import InitialConditionsWindow
|
||||
# from View.Stricklers.Window import StricklersWindow
|
||||
# from View.Frictions.Window import FrictionsWindow
|
||||
from View.Stricklers.Window import StricklersWindow
|
||||
from View.Frictions.Window import FrictionsWindow
|
||||
# from View.SedimentLayers.Window import SedimentLayersWindow
|
||||
# from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow
|
||||
# from View.SolverParameters.Window import SolverParametersWindow
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -50,32 +49,23 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class StricklersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Stricklers", study=None, config=None, parent=None):
|
||||
self._title = title + " - " + study.name
|
||||
class StricklersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "Stricklers"
|
||||
_pamhyr_name = "Stricklers"
|
||||
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
|
||||
super(StricklersWindow, self).__init__(
|
||||
name=title, ui="Stricklers", parent=parent
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent = parent
|
||||
)
|
||||
|
||||
self._study = study
|
||||
self._config = config
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
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 = {}
|
||||
|
|
@ -105,11 +95,6 @@ class StricklersWindow(ASubMainWindow, ListedSubWindow):
|
|||
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)
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView_study")
|
||||
return list(
|
||||
|
|
@ -139,14 +124,14 @@ class StricklersWindow(ASubMainWindow, ListedSubWindow):
|
|||
def sort(self):
|
||||
self._table['study'].sort(False)
|
||||
|
||||
def copy(self):
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
def _paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
def _undo(self):
|
||||
self._table['study'].undo()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
self._table['study'].redo()
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from View.Tools.ASubWindow import AWidget
|
|||
logger = logging.getLogger()
|
||||
|
||||
class PamhyrWidget(AWidget):
|
||||
_pamhyr_ui = ""
|
||||
_pamhyr_ui = None
|
||||
_pamhyr_name = "PamhyrWidget"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
|
|
|
|||
Loading…
Reference in New Issue