Show joined rooms, delete left rooms
To make the models update correctly in QML: - ListModel and _QtModel merged - Return a ListModelMap QObject from properties instead of a DefaultDict → QVariantMap
This commit is contained in:
36
harmonyqml/backend/model/list_model_map.py
Normal file
36
harmonyqml/backend/model/list_model_map.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from typing import Any, DefaultDict
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSlot
|
||||
|
||||
from .list_model import ListModel
|
||||
|
||||
|
||||
class ListModelMap(QObject):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.dict: DefaultDict[Any, ListModel] = DefaultDict(ListModel)
|
||||
|
||||
|
||||
@pyqtSlot(str, result="QVariant")
|
||||
def get(self, key) -> ListModel:
|
||||
return self.dict[key]
|
||||
|
||||
|
||||
def __getitem__(self, key) -> ListModel:
|
||||
return self.dict[key]
|
||||
|
||||
|
||||
def __setitem__(self, key, value: ListModel) -> None:
|
||||
self.dict[key] = value
|
||||
|
||||
|
||||
def __detitem__(self, key) -> None:
|
||||
del self.dict[key]
|
||||
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.dict)
|
||||
|
||||
|
||||
def __len__(self) -> int:
|
||||
return len(self.dict)
|
Reference in New Issue
Block a user