Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #418: Error printout in the logger #420

Merged
merged 1 commit into from
Aug 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 17 additions & 11 deletions nw/gui/doceditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,7 @@ def __init__(self, docEditor):
self.theTheme = docEditor.theTheme
self.optState = docEditor.theProject.optState
self.theHandle = None
self.theItem = None

# Make a QPalette that matches the Syntax Theme
self.thePalette = QPalette()
Expand Down Expand Up @@ -2009,27 +2010,33 @@ def setHandle(self, tHandle):
"""Set the handle that will populate the footer's data.
"""
self.theHandle = tHandle
if self.theHandle is None:
logger.verbose("No handle set, so clearing the editor footer")
self.theItem = None
else:
self.theItem = self.theProject.projTree[self.theHandle]

self.updateInfo()
self.updateCounts()

return

def updateInfo(self):
"""Update the content of text labels.
"""
nwItem = self.theProject.projTree[self.theHandle]
if nwItem is None:
sIcon = QPixmap()
sText = ""
if self.theItem is None:
sIcon = QPixmap()
sText = ""
else:
iStatus = nwItem.itemStatus
if nwItem.itemClass == nwItemClass.NOVEL:
iStatus = self.theItem.itemStatus
if self.theItem.itemClass == nwItemClass.NOVEL:
iStatus = self.theProject.statusItems.checkEntry(iStatus)
theIcon = self.theParent.statusIcons[iStatus]
else:
iStatus = self.theProject.importItems.checkEntry(iStatus)
theIcon = self.theParent.importIcons[iStatus]
sIcon = theIcon.pixmap(self.sPx, self.sPx)
sText = nwItem.itemStatus
sText = self.theItem.itemStatus

self.statusIcon.setPixmap(sIcon)
self.statusText.setText(sText)
Expand All @@ -2039,13 +2046,12 @@ def updateInfo(self):
def updateCounts(self):
"""Update the word counts.
"""
nwItem = self.theProject.projTree[self.theHandle]
if nwItem is None:
if self.theItem is None:
wCount = 0
wDiff = 0
else:
wCount = nwItem.wordCount
wDiff = wCount - nwItem.initCount
wCount = self.theItem.wordCount
wDiff = wCount - self.theItem.initCount

self.wordsText.setText("Words: {:n} ({:+n})".format(wCount, wDiff))

Expand Down