Skip to content

Commit

Permalink
Simplify how the project tree is populated
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Jul 25, 2024
1 parent 06aa2e6 commit 33497bc
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
1 change: 1 addition & 0 deletions novelwriter/gui/projtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def closeProjectTasks(self) -> None:

def openProjectTasks(self) -> None:
"""Run open project tasks."""
self.populateTree()
self.projBar.buildQuickLinksMenu()
self.projBar.setEnabled(True)
return
Expand Down
9 changes: 0 additions & 9 deletions novelwriter/guimain.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ def __init__(self) -> None:
self.splitView.setVisible(False)
self.docEditor.closeSearch()

# Initialise the Project Tree
self.rebuildTrees()

# Assemble Main Window Elements
self.mainBox = QHBoxLayout()
self.mainBox.addWidget(self.sideBar)
Expand Down Expand Up @@ -463,7 +460,6 @@ def openProject(self, projFile: str | Path | None) -> bool:

# Update GUI
self._updateWindowTitle(SHARED.project.data.name)
self.rebuildTrees()
self.docEditor.toggleSpellCheck(SHARED.project.data.spellCheck)
self.mainStatus.setRefTime(SHARED.project.projOpened)
self.projView.openProjectTasks()
Expand Down Expand Up @@ -737,11 +733,6 @@ def openSelectedItem(self) -> None:

return

def rebuildTrees(self) -> None:
"""Rebuild the project tree."""
self.projView.populateTree()
return

def rebuildIndex(self, beQuiet: bool = False) -> None:
"""Rebuild the entire index."""
if SHARED.hasProject:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dialogs/test_dlg_projectsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, projPath, mockRn
project.tree[hCharNote].setImport(C.iMajor) # type: ignore
project.tree[hWorldNote].setImport(C.iMain) # type: ignore

nwGUI.rebuildTrees()
nwGUI.projView.populateTree()
project.countStatus()

assert [e.count for _, e in project.data.itemStatus.iterItems()] == [2, 0, 2, 1]
Expand Down
2 changes: 1 addition & 1 deletion tests/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def buildTestProject(obj: object, projPath: Path) -> None:
project._valid = True

if nwGUI is not None:
nwGUI.rebuildTrees()
nwGUI.projView.populateTree()

return

Expand Down

0 comments on commit 33497bc

Please sign in to comment.