mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
- adding characters count. Implementing #334
This commit is contained in:
parent
67db180c25
commit
c6da77baf9
|
@ -60,6 +60,7 @@ class Outline(IntEnum):
|
|||
textFormat = 15
|
||||
revisions = 16
|
||||
customIcon = 17
|
||||
charCount = 18
|
||||
|
||||
class Abstract(IntEnum):
|
||||
title = 0
|
||||
|
|
|
@ -80,6 +80,10 @@ class outlineItem(abstractItem):
|
|||
def wordCount(self):
|
||||
return self._data.get(self.enum.wordCount, 0)
|
||||
|
||||
def charCount(self):
|
||||
return self._data.get(self.enum.charCount, 0)
|
||||
|
||||
|
||||
#######################################################################
|
||||
# Data
|
||||
#######################################################################
|
||||
|
@ -144,6 +148,7 @@ class outlineItem(abstractItem):
|
|||
if column == E.text:
|
||||
wc = F.wordCount(data)
|
||||
self.setData(E.wordCount, wc)
|
||||
self.setData(E.charCount, len(data))
|
||||
|
||||
if column == E.compile:
|
||||
# Title changes when compile changes
|
||||
|
@ -187,9 +192,12 @@ class outlineItem(abstractItem):
|
|||
|
||||
else:
|
||||
wc = 0
|
||||
cc = 0
|
||||
for c in self.children():
|
||||
wc += F.toInt(c.data(self.enum.wordCount))
|
||||
cc += F.toInt(c.data(self.enum.charCount))
|
||||
self._data[self.enum.wordCount] = wc
|
||||
self._data[self.enum.charCount] = cc
|
||||
|
||||
setGoal = F.toInt(self.data(self.enum.setGoal))
|
||||
goal = F.toInt(self.data(self.enum.goal))
|
||||
|
@ -460,6 +468,7 @@ class outlineItem(abstractItem):
|
|||
|
||||
# We don't want to write some datas (computed)
|
||||
XMLExclude = [enums.Outline.wordCount,
|
||||
enums.Outline.charCount,
|
||||
enums.Outline.goal,
|
||||
enums.Outline.goalPercentage,
|
||||
enums.Outline.revisions]
|
||||
|
|
|
@ -302,6 +302,7 @@ class mainEditor(QWidget, Ui_mainEditor):
|
|||
|
||||
wc = item.data(Outline.wordCount)
|
||||
goal = item.data(Outline.goal)
|
||||
chars = item.data(Outline.charCount) # len(item.data(Outline.text))
|
||||
progress = item.data(Outline.goalPercentage)
|
||||
# mw = qApp.activeWindow()
|
||||
|
||||
|
@ -317,12 +318,14 @@ class mainEditor(QWidget, Ui_mainEditor):
|
|||
drawProgress(p, rect, progress, 2)
|
||||
del p
|
||||
self.lblRedacProgress.setPixmap(self.px)
|
||||
self.lblRedacWC.setText(self.tr("{} words / {} ").format(
|
||||
self.lblRedacWC.setText(self.tr("({} chars) {} words / {} ").format(
|
||||
chars,
|
||||
locale.format("%d", wc, grouping=True),
|
||||
locale.format("%d", goal, grouping=True)))
|
||||
else:
|
||||
self.lblRedacProgress.hide()
|
||||
self.lblRedacWC.setText(self.tr("{} words ").format(
|
||||
self.lblRedacWC.setText(self.tr("({} chars) {} words ").format(
|
||||
chars,
|
||||
locale.format("%d", wc, grouping=True)))
|
||||
|
||||
###############################################################################
|
||||
|
|
Loading…
Reference in a new issue