diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-05-22 00:57:14 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-05-22 00:57:14 +0200 |
commit | beeb60e4a12b47ae619e52629040aff5a8f43db2 (patch) | |
tree | f5fa4037fcae00d866ede81efebdc6273202bfee /src/timeline/RoomlistModel.h | |
parent | Make roomlist look nice (diff) | |
download | nheko-beeb60e4a12b47ae619e52629040aff5a8f43db2.tar.xz |
Sort the room list
Diffstat (limited to 'src/timeline/RoomlistModel.h')
-rw-r--r-- | src/timeline/RoomlistModel.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h index c4c9d9ba..c3374bd2 100644 --- a/src/timeline/RoomlistModel.h +++ b/src/timeline/RoomlistModel.h @@ -7,6 +7,7 @@ #include <QAbstractListModel> #include <QHash> #include <QSharedPointer> +#include <QSortFilterProxyModel> #include <QString> #include <mtx/responses/sync.hpp> @@ -24,10 +25,13 @@ public: RoomName, RoomId, LastMessage, + Time, Timestamp, HasUnreadMessages, HasLoudNotification, NotificationCount, + IsInvite, + IsSpace, }; RoomlistModel(TimelineViewManager *parent = nullptr); @@ -73,4 +77,26 @@ private: std::vector<QString> roomids; QHash<QString, QSharedPointer<TimelineModel>> models; std::map<QString, bool> roomReadStatus; + + friend class FilteredRoomlistModel; +}; + +class FilteredRoomlistModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + FilteredRoomlistModel(RoomlistModel *model, QObject *parent = nullptr); + bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; + +public slots: + int roomidToIndex(QString roomid) + { + return mapFromSource(roomlistmodel->index(roomlistmodel->roomidToIndex(roomid))) + .row(); + } + +private: + short int calculateImportance(const QModelIndex &idx) const; + RoomlistModel *roomlistmodel; + bool sortByImportance = true; }; |