#pragma once #include #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); private: std::map events; std::vector eventOrder; std::map userColors; };