Spectral/matrix/messageeventmodel.h

57 lines
1.6 KiB
C
Raw Normal View History

2018-03-05 11:12:13 +00:00
#ifndef MESSAGEEVENTMODEL_H
#define MESSAGEEVENTMODEL_H
#include <QtCore/QAbstractListModel>
#include "room.h"
2018-03-06 11:01:11 +00:00
2018-03-05 11:12:13 +00:00
class MessageEventModel: public QAbstractListModel
{
2018-03-06 11:11:39 +00:00
Q_OBJECT
Q_PROPERTY(QMatrixClient::Room* room READ getRoom WRITE setRoom NOTIFY roomChanged)
2018-03-06 11:11:39 +00:00
2018-03-05 11:12:13 +00:00
public:
2018-03-06 11:01:11 +00:00
enum EventRoles {
EventTypeRole = Qt::UserRole + 1,
EventIdRole,
TimeRole,
SectionRole,
AboveSectionRole,
AuthorRole,
AboveAuthorRole,
2018-03-06 11:01:11 +00:00
ContentRole,
ContentTypeRole,
HighlightRole,
2018-03-06 11:01:11 +00:00
ReadMarkerRole,
SpecialMarksRole,
LongOperationRole,
// For debugging
EventResolvedTypeRole,
2018-03-06 11:01:11 +00:00
};
2018-03-05 11:12:13 +00:00
explicit MessageEventModel(QObject* parent = nullptr);
~MessageEventModel();
2018-03-05 11:12:13 +00:00
QMatrixClient::Room* getRoom() { return m_currentRoom; }
void setRoom(QMatrixClient::Room* room);
2018-03-05 11:12:13 +00:00
Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role) const override;
QHash<int, QByteArray> roleNames() const;
2018-03-05 11:12:13 +00:00
private slots:
void refreshEvent(const QString& eventId);
private:
QMatrixClient::Room* m_currentRoom = nullptr;
2018-03-05 11:12:13 +00:00
QString lastReadEventId;
QDateTime makeMessageTimestamp(QMatrixClient::Room::rev_iter_t baseIt) const;
QString makeDateString(QMatrixClient::Room::rev_iter_t baseIt) const;
2018-03-05 11:12:13 +00:00
void refreshEventRoles(const QString& eventId, const QVector<int> roles);
signals:
void roomChanged();
2018-03-05 11:12:13 +00:00
};
#endif // MESSAGEEVENTMODEL_H