From 98e221b12bbb30c50ad96abfe80d2d1298ce3cb7 Mon Sep 17 00:00:00 2001 From: oroulet Date: Wed, 5 Jul 2017 22:14:14 +0200 Subject: [PATCH] mark model as modified when adding or removing ref nodeset --- uamodeler/model_manager.py | 10 ++++++---- uamodeler/uamodeler.py | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/uamodeler/model_manager.py b/uamodeler/model_manager.py index 1dfebf5..a0598de 100644 --- a/uamodeler/model_manager.py +++ b/uamodeler/model_manager.py @@ -24,6 +24,8 @@ class ModelManager(QObject): """ error = pyqtSignal(Exception) + titleChanged = pyqtSignal(str) + modelChanged = pyqtSignal() def __init__(self, modeler): QObject.__init__(self, modeler) @@ -63,7 +65,7 @@ def close_model(self, force=False): self.server_mgr.stop_server() self.current_path = None self.modified = False - self.modeler.update_title("") + self.titleChanged.emit("") self.modeler.clear_all_widgets() def new_model(self): @@ -81,7 +83,7 @@ def new_model(self): self.modified = False self.modeler.actions.enable_model_actions() self.current_path = None - self.modeler.update_title("No Name") + self.titleChanged.emit("No Name") return True def import_xml(self, path): @@ -105,7 +107,7 @@ def _open_xml(self, path): path = self.import_xml(path) self.modified = False self.current_path = path - self.modeler.update_title(self.current_path) + self.titleChanged.emit(self.current_path) def open(self, path): if path.endswith(".xml"): @@ -137,7 +139,7 @@ def _get_path(self, path): if path is None: raise ValueError("No path is defined") self.current_path = os.path.splitext(path)[0] - self.modeler.update_title(self.current_path) + self.titleChanged.emit(self.current_path) return self.current_path def save_xml(self, path=None): diff --git a/uamodeler/uamodeler.py b/uamodeler/uamodeler.py index 02ed15a..fec0909 100644 --- a/uamodeler/uamodeler.py +++ b/uamodeler/uamodeler.py @@ -165,12 +165,14 @@ class ModelManagerUI(QObject): """ error = pyqtSignal(Exception) + titleChanged = pyqtSignal(str) def __init__(self, modeler): QObject.__init__(self) self.modeler = modeler self._model_mgr = ModelManager(modeler) self._model_mgr.error.connect(self.error) + self._model_mgr.titleChanged.connect(self.titleChanged) self.settings = QSettings() self._last_model_dir = self.settings.value("last_model_dir", ".") self._copy_clipboard = None @@ -181,8 +183,8 @@ def get_current_server(self): def get_new_nodes(self): return self._model_mgr.new_nodes - def setModified(self, val): - self.model_mgr.modified = val + def setModified(self, val=True): + self._model_mgr.modified = val @trycatchslot def new(self): @@ -360,6 +362,7 @@ def __init__(self): self.model_mgr = ModelManagerUI(self) self.model_mgr.error.connect(self.show_error) + self.model_mgr.titleChanged.connect(self.update_title) self.actions = ActionsManager(self.ui, self.model_mgr) self.setup_context_menu_tree() @@ -424,6 +427,7 @@ def _restore_ui_geometri(self): self.ui.splitterLeft.restoreState(self.settings.value("splitter_left", bytearray())) self.ui.splitterRight.restoreState(self.settings.value("splitter_right", bytearray())) self.ui.splitterCenter.restoreState(self.settings.value("splitter_center", bytearray())) + def update_title(self, path): self.setWindowTitle("FreeOpcUa Modeler " + str(path))