Handle the caching in the DocSearch class
This commit is contained in:
@@ -91,7 +91,6 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
|
||||
# Custom Signals
|
||||
statusMessage = pyqtSignal(str)
|
||||
docTextSaved = pyqtSignal(str)
|
||||
docCountsChanged = pyqtSignal(str, int, int, int)
|
||||
editedStatusChanged = pyqtSignal(bool)
|
||||
loadDocumentTagRequest = pyqtSignal(str, Enum)
|
||||
@@ -489,7 +488,6 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
return False
|
||||
|
||||
self.setDocumentChanged(False)
|
||||
self.docTextSaved.emit(tHandle)
|
||||
|
||||
oldHeader = self._nwItem.mainHeading
|
||||
oldCount = SHARED.project.index.getHandleHeaderCount(tHandle)
|
||||
|
||||
@@ -48,7 +48,7 @@ class GuiItemDetails(QWidget):
|
||||
logger.debug("Create: GuiItemDetails")
|
||||
|
||||
# Internal Variables
|
||||
self._itemHandle = None
|
||||
self._handle = None
|
||||
|
||||
# Sizes
|
||||
hSp = CONFIG.pxInt(6)
|
||||
@@ -194,7 +194,7 @@ class GuiItemDetails(QWidget):
|
||||
|
||||
def clearDetails(self) -> None:
|
||||
"""Clear all the data values."""
|
||||
self._itemHandle = None
|
||||
self._handle = None
|
||||
self.labelIcon.clear()
|
||||
self.labelData.clear()
|
||||
self.statusIcon.clear()
|
||||
@@ -210,11 +210,11 @@ class GuiItemDetails(QWidget):
|
||||
|
||||
def refreshDetails(self) -> None:
|
||||
"""Reload the content of the details panel."""
|
||||
self.updateViewBox(self._itemHandle)
|
||||
self.updateViewBox(self._handle)
|
||||
|
||||
def updateTheme(self) -> None:
|
||||
"""Update theme elements."""
|
||||
self.updateViewBox(self._itemHandle)
|
||||
self.updateViewBox(self._handle)
|
||||
return
|
||||
|
||||
##
|
||||
@@ -233,7 +233,7 @@ class GuiItemDetails(QWidget):
|
||||
self.clearDetails()
|
||||
return
|
||||
|
||||
self._itemHandle = tHandle
|
||||
self._handle = tHandle
|
||||
iPx = int(round(0.8*SHARED.theme.baseIconSize))
|
||||
|
||||
# Label
|
||||
@@ -295,7 +295,7 @@ class GuiItemDetails(QWidget):
|
||||
"""Update the counts if the handle is the same as the one we're
|
||||
already showing. Otherwise, do nothing.
|
||||
"""
|
||||
if tHandle == self._itemHandle:
|
||||
if tHandle == self._handle:
|
||||
self.cCountData.setText(f"{cC:n}")
|
||||
self.wCountData.setText(f"{wC:n}")
|
||||
self.pCountData.setText(f"{pC:n}")
|
||||
|
||||
@@ -135,8 +135,6 @@ class GuiProjectSearch(QWidget):
|
||||
self.setLayout(self.outerBox)
|
||||
self.updateTheme()
|
||||
|
||||
SHARED.slowClockTick.connect(self._cacheTimeout)
|
||||
|
||||
logger.debug("Ready: GuiProjectSearch")
|
||||
|
||||
return
|
||||
@@ -205,17 +203,6 @@ class GuiProjectSearch(QWidget):
|
||||
super().keyPressEvent(event)
|
||||
return
|
||||
|
||||
##
|
||||
# Public Slots
|
||||
##
|
||||
|
||||
@pyqtSlot(str)
|
||||
def clearSearchCache(self, tHandle: str) -> None:
|
||||
"""Process document content change."""
|
||||
if not self._blocked:
|
||||
self._search.clearTextCache(tHandle)
|
||||
return
|
||||
|
||||
##
|
||||
# Private Slots
|
||||
##
|
||||
@@ -284,13 +271,6 @@ class GuiProjectSearch(QWidget):
|
||||
CONFIG.searchProjRegEx = state
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
def _cacheTimeout(self) -> None:
|
||||
"""Clear the cache after a period of inactivity."""
|
||||
if not self._blocked and time() - self._time > CACHE_TIMEOUT:
|
||||
self._search.clearTextCache(None)
|
||||
return
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user