Make sure deleted items are also deleted from the index, so the index is up to date
This commit is contained in:
@@ -220,7 +220,7 @@ class GuiDocTree(QTreeWidget):
|
|||||||
def deleteItem(self, tHandle=None):
|
def deleteItem(self, tHandle=None):
|
||||||
"""Delete items from the tree. Note that this does not delete the item from the item tree in
|
"""Delete items from the tree. Note that this does not delete the item from the item tree in
|
||||||
the project object. However, since this is only meta data, there isn't really a need to do
|
the project object. However, since this is only meta data, there isn't really a need to do
|
||||||
that to save memory. As items not in the tree are not saved to the project file, a loaded
|
that to save memory. Items not in the tree are not saved to the project file, so a loaded
|
||||||
project will be clean anyway.
|
project will be clean anyway.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -247,6 +247,7 @@ class GuiDocTree(QTreeWidget):
|
|||||||
self.clearSelection()
|
self.clearSelection()
|
||||||
trItemP.setSelected(True)
|
trItemP.setSelected(True)
|
||||||
self.theProject.setProjectChanged(True)
|
self.theProject.setProjectChanged(True)
|
||||||
|
self.theParent.theIndex.deleteHandle(tHandle)
|
||||||
|
|
||||||
elif nwItemS.itemType == nwItemType.FOLDER:
|
elif nwItemS.itemType == nwItemType.FOLDER:
|
||||||
logger.debug("User requested folder %s deleted" % tHandle)
|
logger.debug("User requested folder %s deleted" % tHandle)
|
||||||
|
|||||||
+23
-5
@@ -64,10 +64,27 @@ class NWIndex():
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Public Methods
|
||||||
|
##
|
||||||
|
|
||||||
def clearIndex(self):
|
def clearIndex(self):
|
||||||
self.tagIndex = {}
|
self.tagIndex = {}
|
||||||
self.refIndex = {}
|
self.refIndex = {}
|
||||||
self.novelIndex = {}
|
self.novelIndex = {}
|
||||||
|
self.noteIndex = {}
|
||||||
|
return
|
||||||
|
|
||||||
|
def deleteHandle(self, tHandle):
|
||||||
|
|
||||||
|
for tTag in self.tagIndex:
|
||||||
|
if self.tagIndex[tTag][1] == tHandle:
|
||||||
|
self.tagIndex.pop(tTag, None)
|
||||||
|
|
||||||
|
self.refIndex.pop(tHandle, None)
|
||||||
|
self.novelIndex.pop(tHandle, None)
|
||||||
|
self.noteIndex.pop(tHandle, None)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -142,6 +159,7 @@ class NWIndex():
|
|||||||
theItem = self.theProject.getItem(tHandle)
|
theItem = self.theProject.getItem(tHandle)
|
||||||
if theItem is None: return False
|
if theItem is None: return False
|
||||||
if theItem.itemType != nwItemType.FILE: return False
|
if theItem.itemType != nwItemType.FILE: return False
|
||||||
|
if theItem.parHandle == self.theProject.trashRoot: return False
|
||||||
itemClass = theItem.itemClass
|
itemClass = theItem.itemClass
|
||||||
itemLayout = theItem.itemLayout
|
itemLayout = theItem.itemLayout
|
||||||
|
|
||||||
@@ -336,19 +354,19 @@ class NWIndex():
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def buildReferenceList(self, theHandle):
|
def buildReferenceList(self, tHandle):
|
||||||
"""Build a list of files referring back to our file, specified by theHandle.
|
"""Build a list of files referring back to our file, specified by tHandle.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
theRefs = {}
|
theRefs = {}
|
||||||
|
|
||||||
tItem = self.theProject.getItem(theHandle)
|
tItem = self.theProject.getItem(tHandle)
|
||||||
if theHandle is None:
|
if tHandle is None:
|
||||||
return theRefs
|
return theRefs
|
||||||
|
|
||||||
theTag = None
|
theTag = None
|
||||||
for tTag in self.tagIndex:
|
for tTag in self.tagIndex:
|
||||||
if theHandle == self.tagIndex[tTag][1]:
|
if tHandle == self.tagIndex[tTag][1]:
|
||||||
theTag = tTag
|
theTag = tTag
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user