Added spellCheck flag to project settings
This commit is contained in:
@@ -156,6 +156,10 @@ class GuiDocEditor(QTextEdit):
|
|||||||
logger.error("Unknown or unsupported document action %s" % str(theAction))
|
logger.error("Unknown or unsupported document action %s" % str(theAction))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def rehighlightDocument(self):
|
||||||
|
self.hLight.rehighlight()
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Document Events and Maintenance
|
# Document Events and Maintenance
|
||||||
##
|
##
|
||||||
|
|||||||
+56
-11
@@ -36,7 +36,7 @@ class NWProject():
|
|||||||
# Debug
|
# Debug
|
||||||
self.handleSeed = None
|
self.handleSeed = None
|
||||||
|
|
||||||
# Project Settings
|
# Class Settings
|
||||||
self.projTree = None
|
self.projTree = None
|
||||||
self.treeOrder = None
|
self.treeOrder = None
|
||||||
self.treeRoots = None
|
self.treeRoots = None
|
||||||
@@ -45,11 +45,17 @@ class NWProject():
|
|||||||
self.projMeta = None
|
self.projMeta = None
|
||||||
self.projCache = None
|
self.projCache = None
|
||||||
self.projFile = None
|
self.projFile = None
|
||||||
|
self.statusCols = None
|
||||||
|
|
||||||
|
# Project Meta
|
||||||
self.projName = None
|
self.projName = None
|
||||||
self.bookTitle = None
|
self.bookTitle = None
|
||||||
self.bookAuthors = None
|
self.bookAuthors = None
|
||||||
self.statusCols = None
|
|
||||||
|
|
||||||
|
# Project Settings
|
||||||
|
self.spellCheck = False
|
||||||
|
|
||||||
|
# Set Defaults
|
||||||
self.clearProject()
|
self.clearProject()
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -130,6 +136,7 @@ class NWProject():
|
|||||||
self.projName = ""
|
self.projName = ""
|
||||||
self.bookTitle = ""
|
self.bookTitle = ""
|
||||||
self.bookAuthors = []
|
self.bookAuthors = []
|
||||||
|
self.spellCheck = False
|
||||||
self.statusCols = [
|
self.statusCols = [
|
||||||
("New", 100,100,100),
|
("New", 100,100,100),
|
||||||
("Note", 200, 50, 0),
|
("Note", 200, 50, 0),
|
||||||
@@ -185,6 +192,12 @@ class NWProject():
|
|||||||
elif xItem.tag == "author":
|
elif xItem.tag == "author":
|
||||||
logger.verbose("Author: '%s'" % xItem.text)
|
logger.verbose("Author: '%s'" % xItem.text)
|
||||||
self.bookAuthors.append(xItem.text)
|
self.bookAuthors.append(xItem.text)
|
||||||
|
elif xChild.tag == "settings":
|
||||||
|
logger.debug("Found project settings")
|
||||||
|
for xItem in xChild:
|
||||||
|
if xItem.text is None: continue
|
||||||
|
if xItem.tag == "spellCheck":
|
||||||
|
self.spellCheck = self._checkBool(xItem.text,False)
|
||||||
elif xChild.tag == "content":
|
elif xChild.tag == "content":
|
||||||
logger.debug("Found project content")
|
logger.debug("Found project content")
|
||||||
for xItem in xChild:
|
for xItem in xChild:
|
||||||
@@ -233,15 +246,16 @@ class NWProject():
|
|||||||
"appVersion" : str(nw.__version__),
|
"appVersion" : str(nw.__version__),
|
||||||
"timeStamp" : datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
"timeStamp" : datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
})
|
})
|
||||||
xProject = etree.SubElement(nwXML,"project")
|
|
||||||
xProjName = etree.SubElement(xProject,"name")
|
# Save Project Meta
|
||||||
xProjName.text = self.projName
|
xProject = etree.SubElement(nwXML,"project")
|
||||||
xBookTitle = etree.SubElement(xProject,"title")
|
self._saveProjectValue(xProject,"name", self.projName, True)
|
||||||
xBookTitle.text = self.bookTitle
|
self._saveProjectValue(xProject,"title", self.bookTitle, True)
|
||||||
for bookAuthor in self.bookAuthors:
|
self._saveProjectValue(xProject,"author",self.bookAuthors)
|
||||||
if bookAuthor == "": continue
|
|
||||||
xBookAuthor = etree.SubElement(xProject,"author")
|
# Save Project Settings
|
||||||
xBookAuthor.text = bookAuthor
|
xSettings = etree.SubElement(nwXML,"settings")
|
||||||
|
self._saveProjectValue(xSettings,"spellCheck",self.spellCheck)
|
||||||
|
|
||||||
# Save Tree Content
|
# Save Tree Content
|
||||||
logger.debug("Writing project content")
|
logger.debug("Writing project content")
|
||||||
@@ -351,6 +365,17 @@ class NWProject():
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _saveProjectValue(self, xParent, theName, theValue, allowNone=True):
|
||||||
|
if not isinstance(theValue, list):
|
||||||
|
theValue = [theValue]
|
||||||
|
for aValue in theValue:
|
||||||
|
if not isinstance(aValue, str):
|
||||||
|
aValue = str(aValue)
|
||||||
|
if aValue == "" and not allowNone: continue
|
||||||
|
xItem = etree.SubElement(xParent,theName)
|
||||||
|
xItem.text = aValue
|
||||||
|
return
|
||||||
|
|
||||||
def _scanProjectFolder(self):
|
def _scanProjectFolder(self):
|
||||||
|
|
||||||
if self.projPath is None:
|
if self.projPath is None:
|
||||||
@@ -457,4 +482,24 @@ class NWProject():
|
|||||||
except:
|
except:
|
||||||
return defaultValue
|
return defaultValue
|
||||||
|
|
||||||
|
def _checkBool(self,checkValue,defaultValue,allowNone=False):
|
||||||
|
if allowNone:
|
||||||
|
if checkValue == None: return None
|
||||||
|
if checkValue == "None": return None
|
||||||
|
if isinstance(checkValue, str):
|
||||||
|
if checkValue == "True":
|
||||||
|
return True
|
||||||
|
elif checkValue == "False":
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return defaultValue
|
||||||
|
elif isinstance(checkValue, int):
|
||||||
|
if checkValue == 1:
|
||||||
|
return True
|
||||||
|
elif checkValue == 0:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return defaultValue
|
||||||
|
return defaultValue
|
||||||
|
|
||||||
# END Class NWProject
|
# END Class NWProject
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
<name></name>
|
<name></name>
|
||||||
<title></title>
|
<title></title>
|
||||||
</project>
|
</project>
|
||||||
|
<settings>
|
||||||
|
<spellCheck>False</spellCheck>
|
||||||
|
</settings>
|
||||||
<content count="6">
|
<content count="6">
|
||||||
<item handle="73475cb40a568" order="None" parent="None">
|
<item handle="73475cb40a568" order="None" parent="None">
|
||||||
<name>Novel</name>
|
<name>Novel</name>
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
<name></name>
|
<name></name>
|
||||||
<title></title>
|
<title></title>
|
||||||
</project>
|
</project>
|
||||||
|
<settings>
|
||||||
|
<spellCheck>False</spellCheck>
|
||||||
|
</settings>
|
||||||
<content count="10">
|
<content count="10">
|
||||||
<item handle="73475cb40a568" order="None" parent="None">
|
<item handle="73475cb40a568" order="None" parent="None">
|
||||||
<name>Novel</name>
|
<name>Novel</name>
|
||||||
|
|||||||
Reference in New Issue
Block a user