summary refs log tree commit diff
path: root/src/timeline2/TimelineModel.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2019-08-30 23:20:53 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2019-11-23 20:06:14 +0100
commit8b5c7b2f2fb43b4f1884e683d60dd2553b9aa994 (patch)
tree5acc7a5af54bb5319eccbfb509e7f0c807aadee1 /src/timeline2/TimelineModel.cpp
parentReplace timeline with empty qml view (diff)
downloadnheko-8b5c7b2f2fb43b4f1884e683d60dd2553b9aa994.tar.xz
Add placeholder timeline model
Diffstat (limited to 'src/timeline2/TimelineModel.cpp')
-rw-r--r--src/timeline2/TimelineModel.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/timeline2/TimelineModel.cpp b/src/timeline2/TimelineModel.cpp
new file mode 100644

index 00000000..592064dd --- /dev/null +++ b/src/timeline2/TimelineModel.cpp
@@ -0,0 +1,47 @@ +#include "TimelineModel.h" + +#include "Utils.h" + +QHash<int, QByteArray> +TimelineModel::roleNames() const +{ + return { + {Type, "type"}, + {Body, "body"}, + {FormattedBody, "formattedBody"}, + {UserId, "userId"}, + {UserName, "userName"}, + {Timestamp, "timestamp"}, + }; +} +int +TimelineModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return (int)this->eventOrder.size(); +} + +QVariant +TimelineModel::data(const QModelIndex &index, int role) const +{ + if (index.row() < 0 && index.row() >= (int)eventOrder.size()) + return QVariant(); + + QString id = eventOrder[index.row()]; + + switch (role) { + case UserId: + return QVariant(QString("")); + default: + return QVariant(); + } +} + +QColor +TimelineModel::userColor(QString id, QColor background) +{ + if (!userColors.count(id)) + userColors.insert( + {id, QColor(utils::generateContrastingHexColor(id, background.name()))}); + return userColors.at(id); +}