mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-29 17:32:17 -07:00
[UserList] Re-sort when a user's online state changes
setUserOnline() flipped the online flag but never re-sorted, so a buddy who went offline kept the position they had while online and stayed at the top of the list. Re-sort (and re-apply the filter) whenever the flag actually changes, mirroring processUserInfo(). Took 10 minutes
This commit is contained in:
parent
941b1e5c25
commit
29452fcead
1 changed files with 16 additions and 0 deletions
|
|
@ -1287,6 +1287,13 @@ void UserListWidget::setUserOnline(const QString &userName, bool online)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No state change: nothing to re-sort. This also keeps the per-user
|
||||||
|
// presence broadcasts (userJoinedOnline fires for every online user) cheap
|
||||||
|
// when the row already carries the right flag.
|
||||||
|
if (twi->data(0, UserListRoles::Online).toBool() == online) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
twi->setOnline(online);
|
twi->setOnline(online);
|
||||||
if (online) {
|
if (online) {
|
||||||
++onlineCount;
|
++onlineCount;
|
||||||
|
|
@ -1294,6 +1301,15 @@ void UserListWidget::setUserOnline(const QString &userName, bool online)
|
||||||
--onlineCount;
|
--onlineCount;
|
||||||
}
|
}
|
||||||
updateCount();
|
updateCount();
|
||||||
|
|
||||||
|
// Online users sort above offline users (UserListTWI::operator<), so a
|
||||||
|
// flag change moves the row: re-sort so e.g. a buddy who went offline no
|
||||||
|
// longer stays pinned at the top of the list.
|
||||||
|
if (!bulkLoading) {
|
||||||
|
sortItems();
|
||||||
|
applyFilter();
|
||||||
|
userTree->viewport()->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserListWidget::updateCount()
|
void UserListWidget::updateCount()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue