From d8a44e63e715622038e032f8e74b2ded1c54915d Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Thu, 27 Feb 2020 22:29:57 +0100 Subject: [PATCH] Some minor cleanup in the outline class --- nw/gui/elements/outline.py | 40 +++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/nw/gui/elements/outline.py b/nw/gui/elements/outline.py index ed10b1ee..35c364de 100644 --- a/nw/gui/elements/outline.py +++ b/nw/gui/elements/outline.py @@ -129,20 +129,12 @@ class GuiProjectOutline(QWidget): # Internal Functions ## - def _saveHeaderState(self): - - colW = [] - for iCol in range(self.mainTree.columnCount()): - colW.append(self.mainTree.columnWidth(iCol)) - - self.treeCols["width"] = colW - self.optState.setValue("GuiProjectOutline", "headState", self.treeCols) - self.optState.saveSettings() - return - def _loadHeaderState(self): + """Load the state of the main tree header, that is, column order + and column width. + """ - treeCols = self.optState.getValue("GuiProjectOutline", "headState", {}) + treeCols = self.optState.getValue("GuiProjectOutline", "headerState", self.treeCols) if "order" not in treeCols.keys(): return if not isinstance(treeCols["order"], list): return @@ -159,7 +151,24 @@ class GuiProjectOutline(QWidget): return + def _saveHeaderState(self): + """Save the state of the main tree header, that is, column order + and column width. + """ + + colW = [] + for iCol in range(self.mainTree.columnCount()): + colW.append(self.mainTree.columnWidth(iCol)) + + self.treeCols["width"] = colW + self.optState.setValue("GuiProjectOutline", "headerState", self.treeCols) + self.optState.saveSettings() + + return + def _populateTree(self): + """Build the tree based on the project index. + """ theLabels = [] for i, n in enumerate(self.treeCols["order"]): @@ -238,6 +247,8 @@ class GuiProjectOutline(QWidget): return def _createTreeItem(self, tHandle, sTitle): + """Populate a tree item with all the column values. + """ nwItem = self.theProject.getItem(tHandle) novIdx = self.theIndex.novelIndex[tHandle][sTitle] @@ -265,10 +276,13 @@ class GuiProjectOutline(QWidget): return newItem def _setItemText(self, tItem, colID, theText, rAlign=False): + """Set the correct text in the correct column, and if necessary, + right align it. + """ if colID in self.colIndex: tItem.setText(self.colIndex[colID], theText) if rAlign: - tItem.setTextAlignment(self.colIndex[colID],Qt.AlignRight) + tItem.setTextAlignment(self.colIndex[colID], Qt.AlignRight) return # END Class GuiProjectOutline