Make the author line in the bubble and reply be part of the content model

This commit is contained in:
James Graham
2024-06-29 12:39:25 +01:00
parent 158b9ea2ca
commit 52d07320ef
20 changed files with 260 additions and 156 deletions

View File

@@ -36,7 +36,6 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
roles[DelegateTypeRole] = "delegateType";
roles[EventIdRole] = "eventId";
roles[TimeRole] = "time";
roles[TimeStringRole] = "timeString";
roles[SectionRole] = "section";
roles[AuthorRole] = "author";
roles[HighlightRole] = "isHighlighted";
@@ -153,7 +152,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
}
if (biggest < m_currentRoom->maxTimelineIndex()) {
auto rowBelowInserted = m_currentRoom->maxTimelineIndex() - biggest + timelineBaseIndex() - 1;
refreshEventRoles(rowBelowInserted, {MessageFilterModel::ShowAuthorRole});
refreshEventRoles(rowBelowInserted, {ContentModelRole});
}
for (auto i = m_currentRoom->maxTimelineIndex() - biggest; i <= m_currentRoom->maxTimelineIndex() - lowest; ++i) {
refreshLastUserEvents(i);
@@ -183,7 +182,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
refreshRow(timelineBaseIndex()); // Refresh the looks
refreshLastUserEvents(0);
if (timelineBaseIndex() > 0) { // Refresh below, see #312
refreshEventRoles(timelineBaseIndex() - 1, {MessageFilterModel::ShowAuthorRole});
refreshEventRoles(timelineBaseIndex() - 1, {ContentModelRole});
}
});
connect(m_currentRoom, &Room::pendingEventChanged, this, &MessageEventModel::refreshRow);
@@ -525,11 +524,6 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
return eventHandler.getTime(isPending, lastUpdated);
}
if (role == TimeStringRole) {
auto lastUpdated = isPending ? pendingIt->lastUpdated() : QDateTime();
return eventHandler.getTimeString(false, QLocale::ShortFormat, isPending, lastUpdated);
}
if (role == SectionRole) {
auto lastUpdated = isPending ? pendingIt->lastUpdated() : QDateTime();
return eventHandler.getTimeString(true, QLocale::ShortFormat, isPending, lastUpdated);