ListModel.updateItem() ignore_roles → no_update
This commit is contained in:
parent
0b32bf2738
commit
606771735a
|
@ -26,15 +26,15 @@ class RoomCategory(ListItem):
|
|||
|
||||
|
||||
class Room(ListItem):
|
||||
_required_init_values = {"roomId", "displayName"}
|
||||
_constant = {"roomId"}
|
||||
_required_init_values = {"roomId", "displayName", "members"}
|
||||
_constant = {"roomId", "members"}
|
||||
|
||||
roomId: str = ""
|
||||
displayName: str = ""
|
||||
topic: Optional[str] = None
|
||||
lastEventDateTime: Optional[QDateTime] = None
|
||||
typingMembers: List[str] = []
|
||||
members: List[str] = []
|
||||
members: ListModel = ListModel()
|
||||
|
||||
inviter: Optional[Dict[str, str]] = None
|
||||
leftEvent: Optional[Dict[str, str]] = None
|
||||
|
|
|
@ -279,9 +279,9 @@ class ListModel(QAbstractListModel):
|
|||
@pyqtSlot(str, "QVariantMap", result=int)
|
||||
@pyqtSlot(str, "QVariantMap", "QStringList", result=int)
|
||||
def updateItem(self,
|
||||
index: Index,
|
||||
value: NewItem,
|
||||
ignore_roles: Sequence[str] = ()) -> int:
|
||||
index: Index,
|
||||
value: NewItem,
|
||||
no_update: Sequence[str] = ()) -> int:
|
||||
value = self._convert_new_value(value)
|
||||
|
||||
i_index: int = self.indexWhere(index, _can_use_default_factory=False) \
|
||||
|
@ -292,7 +292,7 @@ class ListModel(QAbstractListModel):
|
|||
updated_roles: Set[int] = set()
|
||||
|
||||
for role_name, role_num in self.roleNumbers().items():
|
||||
if role_name not in ignore_roles:
|
||||
if role_name not in no_update:
|
||||
old_value = getattr(to_update, role_name)
|
||||
new_value = getattr(value, role_name)
|
||||
|
||||
|
@ -321,10 +321,10 @@ class ListModel(QAbstractListModel):
|
|||
update_with: NewItem,
|
||||
new_index_if_insert: Optional[int] = None,
|
||||
new_index_if_update: Optional[int] = None,
|
||||
ignore_roles: Sequence[str] = ()) -> None:
|
||||
no_update: Sequence[str] = ()) -> None:
|
||||
try:
|
||||
index = self.updateItem(
|
||||
where_main_key_is, update_with, ignore_roles
|
||||
where_main_key_is, update_with, no_update
|
||||
)
|
||||
except (IndexError, ValueError):
|
||||
self.insert(new_index_if_insert or len(self), update_with)
|
||||
|
|
|
@ -148,7 +148,7 @@ class SignalManager(QObject):
|
|||
displayName = get_displayname(self, user),
|
||||
devices = ListModel()
|
||||
),
|
||||
ignore_roles = ("devices",),
|
||||
no_update = ("devices",),
|
||||
)
|
||||
|
||||
|
||||
|
@ -175,7 +175,7 @@ class SignalManager(QObject):
|
|||
lastEventDateTime = QDateTime.currentDateTime(), # FIXME
|
||||
members = list(nio_room.users.keys()),
|
||||
),
|
||||
ignore_roles = ("typingMembers"),
|
||||
no_update = ("typingMembers"),
|
||||
)
|
||||
|
||||
signal = self.roomCategoryChanged
|
||||
|
@ -202,7 +202,7 @@ class SignalManager(QObject):
|
|||
topic = nio_room.topic,
|
||||
members = list(nio_room.users.keys()),
|
||||
),
|
||||
ignore_roles = ("typingMembers", "lastEventDateTime"),
|
||||
no_update = ("typingMembers", "lastEventDateTime"),
|
||||
)
|
||||
|
||||
signal = self.roomCategoryChanged
|
||||
|
@ -237,7 +237,7 @@ class SignalManager(QObject):
|
|||
if left_time else QDateTime.currentDateTime()
|
||||
),
|
||||
),
|
||||
ignore_roles = ("members", "lastEventDateTime"),
|
||||
no_update = ("members", "lastEventDateTime"),
|
||||
)
|
||||
|
||||
signal = self.roomCategoryChanged
|
||||
|
|
Loading…
Reference in New Issue
Block a user