Commit ec165867 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Geometry, ListedSubWindow: Use ListedSubWindow in Geometry windows.

Showing with 47 additions and 13 deletions
+47 -13
......@@ -462,10 +462,12 @@ class ASubWindowFeatures(object):
class ASubMainWindow(QMainWindow, ASubWindowFeatures, WindowToolKit):
def __init__(self, name="", ui="dummy", parent=None):
super(ASubMainWindow, self).__init__(parent=parent)
self.ui = loadUi(
os.path.join(os.path.dirname(__file__), "ui", f"{ui}.ui"),
self
)
if ui is not None:
self.ui = loadUi(
os.path.join(os.path.dirname(__file__), "ui", f"{ui}.ui"),
self
)
self.name = name
self.parent = parent
if self.parent is not None:
......
......@@ -37,7 +37,7 @@ from PyQt5.QtWidgets import (
from Model.Geometry.Reach import Reach
from Model.Geometry.ProfileXYZ import ProfileXYZ
from View.ASubWindow import WindowToolKit
from View.ASubWindow import ASubMainWindow
from View.Geometry.Profile.mainwindow_ui_profile import Ui_MainWindow
from View.Geometry.Profile.Plot import Plot
from View.Geometry.Profile.Table import *
......@@ -45,10 +45,14 @@ from View.Geometry.Profile.Table import *
_translate = QCoreApplication.translate
class ProfileWindow(QMainWindow, WindowToolKit):
def __init__(self, profile=None, parent=None):
class ProfileWindow(ASubMainWindow):
def __init__(self, profile=None, title="Profile", parent=None):
self._title = title
self.parent = parent
super(ProfileWindow, self).__init__(self.parent)
super(ProfileWindow, self).__init__(
name=self._title,
parent=self.parent
)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
......
......@@ -41,7 +41,8 @@ from View.Geometry.PlotXY import PlotXY
from View.Geometry.PlotKPC import PlotKPC
from View.Geometry.PlotAC import PlotAC
from View.ASubWindow import WindowToolKit
from View.ASubWindow import ASubMainWindow, WindowToolKit
from View.ListedSubWindow import ListedSubWindow
from View.Geometry.mainwindow_ui_reach import Ui_MainWindow
from View.Geometry.Table import *
from View.Geometry.Profile.Window import ProfileWindow
......@@ -49,10 +50,14 @@ from View.Geometry.Profile.Window import ProfileWindow
_translate = QCoreApplication.translate
class GeometryWindow(QMainWindow, WindowToolKit):
def __init__(self, model=None, parent=None):
class GeometryWindow(ASubMainWindow, ListedSubWindow):
def __init__(self, model=None, title="Geometry", parent=None):
self._title = title
self.parent = parent
super(GeometryWindow, self).__init__(parent=parent)
super(GeometryWindow, self).__init__(
name=self._title,
parent=parent
)
self._model = model
self._reach = model.river.current_reach().reach
......
......@@ -48,9 +48,32 @@ class ListedSubWindow(object):
self.sub_win_cnt = len(self.sub_win_list)
logger.info(f"Close window: {name} ({self.sub_win_cnt})")
def sub_win_exists(self, name):
def _sub_win_exists(self, name):
return reduce(
lambda acc, n: (acc or (n[0] == name)),
self.sub_win_list,
False
)
def _sub_win_exists_with_contain(self, name, contain):
return reduce(
lambda acc, n: (
acc or
(
(n[0] == name) and
reduce(
lambda acc, a: acc and (a in n[1]._title),
contain,
True
)
)
),
self.sub_win_list,
False
)
def sub_win_exists(self, name, contain = []):
if contain == []:
self._sub_win_exists(name)
else:
self._sub_win_exists_with_contain(name, contain)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment