Update item change signals

This commit is contained in:
Veronica Berglyd Olsen
2024-11-22 00:15:12 +01:00
parent e0b27317f3
commit ffe6cd0a65
11 changed files with 90 additions and 64 deletions
+18 -6
View File
@@ -25,12 +25,15 @@ from __future__ import annotations
import logging
from enum import Enum
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QGridLayout, QLabel, QWidget
from novelwriter import CONFIG, SHARED
from novelwriter.common import elide
from novelwriter.constants import nwLabels, nwStats, trConst
from novelwriter.enum import nwChange
from novelwriter.types import (
QtAlignLeft, QtAlignLeftBase, QtAlignRight, QtAlignRightBase,
QtAlignRightMiddle
@@ -220,12 +223,7 @@ class GuiItemDetails(QWidget):
self.updateViewBox(self._handle)
return
##
# Public Slots
##
@pyqtSlot(str)
def updateViewBox(self, tHandle: str) -> None:
def updateViewBox(self, tHandle: str | None) -> None:
"""Populate the details box from a given handle."""
if tHandle is None:
self.clearDetails()
@@ -286,6 +284,20 @@ class GuiItemDetails(QWidget):
return
##
# Public Slots
##
@pyqtSlot(str, Enum)
def onProjectItemChanged(self, tHandle: str, change: nwChange) -> None:
"""Process project item change."""
if tHandle == self._handle:
if change == nwChange.UPDATE:
self.updateViewBox(tHandle)
elif change == nwChange.DELETE:
self.updateViewBox(None)
return
@pyqtSlot(str, int, int, int)
def updateCounts(self, tHandle: str, cC: int, wC: int, pC: int) -> None:
"""Update the counts if the handle is the same as the one we're