Add users currently typing in room bar

This commit is contained in:
miruka
2019-04-14 16:12:07 -04:00
parent 14a76b710b
commit 8a3189df15
9 changed files with 85 additions and 21 deletions

View File

@@ -1,12 +1,10 @@
# Copyright 2019 miruka
# This file is part of harmonyqml, licensed under GPLv3.
from typing import Dict, NamedTuple, Optional
from typing import Dict, List, NamedTuple, Optional
from PyQt5.QtCore import QDateTime
from .enums import Activity, Presence
class User(NamedTuple):
user_id: str
@@ -16,14 +14,10 @@ class User(NamedTuple):
class Room(NamedTuple):
room_id: str
display_name: Optional[str]
description: str = ""
unread_messages: int = 0
presence: Presence = Presence.none
activity: Activity = Activity.none
last_activity_timestamp_ms: Optional[int] = None
avatar_url: Optional[str] = None
room_id: str
display_name: Optional[str]
description: str = ""
typing_users: List[str] = []
class RoomEvent(NamedTuple):

View File

@@ -10,6 +10,7 @@ from PyQt5.QtCore import (
)
NewValue = Union[Mapping[str, Any], Sequence]
ReturnItem = Dict[str, Any]
class ListModel(QAbstractListModel):
@@ -96,7 +97,7 @@ class ListModel(QAbstractListModel):
@pyqtSlot(int, result="QVariantMap")
def get(self, index: int) -> Dict[str, Any]:
def get(self, index: int) -> ReturnItem:
return self._list[index]._asdict()
@@ -110,6 +111,11 @@ class ListModel(QAbstractListModel):
f"property {prop!r} set to {is_value!r}.")
@pyqtSlot(str, "QVariant", result="QVariantMap")
def getWhere(self, prop: str, is_value: Any) -> ReturnItem:
return self.get(self.indexWhere(prop, is_value))
@pyqtSlot(int, list)
def insert(self, index: int, value: NewValue) -> None:
value = self._convert_new_value(value)