Add property notify signals where needed
This commit is contained in:
parent
4607f53b7a
commit
0df46a0415
|
@ -24,8 +24,9 @@ _CONFIG_LOCK = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
class ClientManager(QObject):
|
class ClientManager(QObject):
|
||||||
clientAdded = pyqtSignal(Client)
|
clientAdded = pyqtSignal(Client)
|
||||||
clientDeleted = pyqtSignal(str)
|
clientDeleted = pyqtSignal(str)
|
||||||
|
_clientsUpdate = pyqtSignal()
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, backend: Backend) -> None:
|
def __init__(self, backend: Backend) -> None:
|
||||||
|
@ -33,12 +34,15 @@ class ClientManager(QObject):
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
self._clients: Dict[str, Client] = {}
|
self._clients: Dict[str, Client] = {}
|
||||||
|
|
||||||
|
self.clientAdded.connect(self._clientsUpdate.emit)
|
||||||
|
self.clientDeleted.connect(self._clientsUpdate.emit)
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"{type(self).__name__}(clients={self.clients!r})"
|
return f"{type(self).__name__}(clients={self.clients!r})"
|
||||||
|
|
||||||
|
|
||||||
@pyqtProperty("QVariantMap", constant=True)
|
@pyqtProperty("QVariantMap", notify=_clientsUpdate)
|
||||||
def clients(self):
|
def clients(self):
|
||||||
return self._clients
|
return self._clients
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class ListItem(QObject):
|
||||||
|
|
||||||
|
|
||||||
@pyqtProperty(str, constant=True)
|
@pyqtProperty(str, constant=True)
|
||||||
def repr(self) -> str:
|
def _repr(self) -> str:
|
||||||
return repr(self)
|
return repr(self)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,13 @@
|
||||||
|
|
||||||
from typing import Deque
|
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 import ListModel
|
||||||
from .list_model_map import ListModelMap
|
from .list_model_map import ListModelMap
|
||||||
|
|
||||||
|
|
||||||
class QMLModels(QObject):
|
class QMLModels(QObject):
|
||||||
roomsChanged = pyqtSignal()
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._accounts: ListModel = ListModel()
|
self._accounts: ListModel = ListModel()
|
||||||
|
@ -25,7 +22,7 @@ class QMLModels(QObject):
|
||||||
return self._accounts
|
return self._accounts
|
||||||
|
|
||||||
|
|
||||||
@pyqtProperty("QVariant", notify=roomsChanged)
|
@pyqtProperty("QVariant", constant=True)
|
||||||
def rooms(self):
|
def rooms(self):
|
||||||
return self._rooms
|
return self._rooms
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user