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 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,
|
||||||
|
|
@ -59,39 +58,35 @@ _translate = QCoreApplication.translate
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class FrictionsWindow(ASubMainWindow, ListedSubWindow):
|
class FrictionsWindow(PamhyrWindow):
|
||||||
def __init__(self, title="Frictions", study=None, parent=None):
|
_pamhyr_ui = "Frictions"
|
||||||
self._study = study
|
_pamhyr_name = "Edit frictions"
|
||||||
self._reach = self._study.river.current_reach()
|
|
||||||
|
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._frictions = self._reach.frictions
|
||||||
|
|
||||||
self.setup_title(title)
|
name = (
|
||||||
|
self._pamhyr_name + " - "
|
||||||
super(FrictionsWindow, self).__init__(
|
+ study.name + " - "
|
||||||
name=title, ui="Frictions", parent=parent
|
+ self._reach.name
|
||||||
|
)
|
||||||
|
|
||||||
|
super(FrictionsWindow, self).__init__(
|
||||||
|
title = name,
|
||||||
|
study = study,
|
||||||
|
config = config,
|
||||||
|
parent = parent
|
||||||
)
|
)
|
||||||
|
|
||||||
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_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):
|
def setup_table(self):
|
||||||
retranslate()
|
retranslate()
|
||||||
|
|
@ -156,11 +151,6 @@ class FrictionsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||||
self.find(QAction, "action_edit_stricklers").triggered.connect(self.edit_stricklers)
|
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 = self.find(QTableView, f"tableView")
|
||||||
table.selectionModel()\
|
table.selectionModel()\
|
||||||
.selectionChanged\
|
.selectionChanged\
|
||||||
|
|
@ -234,16 +224,16 @@ class FrictionsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
row = self.index_selected_row()
|
row = self.index_selected_row()
|
||||||
self._table.move_down(row)
|
self._table.move_down(row)
|
||||||
|
|
||||||
def copy(self):
|
def _copy(self):
|
||||||
logger.info("TODO: copy")
|
logger.info("TODO: copy")
|
||||||
|
|
||||||
def paste(self):
|
def _paste(self):
|
||||||
logger.info("TODO: paste")
|
logger.info("TODO: paste")
|
||||||
|
|
||||||
def undo(self):
|
def _undo(self):
|
||||||
self._table.undo()
|
self._table.undo()
|
||||||
|
|
||||||
def redo(self):
|
def _redo(self):
|
||||||
self._table.redo()
|
self._table.redo()
|
||||||
|
|
||||||
def edit_stricklers(self):
|
def edit_stricklers(self):
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ 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
|
||||||
# from View.SedimentLayers.Window import SedimentLayersWindow
|
# from View.SedimentLayers.Window import SedimentLayersWindow
|
||||||
# from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow
|
# from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow
|
||||||
# from View.SolverParameters.Window import SolverParametersWindow
|
# from View.SolverParameters.Window import SolverParametersWindow
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
@ -50,32 +49,23 @@ _translate = QCoreApplication.translate
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class StricklersWindow(ASubMainWindow, ListedSubWindow):
|
class StricklersWindow(PamhyrWindow):
|
||||||
def __init__(self, title="Stricklers", study=None, config=None, parent=None):
|
_pamhyr_ui = "Stricklers"
|
||||||
self._title = title + " - " + study.name
|
_pamhyr_name = "Stricklers"
|
||||||
|
|
||||||
|
def __init__(self, study=None, config=None, parent=None):
|
||||||
|
name = self._pamhyr_name + " - " + study.name
|
||||||
|
|
||||||
super(StricklersWindow, self).__init__(
|
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_table()
|
||||||
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 = {}
|
||||||
|
|
@ -105,11 +95,6 @@ class StricklersWindow(ASubMainWindow, ListedSubWindow):
|
||||||
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)
|
|
||||||
|
|
||||||
def index_selected_rows(self):
|
def index_selected_rows(self):
|
||||||
table = self.find(QTableView, f"tableView_study")
|
table = self.find(QTableView, f"tableView_study")
|
||||||
return list(
|
return list(
|
||||||
|
|
@ -139,14 +124,14 @@ class StricklersWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def sort(self):
|
def sort(self):
|
||||||
self._table['study'].sort(False)
|
self._table['study'].sort(False)
|
||||||
|
|
||||||
def copy(self):
|
def _copy(self):
|
||||||
logger.info("TODO: copy")
|
logger.info("TODO: copy")
|
||||||
|
|
||||||
def paste(self):
|
def _paste(self):
|
||||||
logger.info("TODO: paste")
|
logger.info("TODO: paste")
|
||||||
|
|
||||||
def undo(self):
|
def _undo(self):
|
||||||
self._table['study'].undo()
|
self._table['study'].undo()
|
||||||
|
|
||||||
def redo(self):
|
def _redo(self):
|
||||||
self._table['study'].redo()
|
self._table['study'].redo()
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ from View.Tools.ASubWindow import AWidget
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class PamhyrWidget(AWidget):
|
class PamhyrWidget(AWidget):
|
||||||
_pamhyr_ui = ""
|
_pamhyr_ui = None
|
||||||
_pamhyr_name = "PamhyrWidget"
|
_pamhyr_name = "PamhyrWidget"
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue