mirror of https://gitlab.com/pamhyr/pamhyr2
Results: Message box where study version and results version are different.
parent
fa8fe508a7
commit
46b943c800
|
|
@ -49,6 +49,7 @@ class Results(SQLSubModel):
|
|||
self._meta_data = {
|
||||
# Keep results creation date
|
||||
"creation_date": datetime.now(),
|
||||
"study_revision": study.status.version,
|
||||
}
|
||||
|
||||
@property
|
||||
|
|
@ -212,7 +213,7 @@ class Results(SQLSubModel):
|
|||
"nb_timestamps, timestamps, " +
|
||||
"scenario) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
self._pamhyr_id, solver_name, solver_type,
|
||||
self._status.scenario.id, self.get("creation_date"),
|
||||
self._status.version, self.get("creation_date"),
|
||||
len(ts), struct.pack(sf, *ts), self._owner_scenario
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -90,8 +90,14 @@ class StudyStatus(object):
|
|||
logger.debug("model status set as saved")
|
||||
self._saved = True
|
||||
|
||||
def _set_as_not_saved(self):
|
||||
self._saved = False
|
||||
|
||||
def _set_as_saved(self):
|
||||
self._saved = True
|
||||
|
||||
def modified(self):
|
||||
if self._saved:
|
||||
self.version += 1
|
||||
|
||||
self._saved = False
|
||||
self._set_as_not_saved()
|
||||
|
|
|
|||
|
|
@ -389,6 +389,8 @@ class Study(SQLModel):
|
|||
|
||||
new._river._db_load_results(sql_exec, data=data)
|
||||
|
||||
new.status._set_as_saved()
|
||||
|
||||
return new
|
||||
|
||||
def _save(self, progress=None):
|
||||
|
|
|
|||
|
|
@ -608,6 +608,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
self._last_solver = solver
|
||||
self.last_results = results
|
||||
|
||||
self._study.status.set_as_not_saved()
|
||||
self.enable_actions("action_menu_results_last", True)
|
||||
|
||||
############
|
||||
|
|
@ -1485,6 +1486,25 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
)
|
||||
sol.show()
|
||||
|
||||
def msg_box_results_continue(self):
|
||||
dlg = QMessageBox(self)
|
||||
|
||||
dlg.setWindowTitle(self._trad["mb_results_continue_title"])
|
||||
dlg.setText(self._trad["mb_results_continue_msg"])
|
||||
opt = QMessageBox.No | QMessageBox.Yes
|
||||
|
||||
dlg.setStandardButtons(opt)
|
||||
dlg.setIcon(QMessageBox.Question)
|
||||
dlg.button(QMessageBox.Yes).setText(self._trad["Yes"])
|
||||
dlg.button(QMessageBox.No).setText(self._trad["No"])
|
||||
|
||||
res = dlg.exec()
|
||||
|
||||
if res == QMessageBox.Yes:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def open_solver_results(self, solver, results=None):
|
||||
def reading_fn():
|
||||
self._tmp_results = results
|
||||
|
|
@ -1530,6 +1550,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
if not results.is_valid:
|
||||
return
|
||||
|
||||
if results.get('study_revision') != self._study.status.version:
|
||||
if not self.msg_box_results_continue():
|
||||
return
|
||||
|
||||
# Windows already opened
|
||||
if self.sub_window_exists(
|
||||
ResultsWindow,
|
||||
|
|
|
|||
|
|
@ -217,6 +217,17 @@ class MainTranslate(UnitTranslate):
|
|||
"Do you want to save current study before closing it?"
|
||||
)
|
||||
|
||||
self._dict["mb_results_continue_title"] = _translate(
|
||||
"MainWindow", "Results"
|
||||
)
|
||||
self._dict["mb_results_continue_msg"] = _translate(
|
||||
"MainWindow",
|
||||
"The version of the results does not match "
|
||||
"the version of the study. "
|
||||
"One or more data has been modified after the last simulation "
|
||||
"Do you still want to open those results?"
|
||||
)
|
||||
|
||||
self._dict["x"] = _translate("MainWindow", "X (m)")
|
||||
self._dict["y"] = _translate("MainWindow", "Y (m)")
|
||||
self._dict["Yes"] = _translate("MainWindow", "Yes")
|
||||
|
|
|
|||
Loading…
Reference in New Issue