Folders can now be deleted as well, and depth and haschildren flags removed from item meta data.

This commit is contained in:
Veronica K. B. Olsen
2019-05-04 17:24:17 +02:00
parent c775636a71
commit edcf9665b5
6 changed files with 71 additions and 74 deletions
+6 -16
View File
@@ -35,7 +35,6 @@ class NWItem():
self.itemClass = nwItemClass.NO_CLASS
self.itemLayout = nwItemLayout.NO_LAYOUT
self.itemStatus = 0
self.itemDepth = None
self.isExpanded = False
self.charCount = 0
@@ -54,12 +53,11 @@ class NWItem():
"parent" : str(self.parHandle),
"order" : str(self.itemOrder),
})
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,"expanded", text=str(self.isExpanded))
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,"expanded", text=str(self.isExpanded))
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)
@@ -87,7 +85,7 @@ class NWItem():
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)
elif tagName == "charCount": self.setCharCount(tagValue)
elif tagName == "wordCount": self.setWordCount(tagValue)
@@ -160,14 +158,6 @@ class NWItem():
self.itemStatus = theStatus
return
def setDepth(self, theDepth):
theDepth = self._checkInt(theDepth,-1)
if theDepth >= 0 and theDepth <= self.MAX_DEPTH:
self.itemDepth = theDepth
else:
logger.error("Invalid item depth %d" % theDepth)
return
def setExpanded(self, expState):
if isinstance(expState, str):
self.isExpanded = expState == str(True)
+2 -17
View File
@@ -102,6 +102,7 @@ class NWProject():
hNovel = self.newRoot("Novel", nwItemClass.NOVEL)
hChars = self.newRoot("Characters", nwItemClass.CHARACTER)
hWorld = self.newRoot("Plot", nwItemClass.PLOT)
hWorld = self.newRoot("World", nwItemClass.WORLD)
hChapt = self.newFolder("New Chapter", nwItemClass.NOVEL, hNovel)
hScene = self.newFile("New Scene", nwItemClass.NOVEL, hChapt)
@@ -234,7 +235,7 @@ class NWProject():
# Save Tree Content
logger.debug("Writing project content")
xContent = etree.SubElement(nwXML,"content",attrib={"count":str(len(self.projTree))})
xContent = etree.SubElement(nwXML,"content",attrib={"count":str(len(self.treeOrder))})
for tHandle in self.treeOrder:
self.projTree[tHandle].packXML(xContent)
@@ -373,16 +374,6 @@ class NWProject():
return
def countItemDepth(self, tHandle):
theDepth = 0
nwItem = self.getItem(tHandle)
while nwItem.parHandle is not None:
theDepth += 1
nwItem = self.getItem(nwItem.parHandle)
if theDepth > NWItem.MAX_DEPTH:
return None
return theDepth
def _appendItem(self, tHandle, pHandle, nwItem):
tHandle = self._checkString(tHandle,self._makeHandle(),False)
pHandle = self._checkString(pHandle,None,True)
@@ -405,12 +396,6 @@ class NWProject():
else:
logger.error("Only one trash folder allowed")
itemDepth = self.countItemDepth(tHandle)
if itemDepth is None:
logger.error("The depth of entry %s could not be determined" % tHandle)
else:
nwItem.setDepth(itemDepth)
return
def _makeStatusIcons(self):