diff options
author | Loren Burkholder <computersemiexpert@outlook.com> | 2021-07-28 21:31:37 -0400 |
---|---|---|
committer | Loren Burkholder <computersemiexpert@outlook.com> | 2021-07-29 21:07:52 -0400 |
commit | 7e538851d6e3779434722e56a968e9f8b8a9da0d (patch) | |
tree | 8147ac95a7e17b66c398cb3d09185d3194f5520b /src/ReadReceiptsModel.h | |
parent | Reset model instead of doing weird convoluted updates (diff) | |
download | nheko-7e538851d6e3779434722e56a968e9f8b8a9da0d.tar.xz |
Use a QSortFilterProxyModel instead of resetting the model
Diffstat (limited to 'src/ReadReceiptsModel.h')
-rw-r--r-- | src/ReadReceiptsModel.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/ReadReceiptsModel.h b/src/ReadReceiptsModel.h index f2e39f88..9e26bcd5 100644 --- a/src/ReadReceiptsModel.h +++ b/src/ReadReceiptsModel.h @@ -8,15 +8,13 @@ #include <QAbstractListModel> #include <QDateTime> #include <QObject> +#include <QSortFilterProxyModel> #include <QString> class ReadReceiptsModel : public QAbstractListModel { Q_OBJECT - Q_PROPERTY(QString eventId READ eventId CONSTANT) - Q_PROPERTY(QString roomId READ roomId CONSTANT) - public: enum Roles { @@ -24,6 +22,7 @@ public: DisplayName, AvatarUrl, Timestamp, + RawTimestamp, }; explicit ReadReceiptsModel(QString event_id, QString room_id, QObject *parent = nullptr); @@ -51,4 +50,26 @@ private: QVector<QPair<QString, QDateTime>> readReceipts_; }; +class ReadReceiptsProxy : public QSortFilterProxyModel +{ + Q_OBJECT + + Q_PROPERTY(QString eventId READ eventId CONSTANT) + Q_PROPERTY(QString roomId READ roomId CONSTANT) + +public: + explicit ReadReceiptsProxy(QString event_id, QString room_id, QObject *parent = nullptr); + + QString eventId() const { return event_id_; } + QString roomId() const { return room_id_; } + + bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const; + +private: + QString event_id_; + QString room_id_; + + ReadReceiptsModel model_; +}; + #endif // READRECEIPTSMODEL_H |