2019-08-31 00:20:53 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QColor>
|
2019-08-31 23:43:31 +03:00
|
|
|
#include <QHash>
|
2019-08-31 00:20:53 +03:00
|
|
|
|
2019-08-31 23:43:31 +03:00
|
|
|
#include <mtx/responses.hpp>
|
2019-08-31 00:20:53 +03:00
|
|
|
|
|
|
|
class TimelineModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit TimelineModel(QObject *parent = 0)
|
|
|
|
: QAbstractListModel(parent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
enum Roles
|
|
|
|
{
|
|
|
|
Type,
|
|
|
|
Body,
|
|
|
|
FormattedBody,
|
|
|
|
UserId,
|
|
|
|
UserName,
|
|
|
|
Timestamp,
|
|
|
|
};
|
|
|
|
|
|
|
|
QHash<int, QByteArray> 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);
|
|
|
|
|
2019-08-31 23:43:31 +03:00
|
|
|
void addEvents(const mtx::responses::Timeline &events);
|
|
|
|
|
2019-08-31 00:20:53 +03:00
|
|
|
private:
|
2019-08-31 23:43:31 +03:00
|
|
|
QHash<QString, mtx::events::collections::TimelineEvents> events;
|
2019-08-31 00:20:53 +03:00
|
|
|
std::vector<QString> eventOrder;
|
|
|
|
|
2019-08-31 23:43:31 +03:00
|
|
|
QHash<QString, QColor> userColors;
|
2019-08-31 00:20:53 +03:00
|
|
|
};
|
|
|
|
|