Added some useful menu option, and settings in project file
This commit is contained in:
@@ -63,6 +63,11 @@ class NWIndex():
|
||||
self.noteIndex = None
|
||||
self.textCounts = None
|
||||
|
||||
# TimeStamps
|
||||
self.timeNovel = 0
|
||||
self.timeNote = 0
|
||||
self.timeIndex = 0
|
||||
|
||||
self.clearIndex()
|
||||
|
||||
return
|
||||
@@ -72,14 +77,21 @@ class NWIndex():
|
||||
##
|
||||
|
||||
def clearIndex(self):
|
||||
"""Clear the index dictionaries and time stamps.
|
||||
"""
|
||||
self.tagIndex = {}
|
||||
self.refIndex = {}
|
||||
self.novelIndex = {}
|
||||
self.noteIndex = {}
|
||||
self.textCounts = {}
|
||||
self.timeNovel = 0
|
||||
self.timeNote = 0
|
||||
self.timeIndex = 0
|
||||
return
|
||||
|
||||
def deleteHandle(self, tHandle):
|
||||
"""Delete all entries of a given document handle.
|
||||
"""
|
||||
|
||||
delTags = []
|
||||
for tTag in self.tagIndex:
|
||||
@@ -129,6 +141,11 @@ class NWIndex():
|
||||
if "textCounts" in theData.keys():
|
||||
self.textCounts = theData["textCounts"]
|
||||
|
||||
nowTime = time()
|
||||
self.timeNovel = nowTime
|
||||
self.timeNote = nowTime
|
||||
self.timeIndex = nowTime
|
||||
|
||||
self.checkIndex()
|
||||
|
||||
return True
|
||||
@@ -289,6 +306,14 @@ class NWIndex():
|
||||
cC, wC, pC = countWords(theText)
|
||||
self.textCounts[tHandle] = [cC, wC, pC]
|
||||
|
||||
# Update timestamps for index changes
|
||||
nowTime = time()
|
||||
self.timeIndex = nowTime
|
||||
if isNovel:
|
||||
self.timeNovel = nowTime
|
||||
else:
|
||||
self.timeNote = nowTime
|
||||
|
||||
return True
|
||||
|
||||
def indexTitle(self, tHandle, isNovel, aLine, nLine, itemLayout):
|
||||
|
||||
@@ -67,6 +67,7 @@ class NWProject():
|
||||
|
||||
# Project Settings
|
||||
self.spellCheck = False
|
||||
self.autoOutline = True
|
||||
self.statusItems = None
|
||||
self.importItems = None
|
||||
self.lastEdited = None
|
||||
@@ -169,6 +170,7 @@ class NWProject():
|
||||
self.bookAuthors = []
|
||||
self.autoReplace = {}
|
||||
self.spellCheck = False
|
||||
self.autoOutline = True
|
||||
self.statusItems = NWStatus()
|
||||
self.statusItems.addEntry("New", (100,100,100))
|
||||
self.statusItems.addEntry("Note", (200, 50, 0))
|
||||
@@ -299,6 +301,8 @@ class NWProject():
|
||||
continue
|
||||
if xItem.tag == "spellCheck":
|
||||
self.spellCheck = checkBool(xItem.text,False)
|
||||
elif xItem.tag == "autoOutline":
|
||||
self.autoOutline = checkBool(xItem.text,True)
|
||||
elif xItem.tag == "lastEdited":
|
||||
self.lastEdited = checkString(xItem.text,None,True)
|
||||
elif xItem.tag == "lastViewed":
|
||||
@@ -390,6 +394,7 @@ class NWProject():
|
||||
# Save Project Settings
|
||||
xSettings = etree.SubElement(nwXML, "settings")
|
||||
self._saveProjectValue(xSettings, "spellCheck", self.spellCheck)
|
||||
self._saveProjectValue(xSettings, "autoOutline", self.autoOutline)
|
||||
self._saveProjectValue(xSettings, "lastEdited", self.lastEdited)
|
||||
self._saveProjectValue(xSettings, "lastViewed", self.lastViewed)
|
||||
self._saveProjectValue(xSettings, "lastWordCount", self.currWCount)
|
||||
@@ -513,6 +518,12 @@ class NWProject():
|
||||
self.setProjectChanged(True)
|
||||
return True
|
||||
|
||||
def setAutoOutline(self, theMode):
|
||||
if self.autoOutline != theMode:
|
||||
self.autoOutline = theMode
|
||||
self.setProjectChanged(True)
|
||||
return True
|
||||
|
||||
def setTreeOrder(self, newOrder):
|
||||
if len(self.treeOrder) != len(newOrder):
|
||||
logger.warning("Size of new and old tree order does not match")
|
||||
|
||||
Reference in New Issue
Block a user