Restructure the record of root items in the tree class

This commit is contained in:
Veronica Berglyd Olsen
2022-04-02 19:13:54 +02:00
parent 8ddda4783d
commit f9ddcd2f8a
7 changed files with 66 additions and 33 deletions
+12
View File
@@ -608,6 +608,7 @@ class NWProject():
self.theParent.setStatus(self.tr("Opened Project: {0}").format(self.projName))
self._scanProjectFolder()
self._checkProjectTree()
self._loadProjectLocalisation()
self.updateWordCounts()
@@ -1340,6 +1341,17 @@ class NWProject():
xEntry.text = aValue
return
def _checkProjectTree(self):
"""Check the project tree and make sure all items have sensible
values.
"""
for tItem in self.projTree:
tHandle = tItem.itemHandle
logger.verbose("Checking item '%s'", tHandle)
if tItem.itemRoot is None:
self.projTree.updateItemRoot(tHandle)
logger.warning("Corrected the root setting of item '%s'", tHandle)
def _scanProjectFolder(self):
"""Scan the project folder and check that the files in it are
also in the project XML file. If they aren't, import them as