Updated room sorting

Change the LastActivity sort order to Activity and update to a more flexible way of sorting based on an order from model roles.
Add options to actually switch between Alphabetical and Activity

Based on some old work by @tdfischer 

implements #103
This commit is contained in:
James Graham
2024-02-28 17:57:32 +00:00
parent 0c24996b44
commit 1ae3fc86da
7 changed files with 107 additions and 43 deletions

View File

@@ -220,6 +220,8 @@ QHash<int, QByteArray> RoomTreeModel::roleNames() const
roles[IsDirectChat] = "isDirectChat";
roles[DelegateTypeRole] = "delegateType";
roles[IconRole] = "icon";
roles[AttentionRole] = "attention";
roles[FavouriteRole] = "favourite";
return roles;
}
@@ -270,10 +272,10 @@ QVariant RoomTreeModel::data(const QModelIndex &index, int role) const
return NeoChatRoomType::typeForRoom(room);
}
if (role == NotificationCountRole) {
return room->notificationCount();
return int(room->notificationCount());
}
if (role == HighlightCountRole) {
return room->highlightCount();
return int(room->highlightCount());
}
if (role == LastActiveTimeRole) {
return room->lastActiveTime();
@@ -315,6 +317,12 @@ QVariant RoomTreeModel::data(const QModelIndex &index, int role) const
if (role == DelegateTypeRole) {
return QStringLiteral("normal");
}
if (role == AttentionRole) {
return room->notificationCount() + room->highlightCount() > 0;
}
if (role == FavouriteRole) {
return room->isFavourite();
}
return {};
}