From 5e90b1ff77497bb59fc89565f2315de9c6543eb3 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 14 Apr 2020 22:20:40 +0200 Subject: [PATCH] Clear the outline header between projects --- nw/gui/elements/outline.py | 15 ++++++++++----- nw/guimain.py | 1 + nw/tools/optionstate.py | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/nw/gui/elements/outline.py b/nw/gui/elements/outline.py index 7d5ab4a5..51b6817f 100644 --- a/nw/gui/elements/outline.py +++ b/nw/gui/elements/outline.py @@ -97,24 +97,29 @@ class GuiProjectOutline(QTreeWidget): self.colIndex = {} self.treeNCols = 0 - self.initOutline() + self.clearOutline() self.headerMenu.setHiddenState(self.colHidden) logger.debug("ProjectOutline initialisation complete") return - def initOutline(self): - """Set the default values for the Outline tree. + def clearOutline(self): + """Clear the tree and header and set the default values for the + columns arrays. """ + self.clear() + self.setColumnCount(1) + self.setHeaderLabel(nwLabels.OUTLINE_COLS[nwOutline.TITLE]) + self.treeOrder = [] self.colWidth = {} self.colHidden = {} self.colIndex = {} self.treeNCols = 0 - for hItem in nwOutline: + for i, hItem in enumerate(nwOutline): self.treeOrder.append(hItem) self.colWidth[hItem] = self.DEF_WIDTH[hItem] self.colHidden[hItem] = self.DEF_HIDDEN[hItem] @@ -153,7 +158,7 @@ class GuiProjectOutline(QTreeWidget): """Called before a project is closed. """ self._saveHeaderState() - self.clear() + self.clearOutline() self.firstView = True return diff --git a/nw/guimain.py b/nw/guimain.py index cb1331bc..43dea7fb 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -315,6 +315,7 @@ class GuiMain(QMainWindow): self.theIndex.clearIndex() self.clearGUI() self.hasProject = False + self.tabWidget.setCurrentWidget(self.splitView) return saveOK diff --git a/nw/tools/optionstate.py b/nw/tools/optionstate.py index 881ff4e5..2f0fa554 100644 --- a/nw/tools/optionstate.py +++ b/nw/tools/optionstate.py @@ -38,6 +38,9 @@ class OptionState(): """Load the options dictionary from the project settings file. """ + if self.theProject.projMeta is None: + return False + stateFile = path.join(self.theProject.projMeta, nwFiles.OPTS_FILE) theState = {} @@ -60,6 +63,9 @@ class OptionState(): """Save the options dictionary to the project settings file. """ + if self.theProject.projMeta is None: + return False + stateFile = path.join(self.theProject.projMeta, nwFiles.OPTS_FILE) logger.debug("Saving GUI options file")