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