Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include <map>
#include <vector>
#include <QAbstractListModel>
#include <QColor>
#include <mtx/events/collections.hpp>
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);
private:
std::map<QString, mtx::events::collections::TimelineEvents> events;
std::vector<QString> eventOrder;
std::map<QString, QColor> userColors;
};