moment/harmonyqml/backend/model/qml_models.py
miruka 9e5e2c6718 Use a Deque for roomEvents's ListModel
- Take a custom container callable for ListModel __init__ (defaults to
  list, must be a MutableSequence)

- Use a Deque for roomEvents, which is much faster for inserting
  new items at the beginning.
2019-04-17 17:24:36 -04:00

36 lines
861 B
Python

# Copyright 2019 miruka
# This file is part of harmonyqml, licensed under GPLv3.
from typing import Deque
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._room_events: ListModelMap = ListModelMap(models_container=Deque)
@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 roomEvents(self):
return self._room_events