From 1ad156054c4895f7e5a01b07e03c4ff23c42aa1f Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 9 May 2020 21:49:05 +0200 Subject: [PATCH] Make sure information is synced properly when item label is changed --- nw/gui/dialogs/itemeditor.py | 4 ++-- nw/gui/elements/doceditor.py | 8 ++++++++ nw/gui/elements/doctree.py | 4 ++-- nw/gui/elements/docviewer.py | 8 ++++++++ nw/guimain.py | 5 ++++- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/nw/gui/dialogs/itemeditor.py b/nw/gui/dialogs/itemeditor.py index fbd7d4dd..432ddb08 100644 --- a/nw/gui/dialogs/itemeditor.py +++ b/nw/gui/dialogs/itemeditor.py @@ -44,7 +44,7 @@ class GuiItemEditor(QDialog): def __init__(self, theParent, theProject, tHandle): QDialog.__init__(self, theParent) - logger.debug("Initialising ItemEditor ...") + logger.debug("Initialising GuiItemEditor ...") self.mainConf = nw.CONFIG self.theProject = theProject @@ -141,7 +141,7 @@ class GuiItemEditor(QDialog): self.editName.selectAll() - logger.debug("ItemEditor initialisation complete") + logger.debug("GuiItemEditor initialisation complete") return diff --git a/nw/gui/elements/doceditor.py b/nw/gui/elements/doceditor.py index 96966ddd..8aa583da 100644 --- a/nw/gui/elements/doceditor.py +++ b/nw/gui/elements/doceditor.py @@ -352,6 +352,14 @@ class GuiDocEditor(QTextEdit): return + def updateDocTitle(self, tHandle): + """Called when an item label is changed to check if the document + title bar needs updating, + """ + if tHandle == self.theHandle: + self.docTitle.setTitleFromHandle(self.theHandle) + return + ## # Setters and Getters ## diff --git a/nw/gui/elements/doctree.py b/nw/gui/elements/doctree.py index 193295e1..0c6b8bb2 100644 --- a/nw/gui/elements/doctree.py +++ b/nw/gui/elements/doctree.py @@ -526,8 +526,8 @@ class GuiDocTree(QTreeWidget): newItem.setText(self.C_HANDLE, tHandle) # newItem.setForeground(self.C_COUNT,QColor(*self.theParent.theTheme.treeWCount)) - newItem.setTextAlignment(self.C_COUNT,Qt.AlignRight) - newItem.setFont(self.C_FLAGS,self.fontFlags) + newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight) + newItem.setFont(self.C_FLAGS, self.fontFlags) self.theMap[tHandle] = newItem if pHandle is None: diff --git a/nw/gui/elements/docviewer.py b/nw/gui/elements/docviewer.py index af51e908..9f3d65ff 100644 --- a/nw/gui/elements/docviewer.py +++ b/nw/gui/elements/docviewer.py @@ -192,6 +192,14 @@ class GuiDocViewer(QTextBrowser): return False return True + def updateDocTitle(self, tHandle): + """Called when an item label is changed to check if the document + title bar needs updating, + """ + if tHandle == self.theHandle: + self.docTitle.setTitleFromHandle(self.theHandle) + return + ## # Events ## diff --git a/nw/guimain.py b/nw/guimain.py index bbf047b0..c76e9c6f 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -629,6 +629,9 @@ class GuiMain(QMainWindow): dlgProj = GuiItemEditor(self, self.theProject, tHandle) if dlgProj.exec_(): self.treeView.setTreeItemValues(tHandle) + self.treeMeta.updateViewBox(tHandle) + self.docEditor.updateDocTitle(tHandle) + self.docViewer.updateDocTitle(tHandle) return @@ -1006,7 +1009,7 @@ class GuiMain(QMainWindow): def _treeSingleClick(self): sHandle = self.treeView.getSelectedHandle() if sHandle is not None: - self.treeMeta.buildViewBox(sHandle) + self.treeMeta.updateViewBox(sHandle) return def _treeDoubleClick(self, tItem, colNo):