Added item status, and added icons and flags to the main treeview
This commit is contained in:
+20
-3
@@ -25,7 +25,7 @@ class NWItem():
|
||||
|
||||
MAX_DEPTH = 8
|
||||
CLASS_NAME = {
|
||||
nwItemClass.NO_CLASS : "Folder",
|
||||
nwItemClass.NO_CLASS : "Custom",
|
||||
nwItemClass.NOVEL : "Novel",
|
||||
nwItemClass.PLOT : "Plot",
|
||||
nwItemClass.CHARACTER : "Characters",
|
||||
@@ -42,6 +42,15 @@ class NWItem():
|
||||
nwItemClass.TIMELINE : "T",
|
||||
nwItemClass.OBJECT : "O",
|
||||
}
|
||||
LAYOUT_NAME = {
|
||||
nwItemLayout.NO_LAYOUT : "None",
|
||||
nwItemLayout.TITLE_PAGE : "Title Page",
|
||||
nwItemLayout.SIMPLE_PAGE : "Simple Page",
|
||||
nwItemLayout.PARTITION : "Partition",
|
||||
nwItemLayout.CHAPTER : "Chapter",
|
||||
nwItemLayout.SCENE : "Scene",
|
||||
nwItemLayout.NOTE : "Note",
|
||||
}
|
||||
LAYOUT_FLAG = {
|
||||
nwItemLayout.NO_LAYOUT : "Xo",
|
||||
nwItemLayout.TITLE_PAGE : "Tt",
|
||||
@@ -49,6 +58,7 @@ class NWItem():
|
||||
nwItemLayout.PARTITION : "Pt",
|
||||
nwItemLayout.CHAPTER : "Ch",
|
||||
nwItemLayout.SCENE : "Sc",
|
||||
nwItemLayout.NOTE : "Nt",
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
@@ -60,6 +70,7 @@ class NWItem():
|
||||
self.itemType = nwItemType.NO_TYPE
|
||||
self.itemClass = nwItemClass.NO_CLASS
|
||||
self.itemLayout = nwItemLayout.NO_LAYOUT
|
||||
self.itemStatus = 0
|
||||
self.itemDepth = None
|
||||
self.hasChildren = False
|
||||
self.isExpanded = False
|
||||
@@ -83,12 +94,12 @@ class NWItem():
|
||||
xSub = self._subPack(xPack,"name", text=str(self.itemName))
|
||||
xSub = self._subPack(xPack,"type", text=str(self.itemType.name))
|
||||
xSub = self._subPack(xPack,"class", text=str(self.itemClass.name))
|
||||
xSub = self._subPack(xPack,"status", text=str(self.itemStatus))
|
||||
xSub = self._subPack(xPack,"depth", text=str(self.itemDepth))
|
||||
xSub = self._subPack(xPack,"children", text=str(self.hasChildren))
|
||||
xSub = self._subPack(xPack,"expanded", text=str(self.isExpanded))
|
||||
if self.itemClass == nwItemClass.NOVEL and self.itemLayout is not nwItemLayout.NO_LAYOUT:
|
||||
xSub = self._subPack(xPack,"layout", text=str(self.itemLayout.name))
|
||||
if self.itemType == nwItemType.FILE:
|
||||
xSub = self._subPack(xPack,"layout", text=str(self.itemLayout.name))
|
||||
xSub = self._subPack(xPack,"charCount", text=str(self.charCount), none=False)
|
||||
xSub = self._subPack(xPack,"wordCount", text=str(self.wordCount), none=False)
|
||||
xSub = self._subPack(xPack,"paraCount", text=str(self.paraCount), none=False)
|
||||
@@ -113,6 +124,7 @@ class NWItem():
|
||||
elif tagName == "type": self.setType(tagValue)
|
||||
elif tagName == "class": self.setClass(tagValue)
|
||||
elif tagName == "layout": self.setLayout(tagValue)
|
||||
elif tagName == "status": self.setStatus(tagValue)
|
||||
elif tagName == "depth": self.setDepth(tagValue)
|
||||
elif tagName == "children": self.setChildren(tagValue)
|
||||
elif tagName == "expanded": self.setExpanded(tagValue)
|
||||
@@ -182,6 +194,11 @@ class NWItem():
|
||||
self.itemLayout = nwItemLayout.NO_LAYOUT
|
||||
return
|
||||
|
||||
def setStatus(self, theStatus):
|
||||
theStatus = self._checkInt(theStatus,0)
|
||||
self.itemStatus = theStatus
|
||||
return
|
||||
|
||||
def setDepth(self, theDepth):
|
||||
theDepth = self._checkInt(theDepth,-1)
|
||||
if theDepth >= 0 and theDepth <= self.MAX_DEPTH:
|
||||
|
||||
@@ -19,6 +19,8 @@ from hashlib import sha256
|
||||
from datetime import datetime
|
||||
from time import time
|
||||
|
||||
from PyQt5.QtGui import QIcon, QPixmap, QColor
|
||||
|
||||
from nw.enum import nwItemType, nwItemClass, nwItemAction
|
||||
from nw.project.item import NWItem
|
||||
|
||||
@@ -41,6 +43,16 @@ class NWProject():
|
||||
self.bookTitle = ""
|
||||
self.bookAuthors = []
|
||||
|
||||
self.statusCols = [
|
||||
("New", 100,100,100),
|
||||
("Note", 200, 50, 0),
|
||||
("Draft", 200,150, 0),
|
||||
("Finished", 50,200, 0),
|
||||
]
|
||||
self.statusIcons = []
|
||||
self.statusLabels = []
|
||||
self._makeStatusIcons()
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
@@ -79,6 +91,7 @@ class NWProject():
|
||||
self.projName = ""
|
||||
self.bookTitle = ""
|
||||
self.bookAuthors = []
|
||||
self._makeStatusIcons()
|
||||
hNovel = self.newRoot("Novel", nwItemClass.NOVEL)
|
||||
hChars = self.newRoot("Characters", nwItemClass.CHARACTER)
|
||||
hWorld = self.newRoot("World", nwItemClass.WORLD)
|
||||
@@ -147,6 +160,7 @@ class NWProject():
|
||||
nwItem.setFromTag(xValue.tag,xValue.text)
|
||||
self._appendItem(tHandle,pHandle,nwItem)
|
||||
|
||||
self._makeStatusIcons()
|
||||
self.mainConf.setRecent(self.projPath)
|
||||
|
||||
return True
|
||||
@@ -365,6 +379,16 @@ class NWProject():
|
||||
|
||||
return
|
||||
|
||||
def _makeStatusIcons(self):
|
||||
self.statusIcons = []
|
||||
self.statusLabels = []
|
||||
for sLabel, sR, sG, sB in self.statusCols:
|
||||
theIcon = QPixmap(32,32)
|
||||
theIcon.fill(QColor(sR,sG,sB))
|
||||
self.statusIcons.append(QIcon(theIcon))
|
||||
self.statusLabels.append(sLabel)
|
||||
return
|
||||
|
||||
def _makeHandle(self, addSeed=""):
|
||||
newSeed = str(time()) + addSeed
|
||||
logger.verbose("Generating handle with seed '%s'" % newSeed)
|
||||
|
||||
Reference in New Issue
Block a user