Rename some internal variables in the NWItem class
This commit is contained in:
+51
-51
@@ -301,142 +301,142 @@ class NWItem():
|
|||||||
# Set Item Values
|
# Set Item Values
|
||||||
##
|
##
|
||||||
|
|
||||||
def setName(self, theName):
|
def setName(self, name):
|
||||||
"""Set the item name.
|
"""Set the item name.
|
||||||
"""
|
"""
|
||||||
if isinstance(theName, str):
|
if isinstance(name, str):
|
||||||
self._name = simplified(theName)
|
self._name = simplified(name)
|
||||||
else:
|
else:
|
||||||
self._name = ""
|
self._name = ""
|
||||||
return
|
return
|
||||||
|
|
||||||
def setHandle(self, theHandle):
|
def setHandle(self, tHandle):
|
||||||
"""Set the item handle, and ensure it is valid.
|
"""Set the item handle, and ensure it is valid.
|
||||||
"""
|
"""
|
||||||
if isHandle(theHandle):
|
if isHandle(tHandle):
|
||||||
self._handle = theHandle
|
self._handle = tHandle
|
||||||
else:
|
else:
|
||||||
self._handle = None
|
self._handle = None
|
||||||
return
|
return
|
||||||
|
|
||||||
def setParent(self, theParent):
|
def setParent(self, pHandle):
|
||||||
"""Set the parent handle, and ensure it is valid.
|
"""Set the parent handle, and ensure it is valid.
|
||||||
"""
|
"""
|
||||||
if theParent is None:
|
if pHandle is None:
|
||||||
self._parent = None
|
self._parent = None
|
||||||
elif isHandle(theParent):
|
elif isHandle(pHandle):
|
||||||
self._parent = theParent
|
self._parent = pHandle
|
||||||
else:
|
else:
|
||||||
self._parent = None
|
self._parent = None
|
||||||
return
|
return
|
||||||
|
|
||||||
def setOrder(self, theOrder):
|
def setOrder(self, order):
|
||||||
"""Set the item order, and ensure that it is valid. This value
|
"""Set the item order, and ensure that it is valid. This value
|
||||||
is purely a meta value, and not actually used by novelWriter at
|
is purely a meta value, and not actually used by novelWriter at
|
||||||
the moment.
|
the moment.
|
||||||
"""
|
"""
|
||||||
self._order = checkInt(theOrder, 0)
|
self._order = checkInt(order, 0)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setType(self, theType):
|
def setType(self, itemType):
|
||||||
"""Set the item type from either a proper nwItemType, or set it
|
"""Set the item type from either a proper nwItemType, or set it
|
||||||
from a string representing an nwItemType.
|
from a string representing an nwItemType.
|
||||||
"""
|
"""
|
||||||
if isinstance(theType, nwItemType):
|
if isinstance(itemType, nwItemType):
|
||||||
self._type = theType
|
self._type = itemType
|
||||||
elif isItemType(theType):
|
elif isItemType(itemType):
|
||||||
self._type = nwItemType[theType]
|
self._type = nwItemType[itemType]
|
||||||
else:
|
else:
|
||||||
logger.error("Unrecognised item type '%s'", theType)
|
logger.error("Unrecognised item type '%s'", itemType)
|
||||||
self._type = nwItemType.NO_TYPE
|
self._type = nwItemType.NO_TYPE
|
||||||
return
|
return
|
||||||
|
|
||||||
def setClass(self, theClass):
|
def setClass(self, itemClass):
|
||||||
"""Set the item class from either a proper nwItemClass, or set
|
"""Set the item class from either a proper nwItemClass, or set
|
||||||
it from a string representing an nwItemClass.
|
it from a string representing an nwItemClass.
|
||||||
"""
|
"""
|
||||||
if isinstance(theClass, nwItemClass):
|
if isinstance(itemClass, nwItemClass):
|
||||||
self._class = theClass
|
self._class = itemClass
|
||||||
elif isItemClass(theClass):
|
elif isItemClass(itemClass):
|
||||||
self._class = nwItemClass[theClass]
|
self._class = nwItemClass[itemClass]
|
||||||
else:
|
else:
|
||||||
logger.error("Unrecognised item class '%s'", theClass)
|
logger.error("Unrecognised item class '%s'", itemClass)
|
||||||
self._class = nwItemClass.NO_CLASS
|
self._class = nwItemClass.NO_CLASS
|
||||||
return
|
return
|
||||||
|
|
||||||
def setLayout(self, theLayout):
|
def setLayout(self, itemLayout):
|
||||||
"""Set the item layout from either a proper nwItemLayout, or set
|
"""Set the item layout from either a proper nwItemLayout, or set
|
||||||
it from a string representing an nwItemLayout.
|
it from a string representing an nwItemLayout.
|
||||||
"""
|
"""
|
||||||
if isinstance(theLayout, nwItemLayout):
|
if isinstance(itemLayout, nwItemLayout):
|
||||||
self._layout = theLayout
|
self._layout = itemLayout
|
||||||
elif isItemLayout(theLayout):
|
elif isItemLayout(itemLayout):
|
||||||
self._layout = nwItemLayout[theLayout]
|
self._layout = nwItemLayout[itemLayout]
|
||||||
elif theLayout in nwLists.DEP_LAYOUT:
|
elif itemLayout in nwLists.DEP_LAYOUT:
|
||||||
self._layout = nwItemLayout.DOCUMENT
|
self._layout = nwItemLayout.DOCUMENT
|
||||||
else:
|
else:
|
||||||
logger.error("Unrecognised item layout '%s'", theLayout)
|
logger.error("Unrecognised item layout '%s'", itemLayout)
|
||||||
self._layout = nwItemLayout.NO_LAYOUT
|
self._layout = nwItemLayout.NO_LAYOUT
|
||||||
return
|
return
|
||||||
|
|
||||||
def setStatus(self, theStatus):
|
def setStatus(self, itemStatus):
|
||||||
"""Set the item status by looking it up in the valid status
|
"""Set the item status by looking it up in the valid status
|
||||||
items of the current project.
|
items of the current project.
|
||||||
"""
|
"""
|
||||||
self._status = self.theProject.statusItems.check(theStatus)
|
self._status = self.theProject.statusItems.check(itemStatus)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setImport(self, theImport):
|
def setImport(self, itemImport):
|
||||||
"""Set the item importance by looking it up in the valid import
|
"""Set the item importance by looking it up in the valid import
|
||||||
items of the current project.
|
items of the current project.
|
||||||
"""
|
"""
|
||||||
self._import = self.theProject.importItems.check(theImport)
|
self._import = self.theProject.importItems.check(itemImport)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setExpanded(self, expState):
|
def setExpanded(self, state):
|
||||||
"""Set the expanded status of an item in the project tree.
|
"""Set the expanded status of an item in the project tree.
|
||||||
"""
|
"""
|
||||||
if isinstance(expState, str):
|
if isinstance(state, str):
|
||||||
self._expanded = (expState == str(True))
|
self._expanded = (state == str(True))
|
||||||
else:
|
else:
|
||||||
self._expanded = (expState is True)
|
self._expanded = (state is True)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setExported(self, expState):
|
def setExported(self, state):
|
||||||
"""Set the export flag.
|
"""Set the export flag.
|
||||||
"""
|
"""
|
||||||
if isinstance(expState, str):
|
if isinstance(state, str):
|
||||||
self._exported = (expState == str(True))
|
self._exported = (state == str(True))
|
||||||
else:
|
else:
|
||||||
self._exported = (expState is True)
|
self._exported = (state is True)
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Set Document Meta Data
|
# Set Document Meta Data
|
||||||
##
|
##
|
||||||
|
|
||||||
def setCharCount(self, theCount):
|
def setCharCount(self, count):
|
||||||
"""Set the character count, and ensure that it is an integer.
|
"""Set the character count, and ensure that it is an integer.
|
||||||
"""
|
"""
|
||||||
self._charCount = max(0, checkInt(theCount, 0))
|
self._charCount = max(0, checkInt(count, 0))
|
||||||
return
|
return
|
||||||
|
|
||||||
def setWordCount(self, theCount):
|
def setWordCount(self, count):
|
||||||
"""Set the word count, and ensure that it is an integer.
|
"""Set the word count, and ensure that it is an integer.
|
||||||
"""
|
"""
|
||||||
self._wordCount = max(0, checkInt(theCount, 0))
|
self._wordCount = max(0, checkInt(count, 0))
|
||||||
return
|
return
|
||||||
|
|
||||||
def setParaCount(self, theCount):
|
def setParaCount(self, count):
|
||||||
"""Set the paragraph count, and ensure that it is an integer.
|
"""Set the paragraph count, and ensure that it is an integer.
|
||||||
"""
|
"""
|
||||||
self._paraCount = max(0, checkInt(theCount, 0))
|
self._paraCount = max(0, checkInt(count, 0))
|
||||||
return
|
return
|
||||||
|
|
||||||
def setCursorPos(self, thePosition):
|
def setCursorPos(self, position):
|
||||||
"""Set the cursor position, and ensure that it is an integer.
|
"""Set the cursor position, and ensure that it is an integer.
|
||||||
"""
|
"""
|
||||||
self._cursorPos = max(0, checkInt(thePosition, 0))
|
self._cursorPos = max(0, checkInt(position, 0))
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveInitialCount(self):
|
def saveInitialCount(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user