Add project variables for character counts

This commit is contained in:
Veronica Berglyd Olsen
2025-04-29 22:00:53 +02:00
parent 8de6fd25e2
commit bd4a658bd9
8 changed files with 104 additions and 57 deletions
+9 -5
View File
@@ -410,16 +410,20 @@ class NWTree:
return True
def sumWords(self) -> tuple[int, int]:
"""Loop over all entries and add up the word counts."""
noteWords = 0
def sumWords(self) -> tuple[int, int, int, int]:
"""Loop over all entries and add up the word and char counts."""
novelWords = 0
notesWords = 0
novelChars = 0
notesChars = 0
for item in self._items.values():
if item.itemLayout == nwItemLayout.NOTE:
noteWords += item.wordCount
notesWords += item.wordCount
notesChars += item.charCount
elif item.itemLayout == nwItemLayout.DOCUMENT:
novelWords += item.wordCount
return novelWords, noteWords
novelChars += item.charCount
return novelWords, notesWords, novelChars, notesChars
##
# Tree Item Methods