2018-03-05 11:12:13 +00:00
|
|
|
#ifndef MESSAGEEVENTMODEL_H
|
|
|
|
#define MESSAGEEVENTMODEL_H
|
|
|
|
|
2018-09-10 11:46:04 +00:00
|
|
|
#include "room.h"
|
2018-11-22 00:01:07 +00:00
|
|
|
#include "spectralroom.h"
|
2018-03-06 11:01:11 +00:00
|
|
|
|
2018-08-18 08:02:47 +00:00
|
|
|
#include <QtCore/QAbstractListModel>
|
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
class MessageEventModel : public QAbstractListModel {
|
|
|
|
Q_OBJECT
|
2019-05-02 06:20:04 +00:00
|
|
|
Q_PROPERTY(SpectralRoom* room READ room WRITE setRoom NOTIFY roomChanged)
|
2018-07-09 02:45:26 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum EventRoles {
|
|
|
|
EventTypeRole = Qt::UserRole + 1,
|
2018-09-17 03:58:02 +00:00
|
|
|
MessageRole,
|
2018-09-10 11:46:04 +00:00
|
|
|
AboveEventTypeRole,
|
2018-07-09 02:45:26 +00:00
|
|
|
EventIdRole,
|
|
|
|
TimeRole,
|
2018-07-29 16:00:41 +00:00
|
|
|
AboveTimeRole,
|
2018-07-09 02:45:26 +00:00
|
|
|
SectionRole,
|
|
|
|
AboveSectionRole,
|
|
|
|
AuthorRole,
|
|
|
|
AboveAuthorRole,
|
|
|
|
ContentRole,
|
|
|
|
ContentTypeRole,
|
|
|
|
HighlightRole,
|
|
|
|
ReadMarkerRole,
|
|
|
|
SpecialMarksRole,
|
|
|
|
LongOperationRole,
|
2018-08-05 16:53:22 +00:00
|
|
|
AnnotationRole,
|
2018-09-13 05:05:51 +00:00
|
|
|
UserMarkerRole,
|
2018-11-27 00:09:45 +00:00
|
|
|
ReplyEventIdRole,
|
|
|
|
ReplyAuthorRole,
|
|
|
|
ReplyDisplayRole,
|
2018-07-09 02:45:26 +00:00
|
|
|
// For debugging
|
|
|
|
EventResolvedTypeRole,
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit MessageEventModel(QObject* parent = nullptr);
|
|
|
|
~MessageEventModel();
|
|
|
|
|
2019-05-02 06:20:04 +00:00
|
|
|
SpectralRoom* room() { return m_currentRoom; }
|
2018-09-17 13:01:02 +00:00
|
|
|
void setRoom(SpectralRoom* room);
|
2018-07-09 02:45:26 +00:00
|
|
|
|
2018-08-05 16:53:22 +00:00
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
2018-08-06 12:13:51 +00:00
|
|
|
QVariant data(const QModelIndex& index,
|
|
|
|
int role = Qt::DisplayRole) const override;
|
2018-09-13 05:05:51 +00:00
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
2018-07-09 02:45:26 +00:00
|
|
|
|
2018-10-22 01:48:37 +00:00
|
|
|
Q_INVOKABLE int eventIDToIndex(const QString& eventID);
|
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
private slots:
|
2018-08-06 15:16:35 +00:00
|
|
|
int refreshEvent(const QString& eventId);
|
2018-08-05 16:53:22 +00:00
|
|
|
void refreshRow(int row);
|
2018-07-09 02:45:26 +00:00
|
|
|
|
|
|
|
private:
|
2018-09-17 13:01:02 +00:00
|
|
|
SpectralRoom* m_currentRoom = nullptr;
|
2018-07-09 02:45:26 +00:00
|
|
|
QString lastReadEventId;
|
2018-08-05 16:53:22 +00:00
|
|
|
int rowBelowInserted = -1;
|
|
|
|
bool movingEvent = 0;
|
2018-07-09 02:45:26 +00:00
|
|
|
|
2018-08-05 16:53:22 +00:00
|
|
|
int timelineBaseIndex() const;
|
2018-08-03 12:58:12 +00:00
|
|
|
QDateTime makeMessageTimestamp(
|
|
|
|
const QMatrixClient::Room::rev_iter_t& baseIt) const;
|
2018-08-05 16:53:22 +00:00
|
|
|
QString renderDate(QDateTime timestamp) const;
|
2018-08-06 12:13:51 +00:00
|
|
|
|
2018-11-22 00:01:07 +00:00
|
|
|
void refreshLastUserEvents(int baseRow);
|
2018-08-05 16:53:22 +00:00
|
|
|
void refreshEventRoles(int row, const QVector<int>& roles = {});
|
2018-08-06 15:16:35 +00:00
|
|
|
int refreshEventRoles(const QString& eventId, const QVector<int>& roles = {});
|
2018-07-09 02:45:26 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void roomChanged();
|
2018-03-05 11:12:13 +00:00
|
|
|
};
|
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
#endif // MESSAGEEVENTMODEL_H
|