Project Details page Overview populated
This commit is contained in:
+24
-3
@@ -42,6 +42,8 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class NWIndex():
|
class NWIndex():
|
||||||
|
|
||||||
|
H_LEVEL = {"H0": 0, "H1": 1, "H2": 2, "H3": 3, "H4": 4}
|
||||||
|
|
||||||
def __init__(self, theProject, theParent):
|
def __init__(self, theProject, theParent):
|
||||||
|
|
||||||
# Internal
|
# Internal
|
||||||
@@ -592,11 +594,30 @@ class NWIndex():
|
|||||||
tKey = "%s:%s" % (tHandle, sTitle)
|
tKey = "%s:%s" % (tHandle, sTitle)
|
||||||
yield tKey, tHandle, sTitle, self._novelIndex[tHandle][sTitle]
|
yield tKey, tHandle, sTitle, self._novelIndex[tHandle][sTitle]
|
||||||
|
|
||||||
|
def getNovelCounts(self, skipExcluded=True):
|
||||||
|
"""Count the number of titles in the novel project.
|
||||||
|
"""
|
||||||
|
hCount = [0, 0, 0, 0, 0]
|
||||||
|
for tItem in self.theProject.projTree:
|
||||||
|
if tItem is None:
|
||||||
|
continue
|
||||||
|
if not tItem.isExported and skipExcluded:
|
||||||
|
continue
|
||||||
|
|
||||||
|
tHandle = tItem.itemHandle
|
||||||
|
if tHandle not in self._novelIndex:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for sTitle in self._novelIndex[tHandle]:
|
||||||
|
theData = self._novelIndex[tHandle][sTitle]
|
||||||
|
iLevel = self.H_LEVEL.get(theData["level"], 0)
|
||||||
|
hCount[iLevel] += 1
|
||||||
|
|
||||||
|
return hCount
|
||||||
|
|
||||||
def getTableOfContents(self, maxDepth, skipExcluded=True):
|
def getTableOfContents(self, maxDepth, skipExcluded=True):
|
||||||
"""Generate a table of contents up to a maxiumum depth.
|
"""Generate a table of contents up to a maxiumum depth.
|
||||||
"""
|
"""
|
||||||
hLevel = {"H0": 0, "H1": 1, "H2": 2, "H3": 3, "H4": 4}
|
|
||||||
|
|
||||||
tOrder = []
|
tOrder = []
|
||||||
tData = {}
|
tData = {}
|
||||||
pKey = None
|
pKey = None
|
||||||
@@ -613,7 +634,7 @@ class NWIndex():
|
|||||||
for sTitle in sorted(self._novelIndex[tHandle]):
|
for sTitle in sorted(self._novelIndex[tHandle]):
|
||||||
tKey = "%s:%s" % (tHandle, sTitle)
|
tKey = "%s:%s" % (tHandle, sTitle)
|
||||||
theData = self._novelIndex[tHandle][sTitle]
|
theData = self._novelIndex[tHandle][sTitle]
|
||||||
iLevel = hLevel.get(theData["level"], 0)
|
iLevel = self.H_LEVEL.get(theData["level"], 0)
|
||||||
if iLevel > maxDepth:
|
if iLevel > maxDepth:
|
||||||
if pKey in tData:
|
if pKey in tData:
|
||||||
theData["wCount"]
|
theData["wCount"]
|
||||||
|
|||||||
+73
-1
@@ -30,9 +30,10 @@ import logging
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
|
from PyQt5.QtGui import QFont
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QWidget, QDialogButtonBox, QVBoxLayout, QTreeWidget, QTreeWidgetItem,
|
QWidget, QDialogButtonBox, QVBoxLayout, QTreeWidget, QTreeWidgetItem,
|
||||||
QLabel, QSpinBox, QGroupBox, QGridLayout
|
QLabel, QSpinBox, QGroupBox, QGridLayout, QHBoxLayout
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.gui.custom import PagedDialog, QSwitch
|
from nw.gui.custom import PagedDialog, QSwitch
|
||||||
@@ -131,6 +132,77 @@ class GuiProjectDetailsMain(QWidget):
|
|||||||
self.mainConf = nw.CONFIG
|
self.mainConf = nw.CONFIG
|
||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
self.theProject = theProject
|
self.theProject = theProject
|
||||||
|
self.theTheme = theParent.theTheme
|
||||||
|
self.theIndex = theParent.theIndex
|
||||||
|
|
||||||
|
fPx = self.theTheme.fontPixelSize
|
||||||
|
vPx = self.mainConf.pxInt(4)
|
||||||
|
hPx = self.mainConf.pxInt(12)
|
||||||
|
|
||||||
|
# Header
|
||||||
|
# ======
|
||||||
|
|
||||||
|
self.bookTitle = QLabel(self.theProject.bookTitle)
|
||||||
|
bookFont = self.bookTitle.font()
|
||||||
|
bookFont.setPixelSize(round(2.2*fPx))
|
||||||
|
bookFont.setWeight(QFont.Bold)
|
||||||
|
self.bookTitle.setFont(bookFont)
|
||||||
|
self.bookTitle.setAlignment(Qt.AlignHCenter)
|
||||||
|
|
||||||
|
self.projName = QLabel("Working Title: %s" % self.theProject.projName)
|
||||||
|
workFont = self.projName.font()
|
||||||
|
workFont.setPixelSize(round(0.8*fPx))
|
||||||
|
workFont.setItalic(True)
|
||||||
|
self.projName.setFont(workFont)
|
||||||
|
self.projName.setAlignment(Qt.AlignHCenter)
|
||||||
|
|
||||||
|
self.bookAuthors = QLabel("By: %s" % ", ".join(self.theProject.bookAuthors))
|
||||||
|
authFont = self.bookAuthors.font()
|
||||||
|
authFont.setPixelSize(round(1.2*fPx))
|
||||||
|
self.bookAuthors.setFont(authFont)
|
||||||
|
self.bookAuthors.setAlignment(Qt.AlignHCenter)
|
||||||
|
|
||||||
|
# Stats
|
||||||
|
# =====
|
||||||
|
|
||||||
|
hCounts = self.theIndex.getNovelCounts()
|
||||||
|
|
||||||
|
self.wordCountLbl = QLabel("<b>Words:</b>")
|
||||||
|
self.wordCountVal = QLabel(f"{self.theProject.currWCount:n}")
|
||||||
|
|
||||||
|
self.chapCountLbl = QLabel("<b>Chapters:</b>")
|
||||||
|
self.chapCountVal = QLabel(f"{hCounts[2]:n}")
|
||||||
|
|
||||||
|
self.sceneCountLbl = QLabel("<b>Scenes:</b>")
|
||||||
|
self.sceneCountVal = QLabel(f"{hCounts[3]:n}")
|
||||||
|
|
||||||
|
self.statsGrid = QGridLayout()
|
||||||
|
self.statsGrid.addWidget(self.wordCountLbl, 0, 0, 1, 1, Qt.AlignLeft)
|
||||||
|
self.statsGrid.addWidget(self.wordCountVal, 0, 1, 1, 1, Qt.AlignRight)
|
||||||
|
self.statsGrid.addWidget(self.chapCountLbl, 1, 0, 1, 1, Qt.AlignLeft)
|
||||||
|
self.statsGrid.addWidget(self.chapCountVal, 1, 1, 1, 1, Qt.AlignRight)
|
||||||
|
self.statsGrid.addWidget(self.sceneCountLbl, 2, 0, 1, 1, Qt.AlignLeft)
|
||||||
|
self.statsGrid.addWidget(self.sceneCountVal, 2, 1, 1, 1, Qt.AlignRight)
|
||||||
|
self.statsGrid.setHorizontalSpacing(hPx)
|
||||||
|
self.statsGrid.setVerticalSpacing(vPx)
|
||||||
|
|
||||||
|
self.statsBox = QHBoxLayout()
|
||||||
|
self.statsBox.addStretch(1)
|
||||||
|
self.statsBox.addLayout(self.statsGrid)
|
||||||
|
self.statsBox.addStretch(1)
|
||||||
|
|
||||||
|
# Assemble
|
||||||
|
# ========
|
||||||
|
|
||||||
|
self.outerBox = QVBoxLayout()
|
||||||
|
self.outerBox.addWidget(self.bookTitle)
|
||||||
|
self.outerBox.addWidget(self.projName)
|
||||||
|
self.outerBox.addWidget(self.bookAuthors)
|
||||||
|
self.outerBox.addSpacing(round(2.5*fPx))
|
||||||
|
self.outerBox.addLayout(self.statsBox)
|
||||||
|
self.outerBox.addStretch(1)
|
||||||
|
|
||||||
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user