Skip to content

Commit

Permalink
mark model as modified when adding or removing ref nodeset
Browse files Browse the repository at this point in the history
  • Loading branch information
oroulet committed Jul 5, 2017
1 parent 7a4becc commit 98e221b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 6 additions & 4 deletions uamodeler/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class ModelManager(QObject):
"""

error = pyqtSignal(Exception)
titleChanged = pyqtSignal(str)
modelChanged = pyqtSignal()

def __init__(self, modeler):
QObject.__init__(self, modeler)
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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"):
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 6 additions & 2 deletions uamodeler/uamodeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 98e221b

Please sign in to comment.