2019-05-10 03:58:46 +10:00
|
|
|
from enum import Enum
|
2019-04-30 13:51:37 +10:00
|
|
|
from typing import Any, Dict, List, Optional
|
2019-04-12 18:33:09 +10:00
|
|
|
|
2019-05-07 03:07:00 +10:00
|
|
|
from PyQt5.QtCore import QDateTime, QSortFilterProxyModel
|
2019-04-12 18:33:09 +10:00
|
|
|
|
2019-05-12 05:52:56 +10:00
|
|
|
from ..pyqt_future import PyQtFuture
|
2019-04-30 13:51:37 +10:00
|
|
|
from .list_item import ListItem
|
2019-05-03 04:20:21 +10:00
|
|
|
from .list_model import ListModel
|
2019-04-21 07:36:21 +10:00
|
|
|
|
|
|
|
|
2019-05-10 10:17:24 +10:00
|
|
|
class Account(ListItem):
|
|
|
|
_required_init_values = {"userId", "roomCategories"}
|
|
|
|
_constant = {"userId", "roomCategories"}
|
2019-04-21 07:36:21 +10:00
|
|
|
|
2019-05-12 05:52:56 +10:00
|
|
|
userId: str = ""
|
|
|
|
roomCategories: ListModel = ListModel()
|
2019-05-10 10:17:24 +10:00
|
|
|
|
|
|
|
|
|
|
|
class RoomCategory(ListItem):
|
|
|
|
_required_init_values = {"name", "rooms", "sortedRooms"}
|
2019-05-12 05:52:56 +10:00
|
|
|
_constant = {"name", "rooms", "sortedRooms"}
|
2019-05-10 10:17:24 +10:00
|
|
|
|
2019-05-12 05:52:56 +10:00
|
|
|
name: str = ""
|
2019-05-10 10:17:24 +10:00
|
|
|
rooms: ListModel = ListModel()
|
|
|
|
sortedRooms: QSortFilterProxyModel = QSortFilterProxyModel()
|
2019-04-21 07:36:21 +10:00
|
|
|
|
|
|
|
|
|
|
|
class Room(ListItem):
|
2019-05-15 09:44:40 +10:00
|
|
|
_required_init_values = {"roomId", "displayName", "members"}
|
|
|
|
_constant = {"roomId", "members"}
|
2019-04-21 07:36:21 +10:00
|
|
|
|
2019-05-07 03:07:00 +10:00
|
|
|
roomId: str = ""
|
|
|
|
displayName: str = ""
|
|
|
|
topic: Optional[str] = None
|
|
|
|
lastEventDateTime: Optional[QDateTime] = None
|
2019-05-12 05:52:56 +10:00
|
|
|
typingMembers: List[str] = []
|
2019-05-15 09:44:40 +10:00
|
|
|
members: ListModel = ListModel()
|
2019-04-21 07:36:21 +10:00
|
|
|
|
2019-05-03 04:20:21 +10:00
|
|
|
inviter: Optional[Dict[str, str]] = None
|
|
|
|
leftEvent: Optional[Dict[str, str]] = None
|
2019-04-21 07:36:21 +10:00
|
|
|
|
|
|
|
|
2019-05-15 10:20:54 +10:00
|
|
|
class RoomMember(ListItem):
|
|
|
|
_required_init_values = {"userId"}
|
|
|
|
_constant = {"userId"}
|
|
|
|
|
|
|
|
userId: str = ""
|
|
|
|
|
|
|
|
|
2019-05-12 05:52:56 +10:00
|
|
|
# ----------
|
|
|
|
|
2019-05-10 10:17:24 +10:00
|
|
|
class RoomEvent(ListItem):
|
2019-05-15 09:39:31 +10:00
|
|
|
_required_init_values = {"eventId", "type", "dict", "dateTime"}
|
2019-05-10 10:17:24 +10:00
|
|
|
_constant = {"type"}
|
2019-05-03 04:20:21 +10:00
|
|
|
|
2019-05-15 09:39:31 +10:00
|
|
|
eventId: str = ""
|
2019-05-10 10:17:24 +10:00
|
|
|
type: str = ""
|
|
|
|
dict: Dict[str, Any] = {}
|
2019-05-15 05:03:12 +10:00
|
|
|
dateTime: QDateTime = QDateTime()
|
2019-05-10 10:17:24 +10:00
|
|
|
isLocalEcho: bool = False
|
2019-05-03 04:20:21 +10:00
|
|
|
|
|
|
|
|
2019-05-10 10:17:24 +10:00
|
|
|
# ----------
|
2019-05-03 04:20:21 +10:00
|
|
|
|
2019-05-12 05:52:56 +10:00
|
|
|
class User(ListItem):
|
|
|
|
_required_init_values = {"userId", "devices"}
|
|
|
|
_constant = {"userId", "devices"}
|
|
|
|
|
|
|
|
# Use PyQtFutures because the info might or might not need a request
|
|
|
|
# to be fetched, and we don't want to block the UI in any case.
|
|
|
|
# QML's property binding ability is used on the PyQtFuture.value
|
|
|
|
userId: str = ""
|
|
|
|
displayName: Optional[PyQtFuture] = None
|
|
|
|
avatarUrl: Optional[PyQtFuture] = None
|
|
|
|
statusMessage: Optional[PyQtFuture] = None
|
|
|
|
devices: ListModel = ListModel()
|
|
|
|
|
|
|
|
|
2019-05-10 03:58:46 +10:00
|
|
|
class Trust(Enum):
|
|
|
|
blacklisted = -1
|
|
|
|
undecided = 0
|
|
|
|
trusted = 1
|
|
|
|
|
|
|
|
|
|
|
|
class Device(ListItem):
|
|
|
|
_required_init_values = {"deviceId", "ed25519Key"}
|
|
|
|
_constant = {"deviceId", "ed25519Key"}
|
|
|
|
|
2019-05-10 04:22:50 +10:00
|
|
|
deviceId: str = ""
|
|
|
|
ed25519Key: str = ""
|
|
|
|
displayName: Optional[str] = None
|
|
|
|
trust: Trust = Trust.undecided
|
|
|
|
lastSeenIp: Optional[str] = None
|
|
|
|
lastSeenDate: Optional[QDateTime] = None
|