Code cleanup in core classes and rename of parHandle to itemParent in NWItem class
This commit is contained in:
+2
-2
@@ -684,8 +684,8 @@ class GuiBuildNovel(QDialog):
|
||||
isNone |= theItem.itemLayout == nwItemLayout.NO_LAYOUT
|
||||
isNone |= theItem.itemClass == nwItemClass.NO_CLASS
|
||||
isNone |= theItem.itemClass == nwItemClass.TRASH
|
||||
isNone |= theItem.parHandle == self.theProject.projTree.trashRoot()
|
||||
isNone |= theItem.parHandle is None
|
||||
isNone |= theItem.itemParent == self.theProject.projTree.trashRoot()
|
||||
isNone |= theItem.itemParent is None
|
||||
isNote = theItem.itemLayout == nwItemLayout.NOTE
|
||||
isNovel = not isNone and not isNote
|
||||
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ class GuiDocMerge(QDialog):
|
||||
), nwAlert.ERROR)
|
||||
return
|
||||
|
||||
nHandle = self.theProject.newFile(srcItem.itemName, srcItem.itemClass, srcItem.parHandle)
|
||||
nHandle = self.theProject.newFile(srcItem.itemName, srcItem.itemClass, srcItem.itemParent)
|
||||
newItem = self.theProject.projTree[nHandle]
|
||||
newItem.setStatus(srcItem.itemStatus)
|
||||
|
||||
|
||||
+2
-2
@@ -154,7 +154,7 @@ class GuiDocSplit(QDialog):
|
||||
return
|
||||
|
||||
# Check that another folder can be created
|
||||
parTree = self.theProject.projTree.getItemPath(srcItem.parHandle)
|
||||
parTree = self.theProject.projTree.getItemPath(srcItem.itemParent)
|
||||
if len(parTree) >= nwConst.maxDepth - 1:
|
||||
self.theParent.makeAlert((
|
||||
"Cannot add new folder for the document split. "
|
||||
@@ -176,7 +176,7 @@ class GuiDocSplit(QDialog):
|
||||
|
||||
# Create the folder
|
||||
fHandle = self.theProject.newFolder(
|
||||
srcItem.itemName, srcItem.itemClass, srcItem.parHandle
|
||||
srcItem.itemName, srcItem.itemClass, srcItem.itemParent
|
||||
)
|
||||
self.theParent.treeView.revealNewTreeItem(fHandle)
|
||||
logger.verbose("Creating folder %s" % fHandle)
|
||||
|
||||
+6
-6
@@ -219,7 +219,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
pItem = self.theProject.projTree[pHandle]
|
||||
if pItem.itemType == nwItemType.FILE:
|
||||
nHandle = pHandle
|
||||
pHandle = pItem.parHandle
|
||||
pHandle = pItem.itemParent
|
||||
|
||||
# If we again have no home, give up
|
||||
if pHandle is None:
|
||||
@@ -270,7 +270,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
"""
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
trItem = self._addTreeItem(nwItem, nHandle)
|
||||
pHandle = nwItem.parHandle
|
||||
pHandle = nwItem.itemParent
|
||||
if pHandle is not None and pHandle in self.theMap:
|
||||
self.theMap[pHandle].setExpanded(True)
|
||||
self.clearSelection()
|
||||
@@ -430,7 +430,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.error("Could not delete item")
|
||||
return False
|
||||
|
||||
pHandle = nwItemS.parHandle
|
||||
pHandle = nwItemS.itemParent
|
||||
if self.theProject.projTree.isTrashRoot(pHandle):
|
||||
# If the file is in the trash folder already, as the
|
||||
# user if they want to permanently delete the file.
|
||||
@@ -815,7 +815,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
project tree.
|
||||
"""
|
||||
tHandle = nwItem.itemHandle
|
||||
pHandle = nwItem.parHandle
|
||||
pHandle = nwItem.itemParent
|
||||
tClass = nwItem.itemClass
|
||||
newItem = QTreeWidgetItem([""]*4)
|
||||
|
||||
@@ -1022,11 +1022,11 @@ class GuiProjectTreeMenu(QMenu):
|
||||
|
||||
trashHandle = self.theTree.theProject.projTree.trashRoot()
|
||||
|
||||
inTrash = theItem.parHandle == trashHandle and trashHandle is not None
|
||||
inTrash = theItem.itemParent == trashHandle and trashHandle is not None
|
||||
isTrash = theItem.itemHandle == trashHandle and trashHandle is not None
|
||||
isFile = theItem.itemType == nwItemType.FILE
|
||||
isArch = theRoot.itemClass == nwItemClass.ARCHIVE
|
||||
isOrph = isFile and theItem.parHandle is None
|
||||
isOrph = isFile and theItem.itemParent is None
|
||||
|
||||
showOpen = isFile
|
||||
showView = isFile
|
||||
|
||||
Reference in New Issue
Block a user