Improve UserListModel performance and other preparations

In a future patch I want to add support for viewing banned/invited
users, and it's also been mentioned that UserListModel is quite slow
too.

The biggest cost is sorting the member list (power level and
alphabetically) and this happened in a few different ways:
* When the member list updated
* The user switches rooms
* Misc events such as the palette changing

But this was pretty inefficient, because internally Quotient::Room keeps
a list of members, and we kept re-sorting that same list. Our
connections were also too broad and despite having signals for members
joining and leaving we just reloaded the entire list anyway.

So my new solution is to keep the list persistently sorted in
NeoChatRoom, and reload that in UserListModel. This model also keeps
track of *all* members - including ones that left - which will be used
for the aforementioned feature. So UserFilterModel now filters out only
the joined members, and that will be configurable in the future.

I also added two new roles to UserListModel for membership and color
respectively (which makes some dead code useful again) and fixed us
overwriting the built-in Qt roles accidentally.
This commit is contained in:
Joshua Goins
2026-01-31 13:11:25 -05:00
parent 5c614e59f2
commit edd64d9b8f
6 changed files with 72 additions and 38 deletions

View File

@@ -283,6 +283,7 @@ QQC2.ScrollView {
required property url avatar
required property int powerLevel
required property string powerLevelString
required property color color
implicitHeight: Kirigami.Units.gridUnit * 2
@@ -304,6 +305,7 @@ QQC2.ScrollView {
}
source: userDelegate.avatar
name: userDelegate.userId
color: userDelegate.color
Layout.fillHeight: true
}