mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Model: Minor change.
This commit is contained in:
1 parent
504ef7ec48
commit
609e9d39db
3 files changed
+11
-4
No files matched your search
+6
-2
@@ -1,5 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class SavedStatus(object):
|
class SavedStatus(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(SavedStatus, self).__init__()
|
super(SavedStatus, self).__init__()
|
||||||
@@ -9,9 +13,9 @@ class SavedStatus(object):
|
|||||||
return self._saved
|
return self._saved
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
# print(" * save")
|
logger.debug("model status set as saved")
|
||||||
self._saved = True
|
self._saved = True
|
||||||
|
|
||||||
def modified(self):
|
def modified(self):
|
||||||
# print(" * modified ...")
|
logger.debug("model status set as modified")
|
||||||
self._saved = False
|
self._saved = False
|
||||||
+2
-2
@@ -74,7 +74,7 @@ class Study(SQLModel):
|
|||||||
fdir, fname = os.path.split(self.filename)
|
fdir, fname = os.path.split(self.filename)
|
||||||
|
|
||||||
if self._old_save_id == 0:
|
if self._old_save_id == 0:
|
||||||
old_dir = os.path.join(fdir, "__old__")
|
old_dir = os.path.join(fdir, "_PAMHYR_", "__old__")
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
old_dir = old_dir.replace("/", "\\")
|
old_dir = old_dir.replace("/", "\\")
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ class Study(SQLModel):
|
|||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
|
||||||
fname = fname + "." + str(self._old_save_id)
|
fname = fname + "." + str(self._old_save_id)
|
||||||
filename = os.path.join(fdir, "__old__", fname)
|
filename = os.path.join(fdir, "_PAMHYR_", "__old__", fname)
|
||||||
shutil.copy(self.filename, filename)
|
shutil.copy(self.filename, filename)
|
||||||
self._old_save_id += 1
|
self._old_save_id += 1
|
||||||
|
|
||||||
|
|||||||
@@ -298,6 +298,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
else:
|
else:
|
||||||
self.model.filename = file_name + ".pamhyr"
|
self.model.filename = file_name + ".pamhyr"
|
||||||
|
|
||||||
|
if self.model.is_saved:
|
||||||
|
return
|
||||||
|
|
||||||
logger.info("Save...")
|
logger.info("Save...")
|
||||||
self.model.save()
|
self.model.save()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user