#pragma once #include #include #include #include class TimelineModel : public QAbstractListModel { Q_OBJECT public: explicit TimelineModel(QObject *parent = 0) : QAbstractListModel(parent) {} enum Roles { Type, Body, FormattedBody, UserId, UserName, Timestamp, }; QHash roleNames() const override; int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; Q_INVOKABLE QColor userColor(QString id, QColor background); void addEvents(const mtx::responses::Timeline &events); private: QHash events; std::vector eventOrder; QHash userColors; };