Add/improve ModelStore and Model __str__
This commit is contained in:
parent
5f72397afe
commit
e027c56047
6
TODO.md
6
TODO.md
|
@ -1,6 +1,3 @@
|
|||
- Investigate?
|
||||
- `QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling)`
|
||||
|
||||
- Refactoring
|
||||
- Use [Animators](https://doc.qt.io/qt-5/qml-qtquick-animator.html)
|
||||
- Sendbox
|
||||
|
@ -14,7 +11,6 @@
|
|||
- When qml syntax highlighting supports ES6 string interpolation, use them
|
||||
|
||||
- Fixes
|
||||
- Terrible performance using `QT_QPA_PLATFORM=wayland-egl`, must use `xcb`
|
||||
- Reloading config files (cache)
|
||||
- Ignore @ when filtering members
|
||||
- Tiny invisible scrollbar
|
||||
|
@ -31,6 +27,7 @@
|
|||
- Keyboard flicking against top/bottom edge
|
||||
- Don't strip user spacing in html
|
||||
- [hr not working](https://bugreports.qt.io/browse/QTBUG-74342)
|
||||
- Terrible performance using `QT_QPA_PLATFORM=wayland-egl`, must use `xcb`
|
||||
|
||||
- UI
|
||||
- Popup:
|
||||
|
@ -93,6 +90,7 @@
|
|||
- preferredIconPack: accept multiple values
|
||||
- Find icon packs in user data dir
|
||||
- Correctly implement uiScale/fontScale + ctrl+-= keys
|
||||
- See `QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling)`
|
||||
- See [Text.fontSizeMode](https://doc.qt.io/qt-5/qml-qtquick-text.html#fontSizeMode-prop)
|
||||
- Way to round avatar corners to allow box radius
|
||||
- If avatar is set, name color from average color?
|
||||
|
|
|
@ -89,10 +89,8 @@ class App:
|
|||
|
||||
from .models.items import Account, Room, Member, Event, Device # noqa
|
||||
|
||||
import json
|
||||
jd = lambda obj: print( # noqa
|
||||
json.dumps(obj, indent=4, ensure_ascii=False),
|
||||
)
|
||||
p = print # pdb's `p` doesn't print a class's __str__ # noqa
|
||||
from pprintpp import pprint as pp # noqa
|
||||
|
||||
log.info("\n=> Run `socat readline tcp:127.0.0.1:4444` in a terminal "
|
||||
"to connect to pdb.")
|
||||
|
|
|
@ -34,7 +34,8 @@ class Room(ModelItem):
|
|||
filter_string: str = ""
|
||||
typing_members: List[str] = field(default_factory=list)
|
||||
|
||||
last_event: Optional[Dict[str, Any]] = None # Event __dict__
|
||||
# Event __dict__
|
||||
last_event: Optional[Dict[str, Any]] = field(default=None, repr=False)
|
||||
|
||||
def __lt__(self, other: "Room") -> bool:
|
||||
# Left rooms may still have an inviter_id, check left first.
|
||||
|
|
|
@ -38,7 +38,9 @@ class Model(MutableMapping):
|
|||
|
||||
def __str__(self) -> str:
|
||||
if isinstance(self.sync_id, tuple):
|
||||
sid = (self.sync_id[0].__name__, *self.sync_id[1:]) # type: ignore
|
||||
reprs = tuple(repr(s) for s in self.sync_id[1:])
|
||||
sid = ", ".join((self.sync_id[0].__name__, *reprs)) # type: ignore
|
||||
sid = f"({sid})"
|
||||
else:
|
||||
sid = self.sync_id.__name__ # type: ignore
|
||||
|
||||
|
@ -111,3 +113,7 @@ class Model(MutableMapping):
|
|||
self.sortable = True
|
||||
|
||||
return self.serialized()
|
||||
|
||||
|
||||
def __lt__(self, other: "Model") -> bool:
|
||||
return str(self.sync_id) < str(other.sync_id)
|
||||
|
|
|
@ -52,3 +52,10 @@ class ModelStore(MutableMapping):
|
|||
|
||||
def __len__(self) -> int:
|
||||
return len(self.data)
|
||||
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "%s(\n %s\n)" % (
|
||||
type(self).__name__,
|
||||
"\n ".join(sorted(str(v) for v in self.values())),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user