[fractal/fractal-next] room-details: Sort members list by power level and name
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] room-details: Sort members list by power level and name
- Date: Mon, 29 Nov 2021 16:50:12 +0000 (UTC)
commit 56eefaf6df29fa139c1ad9854793fbe9814e375f
Author: Kévin Commaille <zecakeh tedomum fr>
Date: Mon Nov 29 15:52:26 2021 +0100
room-details: Sort members list by power level and name
Closes #469
src/session/content/room_details/member_page.rs | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/session/content/room_details/member_page.rs b/src/session/content/room_details/member_page.rs
index 5dee1437..8c464a29 100644
--- a/src/session/content/room_details/member_page.rs
+++ b/src/session/content/room_details/member_page.rs
@@ -118,6 +118,27 @@ impl MemberPage {
let priv_ = imp::MemberPage::from_instance(self);
let members = self.room().members();
+ // Sort the members list by power level, then display name.
+ let sorter = gtk::MultiSorter::new();
+ sorter.append(
+ >k::NumericSorter::builder()
+ .expression(>k::PropertyExpression::new(
+ Member::static_type(),
+ gtk::NONE_EXPRESSION,
+ "power-level",
+ ))
+ .sort_order(gtk::SortType::Descending)
+ .build(),
+ );
+ sorter.append(>k::StringSorter::new(Some(
+ >k::PropertyExpression::new(
+ Member::static_type(),
+ gtk::NONE_EXPRESSION,
+ "display-name",
+ ),
+ )));
+ let sorted_members = gtk::SortListModel::new(Some(members), Some(&sorter));
+
fn search_string(member: Member) -> String {
format!(
"{} {} {} {}",
@@ -148,7 +169,7 @@ impl MemberPage {
.flags(glib::BindingFlags::SYNC_CREATE)
.build();
- let filter_model = gtk::FilterListModel::new(Some(members), Some(&filter));
+ let filter_model = gtk::FilterListModel::new(Some(&sorted_members), Some(&filter));
let model = gtk::NoSelection::new(Some(&filter_model));
priv_.members_list_view.set_model(Some(&model));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]