From 7b9da12aa4f183ad012ad2bb44d2d0b1e748b617 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 13 Apr 2020 16:57:43 +0200 Subject: [PATCH] Fixed a bug where outline header state from previous seession was restored on outline update --- nw/gui/elements/outline.py | 32 +++++++++++-------- .../sampleNovel/data_6/a2d6d5f4f401_main.nwd | 3 +- sample/sampleNovel/nwProject.nwx | 4 +-- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/nw/gui/elements/outline.py b/nw/gui/elements/outline.py index 26ce7855..7d5ab4a5 100644 --- a/nw/gui/elements/outline.py +++ b/nw/gui/elements/outline.py @@ -130,7 +130,7 @@ class GuiProjectOutline(QTreeWidget): """ # If it's the first time, we always build - if self.firstView or overRide: + if self.firstView or self.firstView and overRide: self._loadHeaderState() self._populateTree() self.firstView = False @@ -176,6 +176,7 @@ class GuiProjectOutline(QTreeWidget): of the columns. """ self.treeOrder.insert(newVisualIdx, self.treeOrder.pop(oldVisualIdx)) + self._saveHeaderState() return def _menuColumnToggled(self, isChecked, theItem): @@ -185,6 +186,7 @@ class GuiProjectOutline(QTreeWidget): logger.verbose("User toggled Outline column '%s'" % theItem.name) if theItem in self.colIndex: self.setColumnHidden(self.colIndex[theItem], not isChecked) + self._saveHeaderState() return ## @@ -282,21 +284,23 @@ class GuiProjectOutline(QTreeWidget): """Build the tree based on the project index. """ - theLabels = [] - for i, hItem in enumerate(self.treeOrder): - theLabels.append(nwLabels.OUTLINE_COLS[hItem]) - self.colIndex[hItem] = i - self.clear() - self.setHeaderLabels(theLabels) - for hItem in self.treeOrder: - self.setColumnWidth(self.colIndex[hItem], self.colWidth[hItem]) - self.setColumnHidden(self.colIndex[hItem], self.colHidden[hItem]) - headItem = self.headerItem() - headItem.setTextAlignment(self.colIndex[nwOutline.CCOUNT], Qt.AlignRight) - headItem.setTextAlignment(self.colIndex[nwOutline.WCOUNT], Qt.AlignRight) - headItem.setTextAlignment(self.colIndex[nwOutline.PCOUNT], Qt.AlignRight) + if self.firstView: + theLabels = [] + for i, hItem in enumerate(self.treeOrder): + theLabels.append(nwLabels.OUTLINE_COLS[hItem]) + self.colIndex[hItem] = i + + self.setHeaderLabels(theLabels) + for hItem in self.treeOrder: + self.setColumnWidth(self.colIndex[hItem], self.colWidth[hItem]) + self.setColumnHidden(self.colIndex[hItem], self.colHidden[hItem]) + + headItem = self.headerItem() + headItem.setTextAlignment(self.colIndex[nwOutline.CCOUNT], Qt.AlignRight) + headItem.setTextAlignment(self.colIndex[nwOutline.WCOUNT], Qt.AlignRight) + headItem.setTextAlignment(self.colIndex[nwOutline.PCOUNT], Qt.AlignRight) currTitle = None currChapter = None diff --git a/sample/sampleNovel/data_6/a2d6d5f4f401_main.nwd b/sample/sampleNovel/data_6/a2d6d5f4f401_main.nwd index cee10674..c9e0b7a9 100644 --- a/sample/sampleNovel/data_6/a2d6d5f4f401_main.nwd +++ b/sample/sampleNovel/data_6/a2d6d5f4f401_main.nwd @@ -3,4 +3,5 @@ @pov: Jane @location: Earth -%synopsis: We can add a chapter file, but keep the scene files separate. In the chapter file we can set the meta data that applies to the whole chapter if we wish to. \ No newline at end of file +%synopsis: We can add a chapter file, but keep the scene files separate. In the chapter file we can set the meta data that applies to the whole chapter if we wish to. + diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index 53cd2fe6..5b4c6835 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -71,7 +71,7 @@ 12 3 0 - 15 + 214 Making a Scene