From 33497bc92debdedc63d52d98af6aefc040ec8d6a Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Thu, 25 Jul 2024 20:47:14 +0200 Subject: [PATCH] Simplify how the project tree is populated --- novelwriter/gui/projtree.py | 1 + novelwriter/guimain.py | 9 --------- tests/test_dialogs/test_dlg_projectsettings.py | 2 +- tests/tools.py | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index b6a9fdc0a..a96a43a7e 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -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 diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index a43524c92..1a20ed58a 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -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) @@ -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() @@ -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: diff --git a/tests/test_dialogs/test_dlg_projectsettings.py b/tests/test_dialogs/test_dlg_projectsettings.py index ace5bcae8..9c7836d2a 100644 --- a/tests/test_dialogs/test_dlg_projectsettings.py +++ b/tests/test_dialogs/test_dlg_projectsettings.py @@ -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] diff --git a/tests/tools.py b/tests/tools.py index 072b2313e..6bcfbe312 100644 --- a/tests/tools.py +++ b/tests/tools.py @@ -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