moment/harmonyqml/backend/model/qml_models.py
miruka 30514fb7db 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
2019-04-12 13:18:46 -04:00

34 lines
799 B
Python

# Copyright 2019 miruka
# This file is part of harmonyqml, licensed under GPLv3.
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal
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()
self._rooms: ListModelMap = ListModelMap()
self._messages: ListModelMap = ListModelMap()
@pyqtProperty(ListModel, constant=True)
def accounts(self):
return self._accounts
@pyqtProperty("QVariant", notify=roomsChanged)
def rooms(self):
return self._rooms
@pyqtProperty("QVariant", constant=True)
def messages(self):
return self._messages