mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "d922436ada65947ecd4b250e1bbe17e104ecd5c1" and "f9d83ac68cc980891791acfb3f190a477d41998f" have entirely different histories.
d922436ada
...
f9d83ac68c
|
|
@ -208,7 +208,7 @@ class Reach(SQLSubModel):
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
||||||
def delete(self, indexes):
|
def delete(self, indexes):
|
||||||
"""Set some elements as deleted in profile list
|
"""Delete some elements in profile list
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
indexes: The list of index to delete
|
indexes: The list of index to delete
|
||||||
|
|
@ -250,7 +250,7 @@ class Reach(SQLSubModel):
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
||||||
def delete_profiles(self, profiles):
|
def delete_profiles(self, profiles):
|
||||||
"""Set profiles list as deleted
|
"""Delete some elements in profile list
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
profiles: The list of profile to delete
|
profiles: The list of profile to delete
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,6 @@ from Model.Status import StudyStatus
|
||||||
from Model.Except import NotImplementedMethodeError
|
from Model.Except import NotImplementedMethodeError
|
||||||
from Model.River import River
|
from Model.River import River
|
||||||
from Model.Geometry.Reach import Reach
|
from Model.Geometry.Reach import Reach
|
||||||
from Model.HydraulicStructures.HydraulicStructures import (
|
|
||||||
HydraulicStructure
|
|
||||||
)
|
|
||||||
from Model.HydraulicStructures.Basic.HydraulicStructures import (
|
|
||||||
BasicHS
|
|
||||||
)
|
|
||||||
|
|
||||||
from Checker.Study import *
|
from Checker.Study import *
|
||||||
|
|
||||||
|
|
@ -469,29 +463,18 @@ class Study(SQLModel):
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def memory_clean(self, ids):
|
def memory_clean(self, ids):
|
||||||
if len(ids) == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
reach_class = Reach
|
|
||||||
hs_classes = [HydraulicStructure, BasicHS]
|
|
||||||
list_classes = set(PamhyrModelList.__subclasses__())
|
list_classes = set(PamhyrModelList.__subclasses__())
|
||||||
dict_classes = set(PamhyrModelDict.__subclasses__())
|
dict_classes = set(PamhyrModelDict.__subclasses__())
|
||||||
|
reach_class = Reach
|
||||||
|
|
||||||
def modifier(obj, data):
|
def modifier(obj, data):
|
||||||
t = type(obj)
|
t = type(obj)
|
||||||
|
|
||||||
if t is reach_class:
|
if t in list_classes:
|
||||||
obj._profiles = list(
|
obj._lst = list(
|
||||||
filter(
|
filter(
|
||||||
lambda el: el.id not in ids,
|
lambda el: el.id not in ids,
|
||||||
obj._profiles
|
obj._lst
|
||||||
)
|
|
||||||
)
|
|
||||||
elif t in hs_classes:
|
|
||||||
obj._data = list(
|
|
||||||
filter(
|
|
||||||
lambda el: el.id not in ids,
|
|
||||||
obj._data
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif t in dict_classes:
|
elif t in dict_classes:
|
||||||
|
|
@ -500,11 +483,11 @@ class Study(SQLModel):
|
||||||
if obj._dict[key].id not in ids:
|
if obj._dict[key].id not in ids:
|
||||||
new[key] = obj._dict[key]
|
new[key] = obj._dict[key]
|
||||||
obj._dict = new
|
obj._dict = new
|
||||||
elif t in list_classes:
|
elif t is reach_class:
|
||||||
obj._lst = list(
|
obj._profiles = list(
|
||||||
filter(
|
filter(
|
||||||
lambda el: el.id not in ids,
|
lambda el: el.id not in ids,
|
||||||
obj._lst
|
obj._profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -426,35 +426,30 @@ class GraphWidget(QGraphicsView):
|
||||||
|
|
||||||
dlg.setWindowTitle(self._trad["mb_save_title"])
|
dlg.setWindowTitle(self._trad["mb_save_title"])
|
||||||
dlg.setText(self._trad["mb_save_msg"])
|
dlg.setText(self._trad["mb_save_msg"])
|
||||||
opt = QMessageBox.Cancel | QMessageBox.Save | QMessageBox.Discard
|
opt = QMessageBox.Save | QMessageBox.Cancel
|
||||||
|
|
||||||
dlg.setStandardButtons(opt)
|
dlg.setStandardButtons(opt)
|
||||||
dlg.setIcon(QMessageBox.Warning)
|
dlg.setIcon(QMessageBox.Warning)
|
||||||
dlg.button(QMessageBox.Save).setText(self._trad["Save"])
|
dlg.button(QMessageBox.Save).setText(self._trad["Save"])
|
||||||
dlg.button(QMessageBox.Discard).setText(self._trad["Don't save"])
|
|
||||||
dlg.button(QMessageBox.Cancel).setText(self._trad["Cancel"])
|
dlg.button(QMessageBox.Cancel).setText(self._trad["Cancel"])
|
||||||
|
|
||||||
res = dlg.exec()
|
res = dlg.exec()
|
||||||
|
|
||||||
if res == QMessageBox.Save:
|
if res == QMessageBox.Save:
|
||||||
return "Save"
|
return True
|
||||||
elif res == QMessageBox.Cancel:
|
elif res == QMessageBox.Cancel:
|
||||||
return "Cancel"
|
return False
|
||||||
else:
|
|
||||||
return "Discard"
|
|
||||||
|
|
||||||
def select_scenario(self, item):
|
def select_scenario(self, item):
|
||||||
if type(item) is not ScenarioItem:
|
if type(item) is not ScenarioItem:
|
||||||
return
|
return
|
||||||
|
|
||||||
must_save = self.dialog_save()
|
must_saved = self.dialog_save()
|
||||||
if must_save == "Cancel":
|
|
||||||
return
|
|
||||||
|
|
||||||
def fn():
|
def fn():
|
||||||
self._close_other_window()
|
self._close_other_window()
|
||||||
|
|
||||||
if must_save == "Save":
|
if must_saved:
|
||||||
self._study.save()
|
self._study.save()
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,6 @@ class MainTranslate(UnitTranslate):
|
||||||
self._dict["No"] = _translate("MainWindow", "No")
|
self._dict["No"] = _translate("MainWindow", "No")
|
||||||
self._dict["Cancel"] = _translate("MainWindow", "Cancel")
|
self._dict["Cancel"] = _translate("MainWindow", "Cancel")
|
||||||
self._dict["Save"] = _translate("MainWindow", "Save")
|
self._dict["Save"] = _translate("MainWindow", "Save")
|
||||||
self._dict["Don't save"] = _translate("MainWindow", "Don't save")
|
|
||||||
self._dict["Close"] = _translate("MainWindow", "Close")
|
self._dict["Close"] = _translate("MainWindow", "Close")
|
||||||
self._dict["Solver"] = _translate("MainWindow", "Solver")
|
self._dict["Solver"] = _translate("MainWindow", "Solver")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@ class WaitingDialog(PamhyrDialog):
|
||||||
options=[],
|
options=[],
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
self._to_close = False
|
|
||||||
|
|
||||||
self._payload_fn = payload_fn
|
self._payload_fn = payload_fn
|
||||||
|
|
||||||
|
|
@ -132,7 +131,7 @@ class WaitingDialog(PamhyrDialog):
|
||||||
)
|
)
|
||||||
|
|
||||||
def end_worker(self):
|
def end_worker(self):
|
||||||
self._worker_thread.quit()
|
self._worker_thread.terminate()
|
||||||
self._worker_thread.wait()
|
self._worker_thread.wait()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
|
@ -142,12 +141,4 @@ class WaitingDialog(PamhyrDialog):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger_exception(e)
|
logger_exception(e)
|
||||||
|
|
||||||
self._to_close = True
|
|
||||||
|
|
||||||
super().close()
|
super().close()
|
||||||
|
|
||||||
def closeEvent(self, event):
|
|
||||||
if self._to_close:
|
|
||||||
super().closeEvent(event)
|
|
||||||
else:
|
|
||||||
event.ignore()
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue