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-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-03 04:20:21 +10:00
|
|
|
class RoomEvent(ListItem):
|
|
|
|
_required_init_values = {"type", "dict"}
|
|
|
|
_constant = {"type"}
|
2019-04-21 07:36:21 +10:00
|
|
|
|
2019-05-03 04:20:21 +10:00
|
|
|
type: str = ""
|
|
|
|
dict: Dict[str, Any] = {}
|
|
|
|
dateTime: QDateTime = QDateTime.currentDateTime()
|
|
|
|
isLocalEcho: bool = False
|
2019-04-21 07:36:21 +10:00
|
|
|
|
|
|
|
|
|
|
|
class Room(ListItem):
|
2019-04-30 13:51:37 +10:00
|
|
|
_required_init_values = {"roomId", "displayName"}
|
|
|
|
_constant = {"roomId"}
|
2019-04-21 07:36:21 +10:00
|
|
|
|
2019-05-07 03:07:00 +10:00
|
|
|
roomId: str = ""
|
|
|
|
displayName: str = ""
|
|
|
|
topic: Optional[str] = None
|
|
|
|
typingUsers: List[str] = []
|
|
|
|
lastEventDateTime: Optional[QDateTime] = None
|
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-03 04:20:21 +10:00
|
|
|
class RoomCategory(ListItem):
|
2019-05-07 03:07:00 +10:00
|
|
|
_required_init_values = {"name", "rooms", "sortedRooms"}
|
|
|
|
_constant = {"rooms", "sortedRooms"}
|
2019-05-03 04:20:21 +10:00
|
|
|
|
|
|
|
name: str = ""
|
|
|
|
|
|
|
|
# Must be provided at init, else it will be the same object
|
|
|
|
# for every RoomCategory
|
2019-05-07 03:07:00 +10:00
|
|
|
rooms: ListModel = ListModel()
|
|
|
|
sortedRooms: QSortFilterProxyModel = QSortFilterProxyModel()
|
2019-05-03 04:20:21 +10:00
|
|
|
|
|
|
|
|
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"}
|
|
|
|
|
|
|
|
deviceId: str = ""
|
|
|
|
ed25519Key: str = ""
|
|
|
|
displayName: Optional[str] = None
|
|
|
|
trust: Trust = Trust.undecided
|
|
|
|
|
|
|
|
|
2019-05-03 04:20:21 +10:00
|
|
|
class Account(ListItem):
|
|
|
|
_required_init_values = {"userId", "roomCategories"}
|
|
|
|
_constant = {"userId", "roomCategories"}
|
|
|
|
|
|
|
|
userId: str = ""
|
|
|
|
roomCategories: ListModel = ListModel() # same as RoomCategory.rooms
|
|
|
|
displayName: Optional[str] = None
|
|
|
|
avatarUrl: Optional[str] = None
|
|
|
|
statusMessage: Optional[str] = None
|