Extend and refactor current open document highlighting
This commit is contained in:
@@ -211,6 +211,12 @@ class GuiProjectView(QWidget):
|
||||
self.projTree.setSelectedHandle(tHandle, doScroll=doScroll)
|
||||
return
|
||||
|
||||
@pyqtSlot(str)
|
||||
def setActiveHandle(self, tHandle: str | None) -> None:
|
||||
"""Highlight the active handle."""
|
||||
self.projTree.setActiveHandle(tHandle)
|
||||
return
|
||||
|
||||
@pyqtSlot(str)
|
||||
def updateItemValues(self, tHandle: str) -> None:
|
||||
"""Update tree item."""
|
||||
@@ -500,6 +506,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
self._treeMap: dict[str, QTreeWidgetItem] = {}
|
||||
self._timeChanged = 0.0
|
||||
self._popAlert = None
|
||||
self._actHandle = None
|
||||
|
||||
# Cached Translations
|
||||
self.trActive = self.tr("Active")
|
||||
@@ -1144,6 +1151,19 @@ class GuiProjectTree(QTreeWidget):
|
||||
|
||||
return True
|
||||
|
||||
def setActiveHandle(self, tHandle: str | None) -> None:
|
||||
"""Highlight the rows associated with a given handle."""
|
||||
brushOn = self.palette().alternateBase()
|
||||
brushOff = self.palette().base()
|
||||
if (pHandle := self._actHandle) and (item := self._treeMap.get(pHandle)):
|
||||
for i in range(self.columnCount()):
|
||||
item.setBackground(i, brushOff)
|
||||
if tHandle and (item := self._treeMap.get(tHandle)):
|
||||
for i in range(self.columnCount()):
|
||||
item.setBackground(i, brushOn)
|
||||
self._actHandle = tHandle or None
|
||||
return
|
||||
|
||||
def setExpandedFromHandle(self, tHandle: str | None, isExpanded: bool) -> None:
|
||||
"""Iterate through items below tHandle and change expanded
|
||||
status for all child items. If tHandle is None, it affects the
|
||||
|
||||
Reference in New Issue
Block a user