Restructured the index a bit, and added more columns to the outline

This commit is contained in:
Veronica K. B. Olsen
2019-11-16 16:29:38 +01:00
parent 2b3e95ce73
commit d09fb50bfc
2 changed files with 137 additions and 40 deletions
+54 -7
View File
@@ -15,6 +15,7 @@ import nw
from os import path
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
QWidget, QVBoxLayout, QTreeWidget, QTreeWidgetItem
)
@@ -25,6 +26,31 @@ logger = logging.getLogger(__name__)
class GuiProjectOutline(QWidget):
I_TITLE = 0
I_LEVEL = 1
I_LABEL = 2
I_LINE = 3
I_WORDS = 4
I_CHARS = 5
I_PARAS = 6
I_SYNOP = 7
COL_ORDER = [
I_TITLE, I_LEVEL, I_LABEL, I_LINE,
I_WORDS, I_CHARS, I_PARAS, I_SYNOP,
]
COL_LABELS = {
I_TITLE : "Title",
I_LEVEL : "Level",
I_LABEL : "Document",
I_LINE : "Line",
I_WORDS : "Words",
I_CHARS : "Chars",
I_PARAS : "Pars",
I_SYNOP : "Synopsis",
}
def __init__(self, theParent, theProject):
QWidget.__init__(self, theParent)
@@ -39,8 +65,9 @@ class GuiProjectOutline(QWidget):
self.showSynopsis = True
self.showFilePath = False
self.outerBox = QVBoxLayout()
self.mainTree = QTreeWidget()
self.outerBox = QVBoxLayout()
self.mainTree = QTreeWidget()
self.treeOrder = self.COL_ORDER
self.outerBox.addWidget(self.mainTree)
self.outerBox.setContentsMargins(0,0,0,0)
@@ -52,8 +79,17 @@ class GuiProjectOutline(QWidget):
def populateTree(self):
theLabels = []
for n in self.treeOrder:
theLabels.append(self.COL_LABELS[n])
self.mainTree.clear()
self.mainTree.setHeaderLabels(["Title","Level","Document","Line"])
self.mainTree.setHeaderLabels(theLabels)
treeHead = self.mainTree.headerItem()
treeHead.setTextAlignment(self.I_CHARS,Qt.AlignRight)
treeHead.setTextAlignment(self.I_WORDS,Qt.AlignRight)
treeHead.setTextAlignment(self.I_PARAS,Qt.AlignRight)
currTitle = None
currChapter = None
@@ -69,11 +105,22 @@ class GuiProjectOutline(QWidget):
continue
for tEntry in self.theIndex.novelIndex[tHandle]:
theLine = str(tEntry[0])
newItem = QTreeWidgetItem([""]*4)
newItem.setText(0, tEntry[2])
newItem.setText(1, str(tEntry[1]))
newItem.setText(2, nwItem.itemName)
newItem.setText(3, str(tEntry[0]))
newItem.setText(self.I_TITLE, tEntry[2])
newItem.setText(self.I_LEVEL, str(tEntry[1]))
newItem.setText(self.I_LABEL, nwItem.itemName)
newItem.setText(self.I_LINE, theLine)
cC, wC, pC = self.theIndex.getCounts(tHandle, theLine)
newItem.setText(self.I_CHARS, str(cC))
newItem.setText(self.I_WORDS, str(wC))
newItem.setText(self.I_PARAS, str(pC))
newItem.setTextAlignment(self.I_CHARS,Qt.AlignRight)
newItem.setTextAlignment(self.I_WORDS,Qt.AlignRight)
newItem.setTextAlignment(self.I_PARAS,Qt.AlignRight)
if tEntry[1] == 1:
currTitle = newItem