Add property notify signals where needed

This commit is contained in:
miruka 2019-04-22 11:37:41 -04:00
parent 4607f53b7a
commit 0df46a0415
3 changed files with 10 additions and 9 deletions

View File

@ -24,8 +24,9 @@ _CONFIG_LOCK = threading.Lock()
class ClientManager(QObject):
clientAdded = pyqtSignal(Client)
clientDeleted = pyqtSignal(str)
clientAdded = pyqtSignal(Client)
clientDeleted = pyqtSignal(str)
_clientsUpdate = pyqtSignal()
def __init__(self, backend: Backend) -> None:
@ -33,12 +34,15 @@ class ClientManager(QObject):
self.backend = backend
self._clients: Dict[str, Client] = {}
self.clientAdded.connect(self._clientsUpdate.emit)
self.clientDeleted.connect(self._clientsUpdate.emit)
def __repr__(self) -> str:
return f"{type(self).__name__}(clients={self.clients!r})"
@pyqtProperty("QVariantMap", constant=True)
@pyqtProperty("QVariantMap", notify=_clientsUpdate)
def clients(self):
return self._clients

View File

@ -26,7 +26,7 @@ class ListItem(QObject):
@pyqtProperty(str, constant=True)
def repr(self) -> str:
def _repr(self) -> str:
return repr(self)

View File

@ -3,16 +3,13 @@
from typing import Deque
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal
from PyQt5.QtCore import QObject, pyqtProperty
from .list_model import ListModel
from .list_model_map import ListModelMap
class QMLModels(QObject):
roomsChanged = pyqtSignal()
def __init__(self) -> None:
super().__init__()
self._accounts: ListModel = ListModel()
@ -25,7 +22,7 @@ class QMLModels(QObject):
return self._accounts
@pyqtProperty("QVariant", notify=roomsChanged)
@pyqtProperty("QVariant", constant=True)
def rooms(self):
return self._rooms