Compare commits

..

7 Commits

5 changed files with 30 additions and 15 deletions

View File

@ -105,16 +105,6 @@ class Profile(SQLSubModel):
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
create = False
if major == "0" and int(minor) < 2:
cls._db_create(execute)
create = True
if major == "0" and int(minor) == 2:
if int(release) < 1 and not create:
cls._db_create(execute)
create = True
return cls._update_submodel(execute, version, data)

View File

@ -446,7 +446,7 @@ class Rubar3(CommandLineSolver):
ind = 1
for mail in edge.reach.inter_profiles_rk():
coef = get_stricklers_from_rk(mail, lst)
if coeff is not None:
if coef is not None:
f.write(f"{ind:>6} {coef:>12.5f}")
ind += 1

View File

@ -276,7 +276,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
"action_menu_new": self.open_new_study,
"action_menu_edit": self.open_edit_study,
"action_menu_open": self.open_model,
"action_menu_save": self.save_study,
"action_menu_save": lambda: self.save_study(),
"action_menu_save_as": self.save_as_study,
"action_menu_numerical_parameter": self.open_solver_parameters,
"action_menu_edit_scenarios": self.open_scenarios,
@ -637,7 +637,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
logger.info(f"Open Study - {self._study.name}")
self.set_title()
def save_study(self):
def _save(self, source):
self.save_study(progress_parent=source)
def save_study(self, progress_parent=None):
"""Save current study
Save current study, if study as no associate file, open a
@ -667,11 +670,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self._backup_timer.blockSignals(True)
self._save_mutex.lock()
parent = self
if progress_parent is not None:
parent = progress_parent
sql_request_count = self._study.sql_save_request_count()
progress = QProgressDialog(
"Saving...", None,
0, sql_request_count,
parent=self
parent=parent
)
progress.setWindowModality(Qt.WindowModal)
progress.setValue(0)
@ -684,6 +691,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
progress=lambda: progress.setValue(progress.value() + 1)
)
progress.close()
status += " Done"
logger.info(status)
self.statusbar.showMessage(status, 3000)
@ -758,6 +766,8 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
progress.setValue(progress.value() + 1)
progress.close()
def save_as_study_single_scenario(self, sid=-1):
sql_request_count = self._study.sql_save_request_count()
@ -782,6 +792,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
)
status += " Done"
progress.close()
logger.info(status)
self.statusbar.showMessage(status, 3000)

View File

@ -182,6 +182,7 @@ class PamhyrWindow(ASubMainWindow, ListedSubWindow, PamhyrWindowTools):
self._set_title()
self._set_icon()
self._setup_save_sc()
def _set_title(self):
title = self._title
@ -196,12 +197,25 @@ class PamhyrWindow(ASubMainWindow, ListedSubWindow, PamhyrWindowTools):
self.ui.setWindowTitle(title)
def _setup_save_sc(self):
if self._parent is None:
return
self._save_sc = QShortcut(QKeySequence("Ctrl+S"), self)
self._save_sc.activated.connect(lambda: self._save(self))
def closeEvent(self, event):
self._close_sub_window()
self._propagate_update(Modules.WINDOW_LIST)
super(PamhyrWindow, self).closeEvent(event)
def _save(self, source):
if self._parent is None:
return
return self._parent._save(source)
class PamhyrDialog(ASubWindow, ListedSubWindow, PamhyrWindowTools):
_pamhyr_ui = "dummy"